diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 678143b7f31e..b17abd8f967c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -9,3 +9,4 @@ /java-vertexai/ @googleapis/vertexai-team @googleapis/cloud-sdk-java-team /java-bigquerystorage/ @googleapis/bigquery-team @googleapis/cloud-sdk-java-team /java-bigquery/ @googleapis/bigquery-team @googleapis/cloud-sdk-java-team +/java-firestore/ @googleapis/firestore-team @googleapis/cloud-sdk-java-team diff --git a/.kokoro/common.sh b/.kokoro/common.sh index c2db30296c22..42eb13481d2d 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -23,6 +23,7 @@ excluded_modules=( 'java-bigquerystorage' 'java-datastore' 'java-logging-logback' + 'java-firestore' ) function retry_with_backoff { diff --git a/.kokoro/presubmit/firestore-graalvm-native-presubmit.cfg b/.kokoro/presubmit/firestore-graalvm-native-presubmit.cfg new file mode 100644 index 000000000000..d93af0ca9754 --- /dev/null +++ b/.kokoro/presubmit/firestore-graalvm-native-presubmit.cfg @@ -0,0 +1,37 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.56.1" # {x-version-update:google-cloud-shared-dependencies:current} +} + +env_vars: { + key: "JOB_TYPE" + value: "graalvm-single" +} + +env_vars: { + key: "INTEGRATION_TEST_ARGS" + value: "-DFIRESTORE_EDITION=standard" +} + +env_vars: { + key: "GOOGLE_CLOUD_PROJECT" + value: "java-review" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "secret_manager/java-review_firestore-java-it" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-review_firestore-java-it" +} + +env_vars: { + key: "BUILD_SUBDIR" + value: "java-firestore" +} diff --git a/.kokoro/presubmit/firestore-integration.cfg b/.kokoro/presubmit/firestore-integration.cfg new file mode 100644 index 000000000000..a8deb199a620 --- /dev/null +++ b/.kokoro/presubmit/firestore-integration.cfg @@ -0,0 +1,37 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" +} + +env_vars: { + key: "JOB_TYPE" + value: "integration-single" +} + +env_vars: { + key: "INTEGRATION_TEST_ARGS" + value: "-DFIRESTORE_EDITION=standard" +} + +env_vars: { + key: "GCLOUD_PROJECT" + value: "java-review" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "secret_manager/java-review_firestore-java-it" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-review_firestore-java-it" +} + +env_vars: { + key: "BUILD_SUBDIR" + value: "java-firestore" +} diff --git a/.kokoro/presubmit/logging-graalvm-native-presubmit.cfg b/.kokoro/presubmit/logging-graalvm-native-presubmit.cfg index d16598bb817f..d93af0ca9754 100644 --- a/.kokoro/presubmit/logging-graalvm-native-presubmit.cfg +++ b/.kokoro/presubmit/logging-graalvm-native-presubmit.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.56.1" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.56.1" # {x-version-update:google-cloud-shared-dependencies:current} } env_vars: { @@ -11,28 +11,27 @@ env_vars: { value: "graalvm-single" } -# TODO: remove this after we've migrated all tests and scripts env_vars: { - key: "GCLOUD_PROJECT" - value: "cloud-java-ci-test" + key: "INTEGRATION_TEST_ARGS" + value: "-DFIRESTORE_EDITION=standard" } env_vars: { key: "GOOGLE_CLOUD_PROJECT" - value: "cloud-java-ci-test" + value: "java-review" } env_vars: { key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/cloud-java-ci-it-service-account" + value: "secret_manager/java-review_firestore-java-it" } env_vars: { key: "SECRET_MANAGER_KEYS" - value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets" + value: "java-review_firestore-java-it" } env_vars: { key: "BUILD_SUBDIR" - value: "java-logging" + value: "java-firestore" } diff --git a/.kokoro/presubmit/logging-integration.cfg b/.kokoro/presubmit/logging-integration.cfg index 30143885f2b4..a8deb199a620 100644 --- a/.kokoro/presubmit/logging-integration.cfg +++ b/.kokoro/presubmit/logging-integration.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" + value: "gcr.io/cloud-devrel-kokoro-resources/java8" } env_vars: { @@ -11,28 +11,27 @@ env_vars: { value: "integration-single" } -# TODO: remove this after we've migrated all tests and scripts env_vars: { - key: "GCLOUD_PROJECT" - value: "cloud-java-ci-test" + key: "INTEGRATION_TEST_ARGS" + value: "-DFIRESTORE_EDITION=standard" } env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "cloud-java-ci-test" + key: "GCLOUD_PROJECT" + value: "java-review" } env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/cloud-java-ci-it-service-account" + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "secret_manager/java-review_firestore-java-it" } env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "cloud-java-ci-it-service-account, java-bigqueryconnection-samples-secrets" + key: "SECRET_MANAGER_KEYS" + value: "java-review_firestore-java-it" } env_vars: { key: "BUILD_SUBDIR" - value: "java-logging" + value: "java-firestore" } diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml index 70790ff3c588..5a6adbc6abb2 100644 --- a/gapic-libraries-bom/pom.xml +++ b/gapic-libraries-bom/pom.xml @@ -677,6 +677,13 @@ pom import + + com.google.cloud + google-cloud-firestore-bom + 3.38.1-SNAPSHOT + pom + import + com.google.cloud google-cloud-functions-bom diff --git a/generation/check_non_release_please_versions.sh b/generation/check_non_release_please_versions.sh index 14393d905915..610fc1d12e80 100755 --- a/generation/check_non_release_please_versions.sh +++ b/generation/check_non_release_please_versions.sh @@ -12,6 +12,7 @@ for pomFile in $(find . -mindepth 2 -name pom.xml | sort ); do [[ "${pomFile}" =~ .*java-datastore.* ]] || \ [[ "${pomFile}" =~ .*java-logging-logback.* ]] || \ [[ "${pomFile}" =~ .*java-bigquery.* ]] || \ + [[ "${pomFile}" =~ .*java-firestore.* ]] || \ [[ "${pomFile}" =~ .*.github*. ]]; then continue fi diff --git a/generation_config.yaml b/generation_config.yaml index 0909dc1bc824..83b58e5a592e 100644 --- a/generation_config.yaml +++ b/generation_config.yaml @@ -1103,6 +1103,30 @@ libraries: GAPICs: - proto_path: google/cloud/financialservices/v1 requires_billing: true +- api_shortname: firestore + name_pretty: Cloud Firestore + product_documentation: https://cloud.google.com/firestore + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-firestore/latest/history + issue_tracker: https://issuetracker.google.com/savedsearches/5337669 + release_level: stable + language: java + distribution_name: com.google.cloud:google-cloud-firestore + codeowner_team: '@googleapis/firestore-team' + api_id: firestore.googleapis.com + library_type: GAPIC_COMBO + api_description: is a fully-managed NoSQL document database for mobile, web, and + server development from Firebase and Google Cloud Platform. It's backed by a + multi-region replicated database that ensures once data is committed, it's durable + even in the face of unexpected disasters. Not only that, but despite being a distributed + database, it's also strongly consistent and offers seamless integration with other + Firebase and Google Cloud Platform products, including Google Cloud Functions. + transport: grpc + excluded_poms: google-cloud-firestore,google-cloud-firestore-bom + recommended_package: com.google.cloud.firestore + GAPICs: + - proto_path: google/firestore/v1 + - proto_path: google/firestore/admin/v1 + - proto_path: google/firestore/bundle - api_shortname: cloudfunctions name_pretty: Cloud Functions product_documentation: https://cloud.google.com/functions diff --git a/java-firestore/.OwlBot-hermetic.yaml b/java-firestore/.OwlBot-hermetic.yaml new file mode 100644 index 000000000000..0d7320cbee4a --- /dev/null +++ b/java-firestore/.OwlBot-hermetic.yaml @@ -0,0 +1,28 @@ +deep-remove-regex: +- /java-firestore/grpc-google-.*/src +- /java-firestore/proto-google-.*/src +- /java-firestore/google-cloud-firestore/src/.*/java/com/google/cloud/firestore/v1/ +- /java-firestore/google-cloud-firestore-admin/src +deep-preserve-regex: +- /java-firestore/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java +- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentPathName.java +- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AnyPathName.java +- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DatabaseRootName.java +- /java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRootName.java +- /java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ParentName.java +- /java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore +deep-copy-regex: +- source: /google/firestore/(v\d)/.*-java/proto-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/proto-google-cloud-firestore-$1/src +- source: /google/firestore/(v\d)/.*-java/grpc-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/grpc-google-cloud-firestore-$1/src +- source: /google/firestore/(v\d)/.*-java/gapic-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/google-cloud-firestore/src +- source: /google/firestore/admin/(v\d)/.*-java/proto-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/proto-google-cloud-firestore-admin-$1/src +- source: /google/firestore/admin/(v\d)/.*-java/grpc-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/grpc-google-cloud-firestore-admin-$1/src +- source: /google/firestore/admin/(v\d)/.*-java/gapic-google-.*/src + dest: /owl-bot-staging/java-firestore/$1/google-cloud-firestore-admin/src +- source: /google/firestore/bundle/.*-java/proto-google-.*/src + dest: /owl-bot-staging/java-firestore/v1/proto-google-cloud-firestore-bundle-v1/src diff --git a/java-firestore/.repo-metadata.json b/java-firestore/.repo-metadata.json new file mode 100644 index 000000000000..0d4241b4a7b3 --- /dev/null +++ b/java-firestore/.repo-metadata.json @@ -0,0 +1,23 @@ +{ + "api_shortname": "firestore", + "name_pretty": "Cloud Firestore", + "product_documentation": "https://cloud.google.com/firestore", + "api_description": "is a fully-managed NoSQL document database for mobile, web, and server development from Firebase and Google Cloud Platform. It's backed by a multi-region replicated database that ensures once data is committed, it's durable even in the face of unexpected disasters. Not only that, but despite being a distributed database, it's also strongly consistent and offers seamless integration with other Firebase and Google Cloud Platform products, including Google Cloud Functions.", + "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-firestore/latest/history", + "release_level": "stable", + "transport": "grpc", + "language": "java", + "repo": "googleapis/google-cloud-java", + "repo_short": "java-firestore", + "distribution_name": "com.google.cloud:google-cloud-firestore", + "api_id": "firestore.googleapis.com", + "library_type": "GAPIC_COMBO", + "requires_billing": true, + "codeowner_team": "@googleapis/firestore-team", + "excluded_poms": "google-cloud-firestore,google-cloud-firestore-bom", + "issue_tracker": "https://issuetracker.google.com/savedsearches/5337669", + "recommended_package": "com.google.cloud.firestore", + "library_path_overrides": { + "FirestoreAdminClient": "google-cloud-firestore-admin" + } +} diff --git a/java-firestore/CHANGELOG.md b/java-firestore/CHANGELOG.md new file mode 100644 index 000000000000..dc50428314a9 --- /dev/null +++ b/java-firestore/CHANGELOG.md @@ -0,0 +1,2348 @@ +# Changelog + +## [3.38.0](https://github.com/googleapis/java-firestore/compare/v3.37.0...v3.38.0) (2026-02-26) + + +### Features + +* Add support for `regexFind` and `regexFindAll` Pipeline expressions ([#2310](https://github.com/googleapis/java-firestore/issues/2310)) ([1d92887](https://github.com/googleapis/java-firestore/commit/1d9288719e36e76d8710233b161ae1c79d50be28)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.67.0 ([aeaf77f](https://github.com/googleapis/java-firestore/commit/aeaf77f9ed7ee6bd145f64977cd516e27f29bbe4)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.57.0 ([#2325](https://github.com/googleapis/java-firestore/issues/2325)) ([597ab41](https://github.com/googleapis/java-firestore/commit/597ab41c6387c65d3ef2455303a7f9f66b53fc59)) + +## [3.37.0](https://github.com/googleapis/java-firestore/compare/v3.36.0...v3.37.0) (2026-02-12) + + +### Features + +* Expose the `Database.firestore_data_access_mode` parameter ([01290af](https://github.com/googleapis/java-firestore/commit/01290afaf2f7d9333b30c1a9fc84663393a8ff4d)) +* Next release from main branch is 3.37.0 ([#2314](https://github.com/googleapis/java-firestore/issues/2314)) ([3eed2e8](https://github.com/googleapis/java-firestore/commit/3eed2e8038efc54faa13e3d072169f6d8b2caf2f)) + + +### Bug Fixes + +* Correct FirestoreAdminClient source link in documentation ([#2304](https://github.com/googleapis/java-firestore/issues/2304)) ([1f66dca](https://github.com/googleapis/java-firestore/commit/1f66dcaa3e936d77505383173ec2c2a1821bcce5)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.66.1 ([01290af](https://github.com/googleapis/java-firestore/commit/01290afaf2f7d9333b30c1a9fc84663393a8ff4d)) +* Set max retry at 5 for executePipeline ([#2307](https://github.com/googleapis/java-firestore/issues/2307)) ([acb37fe](https://github.com/googleapis/java-firestore/commit/acb37fe918cd9c6ef1a671551c1d1789bfa36934)) +* Setup CI against enterprise ([#2299](https://github.com/googleapis/java-firestore/issues/2299)) ([510ff73](https://github.com/googleapis/java-firestore/commit/510ff732d471f07f39d3d7074de2e7317663d556)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.56.1 ([#2316](https://github.com/googleapis/java-firestore/issues/2316)) ([5f2f826](https://github.com/googleapis/java-firestore/commit/5f2f826e65e651c5728b459e5cbe6c7f35c5fc77)) + +## [3.36.0](https://github.com/googleapis/java-firestore/compare/v3.35.1...v3.36.0) (2026-01-27) + + +### Features + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.66.0 ([fa4b6a0](https://github.com/googleapis/java-firestore/commit/fa4b6a0d6f3f59e9092019207bbbb90483eb49f9)) + + +### Bug Fixes + +* Remove undesired exists() conditions from query-to-pipeline conversion ([#2293](https://github.com/googleapis/java-firestore/issues/2293)) ([09225e4](https://github.com/googleapis/java-firestore/commit/09225e4b8e6a435fb5544315980e2dd831fefd84)) + + +### Dependencies + +* Update googleapis/sdk-platform-java action to v2.66.0 ([#2297](https://github.com/googleapis/java-firestore/issues/2297)) ([14bcca5](https://github.com/googleapis/java-firestore/commit/14bcca5d450312d663142dbb7e9003d785e6a4de)) +* Update shared config to 3.56.0 ([#2300](https://github.com/googleapis/java-firestore/issues/2300)) ([b18b08d](https://github.com/googleapis/java-firestore/commit/b18b08d6a9f56948e5e4664f1e3bec7313ba7014)) + +## [3.35.1](https://github.com/googleapis/java-firestore/compare/v3.35.0...v3.35.1) (2026-01-19) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.55.1 ([#2285](https://github.com/googleapis/java-firestore/issues/2285)) ([d3f8129](https://github.com/googleapis/java-firestore/commit/d3f8129f4121bac753ccd59600077d80d4dc5fa9)) + +## [3.35.0](https://github.com/googleapis/java-firestore/compare/v3.34.0...v3.35.0) (2026-01-15) + + +### Features + +* Adding gcp resource name span attribute ([#2260](https://github.com/googleapis/java-firestore/issues/2260)) ([926fd8c](https://github.com/googleapis/java-firestore/commit/926fd8c393dfd91f532b61bdf2a50ed8d19d3618)) +* Pipelines enters public preview ([#2272](https://github.com/googleapis/java-firestore/issues/2272)) ([6e30a6c](https://github.com/googleapis/java-firestore/commit/6e30a6c11efe5d428607bfd78f82ba7b49497bd9)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.65.1 ([1573a6f](https://github.com/googleapis/java-firestore/commit/1573a6f8b7d08e6670f26e2fe1af730700000aac)) + +## [3.34.0](https://github.com/googleapis/java-firestore/compare/v3.33.4...v3.34.0) (2025-12-12) + + +### Features + +* Publish the pipelines API to the stable branch ([2cab2e0](https://github.com/googleapis/java-firestore/commit/2cab2e02e5884f3efd9b0f2e212e14ef0d82d855)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.64.2 ([2cab2e0](https://github.com/googleapis/java-firestore/commit/2cab2e02e5884f3efd9b0f2e212e14ef0d82d855)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.54.2 ([#2270](https://github.com/googleapis/java-firestore/issues/2270)) ([05188e3](https://github.com/googleapis/java-firestore/commit/05188e3e779968e67861fcd69d64ae17cfb6cd0b)) + + +### Documentation + +* Minor api documentation changes ([2cab2e0](https://github.com/googleapis/java-firestore/commit/2cab2e02e5884f3efd9b0f2e212e14ef0d82d855)) + +## [3.33.4](https://github.com/googleapis/java-firestore/compare/v3.33.3...v3.33.4) (2025-11-13) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.64.1 ([3de013f](https://github.com/googleapis/java-firestore/commit/3de013f9d19baaa1c4424a9f9de151d32a54d39a)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.54.1 ([#2254](https://github.com/googleapis/java-firestore/issues/2254)) ([21a1395](https://github.com/googleapis/java-firestore/commit/21a1395b79ede7a60d8fc1361770b599e846a080)) + +## [3.33.3](https://github.com/googleapis/java-firestore/compare/v3.33.2...v3.33.3) (2025-10-20) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.53.0 ([#2249](https://github.com/googleapis/java-firestore/issues/2249)) ([e50d2da](https://github.com/googleapis/java-firestore/commit/e50d2da4a55f906021e3761d2ea97efd3b1ea034)) + +## [3.33.2](https://github.com/googleapis/java-firestore/compare/v3.33.1...v3.33.2) (2025-10-07) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.62.3 ([75901e3](https://github.com/googleapis/java-firestore/commit/75901e35b05cfccf38ccf96cddcf4081d7c9566d)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.3 ([#2243](https://github.com/googleapis/java-firestore/issues/2243)) ([dfe553a](https://github.com/googleapis/java-firestore/commit/dfe553a6b106f8e80f62b39cb999af03651a41ff)) + +## [3.33.1](https://github.com/googleapis/java-firestore/compare/v3.33.0...v3.33.1) (2025-09-24) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.62.2 ([3460038](https://github.com/googleapis/java-firestore/commit/3460038d48eb3a96eb10c30aad7d814c56bd8140)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.2 ([#2235](https://github.com/googleapis/java-firestore/issues/2235)) ([f1354dc](https://github.com/googleapis/java-firestore/commit/f1354dc35ac6dc10bdb3b3e3b6ec6eb9379cdaa8)) + +## [3.33.0](https://github.com/googleapis/java-firestore/compare/v3.32.2...v3.33.0) (2025-09-11) + + +### Features + +* Add Firestore CloneDatabase support ([1fa6ae8](https://github.com/googleapis/java-firestore/commit/1fa6ae824c81fd816e39651bb1c48b449d31175b)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.62.1 ([1fa6ae8](https://github.com/googleapis/java-firestore/commit/1fa6ae824c81fd816e39651bb1c48b449d31175b)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.1 ([#2230](https://github.com/googleapis/java-firestore/issues/2230)) ([bc07b64](https://github.com/googleapis/java-firestore/commit/bc07b647b52752db7a556f0a1ca201536bc8a21b)) +* Update googleapis/sdk-platform-java action to v2.62.1 ([#2224](https://github.com/googleapis/java-firestore/issues/2224)) ([d546b5a](https://github.com/googleapis/java-firestore/commit/d546b5a3d30086f86ed3688b725f639fbdf7c11c)) + +## [3.32.2](https://github.com/googleapis/java-firestore/compare/v3.32.1...v3.32.2) (2025-08-26) + + +### Bug Fixes + +* Resolve RejectedExecutionException that occurred on BulkWriter close or executor shutdown ([#2223](https://github.com/googleapis/java-firestore/issues/2223)) ([e919ebb](https://github.com/googleapis/java-firestore/commit/e919ebbef229558098535ba6456b29ed22fa1533)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.0 ([#2222](https://github.com/googleapis/java-firestore/issues/2222)) ([cb90035](https://github.com/googleapis/java-firestore/commit/cb90035e8fa60c162c74b009053506d8f417b3a1)) + +## [3.32.1](https://github.com/googleapis/java-firestore/compare/v3.32.0...v3.32.1) (2025-08-13) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.51.0 ([#2213](https://github.com/googleapis/java-firestore/issues/2213)) ([be04b4e](https://github.com/googleapis/java-firestore/commit/be04b4e87ff5d2f89a2fff8bacb806260f94a227)) +* Update googleapis/sdk-platform-java action to v2.61.0 ([#2214](https://github.com/googleapis/java-firestore/issues/2214)) ([e3aafbe](https://github.com/googleapis/java-firestore/commit/e3aafbe5c7e8d3286aca360174cb086f4d409803)) + +## [3.32.0](https://github.com/googleapis/java-firestore/compare/v3.31.9...v3.32.0) (2025-07-28) + + +### Features + +* Expose tags field in Database and RestoreDatabaseRequest public protos ([0f6774a](https://github.com/googleapis/java-firestore/commit/0f6774ad937d2cc84a3ee6747d07ad96a6713126)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.60.1 ([e90f7d1](https://github.com/googleapis/java-firestore/commit/e90f7d1d992c172afb96a43003d45ca1fb3143b0)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.60.2 ([0f6774a](https://github.com/googleapis/java-firestore/commit/0f6774ad937d2cc84a3ee6747d07ad96a6713126)) +* Implement BulkWriter shutdown logic ([#2202](https://github.com/googleapis/java-firestore/issues/2202)) ([7301774](https://github.com/googleapis/java-firestore/commit/73017741fce52fd37e08af4f3f32fb901b7214a3)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.68.0 ([#2193](https://github.com/googleapis/java-firestore/issues/2193)) ([30c5a19](https://github.com/googleapis/java-firestore/commit/30c5a19f6d1294a4b281de9664ce42917b451a0b)) +* Update dependency com.google.cloud:google-cloud-trace to v2.68.0 ([#2194](https://github.com/googleapis/java-firestore/issues/2194)) ([5fba79d](https://github.com/googleapis/java-firestore/commit/5fba79d7f24a81886e6a5089a9166e16a9491ea0)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.2 ([#2200](https://github.com/googleapis/java-firestore/issues/2200)) ([e4e75cf](https://github.com/googleapis/java-firestore/commit/e4e75cff5656e047aa932dee226c4b2117eba17c)) +* Update opentelemetry.version to v1.52.0 ([#2191](https://github.com/googleapis/java-firestore/issues/2191)) ([cfb4453](https://github.com/googleapis/java-firestore/commit/cfb4453fca5ae483af7710c627996a6c0c7381a7)) + +## [3.31.9](https://github.com/googleapis/java-firestore/compare/v3.31.8...v3.31.9) (2025-07-11) + + +### Bug Fixes + +* Improve performance of the UTF-8 string comparison logic. ([#2182](https://github.com/googleapis/java-firestore/issues/2182)) ([869a381](https://github.com/googleapis/java-firestore/commit/869a3814511f9a6e15641b3279bb871867886940)) + + +### Dependencies + +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.45.0 ([#2184](https://github.com/googleapis/java-firestore/issues/2184)) ([88097cb](https://github.com/googleapis/java-firestore/commit/88097cbe8878b45897c89e102fa82e1975d2d74b)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.1 ([#2186](https://github.com/googleapis/java-firestore/issues/2186)) ([466e597](https://github.com/googleapis/java-firestore/commit/466e597c282533c0e500b57d27f386ef9ea99e5e)) +* Update dependency org.apache.commons:commons-lang3 to v3.18.0 ([#2187](https://github.com/googleapis/java-firestore/issues/2187)) ([1f3c20b](https://github.com/googleapis/java-firestore/commit/1f3c20b1923c3ae000359be91e7e39458c36ce2e)) +* Update googleapis/sdk-platform-java action to v2.60.0 ([#2176](https://github.com/googleapis/java-firestore/issues/2176)) ([8283a08](https://github.com/googleapis/java-firestore/commit/8283a08b1749e06864b50ab1813c13e9eb61c087)) +* Update googleapis/sdk-platform-java action to v2.60.1 ([#2181](https://github.com/googleapis/java-firestore/issues/2181)) ([be9daba](https://github.com/googleapis/java-firestore/commit/be9dabab8467a5aa3986d34f393d597d670af029)) + + +### Documentation + +* Add an example to the detailed comment in compareUtf8Strings() ([#2183](https://github.com/googleapis/java-firestore/issues/2183)) ([e16b158](https://github.com/googleapis/java-firestore/commit/e16b15853d6545c3c1476086c3bc88cb46991718)) + +## [3.31.8](https://github.com/googleapis/java-firestore/compare/v3.31.7...v3.31.8) (2025-07-02) + + +### Dependencies + +* Update beam.version to v2.66.0 ([#2172](https://github.com/googleapis/java-firestore/issues/2172)) ([4b7f49e](https://github.com/googleapis/java-firestore/commit/4b7f49ea48a0a6e9768687e9ec2d05ca3d2dc5a0)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.67.0 ([#2167](https://github.com/googleapis/java-firestore/issues/2167)) ([3c95bf1](https://github.com/googleapis/java-firestore/commit/3c95bf10becd5c84e1ed25fa24e78ef074e3d267)) +* Update dependency com.google.cloud:google-cloud-trace to v2.67.0 ([#2166](https://github.com/googleapis/java-firestore/issues/2166)) ([7920b5b](https://github.com/googleapis/java-firestore/commit/7920b5b0de25057fe4a58948bf7112171f795672)) +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.36.0 ([#2159](https://github.com/googleapis/java-firestore/issues/2159)) ([edcb508](https://github.com/googleapis/java-firestore/commit/edcb508d3b144db073a8aeaaf8a37e535a00bc0d)) +* Update googleapis/sdk-platform-java action to v2.60.0 ([#2163](https://github.com/googleapis/java-firestore/issues/2163)) ([4660432](https://github.com/googleapis/java-firestore/commit/466043294afd9cc10a330c87873595b65e76bf4c)) +* Update googleapis/sdk-platform-java action to v2.60.0 ([#2173](https://github.com/googleapis/java-firestore/issues/2173)) ([4fddfea](https://github.com/googleapis/java-firestore/commit/4fddfea2b14dd7f9b54e72d2f4889e2a3d5f5d2d)) + +## [3.31.7](https://github.com/googleapis/java-firestore/compare/v3.31.6...v3.31.7) (2025-06-25) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.64.0 ([#2143](https://github.com/googleapis/java-firestore/issues/2143)) ([c42dcab](https://github.com/googleapis/java-firestore/commit/c42dcabb11a0374cc3ac70e46b9dde3aff5d7268)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.66.0 ([#2154](https://github.com/googleapis/java-firestore/issues/2154)) ([15f1ceb](https://github.com/googleapis/java-firestore/commit/15f1ceb27c1ef4f460a1d490054b30a15838fc7d)) +* Update dependency com.google.cloud:google-cloud-trace to v2.64.0 ([#2144](https://github.com/googleapis/java-firestore/issues/2144)) ([213f63c](https://github.com/googleapis/java-firestore/commit/213f63cf936b5849ec416b041b570953d2e478f2)) +* Update dependency com.google.cloud:google-cloud-trace to v2.66.0 ([#2155](https://github.com/googleapis/java-firestore/issues/2155)) ([934b6e5](https://github.com/googleapis/java-firestore/commit/934b6e5a3a83acf7bb84726fc7dd44d5d7720513)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.49.2 ([#2149](https://github.com/googleapis/java-firestore/issues/2149)) ([6331e05](https://github.com/googleapis/java-firestore/commit/6331e05fdc4d030ebdaa5e0f53e3229f611736a7)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.0 ([#2158](https://github.com/googleapis/java-firestore/issues/2158)) ([97bd331](https://github.com/googleapis/java-firestore/commit/97bd33163c84c92688907167c8280dd9d167c005)) +* Update googleapis/sdk-platform-java action to v2.59.1 ([#2147](https://github.com/googleapis/java-firestore/issues/2147)) ([4a21735](https://github.com/googleapis/java-firestore/commit/4a21735534fd837de624044b07a5290e9dcd273b)) +* Update googleapis/sdk-platform-java action to v2.59.2 ([#2152](https://github.com/googleapis/java-firestore/issues/2152)) ([6ea90fc](https://github.com/googleapis/java-firestore/commit/6ea90fc88d0641dd5a8e182e71e08bd14345a7c0)) +* Update googleapis/sdk-platform-java action to v2.60.0 ([#2156](https://github.com/googleapis/java-firestore/issues/2156)) ([59d73bc](https://github.com/googleapis/java-firestore/commit/59d73bc388c90228a360c138c820b0e0cc416750)) +* Update opentelemetry.version to v1.51.0 ([#2145](https://github.com/googleapis/java-firestore/issues/2145)) ([2f0958d](https://github.com/googleapis/java-firestore/commit/2f0958d721095009cbc5da55b9c7837b4c307a66)) + +## [3.31.6](https://github.com/googleapis/java-firestore/compare/v3.31.5...v3.31.6) (2025-06-04) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.59.0 ([f44e1e5](https://github.com/googleapis/java-firestore/commit/f44e1e5be5288d1af95cf9deaacf327a64bf9178)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.49.0 ([#2135](https://github.com/googleapis/java-firestore/issues/2135)) ([4006eaf](https://github.com/googleapis/java-firestore/commit/4006eaf7a3758b277636d8a31233770f8354eb6e)) +* Update googleapis/sdk-platform-java action to v2.59.0 ([#2133](https://github.com/googleapis/java-firestore/issues/2133)) ([b1b78bb](https://github.com/googleapis/java-firestore/commit/b1b78bbfbee15f094c2bf4818babe1e1d556cd18)) + +## [3.31.5](https://github.com/googleapis/java-firestore/compare/v3.31.4...v3.31.5) (2025-05-28) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.58.0 ([819dc99](https://github.com/googleapis/java-firestore/commit/819dc99ea4f90a8b5cba21cc7016921aa156f3da)) + + +### Dependencies + +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.44.5 ([#2128](https://github.com/googleapis/java-firestore/issues/2128)) ([b100ac3](https://github.com/googleapis/java-firestore/commit/b100ac3d75e8967e18589d5d719e5bf63969c438)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.63.0 ([#2122](https://github.com/googleapis/java-firestore/issues/2122)) ([d5f6a8e](https://github.com/googleapis/java-firestore/commit/d5f6a8ea2e463143fb0fe4328de87a9886f1e78c)) +* Update dependency com.google.cloud:google-cloud-trace to v2.63.0 ([#2123](https://github.com/googleapis/java-firestore/issues/2123)) ([504fdb4](https://github.com/googleapis/java-firestore/commit/504fdb464783af39b8844392f84bcf8800dd0862)) +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.35.0 ([#2129](https://github.com/googleapis/java-firestore/issues/2129)) ([f5013ad](https://github.com/googleapis/java-firestore/commit/f5013add2338af8b5780df65c691999123795a37)) + +## [3.31.4](https://github.com/googleapis/java-firestore/compare/v3.31.3...v3.31.4) (2025-05-14) + + +### Bug Fixes + +* Status is missing while creating FirestoreException from ApiException ([#2107](https://github.com/googleapis/java-firestore/issues/2107)) ([00a6f54](https://github.com/googleapis/java-firestore/commit/00a6f54e044c963ca960ab1cec022a21cc4da29e)) + + +### Dependencies + +* Update beam.version to v2.65.0 ([#2115](https://github.com/googleapis/java-firestore/issues/2115)) ([a46be91](https://github.com/googleapis/java-firestore/commit/a46be91dab65084c8badcfd309661378e7d5c54c)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.48.0 ([#2117](https://github.com/googleapis/java-firestore/issues/2117)) ([6d74fc8](https://github.com/googleapis/java-firestore/commit/6d74fc86f9e85070207a97c13a82146475ce4a07)) +* Update googleapis/sdk-platform-java action to v2.58.0 ([#2118](https://github.com/googleapis/java-firestore/issues/2118)) ([3a5cb13](https://github.com/googleapis/java-firestore/commit/3a5cb13b1b9c73ac6a077df295d40d5673e8aaa9)) +* Update opentelemetry.version to v1.50.0 ([#2114](https://github.com/googleapis/java-firestore/issues/2114)) ([66d5e21](https://github.com/googleapis/java-firestore/commit/66d5e211533bf0d219c8e582c12632c2072e03ed)) + +## [3.31.3](https://github.com/googleapis/java-firestore/compare/v3.31.2...v3.31.3) (2025-05-08) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.57.0 ([b01cbf9](https://github.com/googleapis/java-firestore/commit/b01cbf94cfd0e9865210c329e3a8cf0bd124c3c7)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.62.0 ([#2105](https://github.com/googleapis/java-firestore/issues/2105)) ([06387ba](https://github.com/googleapis/java-firestore/commit/06387ba3fa34de5030332a45c1b641242fcda475)) +* Update dependency com.google.cloud:google-cloud-trace to v2.62.0 ([#2106](https://github.com/googleapis/java-firestore/issues/2106)) ([ce18e7c](https://github.com/googleapis/java-firestore/commit/ce18e7c88cfef044cc6e79a484db577423e408e4)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.47.0 ([#2103](https://github.com/googleapis/java-firestore/issues/2103)) ([9d90996](https://github.com/googleapis/java-firestore/commit/9d90996a75926907d8b4189b5e2c34a067a9501e)) +* Update googleapis/sdk-platform-java action to v2.57.0 ([#2104](https://github.com/googleapis/java-firestore/issues/2104)) ([9bfc6d3](https://github.com/googleapis/java-firestore/commit/9bfc6d3fbe69526a4fb3a7fcc058744edaecd88f)) + +## [3.31.2](https://github.com/googleapis/java-firestore/compare/v3.31.1...v3.31.2) (2025-05-05) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.56.3 ([1c367cd](https://github.com/googleapis/java-firestore/commit/1c367cd7368e5a9985aa068036c981a6e27508f2)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.61.0 ([#2094](https://github.com/googleapis/java-firestore/issues/2094)) ([20b64e0](https://github.com/googleapis/java-firestore/commit/20b64e0bd3437d137ba6b48ce670b6931a098559)) +* Update dependency com.google.cloud:google-cloud-trace to v2.61.0 ([#2095](https://github.com/googleapis/java-firestore/issues/2095)) ([2eeaa5b](https://github.com/googleapis/java-firestore/commit/2eeaa5bc4d8dc89b0e84f4a14f2b045d5412f379)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.46.3 ([#2099](https://github.com/googleapis/java-firestore/issues/2099)) ([025d07c](https://github.com/googleapis/java-firestore/commit/025d07c32e78b24c53227ade8a5afb06c2f6bfb9)) + +## [3.31.1](https://github.com/googleapis/java-firestore/compare/v3.31.0...v3.31.1) (2025-04-25) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.56.2 ([38aa23d](https://github.com/googleapis/java-firestore/commit/38aa23dcea0d8837403317e75c6abf04b2fc4050)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.46.1 ([#2084](https://github.com/googleapis/java-firestore/issues/2084)) ([83a593e](https://github.com/googleapis/java-firestore/commit/83a593e1745f488bc304fdfcb15d6a08f35eb177)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.46.2 ([#2088](https://github.com/googleapis/java-firestore/issues/2088)) ([757aa1c](https://github.com/googleapis/java-firestore/commit/757aa1c41db6da0a59bedc7a4335b8911def5b41)) +* Update googleapis/sdk-platform-java action to v2.56.1 ([#2081](https://github.com/googleapis/java-firestore/issues/2081)) ([455af48](https://github.com/googleapis/java-firestore/commit/455af48be2eb034d04c0f85efe104e1934abf295)) +* Update googleapis/sdk-platform-java action to v2.56.2 ([#2087](https://github.com/googleapis/java-firestore/issues/2087)) ([9aad696](https://github.com/googleapis/java-firestore/commit/9aad6966385d3873c30748d4e42df2c88cf77333)) + +## [3.31.0](https://github.com/googleapis/java-firestore/compare/v3.30.13...v3.31.0) (2025-04-23) + + +### Features + +* Add the UserCreds API ([f0e1ba1](https://github.com/googleapis/java-firestore/commit/f0e1ba1b9d9bae7235943ac1fbf5793ffec5d555)) +* New Firestore index modes and Database Editions ([f0e1ba1](https://github.com/googleapis/java-firestore/commit/f0e1ba1b9d9bae7235943ac1fbf5793ffec5d555)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.56.0 ([f0e1ba1](https://github.com/googleapis/java-firestore/commit/f0e1ba1b9d9bae7235943ac1fbf5793ffec5d555)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.46.0 ([#2076](https://github.com/googleapis/java-firestore/issues/2076)) ([1d1f633](https://github.com/googleapis/java-firestore/commit/1d1f633fafd2e935fb9cf9382d38a41548dafd41)) +* Update googleapis/sdk-platform-java action to v2.56.0 ([#2075](https://github.com/googleapis/java-firestore/issues/2075)) ([e88755d](https://github.com/googleapis/java-firestore/commit/e88755d777ae0e1c36c3ae0ad22556026db82578)) + +## [3.30.13](https://github.com/googleapis/java-firestore/compare/v3.30.12...v3.30.13) (2025-04-08) + + +### Dependencies + +* Update beam.version to v2.64.0 ([#2068](https://github.com/googleapis/java-firestore/issues/2068)) ([22e7b89](https://github.com/googleapis/java-firestore/commit/22e7b89fcc954ace5d1260a95a2405ca49e7c9f7)) +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.44.4 ([#2071](https://github.com/googleapis/java-firestore/issues/2071)) ([5ccefcf](https://github.com/googleapis/java-firestore/commit/5ccefcfa15f7c8d8bf33e0fdc04f5bdb95c5a72c)) +* Update opentelemetry.version to v1.49.0 ([#2070](https://github.com/googleapis/java-firestore/issues/2070)) ([23a1809](https://github.com/googleapis/java-firestore/commit/23a18095891f6b0ecb2f6d7a040d8ecf6a0f1720)) + +## [3.30.12](https://github.com/googleapis/java-firestore/compare/v3.30.11...v3.30.12) (2025-03-22) + + +### Bug Fixes + +* Elide string processing of 'fine' level log messages unless they will actually be logged ([#2055](https://github.com/googleapis/java-firestore/issues/2055)) ([22a41a2](https://github.com/googleapis/java-firestore/commit/22a41a265a24070ae08e88213319a7df6dd82759)) + + +### Dependencies + +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.34.0 ([#2046](https://github.com/googleapis/java-firestore/issues/2046)) ([cd610f3](https://github.com/googleapis/java-firestore/commit/cd610f3bea6ff676a943363b2fa40067a7705914)) + +## [3.30.11](https://github.com/googleapis/java-firestore/compare/v3.30.10...v3.30.11) (2025-03-20) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.55.1 ([3348504](https://github.com/googleapis/java-firestore/commit/3348504313bef2ec34cc1f7a00eaf5a23fd8debc)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.60.0 ([#2049](https://github.com/googleapis/java-firestore/issues/2049)) ([f68462c](https://github.com/googleapis/java-firestore/commit/f68462c815e7d08bccaa0a750e07919218cc6569)) +* Update dependency com.google.cloud:google-cloud-trace to v2.60.0 ([#2050](https://github.com/googleapis/java-firestore/issues/2050)) ([39111f5](https://github.com/googleapis/java-firestore/commit/39111f594351b6488a770e086d95b236f5d959d6)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.45.1 ([#2038](https://github.com/googleapis/java-firestore/issues/2038)) ([bbe6623](https://github.com/googleapis/java-firestore/commit/bbe66239b08bb7900774963c7a187b3d8d781614)) +* Update dependency node to v22 ([#2037](https://github.com/googleapis/java-firestore/issues/2037)) ([315987f](https://github.com/googleapis/java-firestore/commit/315987f5e5fcbd75fd29e670b7bca54e35381d27)) +* Update googleapis/sdk-platform-java action to v2.55.0 ([#2039](https://github.com/googleapis/java-firestore/issues/2039)) ([093850a](https://github.com/googleapis/java-firestore/commit/093850af5ff9713e9a425ed6c3abf834717670b3)) +* Update googleapis/sdk-platform-java action to v2.55.1 ([#2043](https://github.com/googleapis/java-firestore/issues/2043)) ([40973f2](https://github.com/googleapis/java-firestore/commit/40973f22576e57e9c5296b0526b4ed2b2693a2e1)) +* Update opentelemetry.version to v1.48.0 ([#2036](https://github.com/googleapis/java-firestore/issues/2036)) ([3a35489](https://github.com/googleapis/java-firestore/commit/3a354896e76bf459730b4d686b7c49ae3a88bd11)) + +## [3.30.10](https://github.com/googleapis/java-firestore/compare/v3.30.9...v3.30.10) (2025-03-06) + + +### Bug Fixes + +* Use lazy encoding in UTF-8 encoded string comparison ([#2021](https://github.com/googleapis/java-firestore/issues/2021)) ([11a4c74](https://github.com/googleapis/java-firestore/commit/11a4c743beddbc7415ef0157bbc4f545a27509f7)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.59.0 ([#2030](https://github.com/googleapis/java-firestore/issues/2030)) ([38d80ac](https://github.com/googleapis/java-firestore/commit/38d80ac587351c2c675e669f126a7825bba7235c)) +* Update dependency com.google.cloud:google-cloud-trace to v2.59.0 ([#2031](https://github.com/googleapis/java-firestore/issues/2031)) ([73a68a6](https://github.com/googleapis/java-firestore/commit/73a68a69e156cff1bf1ca6652ddd6e8dc58cf3f3)) + +## [3.30.9](https://github.com/googleapis/java-firestore/compare/v3.30.8...v3.30.9) (2025-02-26) + + +### Dependencies + +* Update beam.version to v2.63.0 ([#2020](https://github.com/googleapis/java-firestore/issues/2020)) ([dce5a4d](https://github.com/googleapis/java-firestore/commit/dce5a4d7d76c4544ecb408f3f0249f0302a199dd)) +* Update dependency com.android.tools.metalava:metalava to v1.0.0-alpha12 ([#2013](https://github.com/googleapis/java-firestore/issues/2013)) ([929d41c](https://github.com/googleapis/java-firestore/commit/929d41c2587a9836a715cb1488b6c24bdebdf5ba)) +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.44.3 ([#2023](https://github.com/googleapis/java-firestore/issues/2023)) ([6123125](https://github.com/googleapis/java-firestore/commit/6123125db23cc8c013498f64d22384669a60365f)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.58.0 ([#2018](https://github.com/googleapis/java-firestore/issues/2018)) ([966a471](https://github.com/googleapis/java-firestore/commit/966a4715173b48a37bf8dedd93b957a1165df8a9)) +* Update dependency com.google.cloud:google-cloud-trace to v2.58.0 ([#2019](https://github.com/googleapis/java-firestore/issues/2019)) ([3bd7fdb](https://github.com/googleapis/java-firestore/commit/3bd7fdbf368fb5f94f6150754cb66f987b467492)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.44.0 ([#2025](https://github.com/googleapis/java-firestore/issues/2025)) ([ff9ef43](https://github.com/googleapis/java-firestore/commit/ff9ef43852242c790a2cb78c9a44f4dc45ff8523)) +* Update dependency io.opentelemetry.semconv:opentelemetry-semconv to v1.30.0 ([#2022](https://github.com/googleapis/java-firestore/issues/2022)) ([3767e36](https://github.com/googleapis/java-firestore/commit/3767e36ca109a133a230f586a0253b01730668cb)) +* Update googleapis/sdk-platform-java action to v2.54.0 ([#2026](https://github.com/googleapis/java-firestore/issues/2026)) ([cde290d](https://github.com/googleapis/java-firestore/commit/cde290dec598ed6698ef6d361b52a5864fd28ab8)) + +## [3.30.8](https://github.com/googleapis/java-firestore/compare/v3.30.7...v3.30.8) (2025-02-13) + + +### Dependencies + +* Migrate to io.opentelemetry.semconv:opentelemetry-semconv dep ([#2014](https://github.com/googleapis/java-firestore/issues/2014)) ([b3df19e](https://github.com/googleapis/java-firestore/commit/b3df19e8ce2d11cc351e74e6155f30a7f947145c)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.43.0 ([#2011](https://github.com/googleapis/java-firestore/issues/2011)) ([b8c050e](https://github.com/googleapis/java-firestore/commit/b8c050e33e348daebf536e8cd6c25abe0280fc34)) +* Update googleapis/sdk-platform-java action to v2.53.0 ([#2012](https://github.com/googleapis/java-firestore/issues/2012)) ([04cc429](https://github.com/googleapis/java-firestore/commit/04cc429320cddef716d71f2b94ff710c1bcfa37a)) +* Update opentelemetry.version to v1.47.0 ([#2009](https://github.com/googleapis/java-firestore/issues/2009)) ([a832829](https://github.com/googleapis/java-firestore/commit/a8328297b2af87fe445cbd88e80ae7cbb87abdc6)) + +## [3.30.7](https://github.com/googleapis/java-firestore/compare/v3.30.6...v3.30.7) (2025-02-04) + + +### Bug Fixes + +* GetAuthenticationType in EmulatorCredentials should not throw. ([#2003](https://github.com/googleapis/java-firestore/issues/2003)) ([29afb41](https://github.com/googleapis/java-firestore/commit/29afb413f1f1f5bdbe7825b13fc3b200e8da211a)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.57.0 ([#2000](https://github.com/googleapis/java-firestore/issues/2000)) ([c5207bc](https://github.com/googleapis/java-firestore/commit/c5207bcb123130e261493283a345e674fc9d4b4b)) +* Update dependency com.google.cloud:google-cloud-trace to v2.57.0 ([#2001](https://github.com/googleapis/java-firestore/issues/2001)) ([b3917a9](https://github.com/googleapis/java-firestore/commit/b3917a98fb50d4bbf14f9840271f99a296df9c24)) + +## [3.30.6](https://github.com/googleapis/java-firestore/compare/v3.30.5...v3.30.6) (2025-01-28) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.42.0 ([#1996](https://github.com/googleapis/java-firestore/issues/1996)) ([050fe55](https://github.com/googleapis/java-firestore/commit/050fe55ab6f117866fa81012ca5ada1b334dd404)) +* Update googleapis/sdk-platform-java action to v2.52.0 ([#1993](https://github.com/googleapis/java-firestore/issues/1993)) ([24dfe38](https://github.com/googleapis/java-firestore/commit/24dfe38b0c2e06662151b76fb5b1b8a793119fdb)) + +## [3.30.5](https://github.com/googleapis/java-firestore/compare/v3.30.4...v3.30.5) (2025-01-24) + + +### Bug Fixes + +* Bump default deadline on CreateDatabase and RestoreDatabase to 2 minutes ([f3dac25](https://github.com/googleapis/java-firestore/commit/f3dac255a9ffb81b95da6a60ad2487f138157578)) + + +### Dependencies + +* Update beam.version to v2.62.0 ([#1984](https://github.com/googleapis/java-firestore/issues/1984)) ([cbf1ceb](https://github.com/googleapis/java-firestore/commit/cbf1cebfa3c17fe3dca103cf6bb2d523857529c9)) + +## [3.30.4](https://github.com/googleapis/java-firestore/compare/v3.30.3...v3.30.4) (2025-01-16) + + +### Bug Fixes + +* Comparing double with long ([#1960](https://github.com/googleapis/java-firestore/issues/1960)) ([8cb4dc8](https://github.com/googleapis/java-firestore/commit/8cb4dc8859b1d8331657704f36baba472ea3115c)) +* Sort strings in UTF-8 encoded byte order ([#1967](https://github.com/googleapis/java-firestore/issues/1967)) ([4309639](https://github.com/googleapis/java-firestore/commit/43096393dd9e49dd9144fd2351e29cb40ea855c5)) + + +### Dependencies + +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.44.2 ([#1981](https://github.com/googleapis/java-firestore/issues/1981)) ([c4ea331](https://github.com/googleapis/java-firestore/commit/c4ea33134a63c722a15288421cc023a1ec5c5c74)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.56.0 ([#1975](https://github.com/googleapis/java-firestore/issues/1975)) ([7388291](https://github.com/googleapis/java-firestore/commit/73882910443407c529e4d6763ebe78fd1c0411b1)) +* Update dependency com.google.cloud:google-cloud-trace to v2.56.0 ([#1976](https://github.com/googleapis/java-firestore/issues/1976)) ([978c053](https://github.com/googleapis/java-firestore/commit/978c053b0801da5f708d0016cae3358d33f1b2bd)) +* Update opentelemetry.version to v1.46.0 ([#1977](https://github.com/googleapis/java-firestore/issues/1977)) ([2b3de13](https://github.com/googleapis/java-firestore/commit/2b3de13db866badf1b405b3b2383cc85076460eb)) + +## [3.30.3](https://github.com/googleapis/java-firestore/compare/v3.30.2...v3.30.3) (2025-01-11) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.51.1 ([f6fcbf1](https://github.com/googleapis/java-firestore/commit/f6fcbf10485317ff370d9698947f3bbf2ae63cfb)) +* Sort document reference by long type id ([#1945](https://github.com/googleapis/java-firestore/issues/1945)) ([c38e3ad](https://github.com/googleapis/java-firestore/commit/c38e3adc08e50a7946523aa0ba4ef46943cf2b85)) + + +### Dependencies + +* Update dependency com.diffplug.spotless:spotless-maven-plugin to v2.44.1 ([#1969](https://github.com/googleapis/java-firestore/issues/1969)) ([7a4813b](https://github.com/googleapis/java-firestore/commit/7a4813b2e5c6be246f7f6a312afba78d76ff3927)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.55.0 ([#1961](https://github.com/googleapis/java-firestore/issues/1961)) ([5c62282](https://github.com/googleapis/java-firestore/commit/5c6228215e1c40de420c765e6aecb81a312e7954)) +* Update dependency com.google.cloud:google-cloud-trace to v2.55.0 ([#1962](https://github.com/googleapis/java-firestore/issues/1962)) ([d8144b5](https://github.com/googleapis/java-firestore/commit/d8144b55ba68b79fafd4f5a3a6a640d959caf2be)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.41.1 ([#1970](https://github.com/googleapis/java-firestore/issues/1970)) ([bbf75cc](https://github.com/googleapis/java-firestore/commit/bbf75cc4b7421ddab8ac5538fc0084218a4e3a1b)) +* Update googleapis/sdk-platform-java action to v2.51.1 ([#1968](https://github.com/googleapis/java-firestore/issues/1968)) ([9f318b0](https://github.com/googleapis/java-firestore/commit/9f318b030637a8e354e4d10651ea2d4073098c2a)) + +## [3.30.2](https://github.com/googleapis/java-firestore/compare/v3.30.1...v3.30.2) (2024-12-13) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.51.0 ([c623c1d](https://github.com/googleapis/java-firestore/commit/c623c1da37f83febe4492e2acb8908f297a210f3)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.41.0 ([#1954](https://github.com/googleapis/java-firestore/issues/1954)) ([888d705](https://github.com/googleapis/java-firestore/commit/888d705cda06103d6defaa17e3d3fd8b9e535f54)) +* Update googleapis/sdk-platform-java action to v2.51.0 ([#1952](https://github.com/googleapis/java-firestore/issues/1952)) ([9826cba](https://github.com/googleapis/java-firestore/commit/9826cbac81038ca445dc534b392124eac0095742)) + +## [3.30.1](https://github.com/googleapis/java-firestore/compare/v3.30.0...v3.30.1) (2024-12-09) + + +### Bug Fixes + +* BulkWriter flush logic ([#1778](https://github.com/googleapis/java-firestore/issues/1778)) ([627619d](https://github.com/googleapis/java-firestore/commit/627619d33a051f6709a563b7375ebe39956f9ebf)) + + +### Dependencies + +* Update opentelemetry.version to v1.45.0 ([#1947](https://github.com/googleapis/java-firestore/issues/1947)) ([5bb839c](https://github.com/googleapis/java-firestore/commit/5bb839cdab3e8f5d4214a2fbce07f9ed34e769ca)) + +## [3.30.0](https://github.com/googleapis/java-firestore/compare/v3.29.1...v3.30.0) (2024-11-26) + + +### Features + +* Introduce `java.time` variables and methods ([#1935](https://github.com/googleapis/java-firestore/issues/1935)) ([6c94910](https://github.com/googleapis/java-firestore/commit/6c949106ed25690bcc9e7f73c6459130ed83b9b9)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.54.0 ([#1937](https://github.com/googleapis/java-firestore/issues/1937)) ([0a90abc](https://github.com/googleapis/java-firestore/commit/0a90abcefdc154cbafd27a0c7c9b991c1b144b1b)) +* Update dependency com.google.cloud:google-cloud-trace to v2.54.0 ([#1933](https://github.com/googleapis/java-firestore/issues/1933)) ([622b742](https://github.com/googleapis/java-firestore/commit/622b74230dd6da5196f4173f2a1113cc0e2da44b)) +* Update dependency org.apache.beam:beam-runners-direct-java to v2.61.0 ([#1939](https://github.com/googleapis/java-firestore/issues/1939)) ([4823bdd](https://github.com/googleapis/java-firestore/commit/4823bddf2552f90303b292a6c1e985cb21e6581d)) + +## [3.29.1](https://github.com/googleapis/java-firestore/compare/v3.29.0...v3.29.1) (2024-11-18) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.50.0 ([aef5ec5](https://github.com/googleapis/java-firestore/commit/aef5ec5c0da68a4bb438100faf9884e000e8a1d1)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.40.0 ([#1928](https://github.com/googleapis/java-firestore/issues/1928)) ([8b6bc9a](https://github.com/googleapis/java-firestore/commit/8b6bc9afba31d3938fbdcda0e5c9616dfd7daa2a)) +* Update googleapis/sdk-platform-java action to v2.50.0 ([#1927](https://github.com/googleapis/java-firestore/issues/1927)) ([700ed0a](https://github.com/googleapis/java-firestore/commit/700ed0ac7ceae1b9c40c919ad9e7342f3bdb85a3)) + +## [3.29.0](https://github.com/googleapis/java-firestore/compare/v3.28.0...v3.29.0) (2024-11-13) + + +### Bug Fixes + +* Drop the setTracingEnabled flag from Options (@BetaApi change) ([#1869](https://github.com/googleapis/java-firestore/issues/1869)) ([712d57e](https://github.com/googleapis/java-firestore/commit/712d57e05da8de41850d94fa19eb253cf3020c0f)) +* Improve error messages in tests ([#1855](https://github.com/googleapis/java-firestore/issues/1855)) ([cb5f9d6](https://github.com/googleapis/java-firestore/commit/cb5f9d6f481c9c839a387579bf60742b7c2c0508)) +* Make StreamableQuery#internalStream package-private to avoid documentation and prevent clirr errors ([593acc3](https://github.com/googleapis/java-firestore/commit/593acc3614f86bdf42387eac5ef8d7ce14dbbec8)) + + +### Dependencies + +* Update opentelemetry.version to v1.44.1 ([#1924](https://github.com/googleapis/java-firestore/issues/1924)) ([68deeac](https://github.com/googleapis/java-firestore/commit/68deeac02eabb927ba8b91c77f3be8471ba66718)) + +## [3.28.0](https://github.com/googleapis/java-firestore/compare/v3.27.4...v3.28.0) (2024-10-29) + + +### Features + +* Improve Logging ([#1892](https://github.com/googleapis/java-firestore/issues/1892)) ([e74457a](https://github.com/googleapis/java-firestore/commit/e74457a1448189978e791fb3efe76d5fe8370ff7)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.53.0 ([#1913](https://github.com/googleapis/java-firestore/issues/1913)) ([cbaa7a7](https://github.com/googleapis/java-firestore/commit/cbaa7a7c44c82a173194e3c36289bc6b867b93b7)) +* Update dependency com.google.cloud:google-cloud-trace to v2.53.0 ([#1914](https://github.com/googleapis/java-firestore/issues/1914)) ([d3834e1](https://github.com/googleapis/java-firestore/commit/d3834e10b509b3d5c0e1a55318001f9eb80e7f45)) + +## [3.27.4](https://github.com/googleapis/java-firestore/compare/v3.27.3...v3.27.4) (2024-10-28) + + +### Bug Fixes + +* Add the deprecation notice for tracing enable/disable option. ([#1866](https://github.com/googleapis/java-firestore/issues/1866)) ([d213245](https://github.com/googleapis/java-firestore/commit/d213245a77b42eca110ef579a0c9fa7108357717)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.49.0 ([0bd75f1](https://github.com/googleapis/java-firestore/commit/0bd75f11587a55eb380b094f2900f2f847a7a103)) + + +### Dependencies + +* Update beam.version to v2.60.0 ([#1894](https://github.com/googleapis/java-firestore/issues/1894)) ([434e6e0](https://github.com/googleapis/java-firestore/commit/434e6e0b9a738f9ac08788dbf5dd94a0678733aa)) +* Update googleapis/sdk-platform-java action to v2.48.0 ([#1899](https://github.com/googleapis/java-firestore/issues/1899)) ([eaf3c0c](https://github.com/googleapis/java-firestore/commit/eaf3c0cfe3dd4dce8afeb9fbb8e2455492c31443)) +* Update sdk-platform-java dependencies ([#1901](https://github.com/googleapis/java-firestore/issues/1901)) ([a698223](https://github.com/googleapis/java-firestore/commit/a698223668a5886c65f00760051b8e022d18559c)) +* Update sdk-platform-java dependencies ([#1906](https://github.com/googleapis/java-firestore/issues/1906)) ([d70f77a](https://github.com/googleapis/java-firestore/commit/d70f77a85c2e17930626674ff292713a276d71ce)) + +## [3.27.3](https://github.com/googleapis/java-firestore/compare/v3.27.2...v3.27.3) (2024-10-16) + + +### Dependencies + +* Update opentelemetry.version to v1.43.0 ([#1884](https://github.com/googleapis/java-firestore/issues/1884)) ([f07ac99](https://github.com/googleapis/java-firestore/commit/f07ac990fece6d59d898419d1cca0b2a91a64248)) + +## [3.27.2](https://github.com/googleapis/java-firestore/compare/v3.27.1...v3.27.2) (2024-10-10) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.52.0 ([#1879](https://github.com/googleapis/java-firestore/issues/1879)) ([33cdd41](https://github.com/googleapis/java-firestore/commit/33cdd41949739d37c66830d9b85757d19dbbe31e)) +* Update dependency com.google.cloud:google-cloud-trace to v2.52.0 ([#1880](https://github.com/googleapis/java-firestore/issues/1880)) ([2827f77](https://github.com/googleapis/java-firestore/commit/2827f777bf08bdda3599f1a81193e6957533aa19)) +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.33.0 ([#1876](https://github.com/googleapis/java-firestore/issues/1876)) ([b3fba1f](https://github.com/googleapis/java-firestore/commit/b3fba1f58317e00573f37060bd082283ce9ec2ed)) + +## [3.27.1](https://github.com/googleapis/java-firestore/compare/v3.27.0...v3.27.1) (2024-10-07) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.47.0 ([c606cea](https://github.com/googleapis/java-firestore/commit/c606ceaccd61cede8799d12b074682a15a03ccff)) +* Update to Java 11, since runtime doesn't support 8. ([#1867](https://github.com/googleapis/java-firestore/issues/1867)) ([723c7cc](https://github.com/googleapis/java-firestore/commit/723c7ccc783b2f56ca72867cd741df197a9f68d7)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.37.0 ([#1871](https://github.com/googleapis/java-firestore/issues/1871)) ([8503a3e](https://github.com/googleapis/java-firestore/commit/8503a3e6badc31eaae4d318925097d010d9d73e4)) +* Update googleapis/sdk-platform-java action to v2.47.0 ([#1870](https://github.com/googleapis/java-firestore/issues/1870)) ([971b164](https://github.com/googleapis/java-firestore/commit/971b164104fe072255a26dfaa4e93958fb43b706)) + +## [3.27.0](https://github.com/googleapis/java-firestore/compare/v3.26.5...v3.27.0) (2024-10-02) + + +### Features + +* Add support for vector search with Query#findNearest ([#1827](https://github.com/googleapis/java-firestore/issues/1827)) ([4ad463a](https://github.com/googleapis/java-firestore/commit/4ad463a6932b90ca0cb3dd015b2543ffbf850eb9)) + + +### Dependencies + +* Update googleapis/sdk-platform-java action to v2.46.1 ([#1862](https://github.com/googleapis/java-firestore/issues/1862)) ([f35bcdb](https://github.com/googleapis/java-firestore/commit/f35bcdbfced37438379b969efe071958b6ac94a0)) + +## [3.26.5](https://github.com/googleapis/java-firestore/compare/v3.26.4...v3.26.5) (2024-09-30) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.46.1 ([f9ddf32](https://github.com/googleapis/java-firestore/commit/f9ddf32e6a9c071d5008b101523b83ffbacf712e)) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.51.0 ([#1852](https://github.com/googleapis/java-firestore/issues/1852)) ([1efbb10](https://github.com/googleapis/java-firestore/commit/1efbb10c20b7cb3e696b14867b1149d83cb53a16)) +* Update dependency com.google.cloud:google-cloud-trace to v2.51.0 ([#1853](https://github.com/googleapis/java-firestore/issues/1853)) ([e674b7a](https://github.com/googleapis/java-firestore/commit/e674b7a77915a5f55582ee54f5304ea958e274b4)) + +## [3.26.4](https://github.com/googleapis/java-firestore/compare/v3.26.3...v3.26.4) (2024-09-27) + + +### Features + +* Java record serialization/deserialization ([#1842](https://github.com/googleapis/java-firestore/issues/1842)) ([aff93bf](https://github.com/googleapis/java-firestore/commit/aff93bfbf1d39188a050f4423bddd26a1390dad8)) + + +### Bug Fixes + +* Fix clirr check failure ([#1841](https://github.com/googleapis/java-firestore/issues/1841)) ([b8b995f](https://github.com/googleapis/java-firestore/commit/b8b995f543de95fb35d6568570b625ddcccfdb6a)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.0 ([#1843](https://github.com/googleapis/java-firestore/issues/1843)) ([4ef02c3](https://github.com/googleapis/java-firestore/commit/4ef02c34c03c00c924aadeee281b3d1a5f523234)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 ([#1847](https://github.com/googleapis/java-firestore/issues/1847)) ([7415278](https://github.com/googleapis/java-firestore/commit/74152785d92b866a8bc39b908e9079c446abf894)) +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.32.0 ([#1845](https://github.com/googleapis/java-firestore/issues/1845)) ([310d680](https://github.com/googleapis/java-firestore/commit/310d68093b29584e13d1f651a981768225d1c716)) +* Update dependency ubuntu to v24 ([#1848](https://github.com/googleapis/java-firestore/issues/1848)) ([c60fb51](https://github.com/googleapis/java-firestore/commit/c60fb51c213fd81907138825651f12fe598fdce8)) + +## [3.26.3](https://github.com/googleapis/java-firestore/compare/v3.26.2...v3.26.3) (2024-09-18) + + +### Bug Fixes + +* Revert "Feat: Record serialization/deserialization" ([61073e3](https://github.com/googleapis/java-firestore/commit/61073e37c5f7a9dff12b450667f8c759edbf713d)) + +## [3.26.2](https://github.com/googleapis/java-firestore/compare/v3.26.1...v3.26.2) (2024-09-17) + + +### Features + +* Record serialization/deserialization ([#1706](https://github.com/googleapis/java-firestore/issues/1706)) ([f5613b4](https://github.com/googleapis/java-firestore/commit/f5613b4ecb46c61cd7c24ae55606a63f92303360)) + + +### Bug Fixes + +* Remove race condition in test. ([#1826](https://github.com/googleapis/java-firestore/issues/1826)) ([791281e](https://github.com/googleapis/java-firestore/commit/791281e4693f4e9cf2ff052dadf71a2479c6a979)) + +## [3.26.1](https://github.com/googleapis/java-firestore/compare/v3.26.0...v3.26.1) (2024-09-16) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.49.0 ([#1818](https://github.com/googleapis/java-firestore/issues/1818)) ([c651a6f](https://github.com/googleapis/java-firestore/commit/c651a6ffda59597fce70558ea38681b1f7be3354)) +* Update dependency com.google.cloud:google-cloud-trace to v2.49.0 ([#1819](https://github.com/googleapis/java-firestore/issues/1819)) ([9279409](https://github.com/googleapis/java-firestore/commit/9279409f0441fc4105825fc464806c2fb530ae0e)) + +## [3.26.0](https://github.com/googleapis/java-firestore/compare/v3.25.1...v3.26.0) (2024-09-12) + + +### Features + +* Add additional Firestore query snippets ([#1790](https://github.com/googleapis/java-firestore/issues/1790)) ([4099e5b](https://github.com/googleapis/java-firestore/commit/4099e5b3a97d9b40277b88a16b8e682e2f2acbf1)) + + +### Dependencies + +* Update beam.version ([#1794](https://github.com/googleapis/java-firestore/issues/1794)) ([0737ada](https://github.com/googleapis/java-firestore/commit/0737adaf0f990f5ad62a4cac00b490503b804302)) +* Update beam.version to v2.59.0 ([#1813](https://github.com/googleapis/java-firestore/issues/1813)) ([0264e23](https://github.com/googleapis/java-firestore/commit/0264e231909562bd54e8f48e74e9a9e1469ecb5d)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.48.0 ([#1800](https://github.com/googleapis/java-firestore/issues/1800)) ([1c7c12f](https://github.com/googleapis/java-firestore/commit/1c7c12f915e76f25652adbad0864c5c7d810e268)) +* Update dependency com.google.cloud:google-cloud-trace to v2.48.0 ([#1801](https://github.com/googleapis/java-firestore/issues/1801)) ([3d9082c](https://github.com/googleapis/java-firestore/commit/3d9082c2ee04c2e99facac2e5c0f664e33216f08)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.35.0 ([#1810](https://github.com/googleapis/java-firestore/issues/1810)) ([f4010e3](https://github.com/googleapis/java-firestore/commit/f4010e3dafe5696a6a5dbf16b18327ffb672e9ee)) +* Update dependency org.apache.commons:commons-lang3 to v3.17.0 ([#1792](https://github.com/googleapis/java-firestore/issues/1792)) ([61b9810](https://github.com/googleapis/java-firestore/commit/61b981008cd882f8c4dabaa71cef843b607c9e2c)) +* Update opentelemetry.version to v1.42.1 ([#1809](https://github.com/googleapis/java-firestore/issues/1809)) ([cb821d9](https://github.com/googleapis/java-firestore/commit/cb821d981517e318dad4469957d9993c759f56e4)) + +## [3.25.1](https://github.com/googleapis/java-firestore/compare/v3.25.0...v3.25.1) (2024-08-20) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.34.0 ([#1795](https://github.com/googleapis/java-firestore/issues/1795)) ([abb3f7f](https://github.com/googleapis/java-firestore/commit/abb3f7fb25844b0a2b7c9eb2132c17eadb3c528a)) +* Update opentelemetry.version to v1.41.0 ([#1793](https://github.com/googleapis/java-firestore/issues/1793)) ([165aae9](https://github.com/googleapis/java-firestore/commit/165aae94f2628255f84e68eac08ecef75967a237)) + +## [3.25.0](https://github.com/googleapis/java-firestore/compare/v3.24.3...v3.25.0) (2024-08-12) + + +### Features + +* Add support for the VectorValue type ([#1716](https://github.com/googleapis/java-firestore/issues/1716)) ([81bfa0d](https://github.com/googleapis/java-firestore/commit/81bfa0daeb4b75b2b964e8480a9baae711540e02)) +* Expose the proto changes to support `FindNearest.distance_result_field` parameter and the `FindNearest.distance_threshold` parameter ([6456d85](https://github.com/googleapis/java-firestore/commit/6456d855b2eef93869fcb06e39246a6ada589948)) + +## [3.24.3](https://github.com/googleapis/java-firestore/compare/v3.24.2...v3.24.3) (2024-08-06) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2.47.0 ([#1774](https://github.com/googleapis/java-firestore/issues/1774)) ([222629a](https://github.com/googleapis/java-firestore/commit/222629a97da72cfb32e9da6280896d3cee09885c)) +* Update dependency com.google.cloud:google-cloud-trace to v2.47.0 ([#1775](https://github.com/googleapis/java-firestore/issues/1775)) ([d3c2744](https://github.com/googleapis/java-firestore/commit/d3c274427d08a7e4ccbcdaa387645adc201360a5)) + +## [3.24.2](https://github.com/googleapis/java-firestore/compare/v3.24.1...v3.24.2) (2024-07-29) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.33.0 ([#1762](https://github.com/googleapis/java-firestore/issues/1762)) ([76090ce](https://github.com/googleapis/java-firestore/commit/76090ce87a4614c9416a1738fe5edbd07f40e440)) + +## [3.24.1](https://github.com/googleapis/java-firestore/compare/v3.24.0...v3.24.1) (2024-07-22) + + +### Dependencies + +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v1.4.2 ([#1749](https://github.com/googleapis/java-firestore/issues/1749)) ([b20371a](https://github.com/googleapis/java-firestore/commit/b20371a62fa261b50a4522786d4f91a5fac01487)) +* Update dependency com.google.api.grpc:proto-google-cloud-trace-v1 to v2 ([#1755](https://github.com/googleapis/java-firestore/issues/1755)) ([fb71213](https://github.com/googleapis/java-firestore/commit/fb712130e51327a71d0c90f6f3cda76398ec9e0a)) +* Update dependency com.google.cloud:google-cloud-trace to v2 ([#1756](https://github.com/googleapis/java-firestore/issues/1756)) ([f6989d8](https://github.com/googleapis/java-firestore/commit/f6989d89211849cd301e799406f59283b8162ea9)) +* Update dependency com.google.cloud.opentelemetry:exporter-trace to v0.31.0 ([#1750](https://github.com/googleapis/java-firestore/issues/1750)) ([7219bb3](https://github.com/googleapis/java-firestore/commit/7219bb3f0e98462faeb8d7e24f1aedad4cd2de15)) +* Update opentelemetry.version to v1.40.0 ([#1753](https://github.com/googleapis/java-firestore/issues/1753)) ([23ce20b](https://github.com/googleapis/java-firestore/commit/23ce20b08d8da195cf32036de4e73cee831225ef)) + +## [3.24.0](https://github.com/googleapis/java-firestore/compare/v3.23.1...v3.24.0) (2024-07-18) + + +### Features + +* Tracing using OpenTelemetry ([#1728](https://github.com/googleapis/java-firestore/issues/1728)) ([00dc240](https://github.com/googleapis/java-firestore/commit/00dc2403d2a5a5b6809762010a716f17541204e0)) + + +### Dependencies + +* Update dependency org.apache.commons:commons-lang3 to v3.15.0 ([#1745](https://github.com/googleapis/java-firestore/issues/1745)) ([05a6f73](https://github.com/googleapis/java-firestore/commit/05a6f73f259050520880d670e5ab997d12e8cafb)) + +## [3.23.1](https://github.com/googleapis/java-firestore/compare/v3.23.0...v3.23.1) (2024-07-10) + + +### Dependencies + +* Update dependency com.android.tools.metalava:metalava to v1.0.0-alpha11 ([#1736](https://github.com/googleapis/java-firestore/issues/1736)) ([649d7b4](https://github.com/googleapis/java-firestore/commit/649d7b43424201168bf64a38d923b423d731f100)) + +## [3.23.0](https://github.com/googleapis/java-firestore/compare/v3.22.0...v3.23.0) (2024-07-10) + + +### Features + +* Enable hermetic library generation ([#1697](https://github.com/googleapis/java-firestore/issues/1697)) ([85e66df](https://github.com/googleapis/java-firestore/commit/85e66df5fc51f9aaafe71f784773b9107671c477)) + + +### Bug Fixes + +* Correct hermetic library generation script path ([#1727](https://github.com/googleapis/java-firestore/issues/1727)) ([172d224](https://github.com/googleapis/java-firestore/commit/172d224aa767a69e9c02419bb48f506a1861c787)) + +## [3.22.0](https://github.com/googleapis/java-firestore/compare/v3.21.6...v3.22.0) (2024-06-27) + + +### Features + +* Add bulk delete api ([#1704](https://github.com/googleapis/java-firestore/issues/1704)) ([5ef6254](https://github.com/googleapis/java-firestore/commit/5ef625456afbee781951d2a5c6a9c2548feea92e)) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.3 ([#1722](https://github.com/googleapis/java-firestore/issues/1722)) ([c4627a4](https://github.com/googleapis/java-firestore/commit/c4627a4e664d67d5b34a27d791cd0c06ee789f85)) + +## [3.21.6](https://github.com/googleapis/java-firestore/compare/v3.21.5...v3.21.6) (2024-06-26) + + +### Dependencies + +* Update beam.version to v2.57.0 ([#1715](https://github.com/googleapis/java-firestore/issues/1715)) ([d8dcd5b](https://github.com/googleapis/java-firestore/commit/d8dcd5b93ce41c1bb985a3fd626f93ea3981880a)) + +## [3.21.5](https://github.com/googleapis/java-firestore/compare/v3.21.4...v3.21.5) (2024-06-25) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.32.0 ([#1710](https://github.com/googleapis/java-firestore/issues/1710)) ([2906472](https://github.com/googleapis/java-firestore/commit/2906472816001d4ffdc21f3b94a36de7d925f6dc)) + +## [3.21.4](https://github.com/googleapis/java-firestore/compare/v3.21.3...v3.21.4) (2024-06-10) + + +### Bug Fixes + +* Migrate off GeneratedMessageV3 ([#1692](https://github.com/googleapis/java-firestore/issues/1692)) ([44c26e9](https://github.com/googleapis/java-firestore/commit/44c26e978d01242b7ad468adab96958f6fa0a34f)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.31.0 ([#1699](https://github.com/googleapis/java-firestore/issues/1699)) ([ef7349a](https://github.com/googleapis/java-firestore/commit/ef7349aa11d10392c8b4afab693dd731fcd3c43d)) + +## [3.21.3](https://github.com/googleapis/java-firestore/compare/v3.21.2...v3.21.3) (2024-05-17) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.10.2 ([#1685](https://github.com/googleapis/java-firestore/issues/1685)) ([d3f329f](https://github.com/googleapis/java-firestore/commit/d3f329fa4d1b0e833843090cdc7adc27c6bb2505)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.10.2 ([#1686](https://github.com/googleapis/java-firestore/issues/1686)) ([bafebb8](https://github.com/googleapis/java-firestore/commit/bafebb8b69f9ccf8166ce5cd218f3346b0e647b9)) + +## [3.21.2](https://github.com/googleapis/java-firestore/compare/v3.21.1...v3.21.2) (2024-05-16) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.1 ([#1681](https://github.com/googleapis/java-firestore/issues/1681)) ([9fb8531](https://github.com/googleapis/java-firestore/commit/9fb853147d5af34a3ec7e68317be8e588a7cae91)) + +## [3.21.1](https://github.com/googleapis/java-firestore/compare/v3.21.0...v3.21.1) (2024-05-03) + + +### Bug Fixes + +* Add configurable to run tests against different firestore backends ([#1659](https://github.com/googleapis/java-firestore/issues/1659)) ([a60d2a3](https://github.com/googleapis/java-firestore/commit/a60d2a3622a7193844f150a005bfb89204fc43af)) + + +### Dependencies + +* Update beam.version to v2.56.0 ([#1669](https://github.com/googleapis/java-firestore/issues/1669)) ([a4b4d1d](https://github.com/googleapis/java-firestore/commit/a4b4d1dc3e5b13209efb288f0cead7bcea2013e0)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.0 ([#1670](https://github.com/googleapis/java-firestore/issues/1670)) ([5bcbf88](https://github.com/googleapis/java-firestore/commit/5bcbf88b1174d5e2615f66d9997be76481842131)) + +## [3.21.0](https://github.com/googleapis/java-firestore/compare/v3.20.2...v3.21.0) (2024-04-26) + + +### Features + +* Add Vector Index API ([4964982](https://github.com/googleapis/java-firestore/commit/496498271b31a878910c17954350673beade2bef)) +* Add VectorSearch API ([4964982](https://github.com/googleapis/java-firestore/commit/496498271b31a878910c17954350673beade2bef)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.39.0 ([#1629](https://github.com/googleapis/java-firestore/issues/1629)) ([4964982](https://github.com/googleapis/java-firestore/commit/496498271b31a878910c17954350673beade2bef)) + + +### Documentation + +* Allow 14 week backup retention for Firestore daily backups ([4964982](https://github.com/googleapis/java-firestore/commit/496498271b31a878910c17954350673beade2bef)) +* Correct BackupSchedule recurrence docs that mentioned specific time of day ([4964982](https://github.com/googleapis/java-firestore/commit/496498271b31a878910c17954350673beade2bef)) + +## [3.20.2](https://github.com/googleapis/java-firestore/compare/v3.20.1...v3.20.2) (2024-04-19) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.29.0 ([#1652](https://github.com/googleapis/java-firestore/issues/1652)) ([1e3b0b9](https://github.com/googleapis/java-firestore/commit/1e3b0b9dde920d18311de226a52652ef71a6a180)) + +## [3.20.1](https://github.com/googleapis/java-firestore/compare/v3.20.0...v3.20.1) (2024-04-18) + + +### Dependencies + +* Update beam.version to v2.55.1 ([#1643](https://github.com/googleapis/java-firestore/issues/1643)) ([88ce6c3](https://github.com/googleapis/java-firestore/commit/88ce6c3c1855c527243fcdf236d8210e8ecb3610)) + +## [3.20.0](https://github.com/googleapis/java-firestore/compare/v3.19.3...v3.20.0) (2024-03-26) + + +### Features + +* Query Profiling ([#1609](https://github.com/googleapis/java-firestore/issues/1609)) ([55b1a49](https://github.com/googleapis/java-firestore/commit/55b1a49ad3b75835b6b4f8a1cfd8d665c1a56968)) + + +### Dependencies + +* Update beam.version to v2.55.0 ([#1631](https://github.com/googleapis/java-firestore/issues/1631)) ([bdb2e43](https://github.com/googleapis/java-firestore/commit/bdb2e4314d2eacdff69b538876e69e7007427925)) + +## [3.19.3](https://github.com/googleapis/java-firestore/compare/v3.19.2...v3.19.3) (2024-03-21) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.28.1 ([#1625](https://github.com/googleapis/java-firestore/issues/1625)) ([f390946](https://github.com/googleapis/java-firestore/commit/f39094608151df51f32a8f91717eee5840a2d4d2)) + +## [3.19.2](https://github.com/googleapis/java-firestore/compare/v3.19.1...v3.19.2) (2024-03-18) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.28.1 ([#1617](https://github.com/googleapis/java-firestore/issues/1617)) ([44d5e8d](https://github.com/googleapis/java-firestore/commit/44d5e8d9e6e05c9119dd5a5fdfc51ebba27c71c9)) + +## [3.19.1](https://github.com/googleapis/java-firestore/compare/v3.19.0...v3.19.1) (2024-03-15) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.28.0 ([#1612](https://github.com/googleapis/java-firestore/issues/1612)) ([06fa74e](https://github.com/googleapis/java-firestore/commit/06fa74e5fbaf1bbc74ab8d220356ad2c6ab4b7ac)) + +## [3.19.0](https://github.com/googleapis/java-firestore/compare/v3.18.0...v3.19.0) (2024-03-15) + + +### Features + +* A new message `Backup` is added ([#1611](https://github.com/googleapis/java-firestore/issues/1611)) ([434a55b](https://github.com/googleapis/java-firestore/commit/434a55b478fc617c2ec892a30d3eb1ce027ac54f)) +* Add ExplainMetrics field to RunAggregationQueryResponse ([f275b16](https://github.com/googleapis/java-firestore/commit/f275b1603225895e2673131191b4c15927e3bdcd)) +* Add ExplainMetrics field to RunQueryResponse ([f275b16](https://github.com/googleapis/java-firestore/commit/f275b1603225895e2673131191b4c15927e3bdcd)) +* Add ExplainOptions field to RunAggregationQueryRequest ([f275b16](https://github.com/googleapis/java-firestore/commit/f275b1603225895e2673131191b4c15927e3bdcd)) +* Add ExplainOptions field to RunQueryRequest ([f275b16](https://github.com/googleapis/java-firestore/commit/f275b1603225895e2673131191b4c15927e3bdcd)) +* Add new types ExplainOptions, ExplainMetrics, PlanSummary, ExecutionStats ([#1608](https://github.com/googleapis/java-firestore/issues/1608)) ([f275b16](https://github.com/googleapis/java-firestore/commit/f275b1603225895e2673131191b4c15927e3bdcd)) + + +### Bug Fixes + +* Update DocFX profile ([#1603](https://github.com/googleapis/java-firestore/issues/1603)) ([0a2eb16](https://github.com/googleapis/java-firestore/commit/0a2eb1640e1d4fb13d05bc489ace5a773a0b9a78)) + +## [3.18.0](https://github.com/googleapis/java-firestore/compare/v3.17.1...v3.18.0) (2024-03-04) + + +### Features + +* `Instant` support ([#1586](https://github.com/googleapis/java-firestore/issues/1586)) ([77a9bfc](https://github.com/googleapis/java-firestore/commit/77a9bfc9c501eeb10ee97f91b0b0b97e92f2c71d)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.37.0 ([#1597](https://github.com/googleapis/java-firestore/issues/1597)) ([7574dfd](https://github.com/googleapis/java-firestore/commit/7574dfd1c73c73c3de7cf3235e55ed20190991b8)) +* Only override built-in retry settings when the customer provides them. ([#1588](https://github.com/googleapis/java-firestore/issues/1588)) ([103c37a](https://github.com/googleapis/java-firestore/commit/103c37a92764930480149f288fd9350a829d4953)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.27.0 ([#1596](https://github.com/googleapis/java-firestore/issues/1596)) ([2672d71](https://github.com/googleapis/java-firestore/commit/2672d7173b2bd5723beb7fa1be4d3e2bf1ec0e9c)) + +## [3.17.1](https://github.com/googleapis/java-firestore/compare/v3.17.0...v3.17.1) (2024-02-22) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.10.1 ([#1576](https://github.com/googleapis/java-firestore/issues/1576)) ([f45af23](https://github.com/googleapis/java-firestore/commit/f45af236c0b74ab2507e232ed2c3e6c2d9363360)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.10.1 ([#1577](https://github.com/googleapis/java-firestore/issues/1577)) ([396d06b](https://github.com/googleapis/java-firestore/commit/396d06bfa6e0353ddf02c4309a220f10020ca90c)) + +## [3.17.0](https://github.com/googleapis/java-firestore/compare/v3.16.3...v3.17.0) (2024-02-15) + + +### Features + +* Add an API method for reordering firewall policies ([#1572](https://github.com/googleapis/java-firestore/issues/1572)) ([60d8ab1](https://github.com/googleapis/java-firestore/commit/60d8ab167e56806a9ef66d904f6d11f6b45b4ef9)) + + +### Bug Fixes + +* Transactions with `readTime` will omit begin and commit transaction requests, and instead pass `readTime` on individual read requests. ([#1565](https://github.com/googleapis/java-firestore/issues/1565)) ([d5fb01a](https://github.com/googleapis/java-firestore/commit/d5fb01ad99a04f7e1ac8327eb14931db0307b13a)) + + +### Dependencies + +* Update beam.version to v2.54.0 ([#1571](https://github.com/googleapis/java-firestore/issues/1571)) ([e0d4daa](https://github.com/googleapis/java-firestore/commit/e0d4daafcf7f37f399c2e7a32a69429c451f8ee9)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.25.0 ([#1567](https://github.com/googleapis/java-firestore/issues/1567)) ([b6c1531](https://github.com/googleapis/java-firestore/commit/b6c1531abd2f2075ec3eb925682d65a23298dc29)) + +## [3.16.3](https://github.com/googleapis/java-firestore/compare/v3.16.2...v3.16.3) (2024-02-05) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.2 ([#1559](https://github.com/googleapis/java-firestore/issues/1559)) ([502cf05](https://github.com/googleapis/java-firestore/commit/502cf0594c030460db5f7d44c08ea0e9398ad2ac)) + +## [3.16.2](https://github.com/googleapis/java-firestore/compare/v3.16.1...v3.16.2) (2024-02-01) + + +### Bug Fixes + +* Remove QueryMode field from RunAggregationQueryRequest ([32b539c](https://github.com/googleapis/java-firestore/commit/32b539c2431f437ec556923864f967a487c32552)) +* Remove QueryMode field from RunQueryRequest ([32b539c](https://github.com/googleapis/java-firestore/commit/32b539c2431f437ec556923864f967a487c32552)) +* Remove ResultSetStats field from RunAggregationQueryResponse ([32b539c](https://github.com/googleapis/java-firestore/commit/32b539c2431f437ec556923864f967a487c32552)) +* Remove ResultSetStats field from RunQueryResponse ([32b539c](https://github.com/googleapis/java-firestore/commit/32b539c2431f437ec556923864f967a487c32552)) +* Remove types QueryMode, QueryPlan, ResultSetStats ([32b539c](https://github.com/googleapis/java-firestore/commit/32b539c2431f437ec556923864f967a487c32552)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.24.0 ([#1551](https://github.com/googleapis/java-firestore/issues/1551)) ([6874143](https://github.com/googleapis/java-firestore/commit/68741438c7a7fe50da2a72cb9688947ccccf7638)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.10.0 ([#1553](https://github.com/googleapis/java-firestore/issues/1553)) ([701d820](https://github.com/googleapis/java-firestore/commit/701d82078df9e7cff902072abcc6767a67bde3d6)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.10.0 ([#1554](https://github.com/googleapis/java-firestore/issues/1554)) ([581da1f](https://github.com/googleapis/java-firestore/commit/581da1f963ac951b5ca2d5b9edc2ad8a9f189ca6)) + +## [3.16.1](https://github.com/googleapis/java-firestore/compare/v3.16.0...v3.16.1) (2024-01-25) + + +### Bug Fixes + +* `internalStream` should handle duplicate `onComplete`s. ([#1523](https://github.com/googleapis/java-firestore/issues/1523)) ([b3067d7](https://github.com/googleapis/java-firestore/commit/b3067d7b382ea5c4c9124a12a701abe2f7289503)) +* Allow an explicit MustExist precondition for update ([#1542](https://github.com/googleapis/java-firestore/issues/1542)) ([46e09aa](https://github.com/googleapis/java-firestore/commit/46e09aad7f6689d4dfe82bd284905d52edda4364)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.32.0 ([#1534](https://github.com/googleapis/java-firestore/issues/1534)) ([2281320](https://github.com/googleapis/java-firestore/commit/2281320fd924a1d6c259a493ce703a51f0cd8a03)) +* Make rollback best effort. ([#1515](https://github.com/googleapis/java-firestore/issues/1515)) ([4c39af5](https://github.com/googleapis/java-firestore/commit/4c39af50d6d416440164fc5d5360f3912cd8f01b)) +* Thread safe UpdateBuilder ([#1537](https://github.com/googleapis/java-firestore/issues/1537)) ([f9cdab5](https://github.com/googleapis/java-firestore/commit/f9cdab5885bd1d500c6fc412eb3090cea9347d0e)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.22.0 ([#1535](https://github.com/googleapis/java-firestore/issues/1535)) ([04c0e07](https://github.com/googleapis/java-firestore/commit/04c0e0736ddcd49eb42aacb31e2fc087b2a39754)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.23.0 ([#1544](https://github.com/googleapis/java-firestore/issues/1544)) ([79713bf](https://github.com/googleapis/java-firestore/commit/79713bf0fa376a4d22518ae2f5da9660795d9f89)) + + +### Documentation + +* Fix formatting due to unclosed backtick ([#1529](https://github.com/googleapis/java-firestore/issues/1529)) ([3c78fe3](https://github.com/googleapis/java-firestore/commit/3c78fe3c248cb212c6e4f91a5bb7aeb8b9b003b0)) +* Rring BulkWriter out of BetaApi status. ([#1513](https://github.com/googleapis/java-firestore/issues/1513)) ([c2812f7](https://github.com/googleapis/java-firestore/commit/c2812f7cb72257512ffecc98ec1bdb1109d7d044)) + +## [3.16.0](https://github.com/googleapis/java-firestore/compare/v3.15.7...v3.16.0) (2024-01-10) + + +### Features + +* Add DeleteDatabase API and delete protection ([#1508](https://github.com/googleapis/java-firestore/issues/1508)) ([81a1b48](https://github.com/googleapis/java-firestore/commit/81a1b48bae2398f13d0081ea203d8dbac2e74987)) +* Add new types QueryMode, QueryPlan, ResultSetStats ([#1516](https://github.com/googleapis/java-firestore/issues/1516)) ([3060e86](https://github.com/googleapis/java-firestore/commit/3060e868e467a9ef8399f9d15bd91cc819e7bf05)) +* Expose Firestore namespace ID fields in import/export APIs to stable ([21ad25f](https://github.com/googleapis/java-firestore/commit/21ad25f75f91527cf9152a0476af385717e5b111)) +* Expose Firestore PITR fields in Database to stable ([#1495](https://github.com/googleapis/java-firestore/issues/1495)) ([21ad25f](https://github.com/googleapis/java-firestore/commit/21ad25f75f91527cf9152a0476af385717e5b111)) +* Expose Firestore snapshot_time field in export API to stable ([21ad25f](https://github.com/googleapis/java-firestore/commit/21ad25f75f91527cf9152a0476af385717e5b111)) +* Logical termination for firestore.getAll(...). ([#1517](https://github.com/googleapis/java-firestore/issues/1517)) ([c6448fc](https://github.com/googleapis/java-firestore/commit/c6448fc6411de01b3453e58bcbfca633e0849166)) + + +### Bug Fixes + +* Better error message when Transaction/WriteBatch is modified after commit. ([#1503](https://github.com/googleapis/java-firestore/issues/1503)) ([9693c7b](https://github.com/googleapis/java-firestore/commit/9693c7b46dcb63b0348217ecb7c29b95ecd04191)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.31.0 ([#1520](https://github.com/googleapis/java-firestore/issues/1520)) ([c4c5a0b](https://github.com/googleapis/java-firestore/commit/c4c5a0b5a5f0e428b041c0ace80c1bbed3872564)) + + +### Dependencies + +* Update beam.version to v2.53.0 ([#1514](https://github.com/googleapis/java-firestore/issues/1514)) ([7639e0d](https://github.com/googleapis/java-firestore/commit/7639e0d0eefb9df84ab535f61c836d0dfb0ef6cf)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.21.0 ([#1518](https://github.com/googleapis/java-firestore/issues/1518)) ([866b2b4](https://github.com/googleapis/java-firestore/commit/866b2b48ee7acf644dc6355054d7b2ae7e627c13)) + + +### Documentation + +* Assorted typo fixes and whitespace updates ([21ad25f](https://github.com/googleapis/java-firestore/commit/21ad25f75f91527cf9152a0476af385717e5b111)) +* Remove latin abbreviations from comments. ([#1457](https://github.com/googleapis/java-firestore/issues/1457)) ([1cfa03d](https://github.com/googleapis/java-firestore/commit/1cfa03d36a04f17fba91cc7b1f05a59ee149c7aa)) +* Tweak Count API docs ([#1522](https://github.com/googleapis/java-firestore/issues/1522)) ([e25ae13](https://github.com/googleapis/java-firestore/commit/e25ae1391893f26faac9938d49918fcad6a9d0ed)) + +## [3.15.7](https://github.com/googleapis/java-firestore/compare/v3.15.6...v3.15.7) (2023-12-01) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.20.0 ([#1490](https://github.com/googleapis/java-firestore/issues/1490)) ([73a85e7](https://github.com/googleapis/java-firestore/commit/73a85e7b39bee9024ec06995c5d2a269ddf61503)) + +## [3.15.6](https://github.com/googleapis/java-firestore/compare/v3.15.5...v3.15.6) (2023-11-22) + + +### Dependencies + +* Update beam.version to v2.52.0 ([#1480](https://github.com/googleapis/java-firestore/issues/1480)) ([45e33f7](https://github.com/googleapis/java-firestore/commit/45e33f771e012c2ad889466191de03375b7a1e83)) +* Update dependency org.apache.commons:commons-lang3 to v3.14.0 ([#1482](https://github.com/googleapis/java-firestore/issues/1482)) ([3ef71f8](https://github.com/googleapis/java-firestore/commit/3ef71f8da4c07a5e9ef3a44e3f30290d20382c10)) + +## [3.15.5](https://github.com/googleapis/java-firestore/compare/v3.15.4...v3.15.5) (2023-11-14) + + +### Bug Fixes + +* Prevent watch stream from emitting events after close. ([#1471](https://github.com/googleapis/java-firestore/issues/1471)) ([ee3f8c0](https://github.com/googleapis/java-firestore/commit/ee3f8c0c6e2c8aff64f429e8eea649cc6614c74f)) + + +### Dependencies + +* Update actions/github-script action to v7 ([#1473](https://github.com/googleapis/java-firestore/issues/1473)) ([1097a0b](https://github.com/googleapis/java-firestore/commit/1097a0b97c1dff40c07b657417db4ac431822619)) +* Update actions/github-script action to v7 ([#1475](https://github.com/googleapis/java-firestore/issues/1475)) ([d848d87](https://github.com/googleapis/java-firestore/commit/d848d875738260cde620f5cedfc15bf4dae31aac)) + +## [3.15.4](https://github.com/googleapis/java-firestore/compare/v3.15.3...v3.15.4) (2023-11-07) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.19.0 ([#1467](https://github.com/googleapis/java-firestore/issues/1467)) ([a048707](https://github.com/googleapis/java-firestore/commit/a04870759725f03304842373df46f8186861a38f)) + +## [3.15.3](https://github.com/googleapis/java-firestore/compare/v3.15.2...v3.15.3) (2023-11-06) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.1 ([#1463](https://github.com/googleapis/java-firestore/issues/1463)) ([6180322](https://github.com/googleapis/java-firestore/commit/6180322051a63f537d5d355fecc68fe798b44035)) + +## [3.15.2](https://github.com/googleapis/java-firestore/compare/v3.15.1...v3.15.2) (2023-10-20) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.18.0 ([#1450](https://github.com/googleapis/java-firestore/issues/1450)) ([d32d343](https://github.com/googleapis/java-firestore/commit/d32d343ddd4e72c8b434372657a51fc631ba2887)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.28 ([#1451](https://github.com/googleapis/java-firestore/issues/1451)) ([a008a69](https://github.com/googleapis/java-firestore/commit/a008a6943f278658be914b3b88f196a30e36deb1)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.28 ([#1452](https://github.com/googleapis/java-firestore/issues/1452)) ([59daefe](https://github.com/googleapis/java-firestore/commit/59daefe4c3b760c4f3c0b0cf00655465859be4ef)) + +## [3.15.1](https://github.com/googleapis/java-firestore/compare/v3.15.0...v3.15.1) (2023-10-11) + + +### Dependencies + +* Update dependency org.apache.beam:beam-runners-direct-java to v2.51.0 ([#1443](https://github.com/googleapis/java-firestore/issues/1443)) ([738f93a](https://github.com/googleapis/java-firestore/commit/738f93adca3dc42b835c454bf0fc84d87f4bb6b9)) + +## [3.15.0](https://github.com/googleapis/java-firestore/compare/v3.14.4...v3.15.0) (2023-10-10) + + +### Features + +* Sum and Average aggregations ([#1387](https://github.com/googleapis/java-firestore/issues/1387)) ([afa5c01](https://github.com/googleapis/java-firestore/commit/afa5c0124c98a0a58259e54c9bb054248b4d4104)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.17.0 ([#1437](https://github.com/googleapis/java-firestore/issues/1437)) ([cd006f9](https://github.com/googleapis/java-firestore/commit/cd006f90db7c57742d57be74ba244cb0f24a4620)) + +## [3.14.4](https://github.com/googleapis/java-firestore/compare/v3.14.3...v3.14.4) (2023-09-28) + + +### Bug Fixes + +* Add tests for multiple inequality support ([#1392](https://github.com/googleapis/java-firestore/issues/1392)) ([e01b3a1](https://github.com/googleapis/java-firestore/commit/e01b3a1c2489b9cde11543584ab32270960c41ce)) + + +### Dependencies + +* Remove unused dependency that is blocking PR 1428 ([#1429](https://github.com/googleapis/java-firestore/issues/1429)) ([73ff8dc](https://github.com/googleapis/java-firestore/commit/73ff8dca20052715ae88e91bd5c322d06dbeccc0)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.16.1 ([#1431](https://github.com/googleapis/java-firestore/issues/1431)) ([38832f9](https://github.com/googleapis/java-firestore/commit/38832f9853019aedbbf04d34a64d007cbff2752f)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.27 ([#1425](https://github.com/googleapis/java-firestore/issues/1425)) ([dc26bbb](https://github.com/googleapis/java-firestore/commit/dc26bbb91e291d53597221873d3c0995de3d31a2)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.27 ([#1426](https://github.com/googleapis/java-firestore/issues/1426)) ([5e8b299](https://github.com/googleapis/java-firestore/commit/5e8b2998c90829eccef5d18d50541ba5ea3d74f5)) + +## [3.14.3](https://github.com/googleapis/java-firestore/compare/v3.14.2...v3.14.3) (2023-09-12) + + +### Bug Fixes + +* Add reflections configs for generated firestore classes ([#1419](https://github.com/googleapis/java-firestore/issues/1419)) ([1c5e09f](https://github.com/googleapis/java-firestore/commit/1c5e09f08f3e8d57152fa7f0fae52ef2cea8331b)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.15.0 ([#1417](https://github.com/googleapis/java-firestore/issues/1417)) ([3626776](https://github.com/googleapis/java-firestore/commit/3626776483d005ba5d07046eebe25b9c6b39242e)) + +## [3.14.2](https://github.com/googleapis/java-firestore/compare/v3.14.1...v3.14.2) (2023-09-07) + + +### Dependencies + +* Update beam.version to v2.50.0 ([#1410](https://github.com/googleapis/java-firestore/issues/1410)) ([fa14cad](https://github.com/googleapis/java-firestore/commit/fa14cad1ed9536c97279461af9355eb7674c4a85)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.26 ([#1413](https://github.com/googleapis/java-firestore/issues/1413)) ([501af1a](https://github.com/googleapis/java-firestore/commit/501af1ac6d7b62fd6128a1d30cc234c00fc9c592)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.26 ([#1414](https://github.com/googleapis/java-firestore/issues/1414)) ([afb93d2](https://github.com/googleapis/java-firestore/commit/afb93d2ba5e7a300da64bdc98467481c8d0151b7)) + +## [3.14.1](https://github.com/googleapis/java-firestore/compare/v3.14.0...v3.14.1) (2023-08-25) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.25 ([#1405](https://github.com/googleapis/java-firestore/issues/1405)) ([01720e5](https://github.com/googleapis/java-firestore/commit/01720e5a56645e5e0f4aae83af401256eab2aadb)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.25 ([#1406](https://github.com/googleapis/java-firestore/issues/1406)) ([438ad97](https://github.com/googleapis/java-firestore/commit/438ad974e4e37f60d889ccfe716d2427ebf74ffc)) + +## [3.14.0](https://github.com/googleapis/java-firestore/compare/v3.13.8...v3.14.0) (2023-08-08) + + +### Features + +* Publish proto definitions for SUM/AVG in Firestore ([#1304](https://github.com/googleapis/java-firestore/issues/1304)) ([b025d11](https://github.com/googleapis/java-firestore/commit/b025d118433b3930b5186621ef852b4219c2274d)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.14.0 ([#1385](https://github.com/googleapis/java-firestore/issues/1385)) ([d215982](https://github.com/googleapis/java-firestore/commit/d215982730aae862bb0b113887b3ebfc1413d602)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.24 ([#1388](https://github.com/googleapis/java-firestore/issues/1388)) ([24be02b](https://github.com/googleapis/java-firestore/commit/24be02b562780a76847608ca18e8ab2aa4d4514e)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.24 ([#1389](https://github.com/googleapis/java-firestore/issues/1389)) ([34e30e0](https://github.com/googleapis/java-firestore/commit/34e30e053e891f2dadcb09e4dc918dca2709c23d)) + +## [3.13.8](https://github.com/googleapis/java-firestore/compare/v3.13.7...v3.13.8) (2023-07-28) + + +### Dependencies + +* Update dependency org.apache.commons:commons-lang3 to v3.13.0 ([#1380](https://github.com/googleapis/java-firestore/issues/1380)) ([f6f07fb](https://github.com/googleapis/java-firestore/commit/f6f07fbccfcb331d318f66d75a7083695dc21bbb)) + +## [3.13.7](https://github.com/googleapis/java-firestore/compare/v3.13.6...v3.13.7) (2023-07-27) + + +### Dependencies + +* Update beam.version to v2.49.0 ([#1357](https://github.com/googleapis/java-firestore/issues/1357)) ([6eaf446](https://github.com/googleapis/java-firestore/commit/6eaf44650e6ef8ea0ec68e3a7195519c2f631ed2)) + +## [3.13.6](https://github.com/googleapis/java-firestore/compare/v3.13.5...v3.13.6) (2023-07-24) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.0 ([#1368](https://github.com/googleapis/java-firestore/issues/1368)) ([188a8e9](https://github.com/googleapis/java-firestore/commit/188a8e9abfa3c500327e45327966e609b12b2267)) + +## [3.13.5](https://github.com/googleapis/java-firestore/compare/v3.13.4...v3.13.5) (2023-07-20) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.1 ([#1364](https://github.com/googleapis/java-firestore/issues/1364)) ([7dde6ee](https://github.com/googleapis/java-firestore/commit/7dde6ee0b0e39c72665314da25dd9a71aab29e75)) + +## [3.13.4](https://github.com/googleapis/java-firestore/compare/v3.13.3...v3.13.4) (2023-07-20) + + +### Bug Fixes + +* Remove 'x-goog-request-params' header from GRPC requests due to incorrect format. ([#1358](https://github.com/googleapis/java-firestore/issues/1358)) ([1a1bf5f](https://github.com/googleapis/java-firestore/commit/1a1bf5f101d44b0870b44ddf225ccd66d9c2bbc8)) + +## [3.13.3](https://github.com/googleapis/java-firestore/compare/v3.13.2...v3.13.3) (2023-07-13) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.0 ([#1351](https://github.com/googleapis/java-firestore/issues/1351)) ([7c11f8a](https://github.com/googleapis/java-firestore/commit/7c11f8a3667ad9bcc217813a7867e0d18760948e)) + +## [3.13.2](https://github.com/googleapis/java-firestore/compare/v3.13.1...v3.13.2) (2023-06-22) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.12.0 ([#1338](https://github.com/googleapis/java-firestore/issues/1338)) ([0ef1882](https://github.com/googleapis/java-firestore/commit/0ef18821e1bec0a99da5609f6b894f0c4131f6c5)) + +## [3.13.1](https://github.com/googleapis/java-firestore/compare/v3.13.0...v3.13.1) (2023-06-21) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.23 ([#1329](https://github.com/googleapis/java-firestore/issues/1329)) ([ea5e78f](https://github.com/googleapis/java-firestore/commit/ea5e78fd136cad86ce439ca0e7338ed84ef1a3d7)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.23 ([#1330](https://github.com/googleapis/java-firestore/issues/1330)) ([63a01e6](https://github.com/googleapis/java-firestore/commit/63a01e6034ed2c6f6f3613da01ca07d6dffb1909)) + +## [3.13.0](https://github.com/googleapis/java-firestore/compare/v3.12.1...v3.13.0) (2023-06-12) + + +### Features + +* Add toString methods to classes comprising WriteBatch ([#1281](https://github.com/googleapis/java-firestore/issues/1281)) ([9df8028](https://github.com/googleapis/java-firestore/commit/9df80286f350ce35c5ed4b2a44df117b7e241a4a)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.11.0 ([#1322](https://github.com/googleapis/java-firestore/issues/1322)) ([c2bca72](https://github.com/googleapis/java-firestore/commit/c2bca72f27206eaed813199be7b4944d085246e2)) + +## [3.12.1](https://github.com/googleapis/java-firestore/compare/v3.12.0...v3.12.1) (2023-06-05) + + +### Dependencies + +* Update beam.version to v2.48.0 ([#1311](https://github.com/googleapis/java-firestore/issues/1311)) ([0a20e1a](https://github.com/googleapis/java-firestore/commit/0a20e1a32a231372313f77c29ecaec3f085fcb6e)) + +## [3.12.0](https://github.com/googleapis/java-firestore/compare/v3.11.0...v3.12.0) (2023-05-30) + + +### Features + +* Add ApiScope and COLLECTION_RECURSIVE query_scope for Firestore index ([#1300](https://github.com/googleapis/java-firestore/issues/1300)) ([b84a7cd](https://github.com/googleapis/java-firestore/commit/b84a7cd2155484692fc8447c0d27a1cdaa9c8fa1)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.10.1 ([#1305](https://github.com/googleapis/java-firestore/issues/1305)) ([b734212](https://github.com/googleapis/java-firestore/commit/b734212cec11e51b5219b71725df92b7c722791d)) + +## [3.11.0](https://github.com/googleapis/java-firestore/compare/v3.10.0...v3.11.0) (2023-05-12) + + +### Features + +* Add bloom filter related proto fields ([#1285](https://github.com/googleapis/java-firestore/issues/1285)) ([9b14c1b](https://github.com/googleapis/java-firestore/commit/9b14c1b69ca5a70cd92feaa41a520e732c0b3cee)) + + +### Dependencies + +* Update beam.version to v2.47.0 ([#1292](https://github.com/googleapis/java-firestore/issues/1292)) ([e9f11e8](https://github.com/googleapis/java-firestore/commit/e9f11e86aafaa4a50cca789c7349ac59c4c63ccb)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.9.0 ([#1291](https://github.com/googleapis/java-firestore/issues/1291)) ([6dd0e8f](https://github.com/googleapis/java-firestore/commit/6dd0e8fe93cd1f18a949ffd98a247d7364d9f475)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.22 ([#1293](https://github.com/googleapis/java-firestore/issues/1293)) ([e8e5f9b](https://github.com/googleapis/java-firestore/commit/e8e5f9b056c94d68c01b90bf49b1d6908b511ab5)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.22 ([#1294](https://github.com/googleapis/java-firestore/issues/1294)) ([f0ceb7f](https://github.com/googleapis/java-firestore/commit/f0ceb7fc076e43eb62c1a75fa620ee3e510739f4)) + +## [3.10.0](https://github.com/googleapis/java-firestore/compare/v3.9.6...v3.10.0) (2023-04-27) + + +### Features + +* Add bloom filter related proto fields (only in the preview API surface) ([#1274](https://github.com/googleapis/java-firestore/issues/1274)) ([41909b7](https://github.com/googleapis/java-firestore/commit/41909b712bd0e373218f03ae7e978df1259cfd0d)) + +## [3.9.6](https://github.com/googleapis/java-firestore/compare/v3.9.5...v3.9.6) (2023-04-26) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.3 ([#1275](https://github.com/googleapis/java-firestore/issues/1275)) ([1f32893](https://github.com/googleapis/java-firestore/commit/1f328937a9e1a1ed5b76400a65580ee79562d1f2)) + +## [3.9.5](https://github.com/googleapis/java-firestore/compare/v3.9.4...v3.9.5) (2023-04-25) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.8.0 ([#1268](https://github.com/googleapis/java-firestore/issues/1268)) ([8a92dc9](https://github.com/googleapis/java-firestore/commit/8a92dc915ae30c339a90d0e2fe1afb2cbbb0aa3f)) + +## [3.9.4](https://github.com/googleapis/java-firestore/compare/v3.9.3...v3.9.4) (2023-04-12) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.7.0 ([#1257](https://github.com/googleapis/java-firestore/issues/1257)) ([52db039](https://github.com/googleapis/java-firestore/commit/52db039efcc9330897fd0724929573b5d66fbfee)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.21 ([#1258](https://github.com/googleapis/java-firestore/issues/1258)) ([12bcf02](https://github.com/googleapis/java-firestore/commit/12bcf0295fc9b1538b97b24ed7d3797fa97f0294)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.21 ([#1259](https://github.com/googleapis/java-firestore/issues/1259)) ([19b5da2](https://github.com/googleapis/java-firestore/commit/19b5da23da2b87b7041446582b9fc8cc08045456)) + +## [3.9.3](https://github.com/googleapis/java-firestore/compare/v3.9.2...v3.9.3) (2023-03-29) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.6.0 ([#1247](https://github.com/googleapis/java-firestore/issues/1247)) ([aa098e0](https://github.com/googleapis/java-firestore/commit/aa098e0966d46cf6e2206baab95f4acbfcbfbc92)) + +## [3.9.2](https://github.com/googleapis/java-firestore/compare/v3.9.1...v3.9.2) (2023-03-20) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.5.0 ([#1239](https://github.com/googleapis/java-firestore/issues/1239)) ([61b1439](https://github.com/googleapis/java-firestore/commit/61b14391c965b20c49a50e293e2a6f12c7abb5e0)) + +## [3.9.1](https://github.com/googleapis/java-firestore/compare/v3.9.0...v3.9.1) (2023-03-15) + + +### Dependencies + +* Update beam.version to v2.46.0 ([#1228](https://github.com/googleapis/java-firestore/issues/1228)) ([ffc853f](https://github.com/googleapis/java-firestore/commit/ffc853fa85956dd635c79bdd12b0ae38165cbdbb)) + +## [3.9.0](https://github.com/googleapis/java-firestore/compare/v3.8.2...v3.9.0) (2023-03-06) + + +### Features + +* Enable `OR` Query support. ([#1007](https://github.com/googleapis/java-firestore/issues/1007)) ([e502cd4](https://github.com/googleapis/java-firestore/commit/e502cd4a91396360815f540d6058291a75e15951)) + +## [3.8.2](https://github.com/googleapis/java-firestore/compare/v3.8.1...v3.8.2) (2023-03-02) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.4.0 ([#1219](https://github.com/googleapis/java-firestore/issues/1219)) ([fe84125](https://github.com/googleapis/java-firestore/commit/fe84125054618bb1dbcfa1d648369a8df0120531)) + +## [3.8.1](https://github.com/googleapis/java-firestore/compare/v3.8.0...v3.8.1) (2023-02-17) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.3.0 ([#1206](https://github.com/googleapis/java-firestore/issues/1206)) ([a118ce0](https://github.com/googleapis/java-firestore/commit/a118ce07b9af0f1ae16197de7d26a3a035223b20)) + +## [3.8.0](https://github.com/googleapis/java-firestore/compare/v3.7.10...v3.8.0) (2023-02-15) + + +### Features + +* Add `OR` query support ([#1198](https://github.com/googleapis/java-firestore/issues/1198)) ([566b788](https://github.com/googleapis/java-firestore/commit/566b7884fd462630195dc2ffee79cc5345c80c03)) + + +### Dependencies + +* Update beam.version to v2.45.0 ([#1201](https://github.com/googleapis/java-firestore/issues/1201)) ([196a75d](https://github.com/googleapis/java-firestore/commit/196a75d4708ec8b1e61c114ea815a66eb5ab27f4)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.20 ([#1196](https://github.com/googleapis/java-firestore/issues/1196)) ([51fe67c](https://github.com/googleapis/java-firestore/commit/51fe67c59d674ea76332f5c0b0fccd9a2c10d39c)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.20 ([#1197](https://github.com/googleapis/java-firestore/issues/1197)) ([a66b8b4](https://github.com/googleapis/java-firestore/commit/a66b8b4e38a8109753769bcbda2dcb2ae8d58692)) + +## [3.7.10](https://github.com/googleapis/java-firestore/compare/v3.7.9...v3.7.10) (2023-02-06) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.2.0 ([#1185](https://github.com/googleapis/java-firestore/issues/1185)) ([42c34da](https://github.com/googleapis/java-firestore/commit/42c34dabe3ecb89401967f0f25593cfcfb63bc94)) + +## [3.7.9](https://github.com/googleapis/java-firestore/compare/v3.7.8...v3.7.9) (2023-01-27) + + +### Bug Fixes + +* **java:** Fix error message returned for invalid snapshot listener inequality filter ([#1093](https://github.com/googleapis/java-firestore/issues/1093)) ([bf7f4a3](https://github.com/googleapis/java-firestore/commit/bf7f4a3b87311437a364cadaf46da4cb018a28c7)) +* **java:** Skip fixing poms for special modules ([#1744](https://github.com/googleapis/java-firestore/issues/1744)) ([#1172](https://github.com/googleapis/java-firestore/issues/1172)) ([222be48](https://github.com/googleapis/java-firestore/commit/222be4882971e5175ae7b9b029cc83047a5a7163)) + +## [3.7.8](https://github.com/googleapis/java-firestore/compare/v3.7.7...v3.7.8) (2023-01-20) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.2 ([#1174](https://github.com/googleapis/java-firestore/issues/1174)) ([187a9be](https://github.com/googleapis/java-firestore/commit/187a9be1695d21abed12b60b8de2649f7afe54a3)) + +## [3.7.7](https://github.com/googleapis/java-firestore/compare/v3.7.6...v3.7.7) (2023-01-18) + + +### Dependencies + +* Update beam.version to v2.44.0 ([#1166](https://github.com/googleapis/java-firestore/issues/1166)) ([3364d6e](https://github.com/googleapis/java-firestore/commit/3364d6e859f43145beeab81817db4e524740a00b)) + +## [3.7.6](https://github.com/googleapis/java-firestore/compare/v3.7.5...v3.7.6) (2023-01-13) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.2 ([#1158](https://github.com/googleapis/java-firestore/issues/1158)) ([418b2bf](https://github.com/googleapis/java-firestore/commit/418b2bfed98f3e88dac63771e4b55f2b157fe184)) + +## [3.7.5](https://github.com/googleapis/java-firestore/compare/v3.7.4...v3.7.5) (2023-01-13) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.1 ([#1157](https://github.com/googleapis/java-firestore/issues/1157)) ([c7c688b](https://github.com/googleapis/java-firestore/commit/c7c688b1357edfc61f1f86b2c282b80ddb48f2c4)) + +## [3.7.4](https://github.com/googleapis/java-firestore/compare/v3.7.3...v3.7.4) (2022-12-08) + + +### Dependencies + +* Update multiple dependencies atomically ([#1145](https://github.com/googleapis/java-firestore/issues/1145)) ([36bb40b](https://github.com/googleapis/java-firestore/commit/36bb40b97fb3a2eb44b35437fe0322644dc2bffd)) + +## [3.7.3](https://github.com/googleapis/java-firestore/compare/v3.7.2...v3.7.3) (2022-11-21) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.18 ([#1132](https://github.com/googleapis/java-firestore/issues/1132)) ([6b57290](https://github.com/googleapis/java-firestore/commit/6b572900bc792c18d8f161fb1d1a01b72a9962d9)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.18 ([#1133](https://github.com/googleapis/java-firestore/issues/1133)) ([8cb45ae](https://github.com/googleapis/java-firestore/commit/8cb45aebb9424187ae4c7ed00cb337b73baac0d7)) + +## [3.7.2](https://github.com/googleapis/java-firestore/compare/v3.7.1...v3.7.2) (2022-11-18) + + +### Dependencies + +* Update beam.version to v2.43.0 ([#1127](https://github.com/googleapis/java-firestore/issues/1127)) ([ff1df71](https://github.com/googleapis/java-firestore/commit/ff1df71f96b7c6c1fda0e53cdca5097b024d9812)) + +## [3.7.1](https://github.com/googleapis/java-firestore/compare/v3.7.0...v3.7.1) (2022-11-08) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.6 ([#1092](https://github.com/googleapis/java-firestore/issues/1092)) ([019840f](https://github.com/googleapis/java-firestore/commit/019840fb0883fb41cdc294f09e35f39745a78cb4)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.17 ([#1087](https://github.com/googleapis/java-firestore/issues/1087)) ([a78be32](https://github.com/googleapis/java-firestore/commit/a78be324ccd0ba2ebff429447b8ce0fe39727360)) + +## [3.7.0](https://github.com/googleapis/java-firestore/compare/v3.6.0...v3.7.0) (2022-10-22) + + +### Features + +* Add retry logic to COUNT queries ([#1062](https://github.com/googleapis/java-firestore/issues/1062)) ([5789e4b](https://github.com/googleapis/java-firestore/commit/5789e4b57f38e8cab82bc720b28578e86d82a2cc)) + + +### Bug Fixes + +* Fix limitToLast queries with cursors ([#1072](https://github.com/googleapis/java-firestore/issues/1072)) ([e9e1548](https://github.com/googleapis/java-firestore/commit/e9e15489112d49a7f8716300ec9af504fcfb5786)) + + +### Dependencies + +* Update beam.version to v2.42.0 ([#1066](https://github.com/googleapis/java-firestore/issues/1066)) ([03de01a](https://github.com/googleapis/java-firestore/commit/03de01ab58ab3d312bef63c54b202b8c911cef54)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 ([#1071](https://github.com/googleapis/java-firestore/issues/1071)) ([4c3f122](https://github.com/googleapis/java-firestore/commit/4c3f12286424ce7601a106b4338bc89b67ad51fb)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.16 ([#1064](https://github.com/googleapis/java-firestore/issues/1064)) ([a7ddc9e](https://github.com/googleapis/java-firestore/commit/a7ddc9e7fe708bd07595973c56fb2e392917915d)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.15 ([#1065](https://github.com/googleapis/java-firestore/issues/1065)) ([d9e7803](https://github.com/googleapis/java-firestore/commit/d9e7803d257b0edfae8648b925e040c7a6fcdb60)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.16 ([#1069](https://github.com/googleapis/java-firestore/issues/1069)) ([97ef50a](https://github.com/googleapis/java-firestore/commit/97ef50a518c5b207b28e0a81022cc96ed4e5e5ae)) + +## [3.6.0](https://github.com/googleapis/java-firestore/compare/v3.5.0...v3.6.0) (2022-10-04) + + +### Features + +* Count queries (not available for use yet) ([#1033](https://github.com/googleapis/java-firestore/issues/1033)) ([8b60612](https://github.com/googleapis/java-firestore/commit/8b60612f1922a4c377fac357ee7f4304362622f3)) +* Make count queries publicly available for use ([#1042](https://github.com/googleapis/java-firestore/issues/1042)) ([1c8d242](https://github.com/googleapis/java-firestore/commit/1c8d2428d94ab8b3c18a8cad14daa2a1e39af369)) + + +### Documentation + +* AggregateQuery.java: describe why we ignore subsequent responses ([#1041](https://github.com/googleapis/java-firestore/issues/1041)) ([8150544](https://github.com/googleapis/java-firestore/commit/8150544aee0aa04a5e6239dbc4994ddd056393ba)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#1053](https://github.com/googleapis/java-firestore/issues/1053)) ([9b4c26e](https://github.com/googleapis/java-firestore/commit/9b4c26eac062fa73c8b275978f35c5bfb8cdfc21)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.14 ([#1045](https://github.com/googleapis/java-firestore/issues/1045)) ([04b3861](https://github.com/googleapis/java-firestore/commit/04b3861d874dcd63713e62bd7717097ca8f68a3c)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.14 ([#1046](https://github.com/googleapis/java-firestore/issues/1046)) ([6631a58](https://github.com/googleapis/java-firestore/commit/6631a58553a12e1f48d060d0b87cfa8683492b94)) +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.1 ([#1039](https://github.com/googleapis/java-firestore/issues/1039)) ([84423f4](https://github.com/googleapis/java-firestore/commit/84423f4db6e35f9d30a34a5bc2d29050380840ec)) + +## [3.5.0](https://github.com/googleapis/java-firestore/compare/v3.4.2...v3.5.0) (2022-09-16) + + +### Features + +* Add firestore aggregation query apis to the stable googleapis branch ([#1030](https://github.com/googleapis/java-firestore/issues/1030)) ([0e3e2ac](https://github.com/googleapis/java-firestore/commit/0e3e2ac98d1e505e7fe9bb17b2bdb8e7089776cf)) + + +### Dependencies + +* Update actions/setup-java action to v3 ([#1031](https://github.com/googleapis/java-firestore/issues/1031)) ([1aae546](https://github.com/googleapis/java-firestore/commit/1aae5463ae781787a529d424be2d145718250781)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#1032](https://github.com/googleapis/java-firestore/issues/1032)) ([9b68360](https://github.com/googleapis/java-firestore/commit/9b6836031c7af75e4fc3350f36bef425d97cbfeb)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#1034](https://github.com/googleapis/java-firestore/issues/1034)) ([5acd8e4](https://github.com/googleapis/java-firestore/commit/5acd8e415f966a7a902cae6ad324f70377b75528)) + +## [3.4.2](https://github.com/googleapis/java-firestore/compare/v3.4.1...v3.4.2) (2022-08-24) + + +### Dependencies + +* update beam.version to v2.41.0 ([#1022](https://github.com/googleapis/java-firestore/issues/1022)) ([fb14e2f](https://github.com/googleapis/java-firestore/commit/fb14e2fe0fe20614d1973c3be32f7d108a112028)) + +## [3.4.1](https://github.com/googleapis/java-firestore/compare/v3.4.0...v3.4.1) (2022-08-19) + + +### Bug Fixes + +* declare gson as runtime rather than test ([#1004](https://github.com/googleapis/java-firestore/issues/1004)) ([e37e997](https://github.com/googleapis/java-firestore/commit/e37e997075288844c2fb1807b166007177ebea2f)) + +## [3.4.0](https://github.com/googleapis/java-firestore/compare/v3.3.0...v3.4.0) (2022-08-03) + + +### Features + +* Support for Composite Filters. ([#975](https://github.com/googleapis/java-firestore/issues/975)) ([9d0653a](https://github.com/googleapis/java-firestore/commit/9d0653aa5e488af847ae1c8fbbd9ae60bac9149a)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#960](https://github.com/googleapis/java-firestore/issues/960)) ([a9338ff](https://github.com/googleapis/java-firestore/commit/a9338ff8c0039111f1e1da9db460626a7b2c98ec)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#1000](https://github.com/googleapis/java-firestore/issues/1000)) ([a3c4ec5](https://github.com/googleapis/java-firestore/commit/a3c4ec5db33fc0217e2d5c9c0799570a0a63a2d0)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#972](https://github.com/googleapis/java-firestore/issues/972)) ([8cf33b0](https://github.com/googleapis/java-firestore/commit/8cf33b053d784cd2d03ed1d6c37fe17e9f96d677)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.13 ([#988](https://github.com/googleapis/java-firestore/issues/988)) ([f8d9496](https://github.com/googleapis/java-firestore/commit/f8d949688e2eba095d008d6a36bb71cc9860fd61)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.13 ([#989](https://github.com/googleapis/java-firestore/issues/989)) ([4c768e3](https://github.com/googleapis/java-firestore/commit/4c768e3939b2820b8c93216df4fc1bd7352253a1)) +* update dependency org.junit.vintage:junit-vintage-engine to v5.9.0 ([#997](https://github.com/googleapis/java-firestore/issues/997)) ([d4dd4d8](https://github.com/googleapis/java-firestore/commit/d4dd4d8b9f83f54900eae7ea119e24e0e68c551b)) + +## [3.3.0](https://github.com/googleapis/java-firestore/compare/v3.2.0...v3.3.0) (2022-07-01) + + +### Features + +* add logical termination for RunQueryResponse ([#956](https://github.com/googleapis/java-firestore/issues/956)) ([1d869c8](https://github.com/googleapis/java-firestore/commit/1d869c8fbe5e4009bbded2fb24f978f7cf48c515)) + + +### Bug Fixes + +* add build script for JDK 17 native image testing ([#965](https://github.com/googleapis/java-firestore/issues/965)) ([963e384](https://github.com/googleapis/java-firestore/commit/963e384b254056b6879744ba0b5d69fc0699f0bf)) + + +### Performance Improvements + +* Change how proto was called in Query.java ([#970](https://github.com/googleapis/java-firestore/issues/970)) ([f6f6352](https://github.com/googleapis/java-firestore/commit/f6f63520e93d9b3db0a915be58ea3cd37cec68d2)) + + +### Dependencies + +* update beam.version to v2.40.0 ([#978](https://github.com/googleapis/java-firestore/issues/978)) ([44276f8](https://github.com/googleapis/java-firestore/commit/44276f84ac927e02105608d81bb198f45793f823)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#974](https://github.com/googleapis/java-firestore/issues/974)) ([6def73d](https://github.com/googleapis/java-firestore/commit/6def73dbdbdc645d1148b9cc8e390e307a6896d4)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#973](https://github.com/googleapis/java-firestore/issues/973)) ([bfb4ec9](https://github.com/googleapis/java-firestore/commit/bfb4ec9f9de6114259328bbe9a14c0cc7fae84c8)) + +## [3.2.0](https://github.com/googleapis/java-firestore/compare/v3.1.0...v3.2.0) (2022-05-23) + + +### Features + +* enable RunQueryResponse.done ([#942](https://github.com/googleapis/java-firestore/issues/942)) ([055b029](https://github.com/googleapis/java-firestore/commit/055b02930a455c253f443dcbacf935b5c8e37991)) + + +### Documentation + +* **sample:** remove unused native-image-support module ([#952](https://github.com/googleapis/java-firestore/issues/952)) ([17c2de9](https://github.com/googleapis/java-firestore/commit/17c2de9594c8ea549ed623ea482420f00fc7b6b6)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.12.0 ([#959](https://github.com/googleapis/java-firestore/issues/959)) ([f1d6b17](https://github.com/googleapis/java-firestore/commit/f1d6b17550556a6e1ce3cd734a5425b94da4aa6d)) + +## [3.1.0](https://github.com/googleapis/java-firestore/compare/v3.0.21...v3.1.0) (2022-04-21) + + +### Features + +* relocate Firestore native image configuration from java-core ([#941](https://github.com/googleapis/java-firestore/issues/941)) ([900a7a8](https://github.com/googleapis/java-firestore/commit/900a7a855fab436aea3d221139e8c986f188d4be)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([#945](https://github.com/googleapis/java-firestore/issues/945)) ([5b2e318](https://github.com/googleapis/java-firestore/commit/5b2e3189cde0973edb524df88e71f8901f84b136)) +* update dependency com.google.cloud:native-image-support to v0.13.1 ([#944](https://github.com/googleapis/java-firestore/issues/944)) ([b3b474f](https://github.com/googleapis/java-firestore/commit/b3b474f44167985b52cb1fb7e7b4c42be1c58112)) + +### [3.0.21](https://github.com/googleapis/java-firestore/compare/v3.0.20...v3.0.21) (2022-03-30) + + +### Bug Fixes + +* change REST binding for ListDocuments to support root collection ([#900](https://github.com/googleapis/java-firestore/issues/900)) ([aabd4ac](https://github.com/googleapis/java-firestore/commit/aabd4ac4e43e1c58ec25e51117980f4396a3e8d9)) +* **java:** move test native image configs to test/resources ([#929](https://github.com/googleapis/java-firestore/issues/929)) ([9ed6c5e](https://github.com/googleapis/java-firestore/commit/9ed6c5ea50c02411df2c94e782caba1954fd1f73)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.9.0 ([#932](https://github.com/googleapis/java-firestore/issues/932)) ([abebae7](https://github.com/googleapis/java-firestore/commit/abebae7fd9fde7d971150ffcfc010eaa7952932d)) +* update dependency com.google.cloud:native-image-support to v0.12.11 ([#931](https://github.com/googleapis/java-firestore/issues/931)) ([0e1e3c5](https://github.com/googleapis/java-firestore/commit/0e1e3c598628c13c30cb7a51314d109c2106a678)) + +### [3.0.20](https://github.com/googleapis/java-firestore/compare/v3.0.19...v3.0.20) (2022-03-24) + + +### Dependencies + +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.11 ([#923](https://github.com/googleapis/java-firestore/issues/923)) ([43f24b1](https://github.com/googleapis/java-firestore/commit/43f24b12d0c79551f1bc3eb13f3af8c38630f0ca)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.11 ([#924](https://github.com/googleapis/java-firestore/issues/924)) ([70b0d00](https://github.com/googleapis/java-firestore/commit/70b0d001cb4199745e665a9d13731a9ca320ed93)) + +### [3.0.19](https://github.com/googleapis/java-firestore/compare/v3.0.18...v3.0.19) (2022-03-14) + + +### Bug Fixes + +* **java:** fix native image Kokoro test setup ([#919](https://github.com/googleapis/java-firestore/issues/919)) ([7d905a5](https://github.com/googleapis/java-firestore/commit/7d905a5f2c687c1f099d2d976f9708b605b66a60)) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.10 ([#917](https://github.com/googleapis/java-firestore/issues/917)) ([0a650e0](https://github.com/googleapis/java-firestore/commit/0a650e02ff1b0aea7d78b95c743358eff999b8aa)) + +### [3.0.18](https://github.com/googleapis/java-firestore/compare/v3.0.17...v3.0.18) (2022-03-10) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.9 ([#912](https://github.com/googleapis/java-firestore/issues/912)) ([fedf824](https://github.com/googleapis/java-firestore/commit/fedf824a3bf66e245ef3eb10c85d8209c418d6fa)) + +### [3.0.17](https://github.com/googleapis/java-firestore/compare/v3.0.16...v3.0.17) (2022-03-09) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.8 ([#909](https://github.com/googleapis/java-firestore/issues/909)) ([2580d8f](https://github.com/googleapis/java-firestore/commit/2580d8fa0fa35d69160c73fadfb3c817e126fc2b)) + +### [3.0.16](https://github.com/googleapis/java-firestore/compare/v3.0.15...v3.0.16) (2022-03-08) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.7 ([#902](https://github.com/googleapis/java-firestore/issues/902)) ([843dd0e](https://github.com/googleapis/java-firestore/commit/843dd0e9988f26f688c2b73f6a247092b7bea6ef)) + +### [3.0.15](https://github.com/googleapis/java-firestore/compare/v3.0.14...v3.0.15) (2022-03-02) + + +### Documentation + +* **sample:** Use Java 8 for native image sample ([#893](https://github.com/googleapis/java-firestore/issues/893)) ([5955f54](https://github.com/googleapis/java-firestore/commit/5955f54f49637e4a4d22df34dbcddacfef269d34)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#895](https://github.com/googleapis/java-firestore/issues/895)) ([bf1951d](https://github.com/googleapis/java-firestore/commit/bf1951d760f4ba431caa18ecbc0505a5d99f2ae2)) +* update dependency com.google.cloud:native-image-support to v0.12.6 ([#898](https://github.com/googleapis/java-firestore/issues/898)) ([73606e5](https://github.com/googleapis/java-firestore/commit/73606e5617ff54daf60db720aed1436005d50fb5)) + +### [3.0.14](https://github.com/googleapis/java-firestore/compare/v3.0.13...v3.0.14) (2022-03-01) + + +### Bug Fixes + +* fix groupID for artifacts ([#890](https://github.com/googleapis/java-firestore/issues/890)) ([bb46bcb](https://github.com/googleapis/java-firestore/commit/bb46bcb5f52b1f5fb4e3fe7acfb7e74b6fc4eb4b)) +* **java:** add reflection configuration for native image tests ([#878](https://github.com/googleapis/java-firestore/issues/878)) ([1938113](https://github.com/googleapis/java-firestore/commit/19381131ab3c7a7a458e333de9929336fe4edcc9)) + + +### Dependencies + +* update actions/setup-java action to v3 ([#888](https://github.com/googleapis/java-firestore/issues/888)) ([07130f9](https://github.com/googleapis/java-firestore/commit/07130f961091bac19393dd13bff4826584509bd4)) +* update dependency com.google.cloud:native-image-support to v0.12.5 ([#889](https://github.com/googleapis/java-firestore/issues/889)) ([5f4ffcb](https://github.com/googleapis/java-firestore/commit/5f4ffcbe6de3081a47a137be06be9ca6f0969ed5)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.10 ([#880](https://github.com/googleapis/java-firestore/issues/880)) ([a3a9684](https://github.com/googleapis/java-firestore/commit/a3a96846e33e5ca53038c1d03a1f6734796c773f)) + +### [3.0.13](https://github.com/googleapis/java-firestore/compare/v3.0.12...v3.0.13) (2022-02-22) + + +### Bug Fixes + +* retry watch on InternalException ([#875](https://github.com/googleapis/java-firestore/issues/875)) ([a76a0fd](https://github.com/googleapis/java-firestore/commit/a76a0fddbcd8996667a4ee239b3d74ee096161c6)) + + +### Documentation + +* **sample:** Add sample for native image support in Firestore ([#872](https://github.com/googleapis/java-firestore/issues/872)) ([a01fe88](https://github.com/googleapis/java-firestore/commit/a01fe88f17286a2988a4e4e52d11fc4aa43c5f83)) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.4 ([#882](https://github.com/googleapis/java-firestore/issues/882)) ([b2aeb1a](https://github.com/googleapis/java-firestore/commit/b2aeb1a7c8f1baa428f1a718ea145fef77f439fb)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.10 ([#881](https://github.com/googleapis/java-firestore/issues/881)) ([036f7f8](https://github.com/googleapis/java-firestore/commit/036f7f83b1ec4846af91613136cc793c637f43c1)) + +### [3.0.12](https://github.com/googleapis/java-firestore/compare/v3.0.11...v3.0.12) (2022-02-04) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.7.0 ([#860](https://github.com/googleapis/java-firestore/issues/860)) ([bf48381](https://github.com/googleapis/java-firestore/commit/bf48381a64f17cd615c1bcd0bf7c9ffb473400d9)) +* update dependency org.apache.commons:commons-lang3 to v3.12.0 ([#846](https://github.com/googleapis/java-firestore/issues/846)) ([efc73bd](https://github.com/googleapis/java-firestore/commit/efc73bd1949d8214dd6702caa72a70405a6ca059)) + +### [3.0.11](https://github.com/googleapis/java-firestore/compare/v3.0.10...v3.0.11) (2022-01-27) + + +### Bug Fixes + +* close the Watch stream when we receive an error ([#834](https://github.com/googleapis/java-firestore/issues/834)) ([077c9be](https://github.com/googleapis/java-firestore/commit/077c9be3b265e8cd7df149890986f36db94a9874)) + +### [3.0.10](https://www.github.com/googleapis/java-firestore/compare/v3.0.9...v3.0.10) (2022-01-07) + + +### Bug Fixes + +* **java:** add -ntp flag to native image testing command ([#829](https://www.github.com/googleapis/java-firestore/issues/829)) ([a0fb54f](https://www.github.com/googleapis/java-firestore/commit/a0fb54fa433d252ad814009cf28a412adad94405)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.6.0 ([#841](https://www.github.com/googleapis/java-firestore/issues/841)) ([ea34d81](https://www.github.com/googleapis/java-firestore/commit/ea34d811d707f02c06b18d10d3e5d41000208cec)) + +### [3.0.9](https://www.github.com/googleapis/java-firestore/compare/v3.0.8...v3.0.9) (2021-12-03) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.1 ([#825](https://www.github.com/googleapis/java-firestore/issues/825)) ([1b8e3a3](https://www.github.com/googleapis/java-firestore/commit/1b8e3a38f722050d917643043bf4a8eb101c4200)) + +### [3.0.8](https://www.github.com/googleapis/java-firestore/compare/v3.0.7...v3.0.8) (2021-11-16) + + +### Bug Fixes + +* respect total request timeout for Query retries ([#806](https://www.github.com/googleapis/java-firestore/issues/806)) ([feb1921](https://www.github.com/googleapis/java-firestore/commit/feb1921b39fc7630aa6549025c5ffe526e080d54)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.0 ([#814](https://www.github.com/googleapis/java-firestore/issues/814)) ([c1f4dac](https://www.github.com/googleapis/java-firestore/commit/c1f4dac67230b77864b4c4a64982cbbd7e28369f)) + +### [3.0.7](https://www.github.com/googleapis/java-firestore/compare/v3.0.6...v3.0.7) (2021-10-27) + + +### Bug Fixes + +* **java:** java 17 dependency arguments ([#802](https://www.github.com/googleapis/java-firestore/issues/802)) ([ec07294](https://www.github.com/googleapis/java-firestore/commit/ec07294dc67d884a8bd6b0c4c9b9b1cdfb6e95c3)) +* set timeouts for BatchGetDocuments/RunQuery ([#799](https://www.github.com/googleapis/java-firestore/issues/799)) ([6cd2a45](https://www.github.com/googleapis/java-firestore/commit/6cd2a4526561a74f1aed355fa8d0405960b34965)) + +### [3.0.6](https://www.github.com/googleapis/java-firestore/compare/v3.0.5...v3.0.6) (2021-10-19) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.4.0 ([#793](https://www.github.com/googleapis/java-firestore/issues/793)) ([1af36a9](https://www.github.com/googleapis/java-firestore/commit/1af36a9e8eccc5edc4ccfbfd865c2966b0fab366)) + +### [3.0.5](https://www.github.com/googleapis/java-firestore/compare/v3.0.4...v3.0.5) (2021-09-22) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.3.0 ([#775](https://www.github.com/googleapis/java-firestore/issues/775)) ([35469d6](https://www.github.com/googleapis/java-firestore/commit/35469d6f83a8027f2f54ce16b78141811ff393c3)) + +### [3.0.4](https://www.github.com/googleapis/java-firestore/compare/v3.0.3...v3.0.4) (2021-09-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.1 ([#765](https://www.github.com/googleapis/java-firestore/issues/765)) ([e7a6537](https://www.github.com/googleapis/java-firestore/commit/e7a65374525da1b290835f6d6c7ec94d9cbde121)) + +### [3.0.3](https://www.github.com/googleapis/java-firestore/compare/v3.0.2...v3.0.3) (2021-08-31) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.0 ([#753](https://www.github.com/googleapis/java-firestore/issues/753)) ([6744bfa](https://www.github.com/googleapis/java-firestore/commit/6744bfad1dc8a6a4e1da2d3e7cb7cd17514259b7)) +* update google-cloud-conformance-tests to 0.2.0 ([#752](https://www.github.com/googleapis/java-firestore/issues/752)) ([135bc6b](https://www.github.com/googleapis/java-firestore/commit/135bc6be06fff41fb8933b63fcde2f247a293b07)) + +### [3.0.2](https://www.github.com/googleapis/java-firestore/compare/v3.0.1...v3.0.2) (2021-08-23) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#739](https://www.github.com/googleapis/java-firestore/issues/739)) ([99b5820](https://www.github.com/googleapis/java-firestore/commit/99b5820f28c36ac83c44c6547764c7e41e4a8031)) + +### [3.0.1](https://www.github.com/googleapis/java-firestore/compare/v3.0.0...v3.0.1) (2021-08-11) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.0.1 ([#728](https://www.github.com/googleapis/java-firestore/issues/728)) ([167683d](https://www.github.com/googleapis/java-firestore/commit/167683deebf4724795b013cc7d8b495239a918a6)) + +## [3.0.0](https://www.github.com/googleapis/java-firestore/compare/v2.6.2...v3.0.0) (2021-08-09) + + +### ⚠ BREAKING CHANGES + +* update Java compile to 1.8 ([#710](https://github.com/googleapis/java-firestore/pull/710)) +* update gapic generator to 2.0.0, java 8 features (#719) + +### Features + +* update Java compile to 1.8 ([#710](https://github.com/googleapis/java-firestore/pull/710)) +* gapic-generator-java v1.0.13, mtls support ([#712](https://www.github.com/googleapis/java-firestore/issues/712)) ([a27dd9c](https://www.github.com/googleapis/java-firestore/commit/a27dd9cb0e2681a15eae754c97255d0d8c86bcae)) +* update gapic generator to 2.0.0, java 8 features ([#719](https://www.github.com/googleapis/java-firestore/issues/719)) ([0d5b378](https://www.github.com/googleapis/java-firestore/commit/0d5b378075f3723126c8809f4afcc8fc9f81d611)) + + +### Dependencies + +* update shared dependencies to 2.0.0 ([#720](https://www.github.com/googleapis/java-firestore/issues/720)) ([e4f985e](https://www.github.com/googleapis/java-firestore/commit/e4f985e8b17a02f84aa9b100be1aa72f97521763)) + +### [2.6.2](https://www.github.com/googleapis/java-firestore/compare/v2.6.1...v2.6.2) (2021-07-29) + + +### Bug Fixes + +* Add shopt -s nullglob to dependencies script ([8f4b199](https://www.github.com/googleapis/java-firestore/commit/8f4b199c1dfdf268723e11696733fe5fb6bd5c64)) +* Ensures bundles are encoded as UTF8 bytes. ([#695](https://www.github.com/googleapis/java-firestore/issues/695)) ([0946a17](https://www.github.com/googleapis/java-firestore/commit/0946a170a963f50ec77409291c02696f2c416edb)) +* lower batch size on BulkWriter retry ([#688](https://www.github.com/googleapis/java-firestore/issues/688)) ([146b21d](https://www.github.com/googleapis/java-firestore/commit/146b21dd6d5772bfd9e023dbf5a1147b29076cdd)) +* Update dependencies.sh to not break on mac ([#694](https://www.github.com/googleapis/java-firestore/issues/694)) ([8f4b199](https://www.github.com/googleapis/java-firestore/commit/8f4b199c1dfdf268723e11696733fe5fb6bd5c64)) + + +### Documentation + +* began merging variant client samples ([#696](https://www.github.com/googleapis/java-firestore/issues/696)) ([0a10dd8](https://www.github.com/googleapis/java-firestore/commit/0a10dd85de02647a9d08f41d45ebc25ee2689a52)) + +### [2.6.1](https://www.github.com/googleapis/java-firestore/compare/v2.6.0...v2.6.1) (2021-06-30) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#680](https://www.github.com/googleapis/java-firestore/issues/680)) ([b8ffcb4](https://www.github.com/googleapis/java-firestore/commit/b8ffcb43d79029f9b2a490fb84e78653c716b367)) + +## [2.6.0](https://www.github.com/googleapis/java-firestore/compare/v2.5.1...v2.6.0) (2021-06-29) + + +### Features + +* add shutdown() and shutdownNow() ([#673](https://www.github.com/googleapis/java-firestore/issues/673)) ([4f20858](https://www.github.com/googleapis/java-firestore/commit/4f2085887981121316fc046d13e945e6800aaad1)) + + +### Bug Fixes + +* handle thrown exceptions in runAsyncTransaction callback ([#671](https://www.github.com/googleapis/java-firestore/issues/671)) ([969f7fd](https://www.github.com/googleapis/java-firestore/commit/969f7fd72b07aa9c916609b73528ff0f17dfaead)) + +### [2.5.1](https://www.github.com/googleapis/java-firestore/compare/v2.5.0...v2.5.1) (2021-06-22) + + +### Bug Fixes + +* return results from getPartitions() in order ([#653](https://www.github.com/googleapis/java-firestore/issues/653)) ([12d17d1](https://www.github.com/googleapis/java-firestore/commit/12d17d1ac9d7a1c21eca1469164b079de4476633)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.1.1 ([#650](https://www.github.com/googleapis/java-firestore/issues/650)) ([b93ca8a](https://www.github.com/googleapis/java-firestore/commit/b93ca8a2b5751c61b3fbe0ca608056e2c0398575)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.3.0 ([#660](https://www.github.com/googleapis/java-firestore/issues/660)) ([0f13fd0](https://www.github.com/googleapis/java-firestore/commit/0f13fd0c0db0208b9f68a57dabcb1e998b4a7b9b)) + +## [2.5.0](https://www.github.com/googleapis/java-firestore/compare/v2.4.0...v2.5.0) (2021-06-01) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#641](https://www.github.com/googleapis/java-firestore/issues/641)) ([6f40f0f](https://www.github.com/googleapis/java-firestore/commit/6f40f0fc821d31136686a41e82e4b57d0ad3dede)) +* add recursiveDelete() to Firestore ([#622](https://www.github.com/googleapis/java-firestore/issues/622)) ([#649](https://www.github.com/googleapis/java-firestore/issues/649)) ([9ff2f41](https://www.github.com/googleapis/java-firestore/commit/9ff2f41b765c8878c3b3fb7df962f6f1ed537f05)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.2.0 ([#640](https://www.github.com/googleapis/java-firestore/issues/640)) ([9bd881a](https://www.github.com/googleapis/java-firestore/commit/9bd881a5ddd0bdb62396e8b778bf9784c00feba2)) + +## [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) + + +### Features + +* add backoff to BulkWriter ([#600](https://www.github.com/googleapis/java-firestore/issues/600)) ([e295aa5](https://www.github.com/googleapis/java-firestore/commit/e295aa5d20007a513e1647575f6935e243825c4d)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1 ([#607](https://www.github.com/googleapis/java-firestore/issues/607)) ([21e8cde](https://www.github.com/googleapis/java-firestore/commit/21e8cde718b5f2e2f8269d860d0ea3ae810dabdd)) + +### [2.2.7](https://www.github.com/googleapis/java-firestore/compare/v2.2.6...v2.2.7) (2021-04-20) + + +### Bug Fixes + +* release scripts from issuing overlapping phases ([#595](https://www.github.com/googleapis/java-firestore/issues/595)) ([4372479](https://www.github.com/googleapis/java-firestore/commit/43724796ea940062512370c270f6bedc680b5b6a)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.1 ([#597](https://www.github.com/googleapis/java-firestore/issues/597)) ([dbd3d33](https://www.github.com/googleapis/java-firestore/commit/dbd3d331d83fc7b2c4e79946b9921ff158c8b1e9)) + +### [2.2.6](https://www.github.com/googleapis/java-firestore/compare/v2.2.5...v2.2.6) (2021-04-13) + + +### Bug Fixes + +* Removed Jackson dependency ([#508](https://www.github.com/googleapis/java-firestore/issues/508)) ([7ada73d](https://www.github.com/googleapis/java-firestore/commit/7ada73d3c0a282be8ce2682c2e9c737690d9f891)) +* typo ([#587](https://www.github.com/googleapis/java-firestore/issues/587)) ([520ac44](https://www.github.com/googleapis/java-firestore/commit/520ac441bcb7944be378ec6099b9ec4de37844d4)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.0 ([#584](https://www.github.com/googleapis/java-firestore/issues/584)) ([c83a222](https://www.github.com/googleapis/java-firestore/commit/c83a222bd602a489552276c5202796db7fadeffa)) + +### [2.2.5](https://www.github.com/googleapis/java-firestore/compare/v2.2.4...v2.2.5) (2021-03-11) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.1 ([#567](https://www.github.com/googleapis/java-firestore/issues/567)) ([7370d21](https://www.github.com/googleapis/java-firestore/commit/7370d21994126d206f51a8c0c1677b5dc0ee030f)) + +### [2.2.4](https://www.github.com/googleapis/java-firestore/compare/v2.2.3...v2.2.4) (2021-02-25) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.0 ([#554](https://www.github.com/googleapis/java-firestore/issues/554)) ([0ae4ea3](https://www.github.com/googleapis/java-firestore/commit/0ae4ea3ce4bdd3a361331615115bdf25928b7da6)) + +### [2.2.3](https://www.github.com/googleapis/java-firestore/compare/v2.2.2...v2.2.3) (2021-02-19) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.19.0 ([#543](https://www.github.com/googleapis/java-firestore/issues/543)) ([7eed88c](https://www.github.com/googleapis/java-firestore/commit/7eed88c70cfe197a93b88b47db6e4edd89836063)) + +### [2.2.2](https://www.github.com/googleapis/java-firestore/compare/v2.2.1...v2.2.2) (2021-02-19) + + +### Bug Fixes + +* block close() on the termination of all RPC channels ([#512](https://www.github.com/googleapis/java-firestore/issues/512)) ([67bd06a](https://www.github.com/googleapis/java-firestore/commit/67bd06aac7a53a210e1a5c081929104c43a5d48a)) +* **samples:** close firestore instance in test ([#476](https://www.github.com/googleapis/java-firestore/issues/476)) ([fb1cb17](https://www.github.com/googleapis/java-firestore/commit/fb1cb175c06e2782f7cd9cb3bbb9c751e9d33713)) + +### [2.2.1](https://www.github.com/googleapis/java-firestore/compare/v2.2.0...v2.2.1) (2021-02-02) + + +### Bug Fixes + +* don't throw NPE in DocumentSnapshot.getDate() when value is missing ([#513](https://www.github.com/googleapis/java-firestore/issues/513)) ([a41b07e](https://www.github.com/googleapis/java-firestore/commit/a41b07ea8a02aefb9f2798240dd7ba32589791fe)) + +## [2.2.0](https://www.github.com/googleapis/java-firestore/compare/v2.1.0...v2.2.0) (2021-01-20) + + +### Features + +* Add bundle proto building ([#271](https://www.github.com/googleapis/java-firestore/issues/271)) ([994835c](https://www.github.com/googleapis/java-firestore/commit/994835c0a3be077404afa60abd4d4685d17fb533)) +* add bundle.proto from googleapis/googleapis ([#407](https://www.github.com/googleapis/java-firestore/issues/407)) ([37da386](https://www.github.com/googleapis/java-firestore/commit/37da386875d1b65121e8a9a92b1a000537f07625)) +* add CollectionGroup#getPartitions(long) ([#478](https://www.github.com/googleapis/java-firestore/issues/478)) ([bab064e](https://www.github.com/googleapis/java-firestore/commit/bab064edde26325bf0041ffe28d4c63b97a089c5)) +* add implicit ordering for startAt(DocumentReference) calls ([#417](https://www.github.com/googleapis/java-firestore/issues/417)) ([aae6dc9](https://www.github.com/googleapis/java-firestore/commit/aae6dc960f7c42830ceed23c65acaad3e457dcff)) +* add max/min throttling options to BulkWriterOptions ([#400](https://www.github.com/googleapis/java-firestore/issues/400)) ([27a9397](https://www.github.com/googleapis/java-firestore/commit/27a9397f67e151d723241c80ccb2ec9f1bfbba1c)) +* add success and error callbacks to BulkWriter ([#483](https://www.github.com/googleapis/java-firestore/issues/483)) ([3c05037](https://www.github.com/googleapis/java-firestore/commit/3c05037e8fce8d3ce4907fde85bd254fc98ea588)) +* Implementation of Firestore Bundle Builder ([#293](https://www.github.com/googleapis/java-firestore/issues/293)) ([fd5ef90](https://www.github.com/googleapis/java-firestore/commit/fd5ef90b6681cc67aeee6c95f3de80267798dcd0)) +* Release bundles ([#466](https://www.github.com/googleapis/java-firestore/issues/466)) ([3af065e](https://www.github.com/googleapis/java-firestore/commit/3af065e32b193931c805b576f410ad90124b43a7)) + + +### Bug Fixes + +* add @BetaApi, make BulkWriter public, and refactor Executor ([#497](https://www.github.com/googleapis/java-firestore/issues/497)) ([27ff9f6](https://www.github.com/googleapis/java-firestore/commit/27ff9f6dfa92cac9119d2014c24a0759baa44fb7)) +* **build:** sample checkstyle violations ([#457](https://www.github.com/googleapis/java-firestore/issues/457)) ([777ecab](https://www.github.com/googleapis/java-firestore/commit/777ecabd1ce12cbc5f4169de6c23a90f98deac06)) +* bulkWriter: writing to the same doc doesn't create a new batch ([#394](https://www.github.com/googleapis/java-firestore/issues/394)) ([259ece8](https://www.github.com/googleapis/java-firestore/commit/259ece8511db71ea79cc1a080eb785a15db88756)) +* empty commit to trigger release-please ([fcef0d3](https://www.github.com/googleapis/java-firestore/commit/fcef0d302cd0a9339d82db73152289d6f9f67ff2)) +* make BulkWriterOptions public ([#502](https://www.github.com/googleapis/java-firestore/issues/502)) ([6ea05be](https://www.github.com/googleapis/java-firestore/commit/6ea05beb3f27337bef910ca64f0e3f32de6b7e98)) +* retry Query streams ([#426](https://www.github.com/googleapis/java-firestore/issues/426)) ([3513cd3](https://www.github.com/googleapis/java-firestore/commit/3513cd39ff43d26c8432c05ce20693350539ae8f)) +* retry transactions that fail with expired transaction IDs ([#447](https://www.github.com/googleapis/java-firestore/issues/447)) ([5905438](https://www.github.com/googleapis/java-firestore/commit/5905438af6501353e978210808834a26947aae95)) +* verify partition count before invoking GetPartition RPC ([#418](https://www.github.com/googleapis/java-firestore/issues/418)) ([2054ae9](https://www.github.com/googleapis/java-firestore/commit/2054ae971083277e1cf81c2b57500c40a6faa0ef)) + + +### Documentation + +* **sample:** normalize firestore sample's region tags ([#453](https://www.github.com/googleapis/java-firestore/issues/453)) ([b529245](https://www.github.com/googleapis/java-firestore/commit/b529245c75f770e1b47ca5d9561bab55a7610677)) + + +### Dependencies + +* remove explicit version for jackson ([#479](https://www.github.com/googleapis/java-firestore/issues/479)) ([e2aecfe](https://www.github.com/googleapis/java-firestore/commit/e2aecfec51465b8fb3413337a76f9a3de57b8500)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.12 ([#367](https://www.github.com/googleapis/java-firestore/issues/367)) ([2bdd846](https://www.github.com/googleapis/java-firestore/commit/2bdd84693bbd968cafabd0e7ee56d1a9a7dc31ca)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.13 ([#411](https://www.github.com/googleapis/java-firestore/issues/411)) ([e6157b5](https://www.github.com/googleapis/java-firestore/commit/e6157b5cb532e0184125355b12115058e72afa67)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.0 ([#383](https://www.github.com/googleapis/java-firestore/issues/383)) ([cb39ee8](https://www.github.com/googleapis/java-firestore/commit/cb39ee820c2f67e22da623f5a6eaa7ee6bf351e2)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.10.2 ([#403](https://www.github.com/googleapis/java-firestore/issues/403)) ([991dd81](https://www.github.com/googleapis/java-firestore/commit/991dd810360e654fca0b53e0611da0cd77febc7c)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.12.1 ([#425](https://www.github.com/googleapis/java-firestore/issues/425)) ([b897ffa](https://www.github.com/googleapis/java-firestore/commit/b897ffa90427a8f597c02c24f80d1d162be48b23)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.13.0 ([#430](https://www.github.com/googleapis/java-firestore/issues/430)) ([0f8f218](https://www.github.com/googleapis/java-firestore/commit/0f8f218678c3ddebb73748c382cab8e38c2f140d)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.14.1 ([#446](https://www.github.com/googleapis/java-firestore/issues/446)) ([e241f8e](https://www.github.com/googleapis/java-firestore/commit/e241f8ebbfdf202f00424177c69962311b37fc88)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.15.0 ([#460](https://www.github.com/googleapis/java-firestore/issues/460)) ([b82fc35](https://www.github.com/googleapis/java-firestore/commit/b82fc3561d1a397438829ab69df24141481369a2)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.0 ([#481](https://www.github.com/googleapis/java-firestore/issues/481)) ([ae98824](https://www.github.com/googleapis/java-firestore/commit/ae988245e6d6391c85414e9b6f7ae1b8148c3a6d)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([4ace93c](https://www.github.com/googleapis/java-firestore/commit/4ace93c7be580a8f7870e71cad2dc19bb5fdef29)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.0 ([#487](https://www.github.com/googleapis/java-firestore/issues/487)) ([e11e472](https://www.github.com/googleapis/java-firestore/commit/e11e4723bc75727086bee0436492f458def29ff5)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.18.0 ([#495](https://www.github.com/googleapis/java-firestore/issues/495)) ([f78720a](https://www.github.com/googleapis/java-firestore/commit/f78720a155f1294321f05266b9a546bbf2cb9a04)) +* update jackson dependencies to v2.11.3 ([#396](https://www.github.com/googleapis/java-firestore/issues/396)) ([2e176e2](https://www.github.com/googleapis/java-firestore/commit/2e176e2f864262f31e6f93705fa7e794023b9649)) + +## [2.1.0](https://www.github.com/googleapis/java-firestore/compare/v2.0.0...v2.1.0) (2020-09-10) + + +### Features + +* add method to set emulator host programmatically ([#319](https://www.github.com/googleapis/java-firestore/issues/319)) ([#336](https://www.github.com/googleapis/java-firestore/issues/336)) ([97037f4](https://www.github.com/googleapis/java-firestore/commit/97037f42f76e9df3ae458d4e2b04336e64b834c3)), closes [#210](https://www.github.com/googleapis/java-firestore/issues/210) [#190](https://www.github.com/googleapis/java-firestore/issues/190) +* add opencensus tracing support ([#360](https://www.github.com/googleapis/java-firestore/issues/360)) ([edaa539](https://www.github.com/googleapis/java-firestore/commit/edaa5395be0353fb261d954429c624623bc4e346)) +* add support for != and NOT_IN queries ([#350](https://www.github.com/googleapis/java-firestore/issues/350)) ([68aff5b](https://www.github.com/googleapis/java-firestore/commit/68aff5b406fb2732951750f3d5f9768df6ee12b5)) +* generate protos to add NOT_EQUAL, NOT_IN, IS_NOT_NAN, IS_NOT_NULL query operators ([#343](https://www.github.com/googleapis/java-firestore/issues/343)) ([3fb1b63](https://www.github.com/googleapis/java-firestore/commit/3fb1b631f8dd087f0f3e1c43363e9642f497993a)) + + +### Bug Fixes + +* **samples:** re-add maven exec config for Quickstart sample ([#347](https://www.github.com/googleapis/java-firestore/issues/347)) ([4c2329b](https://www.github.com/googleapis/java-firestore/commit/4c2329bf89ffab4bd3060e16e1cf231b7caf4653)) +* add support to deserialize to custom Lists and Maps ([#337](https://www.github.com/googleapis/java-firestore/issues/337)) ([dc897e0](https://www.github.com/googleapis/java-firestore/commit/dc897e00a85e745f57f615460b29d17b7dd247c6)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.9.0 ([#352](https://www.github.com/googleapis/java-firestore/issues/352)) ([783d41e](https://www.github.com/googleapis/java-firestore/commit/783d41e167c7c79957faeeebd7a76ab72b5b157d)) + +## [2.0.0](https://www.github.com/googleapis/java-firestore/compare/v1.35.2...v2.0.0) (2020-08-14) + + +### New Features + +#### Query Partition API + +New API and backend RPC which allows for fetching a set of cursor keys for a +Collection Group Query. Accessible via the new [`CollectionGroup#getPartitions(long,ApiStreamObserver)`](https://googleapis.dev/java/google-cloud-firestore/2.0.0/com/google/cloud/firestore/CollectionGroup.html#getPartitions-long-com.google.api.gax.rpc.ApiStreamObserver-) method. + +#### Read-Only Transaction Options + +[`TransactionOptions`](https://googleapis.dev/java/google-cloud-firestore/2.0.0/com/google/cloud/firestore/TransactionOptions.html) +has been refactored to provide the ability to configure options for read-only +transactions along with the existing configuration for read-write transactions. + +This new ability is provided via the new [`TransactionOptions.createReadOnlyOptionsBuilder()`](https://googleapis.dev/java/google-cloud-firestore/2.0.0/com/google/cloud/firestore/TransactionOptions.html#createReadOnlyOptionsBuilder--) +type safe builder. + +Along with the new type safe builder for read-only options, there is a new type +safe builder for read-write options as well accessible via [`TransactionOptions.createReadWriteOptionsBuilder()`](https://googleapis.dev/java/google-cloud-firestore/2.0.0/com/google/cloud/firestore/TransactionOptions.html#createReadWriteOptionsBuilder--). Each of the existing `TransactionOptions.create(...)` +methods for configuring read-write options has been deprecated in favor of the new builder. + +#### EmulatorCredentials + +`com.google.cloud.firestore.FirestoreOptions.Builder.FakeCredentials` has been +made static and renamed to `com.google.cloud.firestore.FirestoreOptions.EmulatorCredentials` +allowing instantiation outside `FirestoreOptions.Builder`. + +When connecting to the Cloud Firestore Emulator via `FirestoreOptions` rather than +the environment variable `FIRESTORE_EMULATOR_HOST`, a custom credential implementation +must be specified to allow various admin operations in the emulator. Previously +this required users to create their own implementation due to it not being +possible to construct a `FakeCredential`. As part of this change, `EmulatorCredentials` +is static and therefore able to be constructed from any location. + +### Breaking Changes + +#### New Firestore Admin Client API Artifact + +The Cloud Firestore Admin Client has been migrated to its own maven artifact `com.google.cloud:google-cloud-firestore-admin` +rather than being bundled in `com.google.cloud:google-cloud-firestore`. All +packages and classes have retained their existing names. + +The new artifact is included in the `com.google.cloud:google-cloud-firestore-bom`, +`com.google.cloud:google-cloud-bom` and `com.google.cloud:libraries-bom` +artifacts and is accessible by adding the new dependency to your `pom.xml` file: + +```xml + + com.google.cloud + google-cloud-firestore-admin + +``` + +#### Removal of v1beta1 + +Cloud Firestore has been GA for some time now, and the `google-cloud-firestore` +code base has been using the protos and generated classes for the v1 api since +that time. As such, we will no longer be publishing artifacts for the deprecated +v1beta1 protos. All functionality from v1beta1 is present in v1, and all users +should update any code to use v1. + +#### Removal of support for `java.util.Date` in Snapshots + +It is no longer possible to configure the ability for `java.util.Date` to be +returned from `DocumentSnapshot.get(FieldPath)` or `DocumentSnapshot.getData()` +for properties which are stored as Timestamps in Cloud Firestore. + +The default behavior has been to return `com.google.cloud.Timestamp` by default +for some time, and is now the only option. Any code that is dependent on the old +behavior must be updated to use Timestamps instead of Date. + +### Laundry List of Pull Requests + +#### ⚠ BREAKING CHANGES + +* add support for the Query Partition API (#202) + * `Firestore#collectionGroup(...)` has a new return type `CollectionGroup` + which requires any code that previously used the method be re-compiled to + pick up the new signature. `CollectionGroup` extends `Query` and as such + does not require your code to be updated, only the compiled class files. +* move FirestoreAdminClient and associated classes to new artifact google-cloud-firestore-admin (#311) +* remove deprecated v1beta1 protos and grpc client (#305) +* remove deprecated FirestoreOptions#setTimestampsInSnapshotsEnabled (#308) +* remove deprecated getCollections() methods (#307) +* various renames due to generator changes + +#### Features + +* add support for read-only transactions in TransactionOptions ([#320](https://www.github.com/googleapis/java-firestore/issues/320)) ([c25dca3](https://www.github.com/googleapis/java-firestore/commit/c25dca3ed6ca0c156ec60569ebc9f3a481bd4fee)) +* add support for the Query Partition API ([#202](https://www.github.com/googleapis/java-firestore/issues/202)) ([3996548](https://www.github.com/googleapis/java-firestore/commit/39965489cbc836af573e500d57007c88241d7eb6)) + + +#### Bug Fixes + +* refactor FakeCredentials ([#325](https://www.github.com/googleapis/java-firestore/issues/325)) ([269e62c](https://www.github.com/googleapis/java-firestore/commit/269e62c6b8031d48e7f2e282b09b5ffcfadae547)), closes [#190](https://www.github.com/googleapis/java-firestore/issues/190) + + +#### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.5 ([#322](https://www.github.com/googleapis/java-firestore/issues/322)) ([1b21350](https://www.github.com/googleapis/java-firestore/commit/1b21350c0bc4a21cee2b281f944cbd061b1f8898)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.6 ([#324](https://www.github.com/googleapis/java-firestore/issues/324)) ([b945fdb](https://www.github.com/googleapis/java-firestore/commit/b945fdb04da76a1e007d012c809449c5a43bb990)) +* update jackson dependencies to v2.11.2 ([#314](https://www.github.com/googleapis/java-firestore/issues/314)) ([15d68cd](https://www.github.com/googleapis/java-firestore/commit/15d68cd93ac1fd206895fd37155a9ba82b9196ca)) + + +#### Miscellaneous Chores + +* enable gapicv2 ([#188](https://www.github.com/googleapis/java-firestore/issues/188)) ([92224bc](https://www.github.com/googleapis/java-firestore/commit/92224bcd52aa88cc6eb1da28747de0535d776a0f)) +* move FirestoreAdminClient and associated classes to new artifact google-cloud-firestore-admin ([#311](https://www.github.com/googleapis/java-firestore/issues/311)) ([03ef755](https://www.github.com/googleapis/java-firestore/commit/03ef755dd164e6f1ec749f3f985b913b5ae23d14)) +* remove deprecated FirestoreOptions#setTimestampsInSnapshotsEnabled ([#308](https://www.github.com/googleapis/java-firestore/issues/308)) ([7255a42](https://www.github.com/googleapis/java-firestore/commit/7255a42bcee3a6938dd5fafaef3465f948f39600)) +* remove deprecated getCollections() methods ([#307](https://www.github.com/googleapis/java-firestore/issues/307)) ([bb4ddf1](https://www.github.com/googleapis/java-firestore/commit/bb4ddf1ce3cc3bd2e06a4ad5097bd18060e4467b)) +* remove deprecated v1beta1 protos and grpc client ([#305](https://www.github.com/googleapis/java-firestore/issues/305)) ([96adacb](https://www.github.com/googleapis/java-firestore/commit/96adacbf52ace27e54b7a210d7c73b46922fbcbd)) +* add BulkWriter ([#323](https://www.github.com/googleapis/java-firestore/issues/323)) ([e7054df](https://www.github.com/googleapis/java-firestore/commit/e7054df79b4139fdfd0cc6aa0620fbfa1a10a6b0)) +* make BulkWriter package private ([#330](https://github.com/googleapis/java-firestore/pull/330)) ([ef0869a](https://github.com/googleapis/java-firestore/commit/ef0869a7fa619bc15fef27ad90d41cb718cb981d)) + +## [1.35.2](https://www.github.com/googleapis/java-firestore/compare/v1.35.1...v1.35.2) (2020-07-16) + + +### Bug Fixes + +* add Internal#autoId() ([#292](https://www.github.com/googleapis/java-firestore/issues/292)) ([b91c57c](https://www.github.com/googleapis/java-firestore/commit/b91c57c4b2d3e92478ceaa1a39d467c40e1344dc)) +* add support for deleting nested fields that contain periods ([#295](https://www.github.com/googleapis/java-firestore/issues/295)) ([84f602e](https://www.github.com/googleapis/java-firestore/commit/84f602ef8be67e5748b77e549d46ea53d0c74335)) +* use test credentials when connecting to the Emulator from the Firebase Admin SDK ([#296](https://www.github.com/googleapis/java-firestore/issues/296)) ([a0a6e80](https://www.github.com/googleapis/java-firestore/commit/a0a6e806217693fc62a4cf432354c76e719aa140)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.3 ([#289](https://www.github.com/googleapis/java-firestore/issues/289)) ([2ddb8f1](https://www.github.com/googleapis/java-firestore/commit/2ddb8f133dd3bf31d28bf6bd67cddf8ba2e8846b)) + +## [1.35.1](https://www.github.com/googleapis/java-firestore/compare/v1.35.0...v1.35.1) (2020-07-01) + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.2 ([#280](https://www.github.com/googleapis/java-firestore/issues/280)) ([9296f7a](https://www.github.com/googleapis/java-firestore/commit/9296f7a67c6194ea9e75b952d29b0f1aa486d194)) +* update jackson dependencies to v2.11.1 ([#272](https://www.github.com/googleapis/java-firestore/issues/272)) ([1065704](https://www.github.com/googleapis/java-firestore/commit/1065704f3e571f3f51b0e9ed13ec67eb7c662b88)) +* adopt flatten plugin and google-cloud-shared-dependencies ([#261](https://www.github.com/googleapis/java-firestore/issues/261)) ([78b2ebf](https://www.github.com/googleapis/java-firestore/commit/78b2ebf3c75c774f1ace386fa5f32e76b470ed9c)) + +## [1.35.0](https://www.github.com/googleapis/java-firestore/compare/v1.34.0...v1.35.0) (2020-06-17) + + +### Features + +* ability to serialize Query to Proto ([#241](https://www.github.com/googleapis/java-firestore/issues/241)) ([bae22e0](https://www.github.com/googleapis/java-firestore/commit/bae22e0839de55e11dda604c3034feaedbbc172a)) +* add support for fieldmask to document reference ([#245](https://www.github.com/googleapis/java-firestore/issues/245)) ([4a846b1](https://www.github.com/googleapis/java-firestore/commit/4a846b1f067ad8e462df673ada38589da224fcef)) + + +### Dependencies + +* update core dependencies ([#254](https://www.github.com/googleapis/java-firestore/issues/254)) ([9b275ca](https://www.github.com/googleapis/java-firestore/commit/9b275ca5b3f2adbe18be77ea8c86d8446a5833d6)) +* update dependency com.google.api:api-common to v1.9.2 ([#238](https://www.github.com/googleapis/java-firestore/issues/238)) ([c47d327](https://www.github.com/googleapis/java-firestore/commit/c47d32705645a76d8f9598aa954dbc3b1c067c73)) +* update dependency io.grpc:grpc-bom to v1.30.0 ([#244](https://www.github.com/googleapis/java-firestore/issues/244)) ([b5749d4](https://www.github.com/googleapis/java-firestore/commit/b5749d4e9bac3628da66451fa070c1bf6f852614)) + +## [1.34.0](https://www.github.com/googleapis/java-firestore/compare/v1.33.0...v1.34.0) (2020-05-29) + + +### Features + +* add support for BigDecimal to CustomClassMapper ([#196](https://www.github.com/googleapis/java-firestore/issues/196)) ([a471f1e](https://www.github.com/googleapis/java-firestore/commit/a471f1eed1e555e95b3d9bcda31ce0277e35a14a)) +* Create CODEOWNERS ([#207](https://www.github.com/googleapis/java-firestore/issues/207)) ([cd19eae](https://www.github.com/googleapis/java-firestore/commit/cd19eae68a4898a53c6c3cc8189eab30545a661d)) + + +### Bug Fixes + +* add RateLimiter ([#230](https://www.github.com/googleapis/java-firestore/issues/230)) ([47d4a11](https://www.github.com/googleapis/java-firestore/commit/47d4a11625d5888d6f31e494923853a08bb8af77)) +* catch null Firestore in system tests ([#215](https://www.github.com/googleapis/java-firestore/issues/215)) ([2a4a7b5](https://www.github.com/googleapis/java-firestore/commit/2a4a7b50d40ff1c165e3d359d5f4eaf929f6ffbc)) +* Fields used in whereIn should be equality filters ([#216](https://www.github.com/googleapis/java-firestore/issues/216)) ([4a62633](https://www.github.com/googleapis/java-firestore/commit/4a626333e5af0d70a4dc4853ed373dcf50ea0f4a)) +* replace usages of transform proto with update_transform ([#213](https://www.github.com/googleapis/java-firestore/issues/213)) ([46a3c51](https://www.github.com/googleapis/java-firestore/commit/46a3c51386b57f20bd65c564e93181e9ce399e2b)) +* support array of references for IN queries ([#211](https://www.github.com/googleapis/java-firestore/issues/211)) ([b376003](https://www.github.com/googleapis/java-firestore/commit/b3760032952529f148065928c3bf13ff73a34edd)) + + +### Dependencies + +* update core dependencies to v1.93.5 ([#229](https://www.github.com/googleapis/java-firestore/issues/229)) ([b078213](https://www.github.com/googleapis/java-firestore/commit/b078213209f3936cfe9c9e2cdea040c1262621d4)) +* update dependency com.google.api:api-common to v1.9.1 ([#228](https://www.github.com/googleapis/java-firestore/issues/228)) ([7e4568d](https://www.github.com/googleapis/java-firestore/commit/7e4568d8b3f0fc6f591640ccc2d646eb2764e572)) +* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#204](https://www.github.com/googleapis/java-firestore/issues/204)) ([1e05de4](https://www.github.com/googleapis/java-firestore/commit/1e05de4ecfde055a1c84c2f6dd338604b8580a61)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.10 ([#197](https://www.github.com/googleapis/java-firestore/issues/197)) ([69372af](https://www.github.com/googleapis/java-firestore/commit/69372af7253564691b291766e2bf4d80e9ecc770)) +* update dependency com.google.guava:guava-bom to v29 ([#180](https://www.github.com/googleapis/java-firestore/issues/180)) ([3c204b4](https://www.github.com/googleapis/java-firestore/commit/3c204b42ddfbe435ac095368d1e695ed282280bd)) +* update dependency io.grpc:grpc-bom to v1.29.0 ([#206](https://www.github.com/googleapis/java-firestore/issues/206)) ([5d8c50f](https://www.github.com/googleapis/java-firestore/commit/5d8c50f105649100abf4fa7a6882bb0469ccbf8f)) +* update dependency org.threeten:threetenbp to v1.4.4 ([#194](https://www.github.com/googleapis/java-firestore/issues/194)) ([c867bd5](https://www.github.com/googleapis/java-firestore/commit/c867bd5772aa4a4710c622546e69fdc0f1ca22b6)) +* update jackson dependencies to v2.11.0 ([#195](https://www.github.com/googleapis/java-firestore/issues/195)) ([5066812](https://www.github.com/googleapis/java-firestore/commit/50668126e99422cc9498b317c9c76a80a8bf7b30)) +* update protobuf.version to v3.12.0 ([#220](https://www.github.com/googleapis/java-firestore/issues/220)) ([2c0b35d](https://www.github.com/googleapis/java-firestore/commit/2c0b35dfc5786b986b5301a00f06177f527496c3)) +* update protobuf.version to v3.12.2 ([#226](https://www.github.com/googleapis/java-firestore/issues/226)) ([2eeea19](https://www.github.com/googleapis/java-firestore/commit/2eeea193d7eb54b1efa92b4d5dd996c170048a73)) + + +### Documentation + +* update README to include code formatting ([#209](https://www.github.com/googleapis/java-firestore/issues/209)) ([04f8b3b](https://www.github.com/googleapis/java-firestore/commit/04f8b3b0f873c2f1988c184de1e5268e0de9053f)) + +## [1.33.0](https://www.github.com/googleapis/java-firestore/compare/v1.32.5...v1.33.0) (2020-04-08) + + +### Features + +* add new Firestore.runAsyncTransaction ([#103](https://www.github.com/googleapis/java-firestore/issues/103)) ([b28b660](https://www.github.com/googleapis/java-firestore/commit/b28b66088194f997cca62f759e4201cba3da38b5)) + * __NOTICE__ This change will require any users of the library that implement `com.google.cloud.firestore.Firestore` to have to implement the new runAsyncTransaction methods, and is a binary incompatible change in Java 7. Those users who only use `com.google.cloud.firestore.Firestore` through the instance returned from `FirestoreOptions.getDefaultInstance().getService()` will not have to recompile their code. +* add Query.limitToLast() ([#151](https://www.github.com/googleapis/java-firestore/issues/151)) ([c104615](https://www.github.com/googleapis/java-firestore/commit/c104615210271977a48205a8d8e6acd69acc5fb6)) +* base transaction retries on error codes ([#129](https://www.github.com/googleapis/java-firestore/issues/129)) ([00b6eb3](https://www.github.com/googleapis/java-firestore/commit/00b6eb3703c8f4942d6da42b827ecbeeb9a13ef5)), closes [googleapis/nodejs-firestore#953](https://www.github.com/googleapis/nodejs-firestore/issues/953) +* use SecureRandom instead of Random to reduce the chance of auto-id collisions ([#156](https://www.github.com/googleapis/java-firestore/issues/156)) ([0088ee7](https://www.github.com/googleapis/java-firestore/commit/0088ee7b1f0c5bb65d7636de77e2c7f9098978e9)) + + +### Bug Fixes + +* add missing @InternalExtensionOnly annotation to com.google.cloud.firestore.Firestore ([#141](https://www.github.com/googleapis/java-firestore/issues/141)) ([d3458cb](https://www.github.com/googleapis/java-firestore/commit/d3458cbdae14e1f623dcb9848dd0fc51b8a8c30f)) +* add support for updating an individual field with pojo in all update method ([#136](https://www.github.com/googleapis/java-firestore/issues/136)) ([7d6c2c1](https://www.github.com/googleapis/java-firestore/commit/7d6c2c10be4eb5bf7250de4bb0ea447302464d05)) +* mark v1beta1 as deprecated ([#154](https://www.github.com/googleapis/java-firestore/issues/154)) ([495f7f9](https://www.github.com/googleapis/java-firestore/commit/495f7f97405fcd2bff4d09e67ddbeb51615ea843)) + + +### Dependencies + +* update core dependencies ([#127](https://www.github.com/googleapis/java-firestore/issues/127)) ([7995db0](https://www.github.com/googleapis/java-firestore/commit/7995db0d4e7ba38e7f28ce200de95c2069dd323e)) +* update core dependencies ([#167](https://www.github.com/googleapis/java-firestore/issues/167)) ([11f16fd](https://www.github.com/googleapis/java-firestore/commit/11f16fd2b64dff0e7d97df66af4cfa722ce8f418)) +* update core dependencies to v1.55.0 ([#158](https://www.github.com/googleapis/java-firestore/issues/158)) ([f3a20d3](https://www.github.com/googleapis/java-firestore/commit/f3a20d3d35c98c62d78ba6fcd6533878b28b7653)) +* update core dependencies to v1.93.3 ([#132](https://www.github.com/googleapis/java-firestore/issues/132)) ([50394e1](https://www.github.com/googleapis/java-firestore/commit/50394e13fe58b86b13e65aea6b80135c3e9cfe44)) +* update core dependencies to v1.93.4 ([#168](https://www.github.com/googleapis/java-firestore/issues/168)) ([2118232](https://www.github.com/googleapis/java-firestore/commit/211823214cc4cceea86048e2fe8fbdc4e6571b49)) +* update dependency com.google.api:api-common to v1.9.0 ([#153](https://www.github.com/googleapis/java-firestore/issues/153)) ([8ca0ea8](https://www.github.com/googleapis/java-firestore/commit/8ca0ea8d30f3318a89d6efec420b65f2b41dc805)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.8 ([#123](https://www.github.com/googleapis/java-firestore/issues/123)) ([0bbf4b0](https://www.github.com/googleapis/java-firestore/commit/0bbf4b03f722ca45a7c7f5466e19dd490eda94af)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.9 ([#152](https://www.github.com/googleapis/java-firestore/issues/152)) ([d41c41f](https://www.github.com/googleapis/java-firestore/commit/d41c41f6e27d66af133b89155474404fd392245f)) +* update dependency com.google.cloud.samples:shared-configuration to v1.0.13 ([#148](https://www.github.com/googleapis/java-firestore/issues/148)) ([6bd8e7f](https://www.github.com/googleapis/java-firestore/commit/6bd8e7fcc126872c635714a6d2edbecbbde55ea8)) +* update dependency org.threeten:threetenbp to v1.4.2 ([#142](https://www.github.com/googleapis/java-firestore/issues/142)) ([41b2a9a](https://www.github.com/googleapis/java-firestore/commit/41b2a9a8c556ddcdbe7ef244f0ae0e012546e09c)) +* update dependency org.threeten:threetenbp to v1.4.3 ([#165](https://www.github.com/googleapis/java-firestore/issues/165)) ([d8bfa80](https://www.github.com/googleapis/java-firestore/commit/d8bfa801a855a2079fe42cec234a685bc35288a9)) + +### [1.32.5](https://www.github.com/googleapis/java-firestore/compare/v1.32.4...v1.32.5) (2020-03-05) + + +### Bug Fixes + +* deflake-ify ITSystemTest#queryWatch ([#107](https://www.github.com/googleapis/java-firestore/issues/107)) ([f701c67](https://www.github.com/googleapis/java-firestore/commit/f701c67f9015ca96ca42c40f7e58d95dce70b18e)) + + +### Dependencies + +* update core dependencies ([#120](https://www.github.com/googleapis/java-firestore/issues/120)) ([293ba55](https://www.github.com/googleapis/java-firestore/commit/293ba5523bef2310acc91d5d97462c50889b75a8)) +* update core dependencies to v1.93.1 ([#124](https://www.github.com/googleapis/java-firestore/issues/124)) ([6ce14ce](https://www.github.com/googleapis/java-firestore/commit/6ce14ce0fe4ff366792c18816f047c217e67f9f3)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.6 ([#118](https://www.github.com/googleapis/java-firestore/issues/118)) ([7dad920](https://www.github.com/googleapis/java-firestore/commit/7dad9207802c6d8e95aad13622735f43118405e1)) +* update dependency io.grpc:grpc-bom to v1.27.2 ([#116](https://www.github.com/googleapis/java-firestore/issues/116)) ([83ef310](https://www.github.com/googleapis/java-firestore/commit/83ef31071ab3a26ea6d7a8ab2c0009de227b7ee7)) +* update jackson dependencies to v2.10.3 ([#122](https://www.github.com/googleapis/java-firestore/issues/122)) ([85a3ced](https://www.github.com/googleapis/java-firestore/commit/85a3ced134d1752e6bee3b1445d946a51d5925cd)) + +### [1.32.4](https://www.github.com/googleapis/java-firestore/compare/v1.32.3...v1.32.4) (2020-02-18) + + +### Bug Fixes + +* add cause to transaction errors on transaction commit ([#108](https://www.github.com/googleapis/java-firestore/issues/108)) ([00b3c6f](https://www.github.com/googleapis/java-firestore/commit/00b3c6f933eeb4a11cf4b18ea8c938549121f6c6)) +* remove error_prone_annotations exclusion rules from poms ([#97](https://www.github.com/googleapis/java-firestore/issues/97)) ([0f9b474](https://www.github.com/googleapis/java-firestore/commit/0f9b4745f120644e9116a4461372260ce8506160)) + + +### Dependencies + +* update core dependencies to v1.92.5 ([#101](https://www.github.com/googleapis/java-firestore/issues/101)) ([e767078](https://www.github.com/googleapis/java-firestore/commit/e767078638e5ef22f753608cb64586f813ffc21b)) +* update dependency io.grpc:grpc-bom to v1.27.1 ([#106](https://www.github.com/googleapis/java-firestore/issues/106)) ([46a7c48](https://www.github.com/googleapis/java-firestore/commit/46a7c4855a48d4ada559cf4941fb011ed40a6cf3)) +* update opencensus.version to v0.25.0 ([#105](https://www.github.com/googleapis/java-firestore/issues/105)) ([fcdbab3](https://www.github.com/googleapis/java-firestore/commit/fcdbab3856f1b0c0ad81554e381c5158d87e490d)) +* update protobuf.version to v3.11.4 ([#109](https://www.github.com/googleapis/java-firestore/issues/109)) ([4f498b4](https://www.github.com/googleapis/java-firestore/commit/4f498b448d6212ea921a2240413e17b86d2fb3d3)) + + +### Documentation + +* **regen:** update sample code to set total timeout, add API client header test ([#100](https://www.github.com/googleapis/java-firestore/issues/100)) ([d14a4a1](https://www.github.com/googleapis/java-firestore/commit/d14a4a1e30e4f9651a71ad9c10893b1eef321441)) + +### [1.32.3](https://www.github.com/googleapis/java-firestore/compare/v1.32.2...v1.32.3) (2020-02-03) + + +### Dependencies + +* update core dependencies ([#89](https://www.github.com/googleapis/java-firestore/issues/89)) ([7593432](https://www.github.com/googleapis/java-firestore/commit/7593432fdeb3ec88dde1400e8517f6bc35372648)) +* update dependency com.google.auth:google-auth-library-credentials to v0.20.0 ([#86](https://www.github.com/googleapis/java-firestore/issues/86)) ([f32bd9b](https://www.github.com/googleapis/java-firestore/commit/f32bd9bd23d5caf1f121927df173978b66d61833)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.5 ([#90](https://www.github.com/googleapis/java-firestore/issues/90)) ([f701446](https://www.github.com/googleapis/java-firestore/commit/f701446f7fb4d0b46b49a698171c8b1878d18623)) +* update protobuf.version to v3.11.3 ([#94](https://www.github.com/googleapis/java-firestore/issues/94)) ([6155816](https://www.github.com/googleapis/java-firestore/commit/6155816c61ec999ae026884075af053500f5d448)) + +### [1.32.2](https://www.github.com/googleapis/java-firestore/compare/v1.32.1...v1.32.2) (2020-01-14) + + +### Dependencies + +* update core dependencies ([#63](https://www.github.com/googleapis/java-firestore/issues/63)) ([4c1fb09](https://www.github.com/googleapis/java-firestore/commit/4c1fb091ed001cbebab9c2c16aaa93dd6f6875c8)) +* update dependency com.fasterxml.jackson.core:jackson-core to v2.10.2 ([#69](https://www.github.com/googleapis/java-firestore/issues/69)) ([5e296b8](https://www.github.com/googleapis/java-firestore/commit/5e296b8439da390661a3c4eb44452c51fb4bf486)) +* update dependency com.fasterxml.jackson.core:jackson-databind to v2.10.2 ([#70](https://www.github.com/googleapis/java-firestore/issues/70)) ([2f3a14b](https://www.github.com/googleapis/java-firestore/commit/2f3a14b075ff90209190319266ce25a5b94fcb31)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.4 ([#82](https://www.github.com/googleapis/java-firestore/issues/82)) ([6050055](https://www.github.com/googleapis/java-firestore/commit/6050055779d8e45f2904efddd8b58a8b9dd43c40)) +* update dependency com.google.guava:guava-bom to v28.2-android ([#76](https://www.github.com/googleapis/java-firestore/issues/76)) ([c1dcb9f](https://www.github.com/googleapis/java-firestore/commit/c1dcb9f67b141d06226c1ec0d6661ff3c7d7c09c)), closes [#33](https://www.github.com/googleapis/java-firestore/issues/33) +* update dependency com.google.truth:truth to v1.0.1 ([#81](https://www.github.com/googleapis/java-firestore/issues/81)) ([5d16063](https://www.github.com/googleapis/java-firestore/commit/5d16063587bb3d195b3440ff1b62698b21b111af)) +* update dependency org.threeten:threetenbp to v1.4.1 ([#78](https://www.github.com/googleapis/java-firestore/issues/78)) ([0db7256](https://www.github.com/googleapis/java-firestore/commit/0db72560449de74dc92030d84c0116d209f8ba12)) + +### [1.32.1](https://www.github.com/googleapis/java-firestore/compare/v1.32.0...v1.32.1) (2020-01-02) + + +### Bug Fixes + +* add google-cloud-firestore to bom ([#65](https://www.github.com/googleapis/java-firestore/issues/65)) ([b273a58](https://www.github.com/googleapis/java-firestore/commit/b273a58c714c1d4e9b07bda68fe47aa5496d8456)) +* set google-cloud-conformance-tests to test scope ([#44](https://www.github.com/googleapis/java-firestore/issues/44)) ([03983c3](https://www.github.com/googleapis/java-firestore/commit/03983c33228806fcf1fe7d9eaf8240f9d60ad75b)) + + +### Dependencies + +* update dependencies ([#51](https://www.github.com/googleapis/java-firestore/issues/51)) ([ce4c37b](https://www.github.com/googleapis/java-firestore/commit/ce4c37b06683a34665cbc963df7fbb5d5112888b)), closes [#49](https://www.github.com/googleapis/java-firestore/issues/49) [#50](https://www.github.com/googleapis/java-firestore/issues/50) +* update dependency com.google.auth:google-auth-library-credentials to v0.19.0 ([#48](https://www.github.com/googleapis/java-firestore/issues/48)) ([d68b457](https://www.github.com/googleapis/java-firestore/commit/d68b45785ec0d948e1c290ce71e698e19574ca28)) +* update dependency com.google.cloud:google-cloud-conformance-tests to v0.0.3 ([#55](https://www.github.com/googleapis/java-firestore/issues/55)) ([6e6644f](https://www.github.com/googleapis/java-firestore/commit/6e6644fd6e18032d4a2633e74c17f02259d97759)) +* update dependency junit:junit to v4.13 ([#62](https://www.github.com/googleapis/java-firestore/issues/62)) ([7f80e44](https://www.github.com/googleapis/java-firestore/commit/7f80e447a89d27b74730bf89bbcf448e15960ff9)) + + +### Documentation + +* bump bom version in README to 3.1.0 ([#47](https://www.github.com/googleapis/java-firestore/issues/47)) ([d8bebb3](https://www.github.com/googleapis/java-firestore/commit/d8bebb3847f24df13b3a2fd5a1fe5aa11348daaf)) + +## [1.32.0](https://www.github.com/googleapis/java-firestore/compare/1.31.0...v1.32.0) (2019-12-04) + + +### Features + +* **firestore:** allow passing POJOs as field values throughout API reference ([#6843](https://www.github.com/googleapis/java-firestore/issues/6843)) ([180f5a9](https://www.github.com/googleapis/java-firestore/commit/180f5a965ca2ea8b22338d0cc186b3d8d3bb997e)) + + +### Dependencies + +* update gax.version to v1.51.0 ([#31](https://www.github.com/googleapis/java-firestore/issues/31)) ([d5125c5](https://www.github.com/googleapis/java-firestore/commit/d5125c57fe02652d0e1b3bb10a2f162ce7317659)) +* update protobuf packages to v3.11.0 ([#26](https://www.github.com/googleapis/java-firestore/issues/26)) ([862ebce](https://www.github.com/googleapis/java-firestore/commit/862ebce0c9ef77d90bc16b612a856dbc75265929)) +* update protobuf packages to v3.11.1 ([#28](https://www.github.com/googleapis/java-firestore/issues/28)) ([c0c3b2c](https://www.github.com/googleapis/java-firestore/commit/c0c3b2c8b00fdc44dd6235d477538b1c7f085325)) diff --git a/java-firestore/README.md b/java-firestore/README.md new file mode 100644 index 000000000000..2a1b825d9f8b --- /dev/null +++ b/java-firestore/README.md @@ -0,0 +1,225 @@ +# Google Cloud Firestore Client for Java + +Java idiomatic client for [Cloud Firestore][product-docs]. + +[![Maven][maven-version-image]][maven-version-link] +![Stability][stability-image] + +- [Product Documentation][product-docs] +- [Client Library Documentation][javadocs] + + +## Quickstart + +If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: + +```xml + + + + com.google.cloud + libraries-bom + 26.65.0 + pom + import + + + + + + + com.google.cloud + google-cloud-firestore + + +``` + +If you are using Maven without the BOM, add this to your dependencies: + + +```xml + + com.google.cloud + google-cloud-firestore + 3.31.9 + + +``` + +If you are using Gradle 5.x or later, add this to your dependencies: + +```Groovy +implementation platform('com.google.cloud:libraries-bom:26.77.0') + +implementation 'com.google.cloud:google-cloud-firestore' +``` +If you are using Gradle without BOM, add this to your dependencies: + +```Groovy +implementation 'com.google.cloud:google-cloud-firestore:3.38.0' +``` + +If you are using SBT, add this to your dependencies: + +```Scala +libraryDependencies += "com.google.cloud" % "google-cloud-firestore" % "3.38.0" +``` + +## Authentication + +See the [Authentication][authentication] section in the base directory's README. + +## Authorization + +The client application making API calls must be granted [authorization scopes][auth-scopes] required for the desired Cloud Firestore APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Cloud Firestore API calls. + +## Getting Started + +### Prerequisites + +You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Firestore [API enabled][enable-api]. +You will need to [enable billing][enable-billing] to use Google Cloud Firestore. +[Follow these instructions][create-project] to get your project set up. You will also need to set up the local development environment by +[installing the Google Cloud Command Line Interface][cloud-cli] and running the following commands in command line: +`gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`. + +### Installation and setup + +You'll need to obtain the `google-cloud-firestore` library. See the [Quickstart](#quickstart) section +to add `google-cloud-firestore` as a dependency in your code. + +## About Cloud Firestore + + +[Cloud Firestore][product-docs] is a fully-managed NoSQL document database for mobile, web, and server development from Firebase and Google Cloud Platform. It's backed by a multi-region replicated database that ensures once data is committed, it's durable even in the face of unexpected disasters. Not only that, but despite being a distributed database, it's also strongly consistent and offers seamless integration with other Firebase and Google Cloud Platform products, including Google Cloud Functions. + +See the [Cloud Firestore client library docs][javadocs] to learn how to +use this Cloud Firestore Client Library. + + + + + +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-java/tree/main/samples) directory. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| Pipeline Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java) | +| Quickstart | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/Quickstart.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/Quickstart.java) | +| Example Firestore Beam Read | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamRead.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamRead.java) | +| Example Firestore Beam Write | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamWrite.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamWrite.java) | +| Listen Data Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java) | +| Manage Data Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java) | +| Multiple Range Inequality Filters Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippets.java) | +| Query Data Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/QueryDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/QueryDataSnippets.java) | +| References | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/References.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/References.java) | +| Retrieve Data Snippets | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/RetrieveDataSnippets.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/RetrieveDataSnippets.java) | +| City | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/firestore/snippets/model/City.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-java&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/firestore/snippets/model/City.java) | + + + +## Troubleshooting + +To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. + +## Transport + +Cloud Firestore uses gRPC for the transport layer. + +## Supported Java Versions + +Java 8 or above is required for using this client. + +Google's Java client libraries, +[Google Cloud Client Libraries][cloudlibs] +and +[Google Cloud API Libraries][apilibs], +follow the +[Oracle Java SE support roadmap][oracle] +(see the Oracle Java SE Product Releases section). + +### For new development + +In general, new feature development occurs with support for the lowest Java +LTS version covered by Oracle's Premier Support (which typically lasts 5 years +from initial General Availability). If the minimum required JVM for a given +library is changed, it is accompanied by a [semver][semver] major release. + +Java 11 and (in September 2021) Java 17 are the best choices for new +development. + +### Keeping production systems current + +Google tests its client libraries with all current LTS versions covered by +Oracle's Extended Support (which typically lasts 8 years from initial +General Availability). + +#### Legacy support + +Google's client libraries support legacy versions of Java runtimes with long +term stable libraries that don't receive feature updates on a best efforts basis +as it may not be possible to backport all patches. + +Google provides updates on a best efforts basis to apps that continue to use +Java 7, though apps might need to upgrade to current versions of the library +that supports their JVM. + +#### Where to find specific information + +The latest versions and the supported Java versions are identified on +the individual GitHub repository `github.com/GoogleAPIs/java-SERVICENAME` +and on [google-cloud-java][g-c-j]. + +## Versioning + + +This library follows [Semantic Versioning](http://semver.org/). + + + +## Contributing + + +Contributions to this library are always welcome and highly encouraged. + +See [CONTRIBUTING][contributing] for more information how to get started. + +Please note that this project is released with a Contributor Code of Conduct. By participating in +this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more +information. + + +## License + +Apache 2.0 - See [LICENSE][license] for more information. + +Java is a registered trademark of Oracle and/or its affiliates. + +[product-docs]: https://cloud.google.com/firestore +[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-firestore/latest/history +[stability-image]: https://img.shields.io/badge/stability-stable-green +[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-firestore.svg +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-firestore/3.38.0 +[authentication]: https://github.com/googleapis/google-cloud-java#authentication +[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes +[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles +[iam-policy]: https://cloud.google.com/iam/docs/overview#cloud-iam-policy +[developer-console]: https://console.developers.google.com/ +[create-project]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[cloud-cli]: https://cloud.google.com/cli +[troubleshooting]: https://github.com/googleapis/google-cloud-java/blob/main/TROUBLESHOOTING.md +[contributing]: https://github.com/googleapis/google-cloud-java/blob/main/CONTRIBUTING.md +[code-of-conduct]: https://github.com/googleapis/google-cloud-java/blob/main/CODE_OF_CONDUCT.md#contributor-code-of-conduct +[license]: https://github.com/googleapis/google-cloud-java/blob/main/LICENSE +[enable-billing]: https://cloud.google.com/apis/docs/getting-started#enabling_billing +[enable-api]: https://console.cloud.google.com/flows/enableapi?apiid=firestore.googleapis.com +[libraries-bom]: https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM +[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png + +[semver]: https://semver.org/ +[cloudlibs]: https://cloud.google.com/apis/docs/client-libraries-explained +[apilibs]: https://cloud.google.com/apis/docs/client-libraries-explained#google_api_client_libraries +[oracle]: https://www.oracle.com/java/technologies/java-se-support-roadmap.html +[g-c-j]: http://github.com/googleapis/google-cloud-java diff --git a/java-firestore/google-cloud-firestore-admin/pom.xml b/java-firestore/google-cloud-firestore-admin/pom.xml new file mode 100644 index 000000000000..02e61c968481 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/pom.xml @@ -0,0 +1,128 @@ + + + 4.0.0 + google-cloud-firestore-admin + 3.38.1-SNAPSHOT + jar + Google Cloud Firestore Admin Client + https://github.com/googleapis/google-cloud-java + + Java idiomatic client for Google Cloud Firestore Admin API. + + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + com.google.api.grpc + proto-google-cloud-firestore-admin-v1 + + + com.google.api.grpc + grpc-google-cloud-firestore-admin-v1 + test + + + com.google.api + api-common + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api + gax + + + io.grpc + grpc-api + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + com.google.guava + guava + + + io.grpc + grpc-stub + + + + junit + junit + test + + + com.google.api + gax + testlib + test + + + com.google.api + gax-grpc + testlib + test + + + com.google.api + gax-httpjson + testlib + test + + + com.google.api.grpc + grpc-google-common-protos + test + + + com.google.http-client + google-http-client + test + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java new file mode 100644 index 000000000000..276663bce41b --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminClient.java @@ -0,0 +1,5324 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; +import com.google.api.gax.longrunning.OperationFuture; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.v1.stub.FirestoreAdminStub; +import com.google.cloud.firestore.v1.stub.FirestoreAdminStubSettings; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldName; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.LocationName; +import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.firestore.admin.v1.UserCredsName; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: The Cloud Firestore Admin API. + * + *

This API provides several administrative services for Cloud Firestore. + * + *

Project, Database, Namespace, Collection, Collection Group, and Document are used as defined + * in the Google Cloud Firestore API. + * + *

Operation: An Operation represents work being performed in the background. + * + *

The index service manages Cloud Firestore indexes. + * + *

Index creation is performed asynchronously. An Operation resource is created for each such + * asynchronous operation. The state of the operation (including any errors encountered) may be + * queried via the Operation resource. + * + *

The Operations collection provides a record of actions performed for the specified Project + * (including any Operations in progress). Operations are not created directly but through calls on + * other collections or resources. + * + *

An Operation that is done may be deleted so that it is no longer listed as part of the + * Operation collection. Operations are garbage collected after 30 days. By default, ListOperations + * will only return in progress and failed operations. To list completed operation, issue a + * ListOperations request with the filter `done: true`. + * + *

Operations are created by service `FirestoreAdmin`, but are accessed via service + * `google.longrunning.Operations`. + * + *

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

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+ *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
+ *   Index response = firestoreAdminClient.getIndex(name);
+ * }
+ * }
+ * + *

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

CreateIndex

Creates a composite index. This returns a [google.longrunning.Operation][google.longrunning.Operation] which may be used to track the status of the creation. The metadata for the operation will be the type [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createIndexAsync(CreateIndexRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • createIndexAsync(CollectionGroupName parent, Index index) + *

  • createIndexAsync(String parent, Index index) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createIndexOperationCallable() + *

  • createIndexCallable() + *

+ *

ListIndexes

Lists composite indexes.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listIndexes(ListIndexesRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listIndexes(CollectionGroupName parent) + *

  • listIndexes(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listIndexesPagedCallable() + *

  • listIndexesCallable() + *

+ *

GetIndex

Gets a composite index.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getIndex(GetIndexRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getIndex(IndexName name) + *

  • getIndex(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getIndexCallable() + *

+ *

DeleteIndex

Deletes a composite index.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteIndex(DeleteIndexRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteIndex(IndexName name) + *

  • deleteIndex(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteIndexCallable() + *

+ *

GetField

Gets the metadata and configuration for a Field.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getField(GetFieldRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getField(FieldName name) + *

  • getField(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getFieldCallable() + *

+ *

UpdateField

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/*`.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • updateFieldAsync(UpdateFieldRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • updateFieldAsync(Field field) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • updateFieldOperationCallable() + *

  • updateFieldCallable() + *

+ *

ListFields

Lists the field configuration and metadata for this database. + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] only supports listing fields that have been explicitly overridden. To issue this query, call [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listFields(ListFieldsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listFields(CollectionGroupName parent) + *

  • listFields(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listFieldsPagedCallable() + *

  • listFieldsCallable() + *

+ *

ExportDocuments

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 export. The export occurs in the background and its progress can be monitored and managed via the Operation resource that is created. The output of an export may only be used once the associated operation is done. If an export operation is cancelled before completion it may leave partial data behind in Google Cloud Storage. + *

For more details on export behavior and output format, refer to: https://cloud.google.com/firestore/docs/manage-data/export-import

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • exportDocumentsAsync(ExportDocumentsRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • exportDocumentsAsync(DatabaseName name) + *

  • exportDocumentsAsync(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • exportDocumentsOperationCallable() + *

  • exportDocumentsCallable() + *

+ *

ImportDocuments

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 via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Firestore.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • importDocumentsAsync(ImportDocumentsRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • importDocumentsAsync(DatabaseName name) + *

  • importDocumentsAsync(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • importDocumentsOperationCallable() + *

  • importDocumentsCallable() + *

+ *

BulkDeleteDocuments

Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated after the underlying system starts to process the request will not be deleted. The bulk delete occurs in the background and its progress can be monitored and managed via the Operation resource that is created. + *

For more details on bulk delete behavior, refer to: https://cloud.google.com/firestore/docs/manage-data/bulk-delete

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • bulkDeleteDocumentsAsync(BulkDeleteDocumentsRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • bulkDeleteDocumentsAsync(DatabaseName name) + *

  • bulkDeleteDocumentsAsync(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • bulkDeleteDocumentsOperationCallable() + *

  • bulkDeleteDocumentsCallable() + *

+ *

CreateDatabase

Create a database.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createDatabaseAsync(CreateDatabaseRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • createDatabaseAsync(ProjectName parent, Database database, String databaseId) + *

  • createDatabaseAsync(String parent, Database database, String databaseId) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createDatabaseOperationCallable() + *

  • createDatabaseCallable() + *

+ *

GetDatabase

Gets information about a database.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getDatabase(GetDatabaseRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getDatabase(DatabaseName name) + *

  • getDatabase(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getDatabaseCallable() + *

+ *

ListDatabases

List all the databases in the project.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listDatabases(ListDatabasesRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listDatabases(ProjectName parent) + *

  • listDatabases(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listDatabasesCallable() + *

+ *

UpdateDatabase

Updates a database.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • updateDatabaseAsync(UpdateDatabaseRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • updateDatabaseAsync(Database database, FieldMask updateMask) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • updateDatabaseOperationCallable() + *

  • updateDatabaseCallable() + *

+ *

DeleteDatabase

Deletes a database.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteDatabaseAsync(DeleteDatabaseRequest request) + *

+ *

Methods that return long-running operations have "Async" method variants that return `OperationFuture`, which is used to track polling of the service.

+ *
    + *
  • deleteDatabaseAsync(DatabaseName name) + *

  • deleteDatabaseAsync(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteDatabaseOperationCallable() + *

  • deleteDatabaseCallable() + *

+ *

CreateUserCreds

Create a user creds.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createUserCreds(CreateUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • createUserCreds(DatabaseName parent, UserCreds userCreds, String userCredsId) + *

  • createUserCreds(String parent, UserCreds userCreds, String userCredsId) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createUserCredsCallable() + *

+ *

GetUserCreds

Gets a user creds resource. Note that the returned resource does not contain the secret value itself.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getUserCreds(GetUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getUserCreds(UserCredsName name) + *

  • getUserCreds(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getUserCredsCallable() + *

+ *

ListUserCreds

List all user creds in the database. Note that the returned resource does not contain the secret value itself.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listUserCreds(ListUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listUserCreds(DatabaseName parent) + *

  • listUserCreds(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listUserCredsCallable() + *

+ *

EnableUserCreds

Enables a user creds. No-op if the user creds are already enabled.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • enableUserCreds(EnableUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • enableUserCreds(UserCredsName name) + *

  • enableUserCreds(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • enableUserCredsCallable() + *

+ *

DisableUserCreds

Disables a user creds. No-op if the user creds are already disabled.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • disableUserCreds(DisableUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • disableUserCreds(UserCredsName name) + *

  • disableUserCreds(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • disableUserCredsCallable() + *

+ *

ResetUserPassword

Resets the password of a user creds.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • resetUserPassword(ResetUserPasswordRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • resetUserPassword(UserCredsName name) + *

  • resetUserPassword(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • resetUserPasswordCallable() + *

+ *

DeleteUserCreds

Deletes a user creds.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteUserCreds(DeleteUserCredsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteUserCreds(UserCredsName name) + *

  • deleteUserCreds(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteUserCredsCallable() + *

+ *

GetBackup

Gets information about a backup.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getBackup(GetBackupRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getBackup(BackupName name) + *

  • getBackup(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getBackupCallable() + *

+ *

ListBackups

Lists all the backups.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listBackups(ListBackupsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listBackups(LocationName parent) + *

  • listBackups(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listBackupsCallable() + *

+ *

DeleteBackup

Deletes a backup.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteBackup(DeleteBackupRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteBackup(BackupName name) + *

  • deleteBackup(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteBackupCallable() + *

+ *

RestoreDatabase

Creates a new database by restoring from an existing backup. + *

The new database must be in the same cloud region or multi-region location as the existing backup. This behaves similar to [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing backup. + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. The [response][google.longrunning.Operation.response] type is the [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database is not readable or writeable until the LRO has completed.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • restoreDatabaseAsync(RestoreDatabaseRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • restoreDatabaseOperationCallable() + *

  • restoreDatabaseCallable() + *

+ *

CreateBackupSchedule

Creates a backup schedule on a database. At most two backup schedules can be configured on a database, one daily backup schedule and one weekly backup schedule.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createBackupSchedule(CreateBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • createBackupSchedule(DatabaseName parent, BackupSchedule backupSchedule) + *

  • createBackupSchedule(String parent, BackupSchedule backupSchedule) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createBackupScheduleCallable() + *

+ *

GetBackupSchedule

Gets information about a backup schedule.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getBackupSchedule(GetBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • getBackupSchedule(BackupScheduleName name) + *

  • getBackupSchedule(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getBackupScheduleCallable() + *

+ *

ListBackupSchedules

List backup schedules.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listBackupSchedules(ListBackupSchedulesRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listBackupSchedules(DatabaseName parent) + *

  • listBackupSchedules(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listBackupSchedulesCallable() + *

+ *

UpdateBackupSchedule

Updates a backup schedule.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • updateBackupSchedule(UpdateBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • updateBackupSchedule(BackupSchedule backupSchedule, FieldMask updateMask) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • updateBackupScheduleCallable() + *

+ *

DeleteBackupSchedule

Deletes a backup schedule.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteBackupSchedule(DeleteBackupScheduleRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteBackupSchedule(BackupScheduleName name) + *

  • deleteBackupSchedule(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteBackupScheduleCallable() + *

+ *

CloneDatabase

Creates a new database by cloning an existing one. + *

The new database must be in the same cloud region or multi-region location as the existing database. This behaves similar to [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except instead of creating a new empty database, a new database is created with the database type, index configuration, and documents from an existing database. + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress of the clone, with the Operation's [metadata][google.longrunning.Operation.metadata] field type being the [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata]. The [response][google.longrunning.Operation.response] type is the [Database][google.firestore.admin.v1.Database] if the clone was successful. The new database is not readable or writeable until the LRO has completed.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • cloneDatabaseAsync(CloneDatabaseRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • cloneDatabaseOperationCallable() + *

  • cloneDatabaseCallable() + *

+ *
+ * + *

See the individual methods for example code. + * + *

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

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

To customize credentials: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminSettings firestoreAdminSettings =
+ *     FirestoreAdminSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings);
+ * }
+ * + *

To customize the endpoint: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminSettings firestoreAdminSettings =
+ *     FirestoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings);
+ * }
+ * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminSettings firestoreAdminSettings =
+ *     FirestoreAdminSettings.newHttpJsonBuilder().build();
+ * FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create(firestoreAdminSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class FirestoreAdminClient implements BackgroundResource { + private final FirestoreAdminSettings settings; + private final FirestoreAdminStub stub; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; + + /** Constructs an instance of FirestoreAdminClient with default settings. */ + public static final FirestoreAdminClient create() throws IOException { + return create(FirestoreAdminSettings.newBuilder().build()); + } + + /** + * Constructs an instance of FirestoreAdminClient, using the given settings. The channels are + * created based on the settings passed in, or defaults for any settings that are not set. + */ + public static final FirestoreAdminClient create(FirestoreAdminSettings settings) + throws IOException { + return new FirestoreAdminClient(settings); + } + + /** + * Constructs an instance of FirestoreAdminClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(FirestoreAdminSettings). + */ + public static final FirestoreAdminClient create(FirestoreAdminStub stub) { + return new FirestoreAdminClient(stub); + } + + /** + * Constructs an instance of FirestoreAdminClient, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected FirestoreAdminClient(FirestoreAdminSettings settings) throws IOException { + this.settings = settings; + this.stub = ((FirestoreAdminStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + protected FirestoreAdminClient(FirestoreAdminStub stub) { + this.settings = null; + this.stub = stub; + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + public final FirestoreAdminSettings getSettings() { + return settings; + } + + public FirestoreAdminStub getStub() { + return stub; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final com.google.longrunning.OperationsClient getOperationsClient() { + return operationsClient; + } + + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + + // 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 + * status of the creation. The metadata for the operation will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final OperationFuture createIndexAsync( + CollectionGroupName parent, Index index) { + CreateIndexRequest request = + CreateIndexRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setIndex(index) + .build(); + return createIndexAsync(request); + } + + // 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 + * status of the creation. The metadata for the operation will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]").toString();
+   *   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 + */ + public final OperationFuture createIndexAsync( + String parent, Index index) { + CreateIndexRequest request = + CreateIndexRequest.newBuilder().setParent(parent).setIndex(index).build(); + return createIndexAsync(request); + } + + // 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 + * status of the creation. The metadata for the operation will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final OperationFuture createIndexAsync( + CreateIndexRequest request) { + return createIndexOperationCallable().futureCall(request); + } + + // 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 + * status of the creation. The metadata for the operation will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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();
+   * }
+   * }
+ */ + public final OperationCallable + createIndexOperationCallable() { + return stub.createIndexOperationCallable(); + } + + // 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 + * status of the creation. The metadata for the operation will be the type + * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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. + /** + * Lists composite indexes. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIndexesPagedResponse listIndexes(CollectionGroupName parent) { + ListIndexesRequest request = + ListIndexesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listIndexes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists composite indexes. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListIndexesPagedResponse listIndexes(String parent) { + ListIndexesRequest request = ListIndexesRequest.newBuilder().setParent(parent).build(); + return listIndexes(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists composite indexes. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final ListIndexesPagedResponse listIndexes(ListIndexesRequest request) { + return listIndexesPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists composite indexes. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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. + /** + * Lists composite indexes. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listIndexesCallable() { + return stub.listIndexesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a composite index. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Index getIndex(IndexName name) { + GetIndexRequest request = + GetIndexRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a composite index. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Index getIndex(String name) { + GetIndexRequest request = GetIndexRequest.newBuilder().setName(name).build(); + return getIndex(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a composite index. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final Index getIndex(GetIndexRequest request) { + return getIndexCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a composite index. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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. + /** + * Deletes a composite index. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Field getField(FieldName name) { + GetFieldRequest request = + GetFieldRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getField(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata and configuration for a Field. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Field getField(String name) { + GetFieldRequest request = GetFieldRequest.newBuilder().setName(name).build(); + return getField(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata and configuration for a Field. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final Field getField(GetFieldRequest request) { + return getFieldCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets the metadata and configuration for a Field. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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. + /** + * 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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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. + * + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the + * filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListFieldsPagedResponse listFields(CollectionGroupName parent) { + ListFieldsRequest request = + ListFieldsRequest.newBuilder().setParent(parent == null ? null : parent.toString()).build(); + return listFields(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the field configuration and metadata for this database. + * + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the + * filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListFieldsPagedResponse listFields(String parent) { + ListFieldsRequest request = ListFieldsRequest.newBuilder().setParent(parent).build(); + return listFields(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the field configuration and metadata for this database. + * + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the + * filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final ListFieldsPagedResponse listFields(ListFieldsRequest request) { + return listFieldsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the field configuration and metadata for this database. + * + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the + * filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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. + /** + * Lists the field configuration and metadata for this database. + * + *

Currently, [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + * only supports listing fields that have been explicitly overridden. To issue this query, call + * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] with the + * filter set to `indexConfig.usesAncestorConfig:false` or `ttlConfig:*`. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listFieldsCallable() { + return stub.listFieldsCallable(); + } + + // 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 + * export. The export occurs in the background and its progress can be monitored and managed via + * the Operation resource that is created. The output of an export may only be used once the + * associated operation is done. If an export operation is cancelled before completion it may + * leave partial data behind in Google Cloud Storage. + * + *

For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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 + */ + public final OperationFuture + exportDocumentsAsync(DatabaseName name) { + ExportDocumentsRequest request = + ExportDocumentsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return exportDocumentsAsync(request); + } + + // 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 + * export. The export occurs in the background and its progress can be monitored and managed via + * the Operation resource that is created. The output of an export may only be used once the + * associated operation is done. If an export operation is cancelled before completion it may + * leave partial data behind in Google Cloud Storage. + * + *

For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final OperationFuture + exportDocumentsAsync(String name) { + ExportDocumentsRequest request = ExportDocumentsRequest.newBuilder().setName(name).build(); + return exportDocumentsAsync(request); + } + + // 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 + * export. The export occurs in the background and its progress can be monitored and managed via + * the Operation resource that is created. The output of an export may only be used once the + * associated operation is done. If an export operation is cancelled before completion it may + * leave partial data behind in Google Cloud Storage. + * + *

For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .setSnapshotTime(Timestamp.newBuilder().build())
+   *           .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 + */ + public final OperationFuture + exportDocumentsAsync(ExportDocumentsRequest request) { + return exportDocumentsOperationCallable().futureCall(request); + } + + // 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 + * export. The export occurs in the background and its progress can be monitored and managed via + * the Operation resource that is created. The output of an export may only be used once the + * associated operation is done. If an export operation is cancelled before completion it may + * leave partial data behind in Google Cloud Storage. + * + *

For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .setSnapshotTime(Timestamp.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.exportDocumentsOperationCallable().futureCall(request);
+   *   // Do something.
+   *   ExportDocumentsResponse response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationCallable() { + return stub.exportDocumentsOperationCallable(); + } + + // 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 + * export. The export occurs in the background and its progress can be monitored and managed via + * the Operation resource that is created. The output of an export may only be used once the + * associated operation is done. If an export operation is cancelled before completion it may + * leave partial data behind in Google Cloud Storage. + * + *

For more details on export behavior and output format, refer to: + * https://cloud.google.com/firestore/docs/manage-data/export-import + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ExportDocumentsRequest request =
+   *       ExportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setOutputUriPrefix("outputUriPrefix499858205")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .setSnapshotTime(Timestamp.newBuilder().build())
+   *           .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. + /** + * 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 + * via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Firestore. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (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 + */ + public final OperationFuture importDocumentsAsync( + DatabaseName name) { + ImportDocumentsRequest request = + ImportDocumentsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return importDocumentsAsync(request); + } + + // 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 + * via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Firestore. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   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 + */ + public final OperationFuture importDocumentsAsync(String name) { + ImportDocumentsRequest request = ImportDocumentsRequest.newBuilder().setName(name).build(); + return importDocumentsAsync(request); + } + + // 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 + * via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Firestore. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .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 + */ + public final OperationFuture importDocumentsAsync( + ImportDocumentsRequest request) { + return importDocumentsOperationCallable().futureCall(request); + } + + // 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 + * via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Firestore. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.importDocumentsOperationCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final OperationCallable + importDocumentsOperationCallable() { + return stub.importDocumentsOperationCallable(); + } + + // 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 + * via the Operation resource that is created. If an ImportDocuments operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Firestore. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ImportDocumentsRequest request =
+   *       ImportDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .setInputUriPrefix("inputUriPrefix-97481100")
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.importDocumentsCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable importDocumentsCallable() { + return stub.importDocumentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated + * after the underlying system starts to process the request will not be deleted. The bulk delete + * occurs in the background and its progress can be monitored and managed via the Operation + * resource that is created. + * + *

For more details on bulk delete behavior, refer to: + * https://cloud.google.com/firestore/docs/manage-data/bulk-delete + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   BulkDeleteDocumentsResponse response =
+   *       firestoreAdminClient.bulkDeleteDocumentsAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. Database to operate. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture + bulkDeleteDocumentsAsync(DatabaseName name) { + BulkDeleteDocumentsRequest request = + BulkDeleteDocumentsRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return bulkDeleteDocumentsAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated + * after the underlying system starts to process the request will not be deleted. The bulk delete + * occurs in the background and its progress can be monitored and managed via the Operation + * resource that is created. + * + *

For more details on bulk delete behavior, refer to: + * https://cloud.google.com/firestore/docs/manage-data/bulk-delete + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   BulkDeleteDocumentsResponse response =
+   *       firestoreAdminClient.bulkDeleteDocumentsAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. Database to operate. Should be of the form: + * `projects/{project_id}/databases/{database_id}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture + bulkDeleteDocumentsAsync(String name) { + BulkDeleteDocumentsRequest request = + BulkDeleteDocumentsRequest.newBuilder().setName(name).build(); + return bulkDeleteDocumentsAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated + * after the underlying system starts to process the request will not be deleted. The bulk delete + * occurs in the background and its progress can be monitored and managed via the Operation + * resource that is created. + * + *

For more details on bulk delete behavior, refer to: + * https://cloud.google.com/firestore/docs/manage-data/bulk-delete + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BulkDeleteDocumentsRequest request =
+   *       BulkDeleteDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .build();
+   *   BulkDeleteDocumentsResponse response =
+   *       firestoreAdminClient.bulkDeleteDocumentsAsync(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 + bulkDeleteDocumentsAsync(BulkDeleteDocumentsRequest request) { + return bulkDeleteDocumentsOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated + * after the underlying system starts to process the request will not be deleted. The bulk delete + * occurs in the background and its progress can be monitored and managed via the Operation + * resource that is created. + * + *

For more details on bulk delete behavior, refer to: + * https://cloud.google.com/firestore/docs/manage-data/bulk-delete + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BulkDeleteDocumentsRequest request =
+   *       BulkDeleteDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.bulkDeleteDocumentsOperationCallable().futureCall(request);
+   *   // Do something.
+   *   BulkDeleteDocumentsResponse response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable() { + return stub.bulkDeleteDocumentsOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Bulk deletes a subset of documents from Google Cloud Firestore. Documents created or updated + * after the underlying system starts to process the request will not be deleted. The bulk delete + * occurs in the background and its progress can be monitored and managed via the Operation + * resource that is created. + * + *

For more details on bulk delete behavior, refer to: + * https://cloud.google.com/firestore/docs/manage-data/bulk-delete + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BulkDeleteDocumentsRequest request =
+   *       BulkDeleteDocumentsRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .addAllCollectionIds(new ArrayList())
+   *           .addAllNamespaceIds(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.bulkDeleteDocumentsCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable bulkDeleteDocumentsCallable() { + return stub.bulkDeleteDocumentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   Database database = Database.newBuilder().build();
+   *   String databaseId = "databaseId1688905718";
+   *   Database response =
+   *       firestoreAdminClient.createDatabaseAsync(parent, database, databaseId).get();
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form `projects/{project_id}` + * @param database Required. The Database to create. + * @param databaseId Required. The ID to use for the database, which will become the final + * component of the database's resource name. + *

This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ with first + * character a letter and the last a letter or a number. Must not be UUID-like + * /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + *

"(default)" database ID is also valid if the database is Standard edition. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createDatabaseAsync( + ProjectName parent, Database database, String databaseId) { + CreateDatabaseRequest request = + CreateDatabaseRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setDatabase(database) + .setDatabaseId(databaseId) + .build(); + return createDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   Database database = Database.newBuilder().build();
+   *   String databaseId = "databaseId1688905718";
+   *   Database response =
+   *       firestoreAdminClient.createDatabaseAsync(parent, database, databaseId).get();
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form `projects/{project_id}` + * @param database Required. The Database to create. + * @param databaseId Required. The ID to use for the database, which will become the final + * component of the database's resource name. + *

This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ with first + * character a letter and the last a letter or a number. Must not be UUID-like + * /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + *

"(default)" database ID is also valid if the database is Standard edition. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture createDatabaseAsync( + String parent, Database database, String databaseId) { + CreateDatabaseRequest request = + CreateDatabaseRequest.newBuilder() + .setParent(parent) + .setDatabase(database) + .setDatabaseId(databaseId) + .build(); + return createDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateDatabaseRequest request =
+   *       CreateDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .build();
+   *   Database response = firestoreAdminClient.createDatabaseAsync(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 createDatabaseAsync( + CreateDatabaseRequest request) { + return createDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateDatabaseRequest request =
+   *       CreateDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.createDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + createDatabaseOperationCallable() { + return stub.createDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateDatabaseRequest request =
+   *       CreateDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.createDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createDatabaseCallable() { + return stub.createDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   Database response = firestoreAdminClient.getDatabase(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Database getDatabase(DatabaseName name) { + GetDatabaseRequest request = + GetDatabaseRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getDatabase(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   Database response = firestoreAdminClient.getDatabase(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Database getDatabase(String name) { + GetDatabaseRequest request = GetDatabaseRequest.newBuilder().setName(name).build(); + return getDatabase(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetDatabaseRequest request =
+   *       GetDatabaseRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   Database response = firestoreAdminClient.getDatabase(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 Database getDatabase(GetDatabaseRequest request) { + return getDatabaseCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetDatabaseRequest request =
+   *       GetDatabaseRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getDatabaseCallable() { + return stub.getDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all the databases in the project. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ProjectName parent = ProjectName.of("[PROJECT]");
+   *   ListDatabasesResponse response = firestoreAdminClient.listDatabases(parent);
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form `projects/{project_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDatabasesResponse listDatabases(ProjectName parent) { + ListDatabasesRequest request = + ListDatabasesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listDatabases(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all the databases in the project. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = ProjectName.of("[PROJECT]").toString();
+   *   ListDatabasesResponse response = firestoreAdminClient.listDatabases(parent);
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form `projects/{project_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDatabasesResponse listDatabases(String parent) { + ListDatabasesRequest request = ListDatabasesRequest.newBuilder().setParent(parent).build(); + return listDatabases(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all the databases in the project. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListDatabasesRequest request =
+   *       ListDatabasesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setShowDeleted(true)
+   *           .build();
+   *   ListDatabasesResponse response = firestoreAdminClient.listDatabases(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 ListDatabasesResponse listDatabases(ListDatabasesRequest request) { + return listDatabasesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all the databases in the project. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListDatabasesRequest request =
+   *       ListDatabasesRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setShowDeleted(true)
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listDatabasesCallable().futureCall(request);
+   *   // Do something.
+   *   ListDatabasesResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable listDatabasesCallable() { + return stub.listDatabasesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   Database database = Database.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   Database response = firestoreAdminClient.updateDatabaseAsync(database, updateMask).get();
+   * }
+   * }
+ * + * @param database Required. The database to update. + * @param updateMask The list of fields to be updated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture updateDatabaseAsync( + Database database, FieldMask updateMask) { + UpdateDatabaseRequest request = + UpdateDatabaseRequest.newBuilder().setDatabase(database).setUpdateMask(updateMask).build(); + return updateDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateDatabaseRequest request =
+   *       UpdateDatabaseRequest.newBuilder()
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   Database response = firestoreAdminClient.updateDatabaseAsync(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 updateDatabaseAsync( + UpdateDatabaseRequest request) { + return updateDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateDatabaseRequest request =
+   *       UpdateDatabaseRequest.newBuilder()
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.updateDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + updateDatabaseOperationCallable() { + return stub.updateDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateDatabaseRequest request =
+   *       UpdateDatabaseRequest.newBuilder()
+   *           .setDatabase(Database.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.updateDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updateDatabaseCallable() { + return stub.updateDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   Database response = firestoreAdminClient.deleteDatabaseAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. A name of the form `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deleteDatabaseAsync( + DatabaseName name) { + DeleteDatabaseRequest request = + DeleteDatabaseRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return deleteDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   Database response = firestoreAdminClient.deleteDatabaseAsync(name).get();
+   * }
+   * }
+ * + * @param name Required. A name of the form `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture deleteDatabaseAsync(String name) { + DeleteDatabaseRequest request = DeleteDatabaseRequest.newBuilder().setName(name).build(); + return deleteDatabaseAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteDatabaseRequest request =
+   *       DeleteDatabaseRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setEtag("etag3123477")
+   *           .build();
+   *   Database response = firestoreAdminClient.deleteDatabaseAsync(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 deleteDatabaseAsync( + DeleteDatabaseRequest request) { + return deleteDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteDatabaseRequest request =
+   *       DeleteDatabaseRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setEtag("etag3123477")
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.deleteDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + deleteDatabaseOperationCallable() { + return stub.deleteDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteDatabaseRequest request =
+   *       DeleteDatabaseRequest.newBuilder()
+   *           .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setEtag("etag3123477")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.deleteDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteDatabaseCallable() { + return stub.deleteDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   UserCreds userCreds = UserCreds.newBuilder().build();
+   *   String userCredsId = "userCredsId726775445";
+   *   UserCreds response = firestoreAdminClient.createUserCreds(parent, userCreds, userCredsId);
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}` + * @param userCreds Required. The user creds to create. + * @param userCredsId Required. The ID to use for the user creds, which will become the final + * component of the user creds's resource name. + *

This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ with first + * character a letter and the last a letter or a number. Must not be UUID-like + * /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds createUserCreds( + DatabaseName parent, UserCreds userCreds, String userCredsId) { + CreateUserCredsRequest request = + CreateUserCredsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setUserCreds(userCreds) + .setUserCredsId(userCredsId) + .build(); + return createUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   UserCreds userCreds = UserCreds.newBuilder().build();
+   *   String userCredsId = "userCredsId726775445";
+   *   UserCreds response = firestoreAdminClient.createUserCreds(parent, userCreds, userCredsId);
+   * }
+   * }
+ * + * @param parent Required. A parent name of the form + * `projects/{project_id}/databases/{database_id}` + * @param userCreds Required. The user creds to create. + * @param userCredsId Required. The ID to use for the user creds, which will become the final + * component of the user creds's resource name. + *

This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ with first + * character a letter and the last a letter or a number. Must not be UUID-like + * /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds createUserCreds(String parent, UserCreds userCreds, String userCredsId) { + CreateUserCredsRequest request = + CreateUserCredsRequest.newBuilder() + .setParent(parent) + .setUserCreds(userCreds) + .setUserCredsId(userCredsId) + .build(); + return createUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateUserCredsRequest request =
+   *       CreateUserCredsRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setUserCreds(UserCreds.newBuilder().build())
+   *           .setUserCredsId("userCredsId726775445")
+   *           .build();
+   *   UserCreds response = firestoreAdminClient.createUserCreds(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 UserCreds createUserCreds(CreateUserCredsRequest request) { + return createUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Create a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateUserCredsRequest request =
+   *       CreateUserCredsRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setUserCreds(UserCreds.newBuilder().build())
+   *           .setUserCredsId("userCredsId726775445")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.createUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   UserCreds response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createUserCredsCallable() { + return stub.createUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a user creds resource. Note that the returned resource does not contain the secret value + * itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]");
+   *   UserCreds response = firestoreAdminClient.getUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds getUserCreds(UserCredsName name) { + GetUserCredsRequest request = + GetUserCredsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a user creds resource. Note that the returned resource does not contain the secret value + * itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString();
+   *   UserCreds response = firestoreAdminClient.getUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds getUserCreds(String name) { + GetUserCredsRequest request = GetUserCredsRequest.newBuilder().setName(name).build(); + return getUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a user creds resource. Note that the returned resource does not contain the secret value + * itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetUserCredsRequest request =
+   *       GetUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   UserCreds response = firestoreAdminClient.getUserCreds(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 UserCreds getUserCreds(GetUserCredsRequest request) { + return getUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a user creds resource. Note that the returned resource does not contain the secret value + * itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetUserCredsRequest request =
+   *       GetUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   UserCreds response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getUserCredsCallable() { + return stub.getUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all user creds in the database. Note that the returned resource does not contain the + * secret value itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   ListUserCredsResponse response = firestoreAdminClient.listUserCreds(parent);
+   * }
+   * }
+ * + * @param parent Required. A parent database name of the form + * `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListUserCredsResponse listUserCreds(DatabaseName parent) { + ListUserCredsRequest request = + ListUserCredsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all user creds in the database. Note that the returned resource does not contain the + * secret value itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   ListUserCredsResponse response = firestoreAdminClient.listUserCreds(parent);
+   * }
+   * }
+ * + * @param parent Required. A parent database name of the form + * `projects/{project_id}/databases/{database_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListUserCredsResponse listUserCreds(String parent) { + ListUserCredsRequest request = ListUserCredsRequest.newBuilder().setParent(parent).build(); + return listUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all user creds in the database. Note that the returned resource does not contain the + * secret value itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListUserCredsRequest request =
+   *       ListUserCredsRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ListUserCredsResponse response = firestoreAdminClient.listUserCreds(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 ListUserCredsResponse listUserCreds(ListUserCredsRequest request) { + return listUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List all user creds in the database. Note that the returned resource does not contain the + * secret value itself. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListUserCredsRequest request =
+   *       ListUserCredsRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   ListUserCredsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable listUserCredsCallable() { + return stub.listUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Enables a user creds. No-op if the user creds are already enabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]");
+   *   UserCreds response = firestoreAdminClient.enableUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds enableUserCreds(UserCredsName name) { + EnableUserCredsRequest request = + EnableUserCredsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return enableUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Enables a user creds. No-op if the user creds are already enabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString();
+   *   UserCreds response = firestoreAdminClient.enableUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds enableUserCreds(String name) { + EnableUserCredsRequest request = EnableUserCredsRequest.newBuilder().setName(name).build(); + return enableUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Enables a user creds. No-op if the user creds are already enabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   EnableUserCredsRequest request =
+   *       EnableUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   UserCreds response = firestoreAdminClient.enableUserCreds(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 UserCreds enableUserCreds(EnableUserCredsRequest request) { + return enableUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Enables a user creds. No-op if the user creds are already enabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   EnableUserCredsRequest request =
+   *       EnableUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.enableUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   UserCreds response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable enableUserCredsCallable() { + return stub.enableUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Disables a user creds. No-op if the user creds are already disabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]");
+   *   UserCreds response = firestoreAdminClient.disableUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds disableUserCreds(UserCredsName name) { + DisableUserCredsRequest request = + DisableUserCredsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return disableUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Disables a user creds. No-op if the user creds are already disabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString();
+   *   UserCreds response = firestoreAdminClient.disableUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds disableUserCreds(String name) { + DisableUserCredsRequest request = DisableUserCredsRequest.newBuilder().setName(name).build(); + return disableUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Disables a user creds. No-op if the user creds are already disabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DisableUserCredsRequest request =
+   *       DisableUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   UserCreds response = firestoreAdminClient.disableUserCreds(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 UserCreds disableUserCreds(DisableUserCredsRequest request) { + return disableUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Disables a user creds. No-op if the user creds are already disabled. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DisableUserCredsRequest request =
+   *       DisableUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.disableUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   UserCreds response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable disableUserCredsCallable() { + return stub.disableUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Resets the password of a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]");
+   *   UserCreds response = firestoreAdminClient.resetUserPassword(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds resetUserPassword(UserCredsName name) { + ResetUserPasswordRequest request = + ResetUserPasswordRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return resetUserPassword(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Resets the password of a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString();
+   *   UserCreds response = firestoreAdminClient.resetUserPassword(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final UserCreds resetUserPassword(String name) { + ResetUserPasswordRequest request = ResetUserPasswordRequest.newBuilder().setName(name).build(); + return resetUserPassword(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Resets the password of a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ResetUserPasswordRequest request =
+   *       ResetUserPasswordRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   UserCreds response = firestoreAdminClient.resetUserPassword(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 UserCreds resetUserPassword(ResetUserPasswordRequest request) { + return resetUserPasswordCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Resets the password of a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ResetUserPasswordRequest request =
+   *       ResetUserPasswordRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.resetUserPasswordCallable().futureCall(request);
+   *   // Do something.
+   *   UserCreds response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable resetUserPasswordCallable() { + return stub.resetUserPasswordCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]");
+   *   firestoreAdminClient.deleteUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteUserCreds(UserCredsName name) { + DeleteUserCredsRequest request = + DeleteUserCredsRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString();
+   *   firestoreAdminClient.deleteUserCreds(name);
+   * }
+   * }
+ * + * @param name Required. A name of the form + * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteUserCreds(String name) { + DeleteUserCredsRequest request = DeleteUserCredsRequest.newBuilder().setName(name).build(); + deleteUserCreds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteUserCredsRequest request =
+   *       DeleteUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteUserCreds(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 deleteUserCreds(DeleteUserCredsRequest request) { + deleteUserCredsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a user creds. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteUserCredsRequest request =
+   *       DeleteUserCredsRequest.newBuilder()
+   *           .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.deleteUserCredsCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteUserCredsCallable() { + return stub.deleteUserCredsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]");
+   *   Backup response = firestoreAdminClient.getBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to fetch. + *

Format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Backup getBackup(BackupName name) { + GetBackupRequest request = + GetBackupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + return getBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString();
+   *   Backup response = firestoreAdminClient.getBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to fetch. + *

Format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Backup getBackup(String name) { + GetBackupRequest request = GetBackupRequest.newBuilder().setName(name).build(); + return getBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupRequest request =
+   *       GetBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   Backup response = firestoreAdminClient.getBackup(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 Backup getBackup(GetBackupRequest request) { + return getBackupCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupRequest request =
+   *       GetBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.getBackupCallable().futureCall(request);
+   *   // Do something.
+   *   Backup response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getBackupCallable() { + return stub.getBackupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(parent);
+   * }
+   * }
+ * + * @param parent Required. The location to list backups from. + *

Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list + * backups from all locations for the given project. This allows listing backups from a single + * location or from all locations. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupsResponse listBackups(LocationName parent) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listBackups(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString();
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(parent);
+   * }
+   * }
+ * + * @param parent Required. The location to list backups from. + *

Format is `projects/{project}/locations/{location}`. Use `{location} = '-'` to list + * backups from all locations for the given project. This allows listing backups from a single + * location or from all locations. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupsResponse listBackups(String parent) { + ListBackupsRequest request = ListBackupsRequest.newBuilder().setParent(parent).build(); + return listBackups(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupsRequest request =
+   *       ListBackupsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ListBackupsResponse response = firestoreAdminClient.listBackups(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 ListBackupsResponse listBackups(ListBackupsRequest request) { + return listBackupsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backups. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupsRequest request =
+   *       ListBackupsRequest.newBuilder()
+   *           .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString())
+   *           .setFilter("filter-1274492040")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listBackupsCallable().futureCall(request);
+   *   // Do something.
+   *   ListBackupsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable listBackupsCallable() { + return stub.listBackupsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]");
+   *   firestoreAdminClient.deleteBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to delete. + *

format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackup(BackupName name) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder().setName(name == null ? null : name.toString()).build(); + deleteBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString();
+   *   firestoreAdminClient.deleteBackup(name);
+   * }
+   * }
+ * + * @param name Required. Name of the backup to delete. + *

format is `projects/{project}/locations/{location}/backups/{backup}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackup(String name) { + DeleteBackupRequest request = DeleteBackupRequest.newBuilder().setName(name).build(); + deleteBackup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupRequest request =
+   *       DeleteBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteBackup(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 deleteBackup(DeleteBackupRequest request) { + deleteBackupCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupRequest request =
+   *       DeleteBackupRequest.newBuilder()
+   *           .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .build();
+   *   ApiFuture future = firestoreAdminClient.deleteBackupCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteBackupCallable() { + return stub.deleteBackupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   Database response = firestoreAdminClient.restoreDatabaseAsync(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 restoreDatabaseAsync( + RestoreDatabaseRequest request) { + return restoreDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.restoreDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + restoreDatabaseOperationCallable() { + return stub.restoreDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by restoring from an existing backup. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * backup. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing backup. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the restore, with the Operation's [metadata][google.longrunning.Operation.metadata] field + * type being the [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + * The [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the restore was successful. The new database + * is not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   RestoreDatabaseRequest request =
+   *       RestoreDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.restoreDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable restoreDatabaseCallable() { + return stub.restoreDatabaseCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(parent, backupSchedule);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format `projects/{project}/databases/{database}` + * @param backupSchedule Required. The backup schedule to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule( + DatabaseName parent, BackupSchedule backupSchedule) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackupSchedule(backupSchedule) + .build(); + return createBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(parent, backupSchedule);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format `projects/{project}/databases/{database}` + * @param backupSchedule Required. The backup schedule to create. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule(String parent, BackupSchedule backupSchedule) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent) + .setBackupSchedule(backupSchedule) + .build(); + return createBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateBackupScheduleRequest request =
+   *       CreateBackupScheduleRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.createBackupSchedule(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 BackupSchedule createBackupSchedule(CreateBackupScheduleRequest request) { + return createBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a backup schedule on a database. At most two backup schedules can be configured on a + * database, one daily backup schedule and one weekly backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CreateBackupScheduleRequest request =
+   *       CreateBackupScheduleRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.createBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + createBackupScheduleCallable() { + return stub.createBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]");
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(BackupScheduleName name) { + GetBackupScheduleRequest request = + GetBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString();
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(String name) { + GetBackupScheduleRequest request = GetBackupScheduleRequest.newBuilder().setName(name).build(); + return getBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.getBackupSchedule(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 BackupSchedule getBackupSchedule(GetBackupScheduleRequest request) { + return getBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets information about a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.getBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getBackupScheduleCallable() { + return stub.getBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]");
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(parent);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format is `projects/{project}/databases/{database}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesResponse listBackupSchedules(DatabaseName parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[DATABASE]").toString();
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(parent);
+   * }
+   * }
+ * + * @param parent Required. The parent database. + *

Format is `projects/{project}/databases/{database}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesResponse listBackupSchedules(String parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder().setParent(parent).build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupSchedulesRequest request =
+   *       ListBackupSchedulesRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ListBackupSchedulesResponse response = firestoreAdminClient.listBackupSchedules(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 ListBackupSchedulesResponse listBackupSchedules(ListBackupSchedulesRequest request) { + return listBackupSchedulesCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * List backup schedules. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   ListBackupSchedulesRequest request =
+   *       ListBackupSchedulesRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[DATABASE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.listBackupSchedulesCallable().futureCall(request);
+   *   // Do something.
+   *   ListBackupSchedulesResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + listBackupSchedulesCallable() { + return stub.listBackupSchedulesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   BackupSchedule response =
+   *       firestoreAdminClient.updateBackupSchedule(backupSchedule, updateMask);
+   * }
+   * }
+ * + * @param backupSchedule Required. The backup schedule to update. + * @param updateMask The list of fields to be updated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule updateBackupSchedule( + BackupSchedule backupSchedule, FieldMask updateMask) { + UpdateBackupScheduleRequest request = + UpdateBackupScheduleRequest.newBuilder() + .setBackupSchedule(backupSchedule) + .setUpdateMask(updateMask) + .build(); + return updateBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateBackupScheduleRequest request =
+   *       UpdateBackupScheduleRequest.newBuilder()
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   BackupSchedule response = firestoreAdminClient.updateBackupSchedule(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 BackupSchedule updateBackupSchedule(UpdateBackupScheduleRequest request) { + return updateBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   UpdateBackupScheduleRequest request =
+   *       UpdateBackupScheduleRequest.newBuilder()
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .setUpdateMask(FieldMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.updateBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + updateBackupScheduleCallable() { + return stub.updateBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]");
+   *   firestoreAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(BackupScheduleName name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString();
+   *   firestoreAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the backup schedule. + *

Format `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(String name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder().setName(name).build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupScheduleRequest request =
+   *       DeleteBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   firestoreAdminClient.deleteBackupSchedule(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 deleteBackupSchedule(DeleteBackupScheduleRequest request) { + deleteBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   DeleteBackupScheduleRequest request =
+   *       DeleteBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.deleteBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteBackupScheduleCallable() { + return stub.deleteBackupScheduleCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by cloning an existing one. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * database. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing database. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the clone, with the Operation's [metadata][google.longrunning.Operation.metadata] field type + * being the [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the clone was successful. The new database is + * not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CloneDatabaseRequest request =
+   *       CloneDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPitrSnapshot(PitrSnapshot.newBuilder().build())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   Database response = firestoreAdminClient.cloneDatabaseAsync(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 cloneDatabaseAsync( + CloneDatabaseRequest request) { + return cloneDatabaseOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by cloning an existing one. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * database. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing database. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the clone, with the Operation's [metadata][google.longrunning.Operation.metadata] field type + * being the [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the clone was successful. The new database is + * not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CloneDatabaseRequest request =
+   *       CloneDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPitrSnapshot(PitrSnapshot.newBuilder().build())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   OperationFuture future =
+   *       firestoreAdminClient.cloneDatabaseOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Database response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + cloneDatabaseOperationCallable() { + return stub.cloneDatabaseOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new database by cloning an existing one. + * + *

The new database must be in the same cloud region or multi-region location as the existing + * database. This behaves similar to + * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] except + * instead of creating a new empty database, a new database is created with the database type, + * index configuration, and documents from an existing database. + * + *

The [long-running operation][google.longrunning.Operation] can be used to track the progress + * of the clone, with the Operation's [metadata][google.longrunning.Operation.metadata] field type + * being the [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata]. The + * [response][google.longrunning.Operation.response] type is the + * [Database][google.firestore.admin.v1.Database] if the clone was successful. The new database is + * not readable or writeable until the LRO has completed. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+   *   CloneDatabaseRequest request =
+   *       CloneDatabaseRequest.newBuilder()
+   *           .setParent(ProjectName.of("[PROJECT]").toString())
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPitrSnapshot(PitrSnapshot.newBuilder().build())
+   *           .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build())
+   *           .putAllTags(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreAdminClient.cloneDatabaseCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable cloneDatabaseCallable() { + return stub.cloneDatabaseCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListIndexesPagedResponse + extends AbstractPagedListResponse< + ListIndexesRequest, + ListIndexesResponse, + Index, + ListIndexesPage, + ListIndexesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListIndexesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, input -> new ListIndexesPagedResponse(input), MoreExecutors.directExecutor()); + } + + private ListIndexesPagedResponse(ListIndexesPage page) { + super(page, ListIndexesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListIndexesPage + extends AbstractPage { + + private ListIndexesPage( + PageContext context, + ListIndexesResponse response) { + super(context, response); + } + + private static ListIndexesPage createEmptyPage() { + return new ListIndexesPage(null, null); + } + + @Override + protected ListIndexesPage createPage( + PageContext context, + ListIndexesResponse response) { + return new ListIndexesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListIndexesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListIndexesRequest, + ListIndexesResponse, + Index, + ListIndexesPage, + ListIndexesFixedSizeCollection> { + + private ListIndexesFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListIndexesFixedSizeCollection createEmptyCollection() { + return new ListIndexesFixedSizeCollection(null, 0); + } + + @Override + protected ListIndexesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListIndexesFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListFieldsPagedResponse + extends AbstractPagedListResponse< + ListFieldsRequest, + ListFieldsResponse, + Field, + ListFieldsPage, + ListFieldsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListFieldsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, input -> new ListFieldsPagedResponse(input), MoreExecutors.directExecutor()); + } + + private ListFieldsPagedResponse(ListFieldsPage page) { + super(page, ListFieldsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListFieldsPage + extends AbstractPage { + + private ListFieldsPage( + PageContext context, + ListFieldsResponse response) { + super(context, response); + } + + private static ListFieldsPage createEmptyPage() { + return new ListFieldsPage(null, null); + } + + @Override + protected ListFieldsPage createPage( + PageContext context, + ListFieldsResponse response) { + return new ListFieldsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListFieldsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListFieldsRequest, + ListFieldsResponse, + Field, + ListFieldsPage, + ListFieldsFixedSizeCollection> { + + private ListFieldsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListFieldsFixedSizeCollection createEmptyCollection() { + return new ListFieldsFixedSizeCollection(null, 0); + } + + @Override + protected ListFieldsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListFieldsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java new file mode 100644 index 000000000000..37c6bca6cb83 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/FirestoreAdminSettings.java @@ -0,0 +1,757 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.firestore.v1.stub.FirestoreAdminStubSettings; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link FirestoreAdminClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (firestore.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

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 + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getIndex: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminSettings.Builder firestoreAdminSettingsBuilder =
+ *     FirestoreAdminSettings.newBuilder();
+ * firestoreAdminSettingsBuilder
+ *     .getIndexSettings()
+ *     .setRetrySettings(
+ *         firestoreAdminSettingsBuilder
+ *             .getIndexSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
+ *             .build());
+ * FirestoreAdminSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
+ * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting + * retries. + * + *

To configure the RetrySettings of a Long Running Operation method, create an + * OperationTimedPollAlgorithm object and update the RPC's polling algorithm. For example, to + * configure the RetrySettings for createIndex: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminSettings.Builder firestoreAdminSettingsBuilder =
+ *     FirestoreAdminSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * firestoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class FirestoreAdminSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to createIndex. */ + public UnaryCallSettings createIndexSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createIndexSettings(); + } + + /** Returns the object with the settings used for calls to createIndex. */ + public OperationCallSettings + createIndexOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createIndexOperationSettings(); + } + + /** Returns the object with the settings used for calls to listIndexes. */ + public PagedCallSettings + listIndexesSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listIndexesSettings(); + } + + /** Returns the object with the settings used for calls to getIndex. */ + 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() { + return ((FirestoreAdminStubSettings) getStubSettings()).listFieldsSettings(); + } + + /** Returns the object with the settings used for calls to exportDocuments. */ + public UnaryCallSettings exportDocumentsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).exportDocumentsSettings(); + } + + /** Returns the object with the settings used for calls to exportDocuments. */ + public OperationCallSettings< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).exportDocumentsOperationSettings(); + } + + /** Returns the object with the settings used for calls to importDocuments. */ + public UnaryCallSettings importDocumentsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).importDocumentsSettings(); + } + + /** Returns the object with the settings used for calls to importDocuments. */ + public OperationCallSettings + importDocumentsOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).importDocumentsOperationSettings(); + } + + /** Returns the object with the settings used for calls to bulkDeleteDocuments. */ + public UnaryCallSettings bulkDeleteDocumentsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).bulkDeleteDocumentsSettings(); + } + + /** Returns the object with the settings used for calls to bulkDeleteDocuments. */ + public OperationCallSettings< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).bulkDeleteDocumentsOperationSettings(); + } + + /** Returns the object with the settings used for calls to createDatabase. */ + public UnaryCallSettings createDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to createDatabase. */ + public OperationCallSettings + createDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to getDatabase. */ + public UnaryCallSettings getDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to listDatabases. */ + public UnaryCallSettings listDatabasesSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listDatabasesSettings(); + } + + /** Returns the object with the settings used for calls to updateDatabase. */ + public UnaryCallSettings updateDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to updateDatabase. */ + public OperationCallSettings + updateDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to deleteDatabase. */ + public UnaryCallSettings deleteDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to deleteDatabase. */ + public OperationCallSettings + deleteDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to createUserCreds. */ + public UnaryCallSettings createUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to getUserCreds. */ + public UnaryCallSettings getUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to listUserCreds. */ + public UnaryCallSettings listUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to enableUserCreds. */ + public UnaryCallSettings enableUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).enableUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to disableUserCreds. */ + public UnaryCallSettings disableUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).disableUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to resetUserPassword. */ + public UnaryCallSettings resetUserPasswordSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).resetUserPasswordSettings(); + } + + /** Returns the object with the settings used for calls to deleteUserCreds. */ + public UnaryCallSettings deleteUserCredsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteUserCredsSettings(); + } + + /** Returns the object with the settings used for calls to getBackup. */ + public UnaryCallSettings getBackupSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getBackupSettings(); + } + + /** Returns the object with the settings used for calls to listBackups. */ + public UnaryCallSettings listBackupsSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listBackupsSettings(); + } + + /** Returns the object with the settings used for calls to deleteBackup. */ + public UnaryCallSettings deleteBackupSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteBackupSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).restoreDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public OperationCallSettings + restoreDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).restoreDatabaseOperationSettings(); + } + + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).createBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).getBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings + listBackupSchedulesSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).listBackupSchedulesSettings(); + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).updateBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).deleteBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to cloneDatabase. */ + public UnaryCallSettings cloneDatabaseSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).cloneDatabaseSettings(); + } + + /** Returns the object with the settings used for calls to cloneDatabase. */ + public OperationCallSettings + cloneDatabaseOperationSettings() { + return ((FirestoreAdminStubSettings) getStubSettings()).cloneDatabaseOperationSettings(); + } + + public static final FirestoreAdminSettings create(FirestoreAdminStubSettings stub) + throws IOException { + return new FirestoreAdminSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return FirestoreAdminStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return FirestoreAdminStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return FirestoreAdminStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return FirestoreAdminStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return FirestoreAdminStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FirestoreAdminStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return FirestoreAdminStubSettings.defaultTransportChannelProvider(); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirestoreAdminStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected FirestoreAdminSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for FirestoreAdminSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(FirestoreAdminStubSettings.newBuilder(clientContext)); + } + + protected Builder(FirestoreAdminSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(FirestoreAdminStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(FirestoreAdminStubSettings.newBuilder()); + } + + private static Builder createHttpJsonDefault() { + return new Builder(FirestoreAdminStubSettings.newHttpJsonBuilder()); + } + + public FirestoreAdminStubSettings.Builder getStubSettingsBuilder() { + return ((FirestoreAdminStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** 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. */ + public OperationCallSettings.Builder + createIndexOperationSettings() { + return getStubSettingsBuilder().createIndexOperationSettings(); + } + + /** Returns the builder for the settings used for calls to listIndexes. */ + public PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + listIndexesSettings() { + return getStubSettingsBuilder().listIndexesSettings(); + } + + /** Returns the builder for the settings used for calls to getIndex. */ + 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() { + return getStubSettingsBuilder().listFieldsSettings(); + } + + /** Returns the builder for the settings used for calls to exportDocuments. */ + public UnaryCallSettings.Builder exportDocumentsSettings() { + return getStubSettingsBuilder().exportDocumentsSettings(); + } + + /** Returns the builder for the settings used for calls to exportDocuments. */ + public OperationCallSettings.Builder< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings() { + return getStubSettingsBuilder().exportDocumentsOperationSettings(); + } + + /** Returns the builder for the settings used for calls to importDocuments. */ + public UnaryCallSettings.Builder importDocumentsSettings() { + return getStubSettingsBuilder().importDocumentsSettings(); + } + + /** Returns the builder for the settings used for calls to importDocuments. */ + public OperationCallSettings.Builder + importDocumentsOperationSettings() { + return getStubSettingsBuilder().importDocumentsOperationSettings(); + } + + /** Returns the builder for the settings used for calls to bulkDeleteDocuments. */ + public UnaryCallSettings.Builder + bulkDeleteDocumentsSettings() { + return getStubSettingsBuilder().bulkDeleteDocumentsSettings(); + } + + /** Returns the builder for the settings used for calls to bulkDeleteDocuments. */ + public OperationCallSettings.Builder< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings() { + return getStubSettingsBuilder().bulkDeleteDocumentsOperationSettings(); + } + + /** Returns the builder for the settings used for calls to createDatabase. */ + public UnaryCallSettings.Builder createDatabaseSettings() { + return getStubSettingsBuilder().createDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to createDatabase. */ + public OperationCallSettings.Builder + createDatabaseOperationSettings() { + return getStubSettingsBuilder().createDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to getDatabase. */ + public UnaryCallSettings.Builder getDatabaseSettings() { + return getStubSettingsBuilder().getDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to listDatabases. */ + public UnaryCallSettings.Builder + listDatabasesSettings() { + return getStubSettingsBuilder().listDatabasesSettings(); + } + + /** Returns the builder for the settings used for calls to updateDatabase. */ + public UnaryCallSettings.Builder updateDatabaseSettings() { + return getStubSettingsBuilder().updateDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to updateDatabase. */ + public OperationCallSettings.Builder + updateDatabaseOperationSettings() { + return getStubSettingsBuilder().updateDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to deleteDatabase. */ + public UnaryCallSettings.Builder deleteDatabaseSettings() { + return getStubSettingsBuilder().deleteDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to deleteDatabase. */ + public OperationCallSettings.Builder + deleteDatabaseOperationSettings() { + return getStubSettingsBuilder().deleteDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to createUserCreds. */ + public UnaryCallSettings.Builder createUserCredsSettings() { + return getStubSettingsBuilder().createUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to getUserCreds. */ + public UnaryCallSettings.Builder getUserCredsSettings() { + return getStubSettingsBuilder().getUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to listUserCreds. */ + public UnaryCallSettings.Builder + listUserCredsSettings() { + return getStubSettingsBuilder().listUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to enableUserCreds. */ + public UnaryCallSettings.Builder enableUserCredsSettings() { + return getStubSettingsBuilder().enableUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to disableUserCreds. */ + public UnaryCallSettings.Builder + disableUserCredsSettings() { + return getStubSettingsBuilder().disableUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to resetUserPassword. */ + public UnaryCallSettings.Builder + resetUserPasswordSettings() { + return getStubSettingsBuilder().resetUserPasswordSettings(); + } + + /** Returns the builder for the settings used for calls to deleteUserCreds. */ + public UnaryCallSettings.Builder deleteUserCredsSettings() { + return getStubSettingsBuilder().deleteUserCredsSettings(); + } + + /** Returns the builder for the settings used for calls to getBackup. */ + public UnaryCallSettings.Builder getBackupSettings() { + return getStubSettingsBuilder().getBackupSettings(); + } + + /** Returns the builder for the settings used for calls to listBackups. */ + public UnaryCallSettings.Builder + listBackupsSettings() { + return getStubSettingsBuilder().listBackupsSettings(); + } + + /** Returns the builder for the settings used for calls to deleteBackup. */ + public UnaryCallSettings.Builder deleteBackupSettings() { + return getStubSettingsBuilder().deleteBackupSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return getStubSettingsBuilder().restoreDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return getStubSettingsBuilder().restoreDatabaseOperationSettings(); + } + + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return getStubSettingsBuilder().createBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getStubSettingsBuilder().getBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings.Builder + listBackupSchedulesSettings() { + return getStubSettingsBuilder().listBackupSchedulesSettings(); + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return getStubSettingsBuilder().updateBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return getStubSettingsBuilder().deleteBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to cloneDatabase. */ + public UnaryCallSettings.Builder cloneDatabaseSettings() { + return getStubSettingsBuilder().cloneDatabaseSettings(); + } + + /** Returns the builder for the settings used for calls to cloneDatabase. */ + public OperationCallSettings.Builder + cloneDatabaseOperationSettings() { + return getStubSettingsBuilder().cloneDatabaseOperationSettings(); + } + + @Override + public FirestoreAdminSettings build() throws IOException { + return new FirestoreAdminSettings(this); + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json new file mode 100644 index 000000000000..da56c4232be8 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -0,0 +1,114 @@ +{ + "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": { + "BulkDeleteDocuments": { + "methods": ["bulkDeleteDocumentsAsync", "bulkDeleteDocumentsAsync", "bulkDeleteDocumentsAsync", "bulkDeleteDocumentsOperationCallable", "bulkDeleteDocumentsCallable"] + }, + "CloneDatabase": { + "methods": ["cloneDatabaseAsync", "cloneDatabaseOperationCallable", "cloneDatabaseCallable"] + }, + "CreateBackupSchedule": { + "methods": ["createBackupSchedule", "createBackupSchedule", "createBackupSchedule", "createBackupScheduleCallable"] + }, + "CreateDatabase": { + "methods": ["createDatabaseAsync", "createDatabaseAsync", "createDatabaseAsync", "createDatabaseOperationCallable", "createDatabaseCallable"] + }, + "CreateIndex": { + "methods": ["createIndexAsync", "createIndexAsync", "createIndexAsync", "createIndexOperationCallable", "createIndexCallable"] + }, + "CreateUserCreds": { + "methods": ["createUserCreds", "createUserCreds", "createUserCreds", "createUserCredsCallable"] + }, + "DeleteBackup": { + "methods": ["deleteBackup", "deleteBackup", "deleteBackup", "deleteBackupCallable"] + }, + "DeleteBackupSchedule": { + "methods": ["deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupScheduleCallable"] + }, + "DeleteDatabase": { + "methods": ["deleteDatabaseAsync", "deleteDatabaseAsync", "deleteDatabaseAsync", "deleteDatabaseOperationCallable", "deleteDatabaseCallable"] + }, + "DeleteIndex": { + "methods": ["deleteIndex", "deleteIndex", "deleteIndex", "deleteIndexCallable"] + }, + "DeleteUserCreds": { + "methods": ["deleteUserCreds", "deleteUserCreds", "deleteUserCreds", "deleteUserCredsCallable"] + }, + "DisableUserCreds": { + "methods": ["disableUserCreds", "disableUserCreds", "disableUserCreds", "disableUserCredsCallable"] + }, + "EnableUserCreds": { + "methods": ["enableUserCreds", "enableUserCreds", "enableUserCreds", "enableUserCredsCallable"] + }, + "ExportDocuments": { + "methods": ["exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsAsync", "exportDocumentsOperationCallable", "exportDocumentsCallable"] + }, + "GetBackup": { + "methods": ["getBackup", "getBackup", "getBackup", "getBackupCallable"] + }, + "GetBackupSchedule": { + "methods": ["getBackupSchedule", "getBackupSchedule", "getBackupSchedule", "getBackupScheduleCallable"] + }, + "GetDatabase": { + "methods": ["getDatabase", "getDatabase", "getDatabase", "getDatabaseCallable"] + }, + "GetField": { + "methods": ["getField", "getField", "getField", "getFieldCallable"] + }, + "GetIndex": { + "methods": ["getIndex", "getIndex", "getIndex", "getIndexCallable"] + }, + "GetUserCreds": { + "methods": ["getUserCreds", "getUserCreds", "getUserCreds", "getUserCredsCallable"] + }, + "ImportDocuments": { + "methods": ["importDocumentsAsync", "importDocumentsAsync", "importDocumentsAsync", "importDocumentsOperationCallable", "importDocumentsCallable"] + }, + "ListBackupSchedules": { + "methods": ["listBackupSchedules", "listBackupSchedules", "listBackupSchedules", "listBackupSchedulesCallable"] + }, + "ListBackups": { + "methods": ["listBackups", "listBackups", "listBackups", "listBackupsCallable"] + }, + "ListDatabases": { + "methods": ["listDatabases", "listDatabases", "listDatabases", "listDatabasesCallable"] + }, + "ListFields": { + "methods": ["listFields", "listFields", "listFields", "listFieldsPagedCallable", "listFieldsCallable"] + }, + "ListIndexes": { + "methods": ["listIndexes", "listIndexes", "listIndexes", "listIndexesPagedCallable", "listIndexesCallable"] + }, + "ListUserCreds": { + "methods": ["listUserCreds", "listUserCreds", "listUserCreds", "listUserCredsCallable"] + }, + "ResetUserPassword": { + "methods": ["resetUserPassword", "resetUserPassword", "resetUserPassword", "resetUserPasswordCallable"] + }, + "RestoreDatabase": { + "methods": ["restoreDatabaseAsync", "restoreDatabaseOperationCallable", "restoreDatabaseCallable"] + }, + "UpdateBackupSchedule": { + "methods": ["updateBackupSchedule", "updateBackupSchedule", "updateBackupScheduleCallable"] + }, + "UpdateDatabase": { + "methods": ["updateDatabaseAsync", "updateDatabaseAsync", "updateDatabaseOperationCallable", "updateDatabaseCallable"] + }, + "UpdateField": { + "methods": ["updateFieldAsync", "updateFieldAsync", "updateFieldOperationCallable", "updateFieldCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java new file mode 100644 index 000000000000..ad1568fce35a --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -0,0 +1,68 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A client to Cloud Firestore API + * + *

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

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

Service Description: The Cloud Firestore Admin API. + * + *

This API provides several administrative services for Cloud Firestore. + * + *

Project, Database, Namespace, Collection, Collection Group, and Document are used as defined + * in the Google Cloud Firestore API. + * + *

Operation: An Operation represents work being performed in the background. + * + *

The index service manages Cloud Firestore indexes. + * + *

Index creation is performed asynchronously. An Operation resource is created for each such + * asynchronous operation. The state of the operation (including any errors encountered) may be + * queried via the Operation resource. + * + *

The Operations collection provides a record of actions performed for the specified Project + * (including any Operations in progress). Operations are not created directly but through calls on + * other collections or resources. + * + *

An Operation that is done may be deleted so that it is no longer listed as part of the + * Operation collection. Operations are garbage collected after 30 days. By default, ListOperations + * will only return in progress and failed operations. To list completed operation, issue a + * ListOperations request with the filter `done: true`. + * + *

Operations are created by service `FirestoreAdmin`, but are accessed via service + * `google.longrunning.Operations`. + * + *

Sample for FirestoreAdminClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.create()) {
+ *   IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
+ *   Index response = firestoreAdminClient.getIndex(name);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.firestore.v1; + +import javax.annotation.Generated; diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java new file mode 100644 index 000000000000..b332caa5251b --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStub.java @@ -0,0 +1,294 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.OperationsStub; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the FirestoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class FirestoreAdminStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; + } + + public OperationCallable + createIndexOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createIndexOperationCallable()"); + } + + public UnaryCallable createIndexCallable() { + throw new UnsupportedOperationException("Not implemented: createIndexCallable()"); + } + + public UnaryCallable listIndexesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listIndexesPagedCallable()"); + } + + public UnaryCallable listIndexesCallable() { + throw new UnsupportedOperationException("Not implemented: listIndexesCallable()"); + } + + 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()"); + } + + public UnaryCallable listFieldsCallable() { + throw new UnsupportedOperationException("Not implemented: listFieldsCallable()"); + } + + public OperationCallable + exportDocumentsOperationCallable() { + throw new UnsupportedOperationException("Not implemented: exportDocumentsOperationCallable()"); + } + + public UnaryCallable exportDocumentsCallable() { + throw new UnsupportedOperationException("Not implemented: exportDocumentsCallable()"); + } + + public OperationCallable + importDocumentsOperationCallable() { + throw new UnsupportedOperationException("Not implemented: importDocumentsOperationCallable()"); + } + + public UnaryCallable importDocumentsCallable() { + throw new UnsupportedOperationException("Not implemented: importDocumentsCallable()"); + } + + public OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable() { + throw new UnsupportedOperationException( + "Not implemented: bulkDeleteDocumentsOperationCallable()"); + } + + public UnaryCallable bulkDeleteDocumentsCallable() { + throw new UnsupportedOperationException("Not implemented: bulkDeleteDocumentsCallable()"); + } + + public OperationCallable + createDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createDatabaseOperationCallable()"); + } + + public UnaryCallable createDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: createDatabaseCallable()"); + } + + public UnaryCallable getDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: getDatabaseCallable()"); + } + + public UnaryCallable listDatabasesCallable() { + throw new UnsupportedOperationException("Not implemented: listDatabasesCallable()"); + } + + public OperationCallable + updateDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: updateDatabaseOperationCallable()"); + } + + public UnaryCallable updateDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: updateDatabaseCallable()"); + } + + public OperationCallable + deleteDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: deleteDatabaseOperationCallable()"); + } + + public UnaryCallable deleteDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: deleteDatabaseCallable()"); + } + + public UnaryCallable createUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: createUserCredsCallable()"); + } + + public UnaryCallable getUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: getUserCredsCallable()"); + } + + public UnaryCallable listUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: listUserCredsCallable()"); + } + + public UnaryCallable enableUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: enableUserCredsCallable()"); + } + + public UnaryCallable disableUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: disableUserCredsCallable()"); + } + + public UnaryCallable resetUserPasswordCallable() { + throw new UnsupportedOperationException("Not implemented: resetUserPasswordCallable()"); + } + + public UnaryCallable deleteUserCredsCallable() { + throw new UnsupportedOperationException("Not implemented: deleteUserCredsCallable()"); + } + + public UnaryCallable getBackupCallable() { + throw new UnsupportedOperationException("Not implemented: getBackupCallable()"); + } + + public UnaryCallable listBackupsCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupsCallable()"); + } + + public UnaryCallable deleteBackupCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBackupCallable()"); + } + + public OperationCallable + restoreDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseOperationCallable()"); + } + + public UnaryCallable restoreDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: restoreDatabaseCallable()"); + } + + public UnaryCallable createBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: createBackupScheduleCallable()"); + } + + public UnaryCallable getBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: getBackupScheduleCallable()"); + } + + public UnaryCallable + listBackupSchedulesCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupSchedulesCallable()"); + } + + public UnaryCallable updateBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: updateBackupScheduleCallable()"); + } + + public UnaryCallable deleteBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBackupScheduleCallable()"); + } + + public OperationCallable + cloneDatabaseOperationCallable() { + throw new UnsupportedOperationException("Not implemented: cloneDatabaseOperationCallable()"); + } + + public UnaryCallable cloneDatabaseCallable() { + throw new UnsupportedOperationException("Not implemented: cloneDatabaseCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java new file mode 100644 index 000000000000..c99edddcd1d3 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreAdminStubSettings.java @@ -0,0 +1,1751 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.longrunning.OperationSnapshot; +import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.time.Duration; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link FirestoreAdminStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (firestore.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

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 + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getIndex: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminStubSettings.Builder firestoreAdminSettingsBuilder =
+ *     FirestoreAdminStubSettings.newBuilder();
+ * firestoreAdminSettingsBuilder
+ *     .getIndexSettings()
+ *     .setRetrySettings(
+ *         firestoreAdminSettingsBuilder
+ *             .getIndexSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
+ *             .build());
+ * FirestoreAdminStubSettings firestoreAdminSettings = firestoreAdminSettingsBuilder.build();
+ * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting + * retries. + * + *

To configure the RetrySettings of a Long Running Operation method, create an + * OperationTimedPollAlgorithm object and update the RPC's polling algorithm. For example, to + * configure the RetrySettings for createIndex: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreAdminStubSettings.Builder firestoreAdminSettingsBuilder =
+ *     FirestoreAdminStubSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * firestoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class FirestoreAdminStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/datastore") + .build(); + + 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; + private final OperationCallSettings< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings; + private final UnaryCallSettings importDocumentsSettings; + private final OperationCallSettings + importDocumentsOperationSettings; + private final UnaryCallSettings + bulkDeleteDocumentsSettings; + private final OperationCallSettings< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings; + private final UnaryCallSettings createDatabaseSettings; + private final OperationCallSettings + createDatabaseOperationSettings; + private final UnaryCallSettings getDatabaseSettings; + private final UnaryCallSettings + listDatabasesSettings; + private final UnaryCallSettings updateDatabaseSettings; + private final OperationCallSettings + updateDatabaseOperationSettings; + private final UnaryCallSettings deleteDatabaseSettings; + private final OperationCallSettings + deleteDatabaseOperationSettings; + private final UnaryCallSettings createUserCredsSettings; + private final UnaryCallSettings getUserCredsSettings; + private final UnaryCallSettings + listUserCredsSettings; + private final UnaryCallSettings enableUserCredsSettings; + private final UnaryCallSettings disableUserCredsSettings; + private final UnaryCallSettings resetUserPasswordSettings; + private final UnaryCallSettings deleteUserCredsSettings; + private final UnaryCallSettings getBackupSettings; + private final UnaryCallSettings listBackupsSettings; + private final UnaryCallSettings deleteBackupSettings; + private final UnaryCallSettings restoreDatabaseSettings; + private final OperationCallSettings + restoreDatabaseOperationSettings; + private final UnaryCallSettings + createBackupScheduleSettings; + private final UnaryCallSettings + getBackupScheduleSettings; + private final UnaryCallSettings + listBackupSchedulesSettings; + private final UnaryCallSettings + updateBackupScheduleSettings; + private final UnaryCallSettings deleteBackupScheduleSettings; + private final UnaryCallSettings cloneDatabaseSettings; + private final OperationCallSettings + cloneDatabaseOperationSettings; + + 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(); + } + }; + + 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(); + } + }; + + 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() { + return createIndexSettings; + } + + /** Returns the object with the settings used for calls to createIndex. */ + public OperationCallSettings + createIndexOperationSettings() { + return createIndexOperationSettings; + } + + /** Returns the object with the settings used for calls to listIndexes. */ + public PagedCallSettings + listIndexesSettings() { + return listIndexesSettings; + } + + /** Returns the object with the settings used for calls to getIndex. */ + 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() { + return listFieldsSettings; + } + + /** Returns the object with the settings used for calls to exportDocuments. */ + public UnaryCallSettings exportDocumentsSettings() { + return exportDocumentsSettings; + } + + /** Returns the object with the settings used for calls to exportDocuments. */ + public OperationCallSettings< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings() { + return exportDocumentsOperationSettings; + } + + /** Returns the object with the settings used for calls to importDocuments. */ + public UnaryCallSettings importDocumentsSettings() { + return importDocumentsSettings; + } + + /** Returns the object with the settings used for calls to importDocuments. */ + public OperationCallSettings + importDocumentsOperationSettings() { + return importDocumentsOperationSettings; + } + + /** Returns the object with the settings used for calls to bulkDeleteDocuments. */ + public UnaryCallSettings bulkDeleteDocumentsSettings() { + return bulkDeleteDocumentsSettings; + } + + /** Returns the object with the settings used for calls to bulkDeleteDocuments. */ + public OperationCallSettings< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings() { + return bulkDeleteDocumentsOperationSettings; + } + + /** Returns the object with the settings used for calls to createDatabase. */ + public UnaryCallSettings createDatabaseSettings() { + return createDatabaseSettings; + } + + /** Returns the object with the settings used for calls to createDatabase. */ + public OperationCallSettings + createDatabaseOperationSettings() { + return createDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to getDatabase. */ + public UnaryCallSettings getDatabaseSettings() { + return getDatabaseSettings; + } + + /** Returns the object with the settings used for calls to listDatabases. */ + public UnaryCallSettings listDatabasesSettings() { + return listDatabasesSettings; + } + + /** Returns the object with the settings used for calls to updateDatabase. */ + public UnaryCallSettings updateDatabaseSettings() { + return updateDatabaseSettings; + } + + /** Returns the object with the settings used for calls to updateDatabase. */ + public OperationCallSettings + updateDatabaseOperationSettings() { + return updateDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to deleteDatabase. */ + public UnaryCallSettings deleteDatabaseSettings() { + return deleteDatabaseSettings; + } + + /** Returns the object with the settings used for calls to deleteDatabase. */ + public OperationCallSettings + deleteDatabaseOperationSettings() { + return deleteDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to createUserCreds. */ + public UnaryCallSettings createUserCredsSettings() { + return createUserCredsSettings; + } + + /** Returns the object with the settings used for calls to getUserCreds. */ + public UnaryCallSettings getUserCredsSettings() { + return getUserCredsSettings; + } + + /** Returns the object with the settings used for calls to listUserCreds. */ + public UnaryCallSettings listUserCredsSettings() { + return listUserCredsSettings; + } + + /** Returns the object with the settings used for calls to enableUserCreds. */ + public UnaryCallSettings enableUserCredsSettings() { + return enableUserCredsSettings; + } + + /** Returns the object with the settings used for calls to disableUserCreds. */ + public UnaryCallSettings disableUserCredsSettings() { + return disableUserCredsSettings; + } + + /** Returns the object with the settings used for calls to resetUserPassword. */ + public UnaryCallSettings resetUserPasswordSettings() { + return resetUserPasswordSettings; + } + + /** Returns the object with the settings used for calls to deleteUserCreds. */ + public UnaryCallSettings deleteUserCredsSettings() { + return deleteUserCredsSettings; + } + + /** Returns the object with the settings used for calls to getBackup. */ + public UnaryCallSettings getBackupSettings() { + return getBackupSettings; + } + + /** Returns the object with the settings used for calls to listBackups. */ + public UnaryCallSettings listBackupsSettings() { + return listBackupsSettings; + } + + /** Returns the object with the settings used for calls to deleteBackup. */ + public UnaryCallSettings deleteBackupSettings() { + return deleteBackupSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public UnaryCallSettings restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the object with the settings used for calls to restoreDatabase. */ + public OperationCallSettings + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to cloneDatabase. */ + public UnaryCallSettings cloneDatabaseSettings() { + return cloneDatabaseSettings; + } + + /** Returns the object with the settings used for calls to cloneDatabase. */ + public OperationCallSettings + cloneDatabaseOperationSettings() { + return cloneDatabaseOperationSettings; + } + + public FirestoreAdminStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcFirestoreAdminStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFirestoreAdminStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns the default service name. */ + @Override + public String getServiceName() { + return "firestore"; + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") + public static String getDefaultEndpoint() { + return "firestore.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "firestore.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(FirestoreAdminStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(FirestoreAdminStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirestoreAdminStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected FirestoreAdminStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + 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(); + importDocumentsSettings = settingsBuilder.importDocumentsSettings().build(); + importDocumentsOperationSettings = settingsBuilder.importDocumentsOperationSettings().build(); + bulkDeleteDocumentsSettings = settingsBuilder.bulkDeleteDocumentsSettings().build(); + bulkDeleteDocumentsOperationSettings = + settingsBuilder.bulkDeleteDocumentsOperationSettings().build(); + createDatabaseSettings = settingsBuilder.createDatabaseSettings().build(); + createDatabaseOperationSettings = settingsBuilder.createDatabaseOperationSettings().build(); + getDatabaseSettings = settingsBuilder.getDatabaseSettings().build(); + listDatabasesSettings = settingsBuilder.listDatabasesSettings().build(); + updateDatabaseSettings = settingsBuilder.updateDatabaseSettings().build(); + updateDatabaseOperationSettings = settingsBuilder.updateDatabaseOperationSettings().build(); + deleteDatabaseSettings = settingsBuilder.deleteDatabaseSettings().build(); + deleteDatabaseOperationSettings = settingsBuilder.deleteDatabaseOperationSettings().build(); + createUserCredsSettings = settingsBuilder.createUserCredsSettings().build(); + getUserCredsSettings = settingsBuilder.getUserCredsSettings().build(); + listUserCredsSettings = settingsBuilder.listUserCredsSettings().build(); + enableUserCredsSettings = settingsBuilder.enableUserCredsSettings().build(); + disableUserCredsSettings = settingsBuilder.disableUserCredsSettings().build(); + resetUserPasswordSettings = settingsBuilder.resetUserPasswordSettings().build(); + deleteUserCredsSettings = settingsBuilder.deleteUserCredsSettings().build(); + getBackupSettings = settingsBuilder.getBackupSettings().build(); + listBackupsSettings = settingsBuilder.listBackupsSettings().build(); + deleteBackupSettings = settingsBuilder.deleteBackupSettings().build(); + restoreDatabaseSettings = settingsBuilder.restoreDatabaseSettings().build(); + restoreDatabaseOperationSettings = settingsBuilder.restoreDatabaseOperationSettings().build(); + createBackupScheduleSettings = settingsBuilder.createBackupScheduleSettings().build(); + getBackupScheduleSettings = settingsBuilder.getBackupScheduleSettings().build(); + listBackupSchedulesSettings = settingsBuilder.listBackupSchedulesSettings().build(); + updateBackupScheduleSettings = settingsBuilder.updateBackupScheduleSettings().build(); + deleteBackupScheduleSettings = settingsBuilder.deleteBackupScheduleSettings().build(); + cloneDatabaseSettings = settingsBuilder.cloneDatabaseSettings().build(); + cloneDatabaseOperationSettings = settingsBuilder.cloneDatabaseOperationSettings().build(); + } + + /** Builder for FirestoreAdminStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder createIndexSettings; + private final OperationCallSettings.Builder + createIndexOperationSettings; + private final PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + 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; + private final UnaryCallSettings.Builder + exportDocumentsSettings; + private final OperationCallSettings.Builder< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings; + private final UnaryCallSettings.Builder + importDocumentsSettings; + private final OperationCallSettings.Builder< + ImportDocumentsRequest, Empty, ImportDocumentsMetadata> + importDocumentsOperationSettings; + private final UnaryCallSettings.Builder + bulkDeleteDocumentsSettings; + private final OperationCallSettings.Builder< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings; + private final UnaryCallSettings.Builder + createDatabaseSettings; + private final OperationCallSettings.Builder< + CreateDatabaseRequest, Database, CreateDatabaseMetadata> + createDatabaseOperationSettings; + private final UnaryCallSettings.Builder getDatabaseSettings; + private final UnaryCallSettings.Builder + listDatabasesSettings; + private final UnaryCallSettings.Builder + updateDatabaseSettings; + private final OperationCallSettings.Builder< + UpdateDatabaseRequest, Database, UpdateDatabaseMetadata> + updateDatabaseOperationSettings; + private final UnaryCallSettings.Builder + deleteDatabaseSettings; + private final OperationCallSettings.Builder< + DeleteDatabaseRequest, Database, DeleteDatabaseMetadata> + deleteDatabaseOperationSettings; + private final UnaryCallSettings.Builder + createUserCredsSettings; + private final UnaryCallSettings.Builder getUserCredsSettings; + private final UnaryCallSettings.Builder + listUserCredsSettings; + private final UnaryCallSettings.Builder + enableUserCredsSettings; + private final UnaryCallSettings.Builder + disableUserCredsSettings; + private final UnaryCallSettings.Builder + resetUserPasswordSettings; + private final UnaryCallSettings.Builder deleteUserCredsSettings; + private final UnaryCallSettings.Builder getBackupSettings; + private final UnaryCallSettings.Builder + listBackupsSettings; + private final UnaryCallSettings.Builder deleteBackupSettings; + private final UnaryCallSettings.Builder + restoreDatabaseSettings; + private final OperationCallSettings.Builder< + RestoreDatabaseRequest, Database, RestoreDatabaseMetadata> + restoreDatabaseOperationSettings; + private final UnaryCallSettings.Builder + createBackupScheduleSettings; + private final UnaryCallSettings.Builder + getBackupScheduleSettings; + private final UnaryCallSettings.Builder + listBackupSchedulesSettings; + private final UnaryCallSettings.Builder + updateBackupScheduleSettings; + private final UnaryCallSettings.Builder + deleteBackupScheduleSettings; + private final UnaryCallSettings.Builder cloneDatabaseSettings; + private final OperationCallSettings.Builder< + CloneDatabaseRequest, Database, CloneDatabaseMetadata> + cloneDatabaseOperationSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "no_retry_1_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.INTERNAL, + StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_2_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put("no_retry_codes", ImmutableSet.copyOf(Lists.newArrayList())); + RETRYABLE_CODE_DEFINITIONS = definitions.build(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_1_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeoutDuration(Duration.ofMillis(120000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(120000L)) + .setTotalTimeoutDuration(Duration.ofMillis(120000L)) + .build(); + definitions.put("no_retry_2_params", settings); + settings = RetrySettings.newBuilder().setRpcTimeoutMultiplier(1.0).build(); + definitions.put("no_retry_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + createIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createIndexOperationSettings = OperationCallSettings.newBuilder(); + listIndexesSettings = PagedCallSettings.newBuilder(LIST_INDEXES_PAGE_STR_FACT); + getIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getFieldSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateFieldSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateFieldOperationSettings = OperationCallSettings.newBuilder(); + listFieldsSettings = PagedCallSettings.newBuilder(LIST_FIELDS_PAGE_STR_FACT); + exportDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + exportDocumentsOperationSettings = OperationCallSettings.newBuilder(); + importDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + importDocumentsOperationSettings = OperationCallSettings.newBuilder(); + bulkDeleteDocumentsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + bulkDeleteDocumentsOperationSettings = OperationCallSettings.newBuilder(); + createDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createDatabaseOperationSettings = OperationCallSettings.newBuilder(); + getDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listDatabasesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateDatabaseOperationSettings = OperationCallSettings.newBuilder(); + deleteDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteDatabaseOperationSettings = OperationCallSettings.newBuilder(); + createUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + enableUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + disableUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + resetUserPasswordSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteUserCredsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listBackupsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteBackupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + restoreDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + restoreDatabaseOperationSettings = OperationCallSettings.newBuilder(); + createBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listBackupSchedulesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + cloneDatabaseSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + cloneDatabaseOperationSettings = OperationCallSettings.newBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createIndexSettings, + listIndexesSettings, + getIndexSettings, + deleteIndexSettings, + getFieldSettings, + updateFieldSettings, + listFieldsSettings, + exportDocumentsSettings, + importDocumentsSettings, + bulkDeleteDocumentsSettings, + createDatabaseSettings, + getDatabaseSettings, + listDatabasesSettings, + updateDatabaseSettings, + deleteDatabaseSettings, + createUserCredsSettings, + getUserCredsSettings, + listUserCredsSettings, + enableUserCredsSettings, + disableUserCredsSettings, + resetUserPasswordSettings, + deleteUserCredsSettings, + getBackupSettings, + listBackupsSettings, + deleteBackupSettings, + restoreDatabaseSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + listBackupSchedulesSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings, + cloneDatabaseSettings); + 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(); + bulkDeleteDocumentsSettings = settings.bulkDeleteDocumentsSettings.toBuilder(); + bulkDeleteDocumentsOperationSettings = + settings.bulkDeleteDocumentsOperationSettings.toBuilder(); + createDatabaseSettings = settings.createDatabaseSettings.toBuilder(); + createDatabaseOperationSettings = settings.createDatabaseOperationSettings.toBuilder(); + getDatabaseSettings = settings.getDatabaseSettings.toBuilder(); + listDatabasesSettings = settings.listDatabasesSettings.toBuilder(); + updateDatabaseSettings = settings.updateDatabaseSettings.toBuilder(); + updateDatabaseOperationSettings = settings.updateDatabaseOperationSettings.toBuilder(); + deleteDatabaseSettings = settings.deleteDatabaseSettings.toBuilder(); + deleteDatabaseOperationSettings = settings.deleteDatabaseOperationSettings.toBuilder(); + createUserCredsSettings = settings.createUserCredsSettings.toBuilder(); + getUserCredsSettings = settings.getUserCredsSettings.toBuilder(); + listUserCredsSettings = settings.listUserCredsSettings.toBuilder(); + enableUserCredsSettings = settings.enableUserCredsSettings.toBuilder(); + disableUserCredsSettings = settings.disableUserCredsSettings.toBuilder(); + resetUserPasswordSettings = settings.resetUserPasswordSettings.toBuilder(); + deleteUserCredsSettings = settings.deleteUserCredsSettings.toBuilder(); + getBackupSettings = settings.getBackupSettings.toBuilder(); + listBackupsSettings = settings.listBackupsSettings.toBuilder(); + deleteBackupSettings = settings.deleteBackupSettings.toBuilder(); + restoreDatabaseSettings = settings.restoreDatabaseSettings.toBuilder(); + restoreDatabaseOperationSettings = settings.restoreDatabaseOperationSettings.toBuilder(); + createBackupScheduleSettings = settings.createBackupScheduleSettings.toBuilder(); + getBackupScheduleSettings = settings.getBackupScheduleSettings.toBuilder(); + listBackupSchedulesSettings = settings.listBackupSchedulesSettings.toBuilder(); + updateBackupScheduleSettings = settings.updateBackupScheduleSettings.toBuilder(); + deleteBackupScheduleSettings = settings.deleteBackupScheduleSettings.toBuilder(); + cloneDatabaseSettings = settings.cloneDatabaseSettings.toBuilder(); + cloneDatabaseOperationSettings = settings.cloneDatabaseOperationSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + createIndexSettings, + listIndexesSettings, + getIndexSettings, + deleteIndexSettings, + getFieldSettings, + updateFieldSettings, + listFieldsSettings, + exportDocumentsSettings, + importDocumentsSettings, + bulkDeleteDocumentsSettings, + createDatabaseSettings, + getDatabaseSettings, + listDatabasesSettings, + updateDatabaseSettings, + deleteDatabaseSettings, + createUserCredsSettings, + getUserCredsSettings, + listUserCredsSettings, + enableUserCredsSettings, + disableUserCredsSettings, + resetUserPasswordSettings, + deleteUserCredsSettings, + getBackupSettings, + listBackupsSettings, + deleteBackupSettings, + restoreDatabaseSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + listBackupSchedulesSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings, + cloneDatabaseSettings); + } + + private static Builder createDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .createIndexSettings() + .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("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getIndexSettings() + .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("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("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .exportDocumentsSettings() + .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("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .bulkDeleteDocumentsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .createDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); + + builder + .getDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listDatabasesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .updateDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .createUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .enableUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .disableUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .resetUserPasswordSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteUserCredsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getBackupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listBackupsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteBackupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .restoreDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); + + builder + .createBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .getBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .listBackupSchedulesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .updateBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .deleteBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")); + + builder + .cloneDatabaseSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")); + + builder + .createIndexOperationSettings() + .setInitialCallSettings( + 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)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(IndexOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .updateFieldOperationSettings() + .setInitialCallSettings( + 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)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(FieldOperationMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .exportDocumentsOperationSettings() + .setInitialCallSettings( + 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(ExportDocumentsResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(ExportDocumentsMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .importDocumentsOperationSettings() + .setInitialCallSettings( + 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(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(ImportDocumentsMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .bulkDeleteDocumentsOperationSettings() + .setInitialCallSettings( + 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( + BulkDeleteDocumentsResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create( + BulkDeleteDocumentsMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .createDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(CreateDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .updateDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(UpdateDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .deleteDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(DeleteDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .restoreDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(RestoreDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + builder + .cloneDatabaseOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_2_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_2_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Database.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(CloneDatabaseMetadata.class)) + .setPollingAlgorithm( + OperationTimedPollAlgorithm.create( + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(5000L)) + .setRetryDelayMultiplier(1.5) + .setMaxRetryDelayDuration(Duration.ofMillis(45000L)) + .setInitialRpcTimeoutDuration(Duration.ZERO) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ZERO) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build())); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to createIndex. */ + public UnaryCallSettings.Builder createIndexSettings() { + return createIndexSettings; + } + + /** Returns the builder for the settings used for calls to createIndex. */ + public OperationCallSettings.Builder + createIndexOperationSettings() { + return createIndexOperationSettings; + } + + /** Returns the builder for the settings used for calls to listIndexes. */ + public PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + listIndexesSettings() { + return listIndexesSettings; + } + + /** Returns the builder for the settings used for calls to getIndex. */ + 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. */ + public OperationCallSettings.Builder + updateFieldOperationSettings() { + return updateFieldOperationSettings; + } + + /** Returns the builder for the settings used for calls to listFields. */ + public PagedCallSettings.Builder + listFieldsSettings() { + return listFieldsSettings; + } + + /** Returns the builder for the settings used for calls to exportDocuments. */ + public UnaryCallSettings.Builder exportDocumentsSettings() { + return exportDocumentsSettings; + } + + /** Returns the builder for the settings used for calls to exportDocuments. */ + public OperationCallSettings.Builder< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationSettings() { + return exportDocumentsOperationSettings; + } + + /** Returns the builder for the settings used for calls to importDocuments. */ + public UnaryCallSettings.Builder importDocumentsSettings() { + return importDocumentsSettings; + } + + /** Returns the builder for the settings used for calls to importDocuments. */ + public OperationCallSettings.Builder + importDocumentsOperationSettings() { + return importDocumentsOperationSettings; + } + + /** Returns the builder for the settings used for calls to bulkDeleteDocuments. */ + public UnaryCallSettings.Builder + bulkDeleteDocumentsSettings() { + return bulkDeleteDocumentsSettings; + } + + /** Returns the builder for the settings used for calls to bulkDeleteDocuments. */ + public OperationCallSettings.Builder< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationSettings() { + return bulkDeleteDocumentsOperationSettings; + } + + /** Returns the builder for the settings used for calls to createDatabase. */ + public UnaryCallSettings.Builder createDatabaseSettings() { + return createDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to createDatabase. */ + public OperationCallSettings.Builder + createDatabaseOperationSettings() { + return createDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to getDatabase. */ + public UnaryCallSettings.Builder getDatabaseSettings() { + return getDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to listDatabases. */ + public UnaryCallSettings.Builder + listDatabasesSettings() { + return listDatabasesSettings; + } + + /** Returns the builder for the settings used for calls to updateDatabase. */ + public UnaryCallSettings.Builder updateDatabaseSettings() { + return updateDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to updateDatabase. */ + public OperationCallSettings.Builder + updateDatabaseOperationSettings() { + return updateDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to deleteDatabase. */ + public UnaryCallSettings.Builder deleteDatabaseSettings() { + return deleteDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to deleteDatabase. */ + public OperationCallSettings.Builder + deleteDatabaseOperationSettings() { + return deleteDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to createUserCreds. */ + public UnaryCallSettings.Builder createUserCredsSettings() { + return createUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to getUserCreds. */ + public UnaryCallSettings.Builder getUserCredsSettings() { + return getUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to listUserCreds. */ + public UnaryCallSettings.Builder + listUserCredsSettings() { + return listUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to enableUserCreds. */ + public UnaryCallSettings.Builder enableUserCredsSettings() { + return enableUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to disableUserCreds. */ + public UnaryCallSettings.Builder + disableUserCredsSettings() { + return disableUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to resetUserPassword. */ + public UnaryCallSettings.Builder + resetUserPasswordSettings() { + return resetUserPasswordSettings; + } + + /** Returns the builder for the settings used for calls to deleteUserCreds. */ + public UnaryCallSettings.Builder deleteUserCredsSettings() { + return deleteUserCredsSettings; + } + + /** Returns the builder for the settings used for calls to getBackup. */ + public UnaryCallSettings.Builder getBackupSettings() { + return getBackupSettings; + } + + /** Returns the builder for the settings used for calls to listBackups. */ + public UnaryCallSettings.Builder + listBackupsSettings() { + return listBackupsSettings; + } + + /** Returns the builder for the settings used for calls to deleteBackup. */ + public UnaryCallSettings.Builder deleteBackupSettings() { + return deleteBackupSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public UnaryCallSettings.Builder restoreDatabaseSettings() { + return restoreDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to restoreDatabase. */ + public OperationCallSettings.Builder + restoreDatabaseOperationSettings() { + return restoreDatabaseOperationSettings; + } + + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public UnaryCallSettings.Builder + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to cloneDatabase. */ + public UnaryCallSettings.Builder cloneDatabaseSettings() { + return cloneDatabaseSettings; + } + + /** Returns the builder for the settings used for calls to cloneDatabase. */ + public OperationCallSettings.Builder + cloneDatabaseOperationSettings() { + return cloneDatabaseOperationSettings; + } + + @Override + public FirestoreAdminStubSettings build() throws IOException { + return new FirestoreAdminStubSettings(this); + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java new file mode 100644 index 000000000000..692755212d88 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminCallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +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. +/** + * gRPC callable factory implementation for the FirestoreAdmin service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcFirestoreAdminCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java new file mode 100644 index 000000000000..f9be0576c1ba --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreAdminStub.java @@ -0,0 +1,1340 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.longrunning.stub.GrpcOperationsStub; +import com.google.protobuf.Empty; +import io.grpc.MethodDescriptor; +import io.grpc.protobuf.ProtoUtils; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the FirestoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcFirestoreAdminStub extends FirestoreAdminStub { + private static final MethodDescriptor createIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateIndex") + .setRequestMarshaller(ProtoUtils.marshaller(CreateIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listIndexesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListIndexes") + .setRequestMarshaller(ProtoUtils.marshaller(ListIndexesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListIndexesResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor getIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetIndex") + .setRequestMarshaller(ProtoUtils.marshaller(GetIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Index.getDefaultInstance())) + .setSampledToLocalTracing(true) + .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())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor getFieldMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetField") + .setRequestMarshaller(ProtoUtils.marshaller(GetFieldRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Field.getDefaultInstance())) + .setSampledToLocalTracing(true) + .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())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listFieldsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListFields") + .setRequestMarshaller(ProtoUtils.marshaller(ListFieldsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ListFieldsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + exportDocumentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ExportDocuments") + .setRequestMarshaller( + ProtoUtils.marshaller(ExportDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + importDocumentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ImportDocuments") + .setRequestMarshaller( + ProtoUtils.marshaller(ImportDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + bulkDeleteDocumentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/BulkDeleteDocuments") + .setRequestMarshaller( + ProtoUtils.marshaller(BulkDeleteDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + createDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor getDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetDatabase") + .setRequestMarshaller(ProtoUtils.marshaller(GetDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Database.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listDatabasesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListDatabases") + .setRequestMarshaller( + ProtoUtils.marshaller(ListDatabasesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListDatabasesResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + updateDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + deleteDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + createUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateUserCreds") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(UserCreds.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + getUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetUserCreds") + .setRequestMarshaller(ProtoUtils.marshaller(GetUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(UserCreds.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListUserCreds") + .setRequestMarshaller( + ProtoUtils.marshaller(ListUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListUserCredsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + enableUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/EnableUserCreds") + .setRequestMarshaller( + ProtoUtils.marshaller(EnableUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(UserCreds.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + disableUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DisableUserCreds") + .setRequestMarshaller( + ProtoUtils.marshaller(DisableUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(UserCreds.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + resetUserPasswordMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ResetUserPassword") + .setRequestMarshaller( + ProtoUtils.marshaller(ResetUserPasswordRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(UserCreds.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + deleteUserCredsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteUserCreds") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteUserCredsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor getBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackup") + .setRequestMarshaller(ProtoUtils.marshaller(GetBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Backup.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listBackupsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackups") + .setRequestMarshaller(ProtoUtils.marshaller(ListBackupsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBackupsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor deleteBackupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackup") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteBackupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + restoreDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/RestoreDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(RestoreDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + createBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + getBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(GetBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listBackupSchedulesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackupSchedules") + .setRequestMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + updateBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + deleteBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + cloneDatabaseMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CloneDatabase") + .setRequestMarshaller( + ProtoUtils.marshaller(CloneDatabaseRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private final UnaryCallable createIndexCallable; + private final OperationCallable + createIndexOperationCallable; + private final UnaryCallable listIndexesCallable; + 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; + private final OperationCallable< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationCallable; + private final UnaryCallable importDocumentsCallable; + private final OperationCallable + importDocumentsOperationCallable; + private final UnaryCallable bulkDeleteDocumentsCallable; + private final OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable; + private final UnaryCallable createDatabaseCallable; + private final OperationCallable + createDatabaseOperationCallable; + private final UnaryCallable getDatabaseCallable; + private final UnaryCallable listDatabasesCallable; + private final UnaryCallable updateDatabaseCallable; + private final OperationCallable + updateDatabaseOperationCallable; + private final UnaryCallable deleteDatabaseCallable; + private final OperationCallable + deleteDatabaseOperationCallable; + private final UnaryCallable createUserCredsCallable; + private final UnaryCallable getUserCredsCallable; + private final UnaryCallable listUserCredsCallable; + private final UnaryCallable enableUserCredsCallable; + private final UnaryCallable disableUserCredsCallable; + private final UnaryCallable resetUserPasswordCallable; + private final UnaryCallable deleteUserCredsCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable deleteBackupCallable; + private final UnaryCallable restoreDatabaseCallable; + private final OperationCallable + restoreDatabaseOperationCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; + private final UnaryCallable cloneDatabaseCallable; + private final OperationCallable + cloneDatabaseOperationCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + private static final PathTemplate CLONE_DATABASE_0_PATH_TEMPLATE = + PathTemplate.create("projects/{project_id=*}/**"); + private static final PathTemplate CLONE_DATABASE_1_PATH_TEMPLATE = + PathTemplate.create("projects/*/databases/{database_id=*}/**"); + + public static final GrpcFirestoreAdminStub create(FirestoreAdminStubSettings settings) + throws IOException { + return new GrpcFirestoreAdminStub(settings, ClientContext.create(settings)); + } + + public static final GrpcFirestoreAdminStub create(ClientContext clientContext) + throws IOException { + return new GrpcFirestoreAdminStub( + FirestoreAdminStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcFirestoreAdminStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcFirestoreAdminStub( + FirestoreAdminStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcFirestoreAdminStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcFirestoreAdminStub(FirestoreAdminStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcFirestoreAdminCallableFactory()); + } + + /** + * Constructs an instance of GrpcFirestoreAdminStub, using the given settings. This is protected + * so that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcFirestoreAdminStub( + FirestoreAdminStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings createIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings listIndexesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listIndexesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings getFieldTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getFieldMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings updateFieldTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateFieldMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("field.name", String.valueOf(request.getField().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listFieldsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listFieldsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings exportDocumentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(exportDocumentsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings importDocumentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(importDocumentsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings bulkDeleteDocumentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(bulkDeleteDocumentsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings createDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listDatabasesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listDatabasesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings updateDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database.name", String.valueOf(request.getDatabase().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings createUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings enableUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(enableUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings disableUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(disableUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings resetUserPasswordTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(resetUserPasswordMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteUserCredsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteUserCredsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings getBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listBackupsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteBackupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings restoreDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(restoreDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + createBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings + listBackupSchedulesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + updateBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings cloneDatabaseTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(cloneDatabaseMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + if (request.getPitrSnapshot() != null) { + builder.add( + request.getPitrSnapshot().getDatabase(), + "project_id", + CLONE_DATABASE_0_PATH_TEMPLATE); + } + if (request.getPitrSnapshot() != null) { + builder.add( + request.getPitrSnapshot().getDatabase(), + "database_id", + CLONE_DATABASE_1_PATH_TEMPLATE); + } + return builder.build(); + }) + .build(); + + this.createIndexCallable = + callableFactory.createUnaryCallable( + createIndexTransportSettings, settings.createIndexSettings(), clientContext); + this.createIndexOperationCallable = + callableFactory.createOperationCallable( + createIndexTransportSettings, + settings.createIndexOperationSettings(), + clientContext, + operationsStub); + this.listIndexesCallable = + callableFactory.createUnaryCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.listIndexesPagedCallable = + callableFactory.createPagedCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + 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); + this.listFieldsPagedCallable = + callableFactory.createPagedCallable( + listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); + this.exportDocumentsCallable = + callableFactory.createUnaryCallable( + exportDocumentsTransportSettings, settings.exportDocumentsSettings(), clientContext); + this.exportDocumentsOperationCallable = + callableFactory.createOperationCallable( + exportDocumentsTransportSettings, + settings.exportDocumentsOperationSettings(), + clientContext, + operationsStub); + this.importDocumentsCallable = + callableFactory.createUnaryCallable( + importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); + this.importDocumentsOperationCallable = + callableFactory.createOperationCallable( + importDocumentsTransportSettings, + settings.importDocumentsOperationSettings(), + clientContext, + operationsStub); + this.bulkDeleteDocumentsCallable = + callableFactory.createUnaryCallable( + bulkDeleteDocumentsTransportSettings, + settings.bulkDeleteDocumentsSettings(), + clientContext); + this.bulkDeleteDocumentsOperationCallable = + callableFactory.createOperationCallable( + bulkDeleteDocumentsTransportSettings, + settings.bulkDeleteDocumentsOperationSettings(), + clientContext, + operationsStub); + this.createDatabaseCallable = + callableFactory.createUnaryCallable( + createDatabaseTransportSettings, settings.createDatabaseSettings(), clientContext); + this.createDatabaseOperationCallable = + callableFactory.createOperationCallable( + createDatabaseTransportSettings, + settings.createDatabaseOperationSettings(), + clientContext, + operationsStub); + this.getDatabaseCallable = + callableFactory.createUnaryCallable( + getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); + this.listDatabasesCallable = + callableFactory.createUnaryCallable( + listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); + this.updateDatabaseCallable = + callableFactory.createUnaryCallable( + updateDatabaseTransportSettings, settings.updateDatabaseSettings(), clientContext); + this.updateDatabaseOperationCallable = + callableFactory.createOperationCallable( + updateDatabaseTransportSettings, + settings.updateDatabaseOperationSettings(), + clientContext, + operationsStub); + this.deleteDatabaseCallable = + callableFactory.createUnaryCallable( + deleteDatabaseTransportSettings, settings.deleteDatabaseSettings(), clientContext); + this.deleteDatabaseOperationCallable = + callableFactory.createOperationCallable( + deleteDatabaseTransportSettings, + settings.deleteDatabaseOperationSettings(), + clientContext, + operationsStub); + this.createUserCredsCallable = + callableFactory.createUnaryCallable( + createUserCredsTransportSettings, settings.createUserCredsSettings(), clientContext); + this.getUserCredsCallable = + callableFactory.createUnaryCallable( + getUserCredsTransportSettings, settings.getUserCredsSettings(), clientContext); + this.listUserCredsCallable = + callableFactory.createUnaryCallable( + listUserCredsTransportSettings, settings.listUserCredsSettings(), clientContext); + this.enableUserCredsCallable = + callableFactory.createUnaryCallable( + enableUserCredsTransportSettings, settings.enableUserCredsSettings(), clientContext); + this.disableUserCredsCallable = + callableFactory.createUnaryCallable( + disableUserCredsTransportSettings, settings.disableUserCredsSettings(), clientContext); + this.resetUserPasswordCallable = + callableFactory.createUnaryCallable( + resetUserPasswordTransportSettings, + settings.resetUserPasswordSettings(), + clientContext); + this.deleteUserCredsCallable = + callableFactory.createUnaryCallable( + deleteUserCredsTransportSettings, settings.deleteUserCredsSettings(), clientContext); + this.getBackupCallable = + callableFactory.createUnaryCallable( + getBackupTransportSettings, settings.getBackupSettings(), clientContext); + this.listBackupsCallable = + callableFactory.createUnaryCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.restoreDatabaseCallable = + callableFactory.createUnaryCallable( + restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); + this.restoreDatabaseOperationCallable = + callableFactory.createOperationCallable( + restoreDatabaseTransportSettings, + settings.restoreDatabaseOperationSettings(), + clientContext, + operationsStub); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); + this.cloneDatabaseCallable = + callableFactory.createUnaryCallable( + cloneDatabaseTransportSettings, settings.cloneDatabaseSettings(), clientContext); + this.cloneDatabaseOperationCallable = + callableFactory.createOperationCallable( + cloneDatabaseTransportSettings, + settings.cloneDatabaseOperationSettings(), + clientContext, + operationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; + } + + @Override + public OperationCallable + createIndexOperationCallable() { + return createIndexOperationCallable; + } + + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; + } + + @Override + public UnaryCallable listIndexesPagedCallable() { + return listIndexesPagedCallable; + } + + @Override + public UnaryCallable getIndexCallable() { + return getIndexCallable; + } + + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override + public UnaryCallable getFieldCallable() { + return getFieldCallable; + } + + @Override + public UnaryCallable updateFieldCallable() { + return updateFieldCallable; + } + + @Override + public OperationCallable + updateFieldOperationCallable() { + return updateFieldOperationCallable; + } + + @Override + public UnaryCallable listFieldsCallable() { + return listFieldsCallable; + } + + @Override + public UnaryCallable listFieldsPagedCallable() { + return listFieldsPagedCallable; + } + + @Override + public UnaryCallable exportDocumentsCallable() { + return exportDocumentsCallable; + } + + @Override + public OperationCallable + exportDocumentsOperationCallable() { + return exportDocumentsOperationCallable; + } + + @Override + public UnaryCallable importDocumentsCallable() { + return importDocumentsCallable; + } + + @Override + public OperationCallable + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + + @Override + public UnaryCallable bulkDeleteDocumentsCallable() { + return bulkDeleteDocumentsCallable; + } + + @Override + public OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable() { + return bulkDeleteDocumentsOperationCallable; + } + + @Override + public UnaryCallable createDatabaseCallable() { + return createDatabaseCallable; + } + + @Override + public OperationCallable + createDatabaseOperationCallable() { + return createDatabaseOperationCallable; + } + + @Override + public UnaryCallable getDatabaseCallable() { + return getDatabaseCallable; + } + + @Override + public UnaryCallable listDatabasesCallable() { + return listDatabasesCallable; + } + + @Override + public UnaryCallable updateDatabaseCallable() { + return updateDatabaseCallable; + } + + @Override + public OperationCallable + updateDatabaseOperationCallable() { + return updateDatabaseOperationCallable; + } + + @Override + public UnaryCallable deleteDatabaseCallable() { + return deleteDatabaseCallable; + } + + @Override + public OperationCallable + deleteDatabaseOperationCallable() { + return deleteDatabaseOperationCallable; + } + + @Override + public UnaryCallable createUserCredsCallable() { + return createUserCredsCallable; + } + + @Override + public UnaryCallable getUserCredsCallable() { + return getUserCredsCallable; + } + + @Override + public UnaryCallable listUserCredsCallable() { + return listUserCredsCallable; + } + + @Override + public UnaryCallable enableUserCredsCallable() { + return enableUserCredsCallable; + } + + @Override + public UnaryCallable disableUserCredsCallable() { + return disableUserCredsCallable; + } + + @Override + public UnaryCallable resetUserPasswordCallable() { + return resetUserPasswordCallable; + } + + @Override + public UnaryCallable deleteUserCredsCallable() { + return deleteUserCredsCallable; + } + + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public UnaryCallable restoreDatabaseCallable() { + return restoreDatabaseCallable; + } + + @Override + public OperationCallable + restoreDatabaseOperationCallable() { + return restoreDatabaseOperationCallable; + } + + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + + @Override + public UnaryCallable cloneDatabaseCallable() { + return cloneDatabaseCallable; + } + + @Override + public OperationCallable + cloneDatabaseOperationCallable() { + return cloneDatabaseOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java new file mode 100644 index 000000000000..bcaa17ac474a --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminCallableFactory.java @@ -0,0 +1,101 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the FirestoreAdmin service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class HttpJsonFirestoreAdminCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java new file mode 100644 index 000000000000..fa285e4d7bcd --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreAdminStub.java @@ -0,0 +1,2315 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.HttpRule; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshot; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.httpjson.longrunning.stub.HttpJsonOperationsStub; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseMetadata; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseMetadata; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseMetadata; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsMetadata; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldOperationMetadata; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsMetadata; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexOperationMetadata; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseMetadata; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseMetadata; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the FirestoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class HttpJsonFirestoreAdminStub extends FirestoreAdminStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(ExportDocumentsResponse.getDescriptor()) + .add(Field.getDescriptor()) + .add(RestoreDatabaseMetadata.getDescriptor()) + .add(ImportDocumentsMetadata.getDescriptor()) + .add(Database.getDescriptor()) + .add(FieldOperationMetadata.getDescriptor()) + .add(BulkDeleteDocumentsResponse.getDescriptor()) + .add(DeleteDatabaseMetadata.getDescriptor()) + .add(BulkDeleteDocumentsMetadata.getDescriptor()) + .add(UpdateDatabaseMetadata.getDescriptor()) + .add(Empty.getDescriptor()) + .add(Index.getDescriptor()) + .add(CreateDatabaseMetadata.getDescriptor()) + .add(ExportDocumentsMetadata.getDescriptor()) + .add(CloneDatabaseMetadata.getDescriptor()) + .add(IndexOperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateIndex") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("index", request.getIndex(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateIndexRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listIndexesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListIndexes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListIndexesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetIndex") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Index.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteIndex") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getFieldMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetField") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Field.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateFieldMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateField") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "field.name", request.getField().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("field", request.getField(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateFieldRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listFieldsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListFields") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListFieldsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + exportDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ExportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}:exportDocuments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ImportDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}:importDocuments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + bulkDeleteDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/BulkDeleteDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}:bulkDeleteDocuments", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (BulkDeleteDocumentsRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateDatabase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "databaseId", request.getDatabaseId()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("database", request.getDatabase(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetDatabase") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Database.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDatabasesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListDatabases") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "showDeleted", request.getShowDeleted()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDatabasesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateDatabase") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database.name=projects/*/databases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "database.name", request.getDatabase().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("database", request.getDatabase(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteDatabase") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateUserCreds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/userCreds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "userCredsId", request.getUserCredsId()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("userCreds", request.getUserCreds(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserCreds.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetUserCreds") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/userCreds/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserCreds.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListUserCreds") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/userCreds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListUserCredsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + enableUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/EnableUserCreds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/userCreds/*}:enable", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserCreds.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + disableUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DisableUserCreds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/userCreds/*}:disable", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserCreds.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + resetUserPasswordMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ResetUserPassword") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/userCreds/*}:resetPassword", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(UserCreds.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteUserCredsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteUserCreds") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/userCreds/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Backup.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/backups", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBackupsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackup") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + restoreDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/RestoreDatabase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CreateBackupSchedule") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/GetBackupSchedule") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBackupSchedulesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/ListBackupSchedules") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListBackupSchedulesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/UpdateBackupSchedule") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backupSchedule.name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "backupSchedule.name", + request.getBackupSchedule().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/DeleteBackupSchedule") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cloneDatabaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.admin.v1.FirestoreAdmin/CloneDatabase") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/databases:clone", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CloneDatabaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable createIndexCallable; + private final OperationCallable + createIndexOperationCallable; + private final UnaryCallable listIndexesCallable; + 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; + private final OperationCallable< + ExportDocumentsRequest, ExportDocumentsResponse, ExportDocumentsMetadata> + exportDocumentsOperationCallable; + private final UnaryCallable importDocumentsCallable; + private final OperationCallable + importDocumentsOperationCallable; + private final UnaryCallable bulkDeleteDocumentsCallable; + private final OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable; + private final UnaryCallable createDatabaseCallable; + private final OperationCallable + createDatabaseOperationCallable; + private final UnaryCallable getDatabaseCallable; + private final UnaryCallable listDatabasesCallable; + private final UnaryCallable updateDatabaseCallable; + private final OperationCallable + updateDatabaseOperationCallable; + private final UnaryCallable deleteDatabaseCallable; + private final OperationCallable + deleteDatabaseOperationCallable; + private final UnaryCallable createUserCredsCallable; + private final UnaryCallable getUserCredsCallable; + private final UnaryCallable listUserCredsCallable; + private final UnaryCallable enableUserCredsCallable; + private final UnaryCallable disableUserCredsCallable; + private final UnaryCallable resetUserPasswordCallable; + private final UnaryCallable deleteUserCredsCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable deleteBackupCallable; + private final UnaryCallable restoreDatabaseCallable; + private final OperationCallable + restoreDatabaseOperationCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; + private final UnaryCallable cloneDatabaseCallable; + private final OperationCallable + cloneDatabaseOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + private static final PathTemplate CLONE_DATABASE_0_PATH_TEMPLATE = + PathTemplate.create("projects/{project_id=*}/**"); + private static final PathTemplate CLONE_DATABASE_1_PATH_TEMPLATE = + PathTemplate.create("projects/*/databases/{database_id=*}/**"); + + public static final HttpJsonFirestoreAdminStub create(FirestoreAdminStubSettings settings) + throws IOException { + return new HttpJsonFirestoreAdminStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFirestoreAdminStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFirestoreAdminStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFirestoreAdminStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonFirestoreAdminCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFirestoreAdminStub, using the given settings. This is + * protected so that it is easy to make a subclass, but otherwise, the static factory methods + * should be preferred. + */ + protected HttpJsonFirestoreAdminStub( + FirestoreAdminStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create( + clientContext, + callableFactory, + typeRegistry, + ImmutableMap.builder() + .put( + "google.longrunning.Operations.CancelOperation", + HttpRule.newBuilder() + .setPost("/v1/{name=projects/*/databases/*/operations/*}:cancel") + .build()) + .put( + "google.longrunning.Operations.DeleteOperation", + HttpRule.newBuilder() + .setDelete("/v1/{name=projects/*/databases/*/operations/*}") + .build()) + .put( + "google.longrunning.Operations.GetOperation", + HttpRule.newBuilder() + .setGet("/v1/{name=projects/*/databases/*/operations/*}") + .build()) + .put( + "google.longrunning.Operations.ListOperations", + HttpRule.newBuilder() + .setGet("/v1/{name=projects/*/databases/*}/operations") + .build()) + .build()); + + HttpJsonCallSettings createIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings listIndexesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIndexesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getFieldTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getFieldMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings updateFieldTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateFieldMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("field.name", String.valueOf(request.getField().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings listFieldsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listFieldsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings exportDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings importDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + bulkDeleteDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(bulkDeleteDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings createDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listDatabasesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDatabasesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings updateDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database.name", String.valueOf(request.getDatabase().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings createUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings enableUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(enableUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings disableUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(disableUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings resetUserPasswordTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(resetUserPasswordMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteUserCredsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteUserCredsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings listBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings restoreDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + createBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + getBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listBackupSchedulesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + updateBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings cloneDatabaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cloneDatabaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + if (request.getPitrSnapshot() != null) { + builder.add( + request.getPitrSnapshot().getDatabase(), + "project_id", + CLONE_DATABASE_0_PATH_TEMPLATE); + } + if (request.getPitrSnapshot() != null) { + builder.add( + request.getPitrSnapshot().getDatabase(), + "database_id", + CLONE_DATABASE_1_PATH_TEMPLATE); + } + return builder.build(); + }) + .build(); + + this.createIndexCallable = + callableFactory.createUnaryCallable( + createIndexTransportSettings, settings.createIndexSettings(), clientContext); + this.createIndexOperationCallable = + callableFactory.createOperationCallable( + createIndexTransportSettings, + settings.createIndexOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listIndexesCallable = + callableFactory.createUnaryCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.listIndexesPagedCallable = + callableFactory.createPagedCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + 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, + httpJsonOperationsStub); + this.listFieldsCallable = + callableFactory.createUnaryCallable( + listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); + this.listFieldsPagedCallable = + callableFactory.createPagedCallable( + listFieldsTransportSettings, settings.listFieldsSettings(), clientContext); + this.exportDocumentsCallable = + callableFactory.createUnaryCallable( + exportDocumentsTransportSettings, settings.exportDocumentsSettings(), clientContext); + this.exportDocumentsOperationCallable = + callableFactory.createOperationCallable( + exportDocumentsTransportSettings, + settings.exportDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importDocumentsCallable = + callableFactory.createUnaryCallable( + importDocumentsTransportSettings, settings.importDocumentsSettings(), clientContext); + this.importDocumentsOperationCallable = + callableFactory.createOperationCallable( + importDocumentsTransportSettings, + settings.importDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.bulkDeleteDocumentsCallable = + callableFactory.createUnaryCallable( + bulkDeleteDocumentsTransportSettings, + settings.bulkDeleteDocumentsSettings(), + clientContext); + this.bulkDeleteDocumentsOperationCallable = + callableFactory.createOperationCallable( + bulkDeleteDocumentsTransportSettings, + settings.bulkDeleteDocumentsOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createDatabaseCallable = + callableFactory.createUnaryCallable( + createDatabaseTransportSettings, settings.createDatabaseSettings(), clientContext); + this.createDatabaseOperationCallable = + callableFactory.createOperationCallable( + createDatabaseTransportSettings, + settings.createDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getDatabaseCallable = + callableFactory.createUnaryCallable( + getDatabaseTransportSettings, settings.getDatabaseSettings(), clientContext); + this.listDatabasesCallable = + callableFactory.createUnaryCallable( + listDatabasesTransportSettings, settings.listDatabasesSettings(), clientContext); + this.updateDatabaseCallable = + callableFactory.createUnaryCallable( + updateDatabaseTransportSettings, settings.updateDatabaseSettings(), clientContext); + this.updateDatabaseOperationCallable = + callableFactory.createOperationCallable( + updateDatabaseTransportSettings, + settings.updateDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteDatabaseCallable = + callableFactory.createUnaryCallable( + deleteDatabaseTransportSettings, settings.deleteDatabaseSettings(), clientContext); + this.deleteDatabaseOperationCallable = + callableFactory.createOperationCallable( + deleteDatabaseTransportSettings, + settings.deleteDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createUserCredsCallable = + callableFactory.createUnaryCallable( + createUserCredsTransportSettings, settings.createUserCredsSettings(), clientContext); + this.getUserCredsCallable = + callableFactory.createUnaryCallable( + getUserCredsTransportSettings, settings.getUserCredsSettings(), clientContext); + this.listUserCredsCallable = + callableFactory.createUnaryCallable( + listUserCredsTransportSettings, settings.listUserCredsSettings(), clientContext); + this.enableUserCredsCallable = + callableFactory.createUnaryCallable( + enableUserCredsTransportSettings, settings.enableUserCredsSettings(), clientContext); + this.disableUserCredsCallable = + callableFactory.createUnaryCallable( + disableUserCredsTransportSettings, settings.disableUserCredsSettings(), clientContext); + this.resetUserPasswordCallable = + callableFactory.createUnaryCallable( + resetUserPasswordTransportSettings, + settings.resetUserPasswordSettings(), + clientContext); + this.deleteUserCredsCallable = + callableFactory.createUnaryCallable( + deleteUserCredsTransportSettings, settings.deleteUserCredsSettings(), clientContext); + this.getBackupCallable = + callableFactory.createUnaryCallable( + getBackupTransportSettings, settings.getBackupSettings(), clientContext); + this.listBackupsCallable = + callableFactory.createUnaryCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.restoreDatabaseCallable = + callableFactory.createUnaryCallable( + restoreDatabaseTransportSettings, settings.restoreDatabaseSettings(), clientContext); + this.restoreDatabaseOperationCallable = + callableFactory.createOperationCallable( + restoreDatabaseTransportSettings, + settings.restoreDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); + this.cloneDatabaseCallable = + callableFactory.createUnaryCallable( + cloneDatabaseTransportSettings, settings.cloneDatabaseSettings(), clientContext); + this.cloneDatabaseOperationCallable = + callableFactory.createOperationCallable( + cloneDatabaseTransportSettings, + settings.cloneDatabaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createIndexMethodDescriptor); + methodDescriptors.add(listIndexesMethodDescriptor); + methodDescriptors.add(getIndexMethodDescriptor); + methodDescriptors.add(deleteIndexMethodDescriptor); + methodDescriptors.add(getFieldMethodDescriptor); + methodDescriptors.add(updateFieldMethodDescriptor); + methodDescriptors.add(listFieldsMethodDescriptor); + methodDescriptors.add(exportDocumentsMethodDescriptor); + methodDescriptors.add(importDocumentsMethodDescriptor); + methodDescriptors.add(bulkDeleteDocumentsMethodDescriptor); + methodDescriptors.add(createDatabaseMethodDescriptor); + methodDescriptors.add(getDatabaseMethodDescriptor); + methodDescriptors.add(listDatabasesMethodDescriptor); + methodDescriptors.add(updateDatabaseMethodDescriptor); + methodDescriptors.add(deleteDatabaseMethodDescriptor); + methodDescriptors.add(createUserCredsMethodDescriptor); + methodDescriptors.add(getUserCredsMethodDescriptor); + methodDescriptors.add(listUserCredsMethodDescriptor); + methodDescriptors.add(enableUserCredsMethodDescriptor); + methodDescriptors.add(disableUserCredsMethodDescriptor); + methodDescriptors.add(resetUserPasswordMethodDescriptor); + methodDescriptors.add(deleteUserCredsMethodDescriptor); + methodDescriptors.add(getBackupMethodDescriptor); + methodDescriptors.add(listBackupsMethodDescriptor); + methodDescriptors.add(deleteBackupMethodDescriptor); + methodDescriptors.add(restoreDatabaseMethodDescriptor); + methodDescriptors.add(createBackupScheduleMethodDescriptor); + methodDescriptors.add(getBackupScheduleMethodDescriptor); + methodDescriptors.add(listBackupSchedulesMethodDescriptor); + methodDescriptors.add(updateBackupScheduleMethodDescriptor); + methodDescriptors.add(deleteBackupScheduleMethodDescriptor); + methodDescriptors.add(cloneDatabaseMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; + } + + @Override + public OperationCallable + createIndexOperationCallable() { + return createIndexOperationCallable; + } + + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; + } + + @Override + public UnaryCallable listIndexesPagedCallable() { + return listIndexesPagedCallable; + } + + @Override + public UnaryCallable getIndexCallable() { + return getIndexCallable; + } + + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override + public UnaryCallable getFieldCallable() { + return getFieldCallable; + } + + @Override + public UnaryCallable updateFieldCallable() { + return updateFieldCallable; + } + + @Override + public OperationCallable + updateFieldOperationCallable() { + return updateFieldOperationCallable; + } + + @Override + public UnaryCallable listFieldsCallable() { + return listFieldsCallable; + } + + @Override + public UnaryCallable listFieldsPagedCallable() { + return listFieldsPagedCallable; + } + + @Override + public UnaryCallable exportDocumentsCallable() { + return exportDocumentsCallable; + } + + @Override + public OperationCallable + exportDocumentsOperationCallable() { + return exportDocumentsOperationCallable; + } + + @Override + public UnaryCallable importDocumentsCallable() { + return importDocumentsCallable; + } + + @Override + public OperationCallable + importDocumentsOperationCallable() { + return importDocumentsOperationCallable; + } + + @Override + public UnaryCallable bulkDeleteDocumentsCallable() { + return bulkDeleteDocumentsCallable; + } + + @Override + public OperationCallable< + BulkDeleteDocumentsRequest, BulkDeleteDocumentsResponse, BulkDeleteDocumentsMetadata> + bulkDeleteDocumentsOperationCallable() { + return bulkDeleteDocumentsOperationCallable; + } + + @Override + public UnaryCallable createDatabaseCallable() { + return createDatabaseCallable; + } + + @Override + public OperationCallable + createDatabaseOperationCallable() { + return createDatabaseOperationCallable; + } + + @Override + public UnaryCallable getDatabaseCallable() { + return getDatabaseCallable; + } + + @Override + public UnaryCallable listDatabasesCallable() { + return listDatabasesCallable; + } + + @Override + public UnaryCallable updateDatabaseCallable() { + return updateDatabaseCallable; + } + + @Override + public OperationCallable + updateDatabaseOperationCallable() { + return updateDatabaseOperationCallable; + } + + @Override + public UnaryCallable deleteDatabaseCallable() { + return deleteDatabaseCallable; + } + + @Override + public OperationCallable + deleteDatabaseOperationCallable() { + return deleteDatabaseOperationCallable; + } + + @Override + public UnaryCallable createUserCredsCallable() { + return createUserCredsCallable; + } + + @Override + public UnaryCallable getUserCredsCallable() { + return getUserCredsCallable; + } + + @Override + public UnaryCallable listUserCredsCallable() { + return listUserCredsCallable; + } + + @Override + public UnaryCallable enableUserCredsCallable() { + return enableUserCredsCallable; + } + + @Override + public UnaryCallable disableUserCredsCallable() { + return disableUserCredsCallable; + } + + @Override + public UnaryCallable resetUserPasswordCallable() { + return resetUserPasswordCallable; + } + + @Override + public UnaryCallable deleteUserCredsCallable() { + return deleteUserCredsCallable; + } + + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public UnaryCallable restoreDatabaseCallable() { + return restoreDatabaseCallable; + } + + @Override + public OperationCallable + restoreDatabaseOperationCallable() { + return restoreDatabaseOperationCallable; + } + + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + + @Override + public UnaryCallable cloneDatabaseCallable() { + return cloneDatabaseCallable; + } + + @Override + public OperationCallable + cloneDatabaseOperationCallable() { + return cloneDatabaseOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json b/java-firestore/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json new file mode 100644 index 000000000000..212fd8e7592a --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json @@ -0,0 +1,3143 @@ +[ + { + "name": "com.google.api.ClientLibraryDestination", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibraryOrganization", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibrarySettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibrarySettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CommonLanguageSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CommonLanguageSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CppSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CppSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CustomHttpPattern", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CustomHttpPattern$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.DotnetSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.DotnetSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.FieldBehavior", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.GoSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.GoSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Http", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Http$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.HttpRule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.HttpRule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.JavaSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.JavaSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.LaunchStage", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$LongRunning", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$LongRunning$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.NodeSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.NodeSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PhpSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PhpSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Publishing", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Publishing$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$History", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$Style", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceReference", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceReference$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingParameter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingParameter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingRule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingRule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RubySettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RubySettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.SelectiveGapicGeneration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.SelectiveGapicGeneration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.GetLocationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.GetLocationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.Location", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.Location$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Stats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Backup$Stats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BackupSchedule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BackupSchedule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.BulkDeleteDocumentsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CloneDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CloneDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CloneDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CloneDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.CreateUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DailyRecurrence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DailyRecurrence$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$AppEngineIntegrationMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$CmekConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$CmekConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$ConcurrencyMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$DataAccessMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$DatabaseEdition", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$DatabaseType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$DeleteProtectionState", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$CustomerManagedEncryptionOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$CustomerManagedEncryptionOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$GoogleDefaultEncryptionOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$GoogleDefaultEncryptionOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$SourceEncryptionOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$EncryptionConfig$SourceEncryptionOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$PointInTimeRecoveryEnablement", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$SourceInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$SourceInfo$BackupSource", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$SourceInfo$BackupSource$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Database$SourceInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DeleteUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DisableUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.DisableUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.EnableUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.EnableUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ExportDocumentsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$IndexConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$IndexConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$TtlConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$TtlConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Field$TtlConfig$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$IndexConfigDelta", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$IndexConfigDelta$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$IndexConfigDelta$ChangeType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$TtlConfigDelta", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$TtlConfigDelta$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.FieldOperationMetadata$TtlConfigDelta$ChangeType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetFieldRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetFieldRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.GetUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ImportDocumentsMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ImportDocumentsMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ImportDocumentsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ImportDocumentsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$ApiScope", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$Density", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$ArrayConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$Order", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$FlatIndex", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$IndexField$VectorConfig$FlatIndex$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$QueryScope", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Index$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.IndexOperationMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.IndexOperationMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupSchedulesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListBackupsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListDatabasesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListDatabasesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListDatabasesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListDatabasesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListFieldsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListFieldsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListFieldsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListFieldsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListIndexesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListIndexesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListIndexesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListIndexesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListUserCredsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListUserCredsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListUserCredsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ListUserCredsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.LocationMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.LocationMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.OperationState", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.PitrSnapshot", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.PitrSnapshot$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Progress", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.Progress$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RealtimeUpdatesMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ResetUserPasswordRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.ResetUserPasswordRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.RestoreDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateDatabaseMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateDatabaseMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateDatabaseRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateDatabaseRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateFieldRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UpdateFieldRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UserCreds", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UserCreds$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UserCreds$ResourceIdentity", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UserCreds$ResourceIdentity$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.UserCreds$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.WeeklyRecurrence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.admin.v1.WeeklyRecurrence$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.CancelOperationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.CancelOperationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.DeleteOperationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.DeleteOperationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.GetOperationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.GetOperationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.ListOperationsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.ListOperationsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.ListOperationsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.ListOperationsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.Operation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.Operation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.OperationInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.OperationInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.WaitOperationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.longrunning.WaitOperationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Any", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Any$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ReservedRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ReservedRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$Edition", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$EnumReservedRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$EnumReservedRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Declaration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Declaration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$VerificationState", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$EnforceNamingStyle", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$EnumType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$FieldPresence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$JsonFormat", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$MessageEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$RepeatedFieldEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Utf8Validation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature$DefaultSymbolVisibility", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Label", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Type", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$CType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$FeatureSupport", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$FeatureSupport$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$JSType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$OptionRetention", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$OptionTargetType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorSet", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorSet$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions$OptimizeMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation$Semantic", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MessageOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MessageOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions$IdempotencyLevel", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Location", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Location$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SymbolVisibility", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$NamePart", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$NamePart$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Duration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Duration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Empty", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Empty$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.FieldMask", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.FieldMask$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Timestamp", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Timestamp$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.rpc.Status", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.rpc.Status$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.type.DayOfWeek", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + } +] \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java new file mode 100644 index 000000000000..44befb935fbe --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientHttpJsonTest.java @@ -0,0 +1,3119 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.firestore.v1.stub.HttpJsonFirestoreAdminStub; +import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldName; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.LocationName; +import com.google.firestore.admin.v1.PitrSnapshot; +import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.RealtimeUpdatesMode; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.firestore.admin.v1.UserCredsName; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreAdminClientHttpJsonTest { + private static MockHttpService mockService; + private static FirestoreAdminClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFirestoreAdminStub.getMethodDescriptors(), + FirestoreAdminSettings.getDefaultEndpoint()); + FirestoreAdminSettings settings = + FirestoreAdminSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FirestoreAdminSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreAdminClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + Index index = Index.newBuilder().build(); + client.createIndexAsync(parent, index).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIndexesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CollectionGroupName parent = + CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIndexesTest2() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listIndexesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + mockService.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + Index actualResponse = client.getIndex(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.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()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + + Index actualResponse = client.getIndex(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + client.getIndex(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteIndexTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + client.deleteIndex(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.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 + public void deleteIndexTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + + client.deleteIndex(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteIndexExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5884/databases/database-5884/collectionGroups/collectionGroup-5884/indexes/indexe-5884"; + 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()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); + + Field actualResponse = client.getField(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFieldExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.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()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1275/databases/database-1275/collectionGroups/collectionGroup-1275/fields/field-1275"; + + Field actualResponse = client.getField(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getFieldExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1275/databases/database-1275/collectionGroups/collectionGroup-1275/fields/field-1275"; + client.getField(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // 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()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateFieldTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Field field = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + + Field actualResponse = client.updateFieldAsync(field).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateFieldExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Field field = + Field.newBuilder() + .setName( + FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + client.updateFieldAsync(field).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listFieldsTest() throws Exception { + Field responsesElement = Field.newBuilder().build(); + ListFieldsResponse expectedResponse = + ListFieldsResponse.newBuilder() + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFieldsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.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(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listFieldsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1737/databases/database-1737/collectionGroups/collectionGroup-1737"; + client.listFields(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void exportDocumentsTest() throws Exception { + ExportDocumentsResponse expectedResponse = + ExportDocumentsResponse.newBuilder().setOutputUriPrefix("outputUriPrefix499858205").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ExportDocumentsResponse actualResponse = client.exportDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.exportDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @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(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + ExportDocumentsResponse actualResponse = client.exportDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void exportDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.exportDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.importDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importDocumentsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void importDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.importDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void bulkDeleteDocumentsTest() throws Exception { + BulkDeleteDocumentsResponse expectedResponse = BulkDeleteDocumentsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkDeleteDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + BulkDeleteDocumentsResponse actualResponse = client.bulkDeleteDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bulkDeleteDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.bulkDeleteDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void bulkDeleteDocumentsTest2() throws Exception { + BulkDeleteDocumentsResponse expectedResponse = BulkDeleteDocumentsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkDeleteDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + BulkDeleteDocumentsResponse actualResponse = client.bulkDeleteDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void bulkDeleteDocumentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.bulkDeleteDocumentsAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + + Database actualResponse = client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-2353"; + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + + Database actualResponse = client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDatabaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2580/databases/database-2580"; + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDatabaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder() + .addAllDatabases(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDatabasesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest2() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder() + .addAllDatabases(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDatabasesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Database database = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Database actualResponse = client.updateDatabaseAsync(database, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Database database = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDatabaseAsync(database, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + Database actualResponse = client.deleteDatabaseAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.deleteDatabaseAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-2580/databases/database-2580"; + + Database actualResponse = client.deleteDatabaseAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDatabaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2580/databases/database-2580"; + client.deleteDatabaseAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + + UserCreds actualResponse = client.createUserCreds(parent, userCreds, userCredsId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + client.createUserCreds(parent, userCreds, userCredsId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + + UserCreds actualResponse = client.createUserCreds(parent, userCreds, userCredsId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + client.createUserCreds(parent, userCreds, userCredsId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.getUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.getUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + + UserCreds actualResponse = client.getUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + client.getUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUserCredsTest() throws Exception { + ListUserCredsResponse expectedResponse = + ListUserCredsResponse.newBuilder().addAllUserCreds(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListUserCredsResponse actualResponse = client.listUserCreds(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listUserCreds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUserCredsTest2() throws Exception { + ListUserCredsResponse expectedResponse = + ListUserCredsResponse.newBuilder().addAllUserCreds(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + + ListUserCredsResponse actualResponse = client.listUserCreds(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + client.listUserCreds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void enableUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.enableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void enableUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.enableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void enableUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + + UserCreds actualResponse = client.enableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void enableUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + client.enableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void disableUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.disableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void disableUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.disableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void disableUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + + UserCreds actualResponse = client.disableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void disableUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + client.disableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resetUserPasswordTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.resetUserPassword(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void resetUserPasswordExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.resetUserPassword(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resetUserPasswordTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + + UserCreds actualResponse = client.resetUserPassword(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void resetUserPasswordExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + client.resetUserPassword(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteUserCredsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + client.deleteUserCreds(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteUserCredsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.deleteUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteUserCredsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + + client.deleteUserCreds(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteUserCredsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3654/databases/database-3654/userCreds/userCred-3654"; + client.deleteUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest2() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + client.deleteBackup(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + client.deleteBackup(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void restoreDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + + Database actualResponse = client.restoreDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void restoreDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + client.restoreDatabaseAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupSchedulesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9821/databases/database-9821"; + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listBackupSchedulesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9821/databases/database-9821"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-3270/databases/database-3270/backupSchedules/backupSchedule-3270"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cloneDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("cloneDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CloneDatabaseRequest request = + CloneDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setPitrSnapshot(PitrSnapshot.newBuilder().build()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + + Database actualResponse = client.cloneDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cloneDatabaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CloneDatabaseRequest request = + CloneDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setPitrSnapshot(PitrSnapshot.newBuilder().build()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + client.cloneDatabaseAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java new file mode 100644 index 000000000000..dc336081bac0 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/FirestoreAdminClientTest.java @@ -0,0 +1,2800 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListFieldsPagedResponse; +import static com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupName; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BackupScheduleName; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.BulkDeleteDocumentsResponse; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CollectionGroupName; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DatabaseName; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.ExportDocumentsResponse; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FieldName; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.IndexName; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.LocationName; +import com.google.firestore.admin.v1.PitrSnapshot; +import com.google.firestore.admin.v1.ProjectName; +import com.google.firestore.admin.v1.RealtimeUpdatesMode; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.firestore.admin.v1.UserCredsName; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +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; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreAdminClientTest { + private static MockFirestoreAdmin mockFirestoreAdmin; + private static MockLocations mockLocations; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private FirestoreAdminClient client; + + @BeforeClass + public static void startStaticServer() { + mockFirestoreAdmin = new MockFirestoreAdmin(); + mockLocations = new MockLocations(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), + Arrays.asList(mockFirestoreAdmin, mockLocations)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + FirestoreAdminSettings settings = + FirestoreAdminSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreAdminClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(index, actualRequest.getIndex()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createIndexExceptionTest() 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(); + 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 createIndexTest2() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String parent = "parent-995424086"; + Index index = Index.newBuilder().build(); + + Index actualResponse = client.createIndexAsync(parent, index).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(index, actualRequest.getIndex()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createIndexExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + 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()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + 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)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + 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]"); + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIndexesTest2() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + 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)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listIndexesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listIndexes(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()) + .addAllFields(new ArrayList()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getIndexExceptionTest() throws Exception { + 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()) + .setMultikey(true) + .setShardCount(-495377042) + .setUnique(true) + .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. + } + } + + @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 + 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()) + .setTtlConfig(Field.TtlConfig.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getFieldExceptionTest() throws Exception { + 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()) + .setTtlConfig(Field.TtlConfig.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. + } + } + + @Test + public void updateFieldTest() throws Exception { + Field expectedResponse = + Field.newBuilder() + .setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()) + .setIndexConfig(Field.IndexConfig.newBuilder().build()) + .setTtlConfig(Field.TtlConfig.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 + public void listFieldsTest() throws Exception { + Field responsesElement = Field.newBuilder().build(); + ListFieldsResponse expectedResponse = + ListFieldsResponse.newBuilder() + .setNextPageToken("") + .addAllFields(Arrays.asList(responsesElement)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]"); + + 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.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listFieldsExceptionTest() throws Exception { + 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. + } + } + + @Test + public void exportDocumentsTest() 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); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + 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.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void exportDocumentsExceptionTest() throws Exception { + 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()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void importDocumentsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + client.importDocumentsAsync(name).get(); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ImportDocumentsRequest actualRequest = ((ImportDocumentsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void importDocumentsExceptionTest() throws Exception { + 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()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void bulkDeleteDocumentsTest() throws Exception { + BulkDeleteDocumentsResponse expectedResponse = BulkDeleteDocumentsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkDeleteDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + BulkDeleteDocumentsResponse actualResponse = client.bulkDeleteDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BulkDeleteDocumentsRequest actualRequest = ((BulkDeleteDocumentsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void bulkDeleteDocumentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.bulkDeleteDocumentsAsync(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 bulkDeleteDocumentsTest2() throws Exception { + BulkDeleteDocumentsResponse expectedResponse = BulkDeleteDocumentsResponse.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("bulkDeleteDocumentsTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String name = "name3373707"; + + BulkDeleteDocumentsResponse actualResponse = client.bulkDeleteDocumentsAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BulkDeleteDocumentsRequest actualRequest = ((BulkDeleteDocumentsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void bulkDeleteDocumentsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.bulkDeleteDocumentsAsync(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 createDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + ProjectName parent = ProjectName.of("[PROJECT]"); + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + + Database actualResponse = client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateDatabaseRequest actualRequest = ((CreateDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertEquals(databaseId, actualRequest.getDatabaseId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + client.createDatabaseAsync(parent, database, databaseId).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 createDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String parent = "parent-995424086"; + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + + Database actualResponse = client.createDatabaseAsync(parent, database, databaseId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateDatabaseRequest actualRequest = ((CreateDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertEquals(databaseId, actualRequest.getDatabaseId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createDatabaseExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + Database database = Database.newBuilder().build(); + String databaseId = "databaseId1688905718"; + client.createDatabaseAsync(parent, database, databaseId).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 getDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetDatabaseRequest actualRequest = ((GetDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + Database actualResponse = client.getDatabase(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetDatabaseRequest actualRequest = ((GetDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getDatabaseExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getDatabase(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder() + .addAllDatabases(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListDatabasesRequest actualRequest = ((ListDatabasesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listDatabasesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDatabasesTest2() throws Exception { + ListDatabasesResponse expectedResponse = + ListDatabasesResponse.newBuilder() + .addAllDatabases(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListDatabasesResponse actualResponse = client.listDatabases(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListDatabasesRequest actualRequest = ((ListDatabasesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listDatabasesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listDatabases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + Database database = Database.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Database actualResponse = client.updateDatabaseAsync(database, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateDatabaseRequest actualRequest = ((UpdateDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + Database database = Database.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDatabaseAsync(database, updateMask).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 deleteDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + Database actualResponse = client.deleteDatabaseAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteDatabaseRequest actualRequest = ((DeleteDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName name = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.deleteDatabaseAsync(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 deleteDatabaseTest2() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + String name = "name3373707"; + + Database actualResponse = client.deleteDatabaseAsync(name).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteDatabaseRequest actualRequest = ((DeleteDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteDatabaseExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteDatabaseAsync(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 createUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + + UserCreds actualResponse = client.createUserCreds(parent, userCreds, userCredsId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateUserCredsRequest actualRequest = ((CreateUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(userCreds, actualRequest.getUserCreds()); + Assert.assertEquals(userCredsId, actualRequest.getUserCredsId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + client.createUserCreds(parent, userCreds, userCredsId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + + UserCreds actualResponse = client.createUserCreds(parent, userCreds, userCredsId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateUserCredsRequest actualRequest = ((CreateUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(userCreds, actualRequest.getUserCreds()); + Assert.assertEquals(userCredsId, actualRequest.getUserCredsId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + UserCreds userCreds = UserCreds.newBuilder().build(); + String userCredsId = "userCredsId726775445"; + client.createUserCreds(parent, userCreds, userCredsId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.getUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetUserCredsRequest actualRequest = ((GetUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.getUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + UserCreds actualResponse = client.getUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetUserCredsRequest actualRequest = ((GetUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUserCredsTest() throws Exception { + ListUserCredsResponse expectedResponse = + ListUserCredsResponse.newBuilder().addAllUserCreds(new ArrayList()).build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListUserCredsResponse actualResponse = client.listUserCreds(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListUserCredsRequest actualRequest = ((ListUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listUserCreds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listUserCredsTest2() throws Exception { + ListUserCredsResponse expectedResponse = + ListUserCredsResponse.newBuilder().addAllUserCreds(new ArrayList()).build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListUserCredsResponse actualResponse = client.listUserCreds(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListUserCredsRequest actualRequest = ((ListUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listUserCreds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void enableUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.enableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + EnableUserCredsRequest actualRequest = ((EnableUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void enableUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.enableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void enableUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + UserCreds actualResponse = client.enableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + EnableUserCredsRequest actualRequest = ((EnableUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void enableUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.enableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void disableUserCredsTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.disableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DisableUserCredsRequest actualRequest = ((DisableUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void disableUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.disableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void disableUserCredsTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + UserCreds actualResponse = client.disableUserCreds(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DisableUserCredsRequest actualRequest = ((DisableUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void disableUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.disableUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resetUserPasswordTest() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + UserCreds actualResponse = client.resetUserPassword(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ResetUserPasswordRequest actualRequest = ((ResetUserPasswordRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void resetUserPasswordExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.resetUserPassword(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resetUserPasswordTest2() throws Exception { + UserCreds expectedResponse = + UserCreds.newBuilder() + .setName(UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSecurePassword("securePassword715395890") + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + UserCreds actualResponse = client.resetUserPassword(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ResetUserPasswordRequest actualRequest = ((ResetUserPasswordRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void resetUserPasswordExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.resetUserPassword(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteUserCredsTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + + client.deleteUserCreds(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteUserCredsRequest actualRequest = ((DeleteUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteUserCredsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + UserCredsName name = UserCredsName.of("[PROJECT]", "[DATABASE]", "[USER_CREDS]"); + client.deleteUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteUserCredsTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteUserCreds(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteUserCredsRequest actualRequest = ((DeleteUserCredsRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteUserCredsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteUserCreds(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupRequest actualRequest = ((GetBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDatabase(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setDatabaseUid("databaseUid816481493") + .setSnapshotTime(Timestamp.newBuilder().build()) + .setExpireTime(Timestamp.newBuilder().build()) + .setStats(Backup.Stats.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + Backup actualResponse = client.getBackup(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupRequest actualRequest = ((GetBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupsRequest actualRequest = ((ListBackupsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest2() throws Exception { + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .addAllBackups(new ArrayList()) + .addAllUnreachable(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListBackupsResponse actualResponse = client.listBackups(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupsRequest actualRequest = ((ListBackupsRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupsExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + + client.deleteBackup(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteBackup(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupRequest actualRequest = ((DeleteBackupRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void restoreDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + + Database actualResponse = client.restoreDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RestoreDatabaseRequest actualRequest = ((RestoreDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getDatabaseId(), actualRequest.getDatabaseId()); + Assert.assertEquals(request.getBackup(), actualRequest.getBackup()); + Assert.assertEquals(request.getEncryptionConfig(), actualRequest.getEncryptionConfig()); + Assert.assertEquals(request.getTagsMap(), actualRequest.getTagsMap()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void restoreDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setBackup(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + client.restoreDatabaseAsync(request).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 createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + + BackupSchedule actualResponse = client.createBackupSchedule(parent, backupSchedule); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + client.createBackupSchedule(parent, backupSchedule); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .addAllBackupSchedules(new ArrayList()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListBackupSchedulesResponse actualResponse = client.listBackupSchedules(parent); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setRetention(Duration.newBuilder().build()) + .build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateBackupScheduleRequest actualRequest = + ((UpdateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + BackupScheduleName name = BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[DATABASE]", "[BACKUP_SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestoreAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cloneDatabaseTest() throws Exception { + Database expectedResponse = + Database.newBuilder() + .setName(DatabaseName.of("[PROJECT]", "[DATABASE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDeleteTime(Timestamp.newBuilder().build()) + .setLocationId("locationId1541836720") + .setVersionRetentionPeriod(Duration.newBuilder().build()) + .setEarliestVersionTime(Timestamp.newBuilder().build()) + .setKeyPrefix("keyPrefix-2076395055") + .setCmekConfig(Database.CmekConfig.newBuilder().build()) + .setPreviousId("previousId-32447886") + .setSourceInfo(Database.SourceInfo.newBuilder().build()) + .putAllTags(new HashMap()) + .setFreeTier(true) + .setEtag("etag3123477") + .setRealtimeUpdatesMode(RealtimeUpdatesMode.forNumber(0)) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("cloneDatabaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockFirestoreAdmin.addResponse(resultOperation); + + CloneDatabaseRequest request = + CloneDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setPitrSnapshot(PitrSnapshot.newBuilder().build()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + + Database actualResponse = client.cloneDatabaseAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CloneDatabaseRequest actualRequest = ((CloneDatabaseRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getParent(), actualRequest.getParent()); + Assert.assertEquals(request.getDatabaseId(), actualRequest.getDatabaseId()); + Assert.assertEquals(request.getPitrSnapshot(), actualRequest.getPitrSnapshot()); + Assert.assertEquals(request.getEncryptionConfig(), actualRequest.getEncryptionConfig()); + Assert.assertEquals(request.getTagsMap(), actualRequest.getTagsMap()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void cloneDatabaseExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestoreAdmin.addException(exception); + + try { + CloneDatabaseRequest request = + CloneDatabaseRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDatabaseId("databaseId1688905718") + .setPitrSnapshot(PitrSnapshot.newBuilder().build()) + .setEncryptionConfig(Database.EncryptionConfig.newBuilder().build()) + .putAllTags(new HashMap()) + .build(); + client.cloneDatabaseAsync(request).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()); + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java new file mode 100644 index 000000000000..fab780a2b442 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdmin.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockFirestoreAdmin implements MockGrpcService { + private final MockFirestoreAdminImpl serviceImpl; + + public MockFirestoreAdmin() { + serviceImpl = new MockFirestoreAdminImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java new file mode 100644 index 000000000000..45d21acddf80 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockFirestoreAdminImpl.java @@ -0,0 +1,774 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.firestore.admin.v1.Backup; +import com.google.firestore.admin.v1.BackupSchedule; +import com.google.firestore.admin.v1.BulkDeleteDocumentsRequest; +import com.google.firestore.admin.v1.CloneDatabaseRequest; +import com.google.firestore.admin.v1.CreateBackupScheduleRequest; +import com.google.firestore.admin.v1.CreateDatabaseRequest; +import com.google.firestore.admin.v1.CreateIndexRequest; +import com.google.firestore.admin.v1.CreateUserCredsRequest; +import com.google.firestore.admin.v1.Database; +import com.google.firestore.admin.v1.DeleteBackupRequest; +import com.google.firestore.admin.v1.DeleteBackupScheduleRequest; +import com.google.firestore.admin.v1.DeleteDatabaseRequest; +import com.google.firestore.admin.v1.DeleteIndexRequest; +import com.google.firestore.admin.v1.DeleteUserCredsRequest; +import com.google.firestore.admin.v1.DisableUserCredsRequest; +import com.google.firestore.admin.v1.EnableUserCredsRequest; +import com.google.firestore.admin.v1.ExportDocumentsRequest; +import com.google.firestore.admin.v1.Field; +import com.google.firestore.admin.v1.FirestoreAdminGrpc.FirestoreAdminImplBase; +import com.google.firestore.admin.v1.GetBackupRequest; +import com.google.firestore.admin.v1.GetBackupScheduleRequest; +import com.google.firestore.admin.v1.GetDatabaseRequest; +import com.google.firestore.admin.v1.GetFieldRequest; +import com.google.firestore.admin.v1.GetIndexRequest; +import com.google.firestore.admin.v1.GetUserCredsRequest; +import com.google.firestore.admin.v1.ImportDocumentsRequest; +import com.google.firestore.admin.v1.Index; +import com.google.firestore.admin.v1.ListBackupSchedulesRequest; +import com.google.firestore.admin.v1.ListBackupSchedulesResponse; +import com.google.firestore.admin.v1.ListBackupsRequest; +import com.google.firestore.admin.v1.ListBackupsResponse; +import com.google.firestore.admin.v1.ListDatabasesRequest; +import com.google.firestore.admin.v1.ListDatabasesResponse; +import com.google.firestore.admin.v1.ListFieldsRequest; +import com.google.firestore.admin.v1.ListFieldsResponse; +import com.google.firestore.admin.v1.ListIndexesRequest; +import com.google.firestore.admin.v1.ListIndexesResponse; +import com.google.firestore.admin.v1.ListUserCredsRequest; +import com.google.firestore.admin.v1.ListUserCredsResponse; +import com.google.firestore.admin.v1.ResetUserPasswordRequest; +import com.google.firestore.admin.v1.RestoreDatabaseRequest; +import com.google.firestore.admin.v1.UpdateBackupScheduleRequest; +import com.google.firestore.admin.v1.UpdateDatabaseRequest; +import com.google.firestore.admin.v1.UpdateFieldRequest; +import com.google.firestore.admin.v1.UserCreds; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Empty; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockFirestoreAdminImpl extends FirestoreAdminImplBase { + private List requests; + private Queue responses; + + public MockFirestoreAdminImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void createIndex(CreateIndexRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof ListIndexesResponse) { + requests.add(request); + responseObserver.onNext(((ListIndexesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Index) { + requests.add(request); + responseObserver.onNext(((Index) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Field) { + requests.add(request); + responseObserver.onNext(((Field) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof ListFieldsResponse) { + requests.add(request); + responseObserver.onNext(((ListFieldsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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()))); + } + } + + @Override + public void bulkDeleteDocuments( + BulkDeleteDocumentsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method BulkDeleteDocuments, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createDatabase( + CreateDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getDatabase(GetDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Database) { + requests.add(request); + responseObserver.onNext(((Database) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Database.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listDatabases( + ListDatabasesRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListDatabasesResponse) { + requests.add(request); + responseObserver.onNext(((ListDatabasesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListDatabases, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListDatabasesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updateDatabase( + UpdateDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteDatabase( + DeleteDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createUserCreds( + CreateUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof UserCreds) { + requests.add(request); + responseObserver.onNext(((UserCreds) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + UserCreds.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getUserCreds( + GetUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof UserCreds) { + requests.add(request); + responseObserver.onNext(((UserCreds) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + UserCreds.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listUserCreds( + ListUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListUserCredsResponse) { + requests.add(request); + responseObserver.onNext(((ListUserCredsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListUserCredsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void enableUserCreds( + EnableUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof UserCreds) { + requests.add(request); + responseObserver.onNext(((UserCreds) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method EnableUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + UserCreds.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void disableUserCreds( + DisableUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof UserCreds) { + requests.add(request); + responseObserver.onNext(((UserCreds) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DisableUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + UserCreds.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void resetUserPassword( + ResetUserPasswordRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof UserCreds) { + requests.add(request); + responseObserver.onNext(((UserCreds) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ResetUserPassword, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + UserCreds.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteUserCreds( + DeleteUserCredsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteUserCreds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getBackup(GetBackupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Backup) { + requests.add(request); + responseObserver.onNext(((Backup) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetBackup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Backup.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listBackups( + ListBackupsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListBackupsResponse) { + requests.add(request); + responseObserver.onNext(((ListBackupsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListBackups, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListBackupsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteBackup(DeleteBackupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteBackup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void restoreDatabase( + RestoreDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method RestoreDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void createBackupSchedule( + CreateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateBackupSchedule, expected %s or" + + " %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getBackupSchedule( + GetBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listBackupSchedules( + ListBackupSchedulesRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListBackupSchedulesResponse) { + requests.add(request); + responseObserver.onNext(((ListBackupSchedulesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListBackupSchedules, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListBackupSchedulesResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updateBackupSchedule( + UpdateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateBackupSchedule, expected %s or" + + " %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteBackupSchedule( + DeleteBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteBackupSchedule, expected %s or" + + " %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void cloneDatabase( + CloneDatabaseRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Operation) { + requests.add(request); + responseObserver.onNext(((Operation) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CloneDatabase, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java new file mode 100644 index 000000000000..522dacd36bfc --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java new file mode 100644 index 000000000000..c99007072820 --- /dev/null +++ b/java-firestore/google-cloud-firestore-admin/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } +} diff --git a/java-firestore/google-cloud-firestore-bom/pom.xml b/java-firestore/google-cloud-firestore-bom/pom.xml new file mode 100644 index 000000000000..b433c2491535 --- /dev/null +++ b/java-firestore/google-cloud-firestore-bom/pom.xml @@ -0,0 +1,102 @@ + + + 4.0.0 + com.google.cloud + google-cloud-firestore-bom + 3.38.1-SNAPSHOT + pom + + com.google.cloud + google-cloud-pom-parent + 1.82.0-SNAPSHOT + ../../google-cloud-pom-parent/pom.xml + + + Google Cloud Firestore BOM + https://github.com/googleapis/google-cloud-java + + BOM for Google Cloud Firestore + + + + Google LLC + + + + + chingor13 + Jeff Ching + chingor@google.com + Google LLC + + Developer + + + + + + scm:git:https://github.com/googleapis/google-cloud-java.git + scm:git:git@github.com:googleapis/google-cloud-java.git + https://github.com/googleapis/google-cloud-java + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + + com.google.cloud + google-cloud-firestore + 3.38.1-SNAPSHOT + + + com.google.cloud + google-cloud-firestore-admin + 3.38.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + + + com.google.cloud + proto-google-cloud-firestore-bundle-v1 + 3.38.1-SNAPSHOT + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + diff --git a/java-firestore/google-cloud-firestore/EnableAutoValue.txt b/java-firestore/google-cloud-firestore/EnableAutoValue.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/java-firestore/google-cloud-firestore/clirr-ignored-differences.xml b/java-firestore/google-cloud-firestore/clirr-ignored-differences.xml new file mode 100644 index 000000000000..6685f0d8a23e --- /dev/null +++ b/java-firestore/google-cloud-firestore/clirr-ignored-differences.xml @@ -0,0 +1,371 @@ + + + + + + + + 3005 + com/google/cloud/firestore/Transaction + + + + + 7012 + com/google/cloud/firestore/Firestore + void shutdown() + + + 7012 + com/google/cloud/firestore/Firestore + void shutdownNow() + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + void shutdown() + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + void shutdownNow() + + + + + 7012 + com/google/cloud/firestore/Firestore + com.google.cloud.firestore.FirestoreBundle$Builder bundleBuilder() + + + 7012 + com/google/cloud/firestore/Firestore + com.google.cloud.firestore.FirestoreBundle$Builder bundleBuilder(java.lang.String) + + + + + 7002 + com/google/cloud/firestore/DocumentReference + java.lang.Iterable getCollections() + + + 7002 + com/google/cloud/firestore/Firestore + java.lang.Iterable getCollections() + + + 7002 + com/google/cloud/firestore/FirestoreOptions$Builder + com.google.cloud.firestore.FirestoreOptions$Builder setTimestampsInSnapshotsEnabled(boolean) + + + 7002 + com/google/cloud/firestore/FirestoreOptions + boolean areTimestampsInSnapshotsEnabled() + + + 8001 + com/google/cloud/firestore/v1beta1/**/* + * + + + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation createIndex(com.google.firestore.admin.v1.ParentName, com.google.firestore.admin.v1.Index) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation createIndex(java.lang.String, com.google.firestore.admin.v1.Index) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation createIndex(com.google.firestore.admin.v1.CreateIndexRequest) + + + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation exportDocuments(com.google.firestore.admin.v1.DatabaseName) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation exportDocuments(java.lang.String) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation exportDocuments(com.google.firestore.admin.v1.ExportDocumentsRequest) + + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation importDocuments(com.google.firestore.admin.v1.DatabaseName) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation importDocuments(java.lang.String) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation importDocuments(com.google.firestore.admin.v1.ImportDocumentsRequest) + + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation updateField(com.google.firestore.admin.v1.Field) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation updateField(com.google.firestore.admin.v1.UpdateFieldRequest) + + + 7002 + com/google/cloud/firestore/v1/FirestoreAdminClient + com.google.longrunning.Operation updateField(com.google.firestore.admin.v1.UpdateFieldRequest) + + + + + 7002 + com/google/cloud/firestore/v1/FirestoreClient + void deleteDocument(com.google.firestore.v1.AnyPathName) + + + + + 7005 + com/google/cloud/firestore/v1/FirestoreAdminClient* + com.google.cloud.firestore.v1.FirestoreAdminClient$List*PagedResponse list*(com.google.firestore.admin.v1.ParentName) + com.google.cloud.firestore.v1.FirestoreAdminClient$List*PagedResponse list*(com.google.firestore.admin.v1.CollectionGroupName) + + + + + 8001 + com/google/cloud/firestore/v1/**/*FirestoreAdmin* + * + + + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + com.google.api.gax.rpc.UnaryCallable partitionQueryPagedCallable() + + + 7006 + com/google/cloud/firestore/Firestore + com.google.cloud.firestore.Query collectionGroup(java.lang.String) + com.google.cloud.firestore.CollectionGroup + + + + + 7012 + com/google/cloud/firestore/Firestore + com.google.cloud.firestore.BulkWriter bulkWriter(*) + + + 7006 + com/google/cloud/firestore/UpdateBuilder + com.google.cloud.firestore.UpdateBuilder create(*) + java.lang.Object + + + 7006 + com/google/cloud/firestore/UpdateBuilder + com.google.cloud.firestore.UpdateBuilder delete(*) + java.lang.Object + + + 7006 + com/google/cloud/firestore/UpdateBuilder + com.google.cloud.firestore.UpdateBuilder set(*) + java.lang.Object + + + 7006 + com/google/cloud/firestore/UpdateBuilder + com.google.cloud.firestore.UpdateBuilder update(*) + java.lang.Object + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + com.google.api.gax.rpc.UnaryCallable batchWriteCallable() + + + 1001 + com/google/cloud/firestore/BatchWriteResult + + + 6004 + com/google/cloud/firestore/UpdateBuilder + pendingOperations + java.util.Map + java.util.List + + + + + 6001 + com/google/cloud/firestore/UpdateBuilder + pendingOperations + + + 6001 + com/google/cloud/firestore/UpdateBuilder + state + + + 6010 + com/google/cloud/firestore/UpdateBuilder + writes + + + + + 8001 + com/google/cloud/firestore/FirestoreOptions$Builder$FakeCredentials + * + + + + + 7012 + com/google/cloud/firestore/Firestore + com.google.api.core.ApiFuture recursiveDelete(*) + + + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + com.google.api.gax.rpc.ServerStreamingCallable runAggregationQueryCallable() + + + + + 8001 + com/google/cloud/firestore/collection/StandardComparator + * + + + + + 8001 + com/google/cloud/firestore/encoding/CustomClassMapper + * + + + + + 7002 + com/google/cloud/firestore/QuerySnapshot + com.google.cloud.firestore.Query getQuery() + + + + + 7002 + com/google/cloud/firestore/FirestoreOpenTelemetryOptions + boolean isTracingEnabled() + + + 7002 + com/google/cloud/firestore/FirestoreOpenTelemetryOptions$Builder + com.google.cloud.firestore.FirestoreOpenTelemetryOptions$Builder setTracingEnabled(boolean) + + + + com/google/cloud/firestore/StreamableQuery + 7009 + void internalStream(*) + + + + + 6011 + com/google/cloud/firestore/telemetry/TraceUtil + SPAN_NAME_* + + + + + 7005 + com/google/cloud/firestore/StreamableQuery + void internalStream(*) + * + + + + + 7012 + com/google/cloud/firestore/Firestore + com.google.cloud.firestore.PipelineSource pipeline() + + + 7013 + com/google/cloud/firestore/Transaction + com.google.api.core.ApiFuture execute(com.google.cloud.firestore.Pipeline) + + + 7013 + com/google/cloud/firestore/Transaction + com.google.api.core.ApiFuture execute(com.google.cloud.firestore.Pipeline, com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions) + + + 7012 + com/google/cloud/firestore/spi/v1/FirestoreRpc + com.google.api.gax.rpc.ServerStreamingCallable executePipelineCallable() + + diff --git a/java-firestore/google-cloud-firestore/pom.xml b/java-firestore/google-cloud-firestore/pom.xml new file mode 100644 index 000000000000..fe24ca1fabdd --- /dev/null +++ b/java-firestore/google-cloud-firestore/pom.xml @@ -0,0 +1,375 @@ + + + 4.0.0 + google-cloud-firestore + 3.38.1-SNAPSHOT + jar + Google Cloud Firestore + https://github.com/googleapis/google-cloud-java + + Java idiomatic client for Google Cloud Firestore. + + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + google-cloud-firestore + + + + ${project.groupId} + google-cloud-core-grpc + + + com.google.api.grpc + proto-google-cloud-firestore-v1 + + + com.google.cloud + proto-google-cloud-firestore-bundle-v1 + + + com.google.auto.value + auto-value-annotations + + + com.google.api.grpc + grpc-google-cloud-firestore-v1 + test + + + com.google.code.findbugs + jsr305 + + + com.google.api + api-common + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api + gax + + + io.grpc + grpc-api + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + com.google.guava + guava + + + org.threeten + threetenbp + + + io.grpc + grpc-stub + + + com.google.auth + google-auth-library-credentials + + + com.google.cloud + google-cloud-core + + + com.google.code.gson + gson + runtime + + + com.google.protobuf + protobuf-java-util + + + + io.opentelemetry + opentelemetry-api + + + io.opentelemetry + opentelemetry-context + + + io.opentelemetry.instrumentation + opentelemetry-grpc-1.6 + + + io.opentelemetry + opentelemetry-sdk + + + io.opentelemetry + opentelemetry-sdk-metrics + + + com.google.cloud.opentelemetry + exporter-metrics + + + io.opentelemetry.semconv + opentelemetry-semconv + + + com.google.re2j + re2j + + + + + + junit + junit + test + + + com.google.truth + truth + test + + + org.mockito + mockito-core + 4.11.0 + test + + + com.google.api + gax + testlib + test + + + com.google.api + gax-grpc + testlib + test + + + com.google.api + gax-httpjson + testlib + test + + + com.google.api.grpc + grpc-google-common-protos + test + + + com.google.cloud + google-cloud-conformance-tests + 0.3.7 + test + + + org.checkerframework + checker-qual + + + + + org.apache.commons + commons-lang3 + 3.18.0 + test + + + io.opentelemetry + opentelemetry-sdk-testing + test + + + io.opentelemetry + opentelemetry-sdk-trace + test + + + io.opentelemetry + opentelemetry-sdk-common + test + + + com.google.cloud.opentelemetry + exporter-trace + 0.36.0 + test + + + com.google.api.grpc + proto-google-cloud-trace-v1 + 2.87.0 + test + + + com.google.cloud + google-cloud-trace + 2.87.0 + test + + + com.google.http-client + google-http-client + test + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + com.diffplug.spotless + spotless-maven-plugin + 2.45.0 + + + + src/main/java/**/*.kt + src/test/java/**/*.kt + + + + 0.46 + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + default-compile + none + + + default-testCompile + none + + + compile + compile + + compile + + + + testCompile + test-compile + + testCompile + + + + + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + + java17-test + + + + runTestsWithJava17 + true + + false + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-test-source + generate-test-sources + + add-test-source + + + + src/test-jdk17/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + true + + + 17 + 17 + + -parameters + --add-opens=java.base/java.lang=ALL-UNNAMED + --add-opens=java.base/java.util=ALL-UNNAMED + + + + + + + + diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateField.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateField.java new file mode 100644 index 000000000000..f0cc99aac174 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateField.java @@ -0,0 +1,209 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Represents an aggregation that can be performed by Firestore. */ +public abstract class AggregateField { + /** + * Create a {@link CountAggregateField} object that can be used to compute the count of documents + * in the result set of a query. + * + *

The result of a count operation will always be a 64-bit integer value. + * + * @return The `CountAggregateField` object that can be used to compute the count of documents in + * the result set of a query. + */ + @Nonnull + public static CountAggregateField count() { + return new CountAggregateField(); + } + + /** + * Create a {@link SumAggregateField} object that can be used to compute the sum of a specified + * field over a range of documents in the result set of a query. + * + *

The result of a sum operation will always be a 64-bit integer value, a double, or NaN. + * + *

    + *
  • Summing over zero documents or fields will result in 0L. + *
  • Summing over NaN will result in a double value representing NaN. + *
  • A sum that overflows the maximum representable 64-bit integer value will result in a + * double return value. This may result in lost precision of the result. + *
  • A sum that overflows the maximum representable double value will result in a double + * return value representing infinity. + *
+ * + * @param field Specifies the field to sum across the result set. + * @return The `SumAggregateField` object that can be used to compute the sum of a specified field + * over a range of documents in the result set of a query. + */ + @Nonnull + public static SumAggregateField sum(@Nonnull String field) { + return new SumAggregateField(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Create a {@link SumAggregateField} object that can be used to compute the sum of a specified + * field over a range of documents in the result set of a query. + * + *

The result of a sum operation will always be a 64-bit integer value, a double, or NaN. + * + *

    + *
  • Summing over zero documents or fields will result in 0L. + *
  • Summing over NaN will result in a double value representing NaN. + *
  • A sum that overflows the maximum representable 64-bit integer value will result in a + * double return value. This may result in lost precision of the result. + *
  • A sum that overflows the maximum representable double value will result in a double + * return value representing infinity. + *
+ * + * @param fieldPath Specifies the field to sum across the result set. + * @return The `SumAggregateField` object that can be used to compute the sum of a specified field + * over a range of documents in the result set of a query. + */ + @Nonnull + public static SumAggregateField sum(@Nonnull FieldPath fieldPath) { + return new SumAggregateField(fieldPath); + } + + /** + * Create an {@link AverageAggregateField} object that can be used to compute the average of a + * specified field over a range of documents in the result set of a query. + * + *

The result of an average operation will always be a double or NaN. + * + *

    + *
  • Averaging over zero documents or fields will result in a double value representing NaN. + *
  • Averaging over NaN will result in a double value representing NaN. + *
+ * + * @param field Specifies the field to average across the result set. + * @return The `AverageAggregateField` object that can be used to compute the average of a + * specified field over a range of documents in the result set of a query. + */ + @Nonnull + public static AverageAggregateField average(@Nonnull String field) { + return new AverageAggregateField(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Create an {@link AverageAggregateField} object that can be used to compute the average of a + * specified field over a range of documents in the result set of a query. + * + *

The result of an average operation will always be a double or NaN. + * + *

    + *
  • Averaging over zero documents or fields will result in a double value representing NaN. + *
  • Averaging over NaN will result in a double value representing NaN. + *
+ * + * @param fieldPath Specifies the field to average across the result set. + * @return The `AverageAggregateField` object that can be used to compute the average of a + * specified field over a range of documents in the result set of a query. + */ + @Nonnull + public static AverageAggregateField average(@Nonnull FieldPath fieldPath) { + return new AverageAggregateField(fieldPath); + } + + /** The field over which the aggregation is performed. */ + @Nullable FieldPath fieldPath; + + /** Returns the alias used internally for this aggregate field. */ + @Nonnull + String getAlias() { + // Use $operator_$field format if it's an aggregation of a specific field. For example: sum_foo. + // Use $operator format if there's no field. For example: count. + return getOperator() + (fieldPath == null ? "" : "_" + fieldPath.getEncodedPath()); + } + + /** + * Returns the field on which the aggregation takes place. Returns an empty string if there's no + * field (this applies to count). + */ + @Nonnull + String getFieldPath() { + return fieldPath == null ? "" : fieldPath.getEncodedPath(); + } + + /** Returns a string representation of this aggregation's operator. For example: "sum" */ + abstract @Nonnull String getOperator(); + + /** + * Returns true if the given object is equal to this object. Two `AggregateField` objects are + * considered equal if they have the same operator and operate on the same field. + */ + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof AggregateField)) { + return false; + } + AggregateField otherAggregateField = (AggregateField) other; + return getOperator().equals(otherAggregateField.getOperator()) + && getFieldPath().equals(otherAggregateField.getFieldPath()); + } + + /** Calculates and returns the hash code for this object. */ + @Override + public int hashCode() { + return Objects.hash(getOperator(), getFieldPath()); + } + + /** Represents a "sum" aggregation that can be performed by Firestore. */ + public static class SumAggregateField extends AggregateField { + private SumAggregateField(@Nonnull FieldPath field) { + fieldPath = field; + } + + @Override + @Nonnull + public String getOperator() { + return "sum"; + } + } + + /** Represents an "average" aggregation that can be performed by Firestore. */ + public static class AverageAggregateField extends AggregateField { + private AverageAggregateField(@Nonnull FieldPath field) { + fieldPath = field; + } + + @Override + @Nonnull + public String getOperator() { + return "average"; + } + } + + /** Represents a "count" aggregation that can be performed by Firestore. */ + public static class CountAggregateField extends AggregateField { + private CountAggregateField() {} + + @Override + @Nonnull + public String getOperator() { + return "count"; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java new file mode 100644 index 000000000000..dc6962ff90ff --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuery.java @@ -0,0 +1,584 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_RUN_AGGREGATION_QUERY; +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_ATTEMPT; + +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamController; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.pipeline.expressions.AliasedAggregate; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreSettings; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.StructuredAggregationQuery; +import com.google.firestore.v1.StructuredAggregationQuery.Aggregation; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.Value; +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** A query that calculates aggregations over an underlying query. */ +@InternalExtensionOnly +public class AggregateQuery { + @Nonnull private final Query query; + + @Nonnull private final List aggregateFieldList; + + @Nonnull private final Map aliasMap; + + AggregateQuery(@Nonnull Query query, @Nonnull List aggregateFields) { + this.query = query; + this.aggregateFieldList = aggregateFields; + this.aliasMap = new HashMap<>(); + } + + @Nonnull + private TraceUtil getTraceUtil() { + return query.getFirestore().getOptions().getTraceUtil(); + } + + @Nonnull + private MetricsContext createMetricsContext(String method) { + return query.getFirestore().getOptions().getMetricsUtil().createMetricsContext(method); + } + + /** Returns the query whose aggregations will be calculated by this object. */ + @Nonnull + public Query getQuery() { + return query; + } + + Pipeline pipeline() { + Pipeline pipeline = getQuery().pipeline(); + return pipeline.aggregate( + this.aggregateFieldList.stream() + .map(PipelineUtils::toPipelineAggregatorTarget) + .toArray(AliasedAggregate[]::new)); + } + + /** + * Executes this query. + * + * @return An {@link ApiFuture} that will be resolved with the results of the query. + */ + @Nonnull + public ApiFuture get() { + return get(null, null); + } + + /** + * Plans and optionally executes this query. Returns an ApiFuture that will be resolved with the + * planner information, statistics from the query execution (if any), and the query results (if + * any). + * + * @return An ApiFuture that will be resolved with the planner information, statistics from the + * query execution (if any), and the query results (if any). + */ + @Nonnull + public ApiFuture> explain(ExplainOptions options) { + TraceUtil.Span span = + getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_AGGREGATION_QUERY_GET); + + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_RUN_AGGREGATION_QUERY_EXPLAIN); + + try (Scope ignored = span.makeCurrent()) { + AggregateQueryExplainResponseDeliverer responseDeliverer = + new AggregateQueryExplainResponseDeliverer( + /* transactionId= */ null, + /* readTime= */ null, + /* startTimeNanos= */ query.rpcContext.getClock().nanoTime(), + /* explainOptions= */ options, + metricsContext); + runQuery(responseDeliverer, /* attempt */ 0); + ApiFuture> result = responseDeliverer.getFuture(); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + @Nonnull + ApiFuture get( + @Nullable final ByteString transactionId, @Nullable com.google.protobuf.Timestamp readTime) { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + transactionId == null + ? TelemetryConstants.METHOD_NAME_AGGREGATION_QUERY_GET + : TelemetryConstants.METHOD_NAME_TRANSACTION_GET_AGGREGATION_QUERY); + + MetricsContext metricsContext = + createMetricsContext( + transactionId == null + ? TelemetryConstants.METHOD_NAME_RUN_AGGREGATION_QUERY_GET + : TelemetryConstants.METHOD_NAME_RUN_AGGREGATION_QUERY_TRANSACTIONAL); + + try (Scope ignored = span.makeCurrent()) { + AggregateQueryResponseDeliverer responseDeliverer = + new AggregateQueryResponseDeliverer( + transactionId, + readTime, + /* startTimeNanos= */ query.rpcContext.getClock().nanoTime(), + metricsContext); + runQuery(responseDeliverer, /* attempt= */ 0); + ApiFuture result = responseDeliverer.getFuture(); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + private void runQuery(ResponseDeliverer responseDeliverer, int attempt) { + RunAggregationQueryRequest request = + toProto( + responseDeliverer.getTransactionId(), + responseDeliverer.getReadTime(), + responseDeliverer.getExplainOptions()); + AggregateQueryResponseObserver responseObserver = + new AggregateQueryResponseObserver(responseDeliverer, attempt); + ServerStreamingCallable callable = + query.rpcContext.getClient().runAggregationQueryCallable(); + query.rpcContext.streamRequest(request, responseObserver, callable); + } + + @Nonnull + private Map convertServerAggregateFieldsMapToClientAggregateFieldsMap( + @Nonnull Map data) { + ImmutableMap.Builder builder = ImmutableMap.builder(); + data.forEach((serverAlias, value) -> builder.put(aliasMap.get(serverAlias), value)); + return builder.build(); + } + + private abstract static class ResponseDeliverer { + private final @Nullable ByteString transactionId; + private final @Nullable com.google.protobuf.Timestamp readTime; + private final long startTimeNanos; + private final SettableApiFuture future = SettableApiFuture.create(); + private MetricsContext metricsContext; + + ResponseDeliverer( + @Nullable ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime, + long startTimeNanos, + MetricsContext metricsContext) { + this.transactionId = transactionId; + this.readTime = readTime; + this.startTimeNanos = startTimeNanos; + this.metricsContext = metricsContext; + } + + @Nullable + ByteString getTransactionId() { + return transactionId; + } + + @Nullable + com.google.protobuf.Timestamp getReadTime() { + return readTime; + } + + long getStartTimeNanos() { + return startTimeNanos; + } + + @Nullable + ExplainOptions getExplainOptions() { + return null; + } + + ApiFuture getFuture() { + return future; + } + + void deliverFirstResponse() { + metricsContext.recordLatency(MetricType.FIRST_RESPONSE_LATENCY); + } + + void deliverError(Throwable throwable) { + future.setException(throwable); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable); + } + + void deliverResult( + @Nullable Map serverData, + Timestamp readTime, + @Nullable ExplainMetrics metrics) { + try { + T result = processResult(serverData, readTime, metrics); + future.set(result); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + } catch (Exception error) { + deliverError(error); + } + } + + abstract T processResult( + @Nullable Map serverData, + Timestamp readTime, + @Nullable ExplainMetrics metrics); + } + + private class AggregateQueryResponseDeliverer extends ResponseDeliverer { + AggregateQueryResponseDeliverer( + @Nullable ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime, + long startTimeNanos, + MetricsContext metricsContext) { + super(transactionId, readTime, startTimeNanos, metricsContext); + } + + @Override + AggregateQuerySnapshot processResult( + @Nullable Map serverData, + Timestamp readTime, + @Nullable ExplainMetrics metrics) { + if (serverData == null) { + throw new RuntimeException("Did not receive any aggregate query results."); + } + return new AggregateQuerySnapshot( + AggregateQuery.this, + readTime, + convertServerAggregateFieldsMapToClientAggregateFieldsMap(serverData)); + } + } + + private final class AggregateQueryExplainResponseDeliverer + extends ResponseDeliverer> { + private final @Nullable ExplainOptions explainOptions; + + AggregateQueryExplainResponseDeliverer( + @Nullable ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime, + long startTimeNanos, + @Nullable ExplainOptions explainOptions, + MetricsContext metricsContext) { + super(transactionId, readTime, startTimeNanos, metricsContext); + this.explainOptions = explainOptions; + } + + @Override + @Nullable + ExplainOptions getExplainOptions() { + return explainOptions; + } + + @Override + ExplainResults processResult( + @Nullable Map serverData, + Timestamp readTime, + @Nullable ExplainMetrics metrics) { + // The server is required to provide ExplainMetrics for explain queries. + if (metrics == null) { + throw new RuntimeException("Did not receive any metrics for explain query."); + } + AggregateQuerySnapshot snapshot = + serverData == null + ? null + : new AggregateQuerySnapshot( + AggregateQuery.this, + readTime, + convertServerAggregateFieldsMapToClientAggregateFieldsMap(serverData)); + return new ExplainResults<>(metrics, snapshot); + } + } + + private final class AggregateQueryResponseObserver + implements ResponseObserver { + private final ResponseDeliverer responseDeliverer; + private Timestamp readTime = Timestamp.MAX_VALUE; + @Nullable private Map aggregateFieldsMap = null; + @Nullable private ExplainMetrics metrics = null; + private int attempt; + private boolean firstResponse = false; + + AggregateQueryResponseObserver(ResponseDeliverer responseDeliverer, int attempt) { + this.responseDeliverer = responseDeliverer; + this.attempt = attempt; + } + + Map getAttemptAttributes() { + return Collections.singletonMap(ATTRIBUTE_KEY_ATTEMPT, attempt); + } + + private boolean isExplainQuery() { + return this.responseDeliverer.getExplainOptions() != null; + } + + @Override + public void onStart(StreamController streamController) { + getTraceUtil() + .currentSpan() + .addEvent(METHOD_NAME_RUN_AGGREGATION_QUERY + " Stream started.", getAttemptAttributes()); + } + + @Override + public void onResponse(RunAggregationQueryResponse response) { + if (!firstResponse) { + firstResponse = true; + responseDeliverer.deliverFirstResponse(); + } + + getTraceUtil() + .currentSpan() + .addEvent( + METHOD_NAME_RUN_AGGREGATION_QUERY + " Response Received.", getAttemptAttributes()); + if (response.hasReadTime()) { + readTime = Timestamp.fromProto(response.getReadTime()); + } + + if (response.hasResult()) { + aggregateFieldsMap = response.getResult().getAggregateFieldsMap(); + } + + if (response.hasExplainMetrics()) { + metrics = new ExplainMetrics(response.getExplainMetrics()); + } + + if (!isExplainQuery()) { + // Deliver the result; even though the `RunAggregationQuery` RPC is a "streaming" RPC, + // meaning that `onResponse()` can be called multiple times, it _should_ only be called + // once for non-explain queries. But even if it is called more than once, + // `responseDeliverer` will drop superfluous results. For explain queries, there will + // be more than one response, and the last response will contain the metrics. + onComplete(); + } + } + + @Override + public void onError(Throwable throwable) { + if (shouldRetry(throwable)) { + getTraceUtil() + .currentSpan() + .addEvent( + METHOD_NAME_RUN_AGGREGATION_QUERY + ": Retryable Error", + Collections.singletonMap("error.message", throwable.toString())); + + runQuery(responseDeliverer, attempt + 1); + } else { + getTraceUtil() + .currentSpan() + .addEvent( + METHOD_NAME_RUN_AGGREGATION_QUERY + ": Error", + Collections.singletonMap("error.message", throwable.toString())); + responseDeliverer.deliverError(throwable); + } + } + + private boolean shouldRetry(Throwable throwable) { + // Do not retry EXPLAIN requests because it'd be executing + // multiple queries. This means stats would have to be aggregated, + // and that may not even make sense for many statistics. + if (isExplainQuery()) { + return false; + } + + Set retryableCodes = + FirestoreSettings.newBuilder().runAggregationQuerySettings().getRetryableCodes(); + return query.shouldRetryQuery( + throwable, + responseDeliverer.getTransactionId(), + responseDeliverer.getStartTimeNanos(), + retryableCodes); + } + + @Override + public void onComplete() { + responseDeliverer.deliverResult(aggregateFieldsMap, readTime, metrics); + } + } + + /** + * Returns the {@link RunAggregationQueryRequest} that this AggregateQuery instance represents. + * The request contain the serialized form of all aggregations and Query constraints. + * + * @return the serialized RunAggregationQueryRequest + */ + @Nonnull + public RunAggregationQueryRequest toProto() { + return toProto(/* transactionId= */ null, /* readTime= */ null, /* explainOptions= */ null); + } + + @Nonnull + RunAggregationQueryRequest toProto( + @Nullable final ByteString transactionId, + @Nullable final com.google.protobuf.Timestamp readTime, + @Nullable ExplainOptions explainOptions) { + RunQueryRequest runQueryRequest = query.toProto(); + + RunAggregationQueryRequest.Builder request = RunAggregationQueryRequest.newBuilder(); + request.setParent(runQueryRequest.getParent()); + if (transactionId != null) { + request.setTransaction(transactionId); + } + if (readTime != null) { + request.setReadTime(readTime); + } + + if (explainOptions != null) { + request.setExplainOptions(explainOptions.toProto()); + } + + StructuredAggregationQuery.Builder structuredAggregationQuery = + request.getStructuredAggregationQueryBuilder(); + structuredAggregationQuery.setStructuredQuery(runQueryRequest.getStructuredQuery()); + + // We use this set to remove duplicate aggregates. + // For example, `aggregate(sum("foo"), sum("foo"))` + HashSet uniqueAggregates = new HashSet<>(); + List aggregations = new ArrayList<>(); + int aggregationNum = 0; + for (AggregateField aggregateField : aggregateFieldList) { + // `getAlias()` provides a unique representation of an AggregateField. + boolean isNewAggregateField = uniqueAggregates.add(aggregateField.getAlias()); + if (!isNewAggregateField) { + // This is a duplicate AggregateField. We don't need to include it in the request. + continue; + } + + // If there's a field for this aggregation, build its proto. + StructuredQuery.FieldReference field = null; + if (!aggregateField.getFieldPath().isEmpty()) { + field = + StructuredQuery.FieldReference.newBuilder() + .setFieldPath(aggregateField.getFieldPath()) + .build(); + } + // Build the aggregation proto. + Aggregation.Builder aggregation = Aggregation.newBuilder(); + if (aggregateField instanceof AggregateField.CountAggregateField) { + aggregation.setCount(Aggregation.Count.getDefaultInstance()); + } else if (aggregateField instanceof AggregateField.SumAggregateField) { + aggregation.setSum(Aggregation.Sum.newBuilder().setField(field).build()); + } else if (aggregateField instanceof AggregateField.AverageAggregateField) { + aggregation.setAvg(Aggregation.Avg.newBuilder().setField(field).build()); + } else { + throw new RuntimeException("Unsupported aggregation"); + } + // Map all client-side aliases to a unique short-form alias. + // This avoids issues with client-side aliases that exceed the 1500-byte string size limit. + String serverAlias = "aggregate_" + aggregationNum++; + aliasMap.put(serverAlias, aggregateField.getAlias()); + aggregation.setAlias(serverAlias); + aggregations.add(aggregation.build()); + } + structuredAggregationQuery.addAllAggregations(aggregations); + return request.build(); + } + + /** + * Returns an AggregateQuery instance that can be used to execute the provided {@link + * RunAggregationQueryRequest}. + * + *

Only RunAggregationQueryRequests that pertain to the same project as the Firestore instance + * can be deserialized. + * + * @param firestore a Firestore instance to apply the query to. + * @param proto the serialized RunAggregationQueryRequest. + * @return a AggregateQuery instance that can be used to execute the RunAggregationQueryRequest. + */ + @Nonnull + public static AggregateQuery fromProto(Firestore firestore, RunAggregationQueryRequest proto) { + RunQueryRequest runQueryRequest = + RunQueryRequest.newBuilder() + .setParent(proto.getParent()) + .setStructuredQuery(proto.getStructuredAggregationQuery().getStructuredQuery()) + .build(); + Query query = Query.fromProto(firestore, runQueryRequest); + + List aggregateFields = new ArrayList<>(); + List aggregations = proto.getStructuredAggregationQuery().getAggregationsList(); + aggregations.forEach( + aggregation -> { + if (aggregation.hasCount()) { + aggregateFields.add(AggregateField.count()); + } else if (aggregation.hasAvg()) { + aggregateFields.add( + AggregateField.average(aggregation.getAvg().getField().getFieldPath())); + } else if (aggregation.hasSum()) { + aggregateFields.add(AggregateField.sum(aggregation.getSum().getField().getFieldPath())); + } else { + throw new RuntimeException("Unsupported aggregation."); + } + }); + return new AggregateQuery(query, aggregateFields); + } + + /** + * Calculates and returns the hash code for this object. + * + * @return the hash code for this object. + */ + @Override + public int hashCode() { + return Objects.hash(query, aggregateFieldList); + } + + /** + * Compares this object with the given object for equality. + * + *

This object is considered "equal" to the other object if and only if all of the following + * conditions are satisfied: + * + *

    + *
  1. {@code object} is a non-null instance of {@link AggregateQuery}. + *
  2. {@code object} performs the same aggregations as this {@link AggregateQuery}. + *
  3. The underlying {@link Query} of {@code object} compares equal to that of this object. + *
+ * + * @param object The object to compare to this object for equality. + * @return {@code true} if this object is "equal" to the given object, as defined above, or {@code + * false} otherwise. + */ + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } else if (!(object instanceof AggregateQuery)) { + return false; + } + AggregateQuery other = (AggregateQuery) object; + return query.equals(other.query) && aggregateFieldList.equals(other.aggregateFieldList); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuerySnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuerySnapshot.java new file mode 100644 index 000000000000..be98e61d20f1 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/AggregateQuerySnapshot.java @@ -0,0 +1,198 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.Timestamp; +import com.google.firestore.v1.Value; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** The results of executing an {@link AggregateQuery}. */ +@InternalExtensionOnly +public class AggregateQuerySnapshot { + + @Nonnull private final AggregateQuery query; + @Nonnull private final Timestamp readTime; + @Nonnull private final Map data; + + AggregateQuerySnapshot( + @Nonnull AggregateQuery query, + @Nonnull Timestamp readTime, + @Nonnull Map data) { + this.query = query; + this.readTime = readTime; + this.data = data; + } + + /** Returns the query that was executed to produce this result. */ + @Nonnull + public AggregateQuery getQuery() { + return query; + } + + /** Returns the time at which this snapshot was read. */ + @Nonnull + public Timestamp getReadTime() { + return readTime; + } + + /** Returns the number of documents in the result set of the underlying query. */ + public long getCount() { + AggregateField countField = AggregateField.count(); + Object value = get(countField); + if (value == null) { + throw new IllegalArgumentException( + "RunAggregationQueryResponse alias " + countField.getAlias() + " is null"); + } else if (!(value instanceof Long)) { + throw new IllegalArgumentException( + "RunAggregationQueryResponse alias " + + countField.getAlias() + + " has incorrect type: " + + value.getClass().getName()); + } + return (Long) value; + } + + /** Returns the number of documents in the result set of the underlying query. */ + @SuppressWarnings({"unused"}) + public long get(@Nonnull AggregateField.CountAggregateField unused) { + return getCount(); + } + + /** + * Returns the result of the given aggregation from the server without coercion of data types. + * Throws java.lang.RuntimeException if the `aggregateField` was not requested when calling + * `query.aggregate(...)`. + * + * @param aggregateField The aggregation for which the value is requested. + * @return The result of the given aggregation. + */ + @Nullable + public Object get(@Nonnull AggregateField aggregateField) { + if (!data.containsKey(aggregateField.getAlias())) { + throw new IllegalArgumentException( + "'" + + aggregateField.getOperator() + + "(" + + aggregateField.getFieldPath() + + ")" + + "' was not requested in the aggregation query."); + } + Value value = data.get(aggregateField.getAlias()); + if (value.hasNullValue()) { + return null; + } else if (value.hasDoubleValue()) { + return value.getDoubleValue(); + } else if (value.hasIntegerValue()) { + return value.getIntegerValue(); + } else { + throw new IllegalStateException("Found aggregation result that is not an integer nor double"); + } + } + + /** + * Returns the result of the given average aggregation. Since the result of an average aggregation + * performed by the server is always a double, this convenience overload can be used in lieu of + * the above `get` method. Throws java.lang.RuntimeException if the `aggregateField` was not + * requested when calling `query.aggregate(...)`. + * + * @param averageAggregateField The average aggregation for which the value is requested. + * @return The result of the given average aggregation. + */ + @Nullable + public Double get(@Nonnull AggregateField.AverageAggregateField averageAggregateField) { + return (Double) get((AggregateField) averageAggregateField); + } + + /** + * Returns the result of the given aggregation as a double. Coerces all numeric values and throws + * a RuntimeException if the result of the aggregate is non-numeric. In the case of coercion of + * long to double, uses java.lang.Long.doubleValue to perform the conversion, and may result in a + * loss of precision. + * + * @param aggregateField The aggregation for which the value is requested. + * @return The result of the given average aggregation as a double. + */ + @Nullable + public Double getDouble(@Nonnull AggregateField aggregateField) { + Number result = (Number) get(aggregateField); + return result == null ? null : result.doubleValue(); + } + + /** + * Returns the result of the given aggregation as a long. Coerces all numeric values and throws a + * RuntimeException if the result of the aggregate is non-numeric. In case of coercion of double + * to long, uses java.lang.Double.longValue to perform the conversion. + * + * @param aggregateField The aggregation for which the value is requested. + * @return The result of the given average aggregation as a long. + */ + @Nullable + public Long getLong(@Nonnull AggregateField aggregateField) { + Number result = (Number) get(aggregateField); + return result == null ? null : result.longValue(); + } + + /** + * Compares this object with the given object for equality. + * + *

This object is considered "equal" to the other object if and only if all of the following + * conditions are satisfied: + * + *

    + *
  1. {@code object} is a non-null instance of {@link AggregateQuerySnapshot}. + *
  2. The {@link AggregateQuery} of {@code object} compares equal to that of this object. + *
  3. {@code object} has the same results as this object. + *
+ * + * @param object The object to compare to this object for equality. + * @return {@code true} if this object is "equal" to the given object, as defined above, or {@code + * false} otherwise. + */ + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } else if (!(object instanceof AggregateQuerySnapshot)) { + return false; + } + + AggregateQuerySnapshot other = (AggregateQuerySnapshot) object; + + // Don't check `readTime`, because `DocumentSnapshot.equals()` doesn't either. + return query.equals(other.query) && data.equals(other.data); + } + + /** + * Calculates and returns the hash code for this object. + * + * @return the hash code for this object. + */ + @Override + public int hashCode() { + return Objects.hash(query, data); + } + + @InternalApi + Map getData() { + return data; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BasePath.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BasePath.java new file mode 100644 index 000000000000..11c4110c8441 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BasePath.java @@ -0,0 +1,168 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * BasePath represents a path sequence in the Firestore database. It is composed of an ordered + * sequence of string segments. + */ +public abstract class BasePath> implements Comparable { + + /** + * Returns the segments that make up this path. + * + * @return The path segments. + */ + abstract ImmutableList getSegments(); + + /** + * Returns the path of the parent element. + * + * @return The new Path or null if we are already at the root. + */ + @Nullable + B getParent() { + ImmutableList parts = getSegments(); + if (parts.isEmpty()) { + return null; + } + return createPathWithSegments(parts.subList(0, parts.size() - 1)); + } + + /** + * Returns a new path pointing to a child of this Path. + * + * @param path A relative path + */ + B append(String path) { + return append(path, true); + } + + /** + * Returns a new path pointing to a child of this Path. + * + * @param path A relative path + * @param splitPath Whether or not the path should be split + */ + B append(String path, boolean splitPath) { + Preconditions.checkArgument( + path != null && !path.isEmpty(), "'path' must be a non-empty String"); + ImmutableList.Builder components = ImmutableList.builder(); + components.addAll(this.getSegments()); + if (splitPath) { + components.add(splitChildPath(path)); + } else { + components.add(path); + } + return createPathWithSegments(components.build()); + } + + /** + * Returns a new path pointing to a child of this Path. + * + * @param path A relative path + */ + B append(BasePath path) { + ImmutableList segments1 = this.getSegments(); + ImmutableList segments2 = path.getSegments(); + ImmutableList.Builder components = + ImmutableList.builderWithExpectedSize(segments1.size() + segments2.size()); + components.addAll(segments1); + components.addAll(segments2); + return createPathWithSegments(components.build()); + } + + /** + * Checks to see if this path is a prefix of (or equals) another path. + * + * @param path the path to check against + * @return true if current path is a prefix of the other path. + */ + boolean isPrefixOf(BasePath path) { + List prefixSegments = getSegments(); + List childSegments = path.getSegments(); + int size = prefixSegments.size(); + if (size > childSegments.size()) { + return false; + } + for (int i = 0; i < size; i++) { + if (!prefixSegments.get(i).equals(childSegments.get(i))) { + return false; + } + } + return true; + } + + /** + * Compare the current path against another Path object. + * + *

Compare the current path against another Path object. Paths are compared segment by segment, + * prioritizing numeric IDs (e.g., "__id123__") in numeric ascending order, followed by string + * segments in lexicographical order. + * + * @param other The path to compare to. + * @return -1 if current is less than other, 1 if current greater than other, 0 if equal + */ + @Override + public int compareTo(@Nonnull B other) { + List thisSegments = this.getSegments(); + List otherSegments = other.getSegments(); + + int length = Math.min(thisSegments.size(), otherSegments.size()); + for (int i = 0; i < length; i++) { + int cmp = compareSegments(thisSegments.get(i), otherSegments.get(i)); + if (cmp != 0) { + return cmp; + } + } + return Integer.compare(thisSegments.size(), otherSegments.size()); + } + + private int compareSegments(String lhs, String rhs) { + boolean isLhsNumeric = isNumericId(lhs); + boolean isRhsNumeric = isNumericId(rhs); + + if (isLhsNumeric && !isRhsNumeric) { // Only lhs is numeric + return -1; + } else if (!isLhsNumeric && isRhsNumeric) { // Only rhs is numeric + return 1; + } else if (isLhsNumeric && isRhsNumeric) { // both numeric + return Long.compare(extractNumericId(lhs), extractNumericId(rhs)); + } else { // both string + return Order.compareUtf8Strings(lhs, rhs); + } + } + + /** Checks if a segment is a numeric ID (starts with "__id" and ends with "__"). */ + private boolean isNumericId(String segment) { + return segment.startsWith("__id") && segment.endsWith("__"); + } + + private long extractNumericId(String segment) { + return Long.parseLong(segment.substring(4, segment.length() - 2)); + } + + abstract String[] splitChildPath(String path); + + abstract B createPathWithSegments(ImmutableList segments); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BatchWriteResult.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BatchWriteResult.java new file mode 100644 index 000000000000..a9847d79c60e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BatchWriteResult.java @@ -0,0 +1,46 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import javax.annotation.Nullable; + +/** + * A BatchWriteResult wraps the write time and status returned by Firestore when making + * BatchWriteRequests. + */ +@InternalApi +final class BatchWriteResult { + @Nullable private final Timestamp writeTime; + @Nullable private final Exception exception; + + BatchWriteResult(@Nullable Timestamp timestamp, @Nullable Exception exception) { + this.writeTime = timestamp; + this.exception = exception; + } + + @Nullable + public Timestamp getWriteTime() { + return writeTime; + } + + @Nullable + public Exception getException() { + return exception; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Blob.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Blob.java new file mode 100644 index 000000000000..cedef20fda83 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Blob.java @@ -0,0 +1,99 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.protobuf.ByteString; +import java.io.Serializable; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** Immutable class representing an array of bytes in Firestore. */ +public final class Blob implements Serializable { + + private static final long serialVersionUID = 1441087101882481208L; + + private final ByteString byteString; + + private Blob(ByteString byteString) { + this.byteString = byteString; + } + + /** + * Creates a new Blob instance from the provided ByteString. + * + * @param byteString The byteString to use for this Blob instance. + * @return The new Blob instance + */ + @Nonnull + public static Blob fromByteString(@Nonnull ByteString byteString) { + return new Blob(byteString); + } + + /** + * Creates a new Blob instance from the provided bytes. Makes a copy of the bytes passed in. + * + * @param bytes The bytes to use for this Blob instance. + * @return The new Blob instance + */ + @Nonnull + public static Blob fromBytes(@Nonnull byte[] bytes) { + return new Blob(ByteString.copyFrom(bytes)); + } + + /** + * Returns the backing data as a ByteString. + * + * @return The bytes of this blob as a byteString + */ + @Nonnull + public ByteString toByteString() { + return byteString; + } + + /** + * Returns a copy of the underlying bytes as a byte[] array. + * + * @return The bytes of this blob as a byte[] array. + */ + @Nonnull + public byte[] toBytes() { + return byteString.toByteArray(); + } + + /** + * Returns true if this Blob is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this Blob is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + Blob blob = (Blob) obj; + return Objects.equals(byteString, blob.byteString); + } + + @Override + public int hashCode() { + return Objects.hash(byteString); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkCommitBatch.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkCommitBatch.java new file mode 100644 index 000000000000..5ff8bc007d7b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkCommitBatch.java @@ -0,0 +1,143 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.ApiException; +import com.google.cloud.Timestamp; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import io.grpc.Status; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CopyOnWriteArraySet; +import java.util.concurrent.Executor; + +/** Used to represent a batch that contains scheduled BulkWriterOperations. */ +class BulkCommitBatch extends UpdateBuilder> { + + final List pendingOperations = new ArrayList<>(); + private final Set documents = new CopyOnWriteArraySet<>(); + private final Executor executor; + private int maxBatchSize; + + BulkCommitBatch(FirestoreImpl firestore, Executor executor, int maxBatchSize) { + super(firestore); + this.executor = executor; + this.maxBatchSize = maxBatchSize; + } + + int getMaxBatchSize() { + return maxBatchSize; + } + + void setMaxBatchSize(int size) { + Preconditions.checkState( + getMutationsSize() <= size, + "New batch size cannot be less than the number of enqueued writes"); + this.maxBatchSize = size; + } + + ApiFuture wrapResult(int writeIndex) { + return pendingOperations.get(writeIndex).getFuture(); + } + + /** + * Commits all pending operations to the database and verifies all preconditions. + * + *

The writes in the batch are not applied atomically and can be applied out of order. + */ + ApiFuture bulkCommit() { + // Follows same thread safety logic as `UpdateBuilder::commit`. + committed = true; + BatchWriteRequest request = buildBatchWriteRequest(); + + ApiFuture response = + processExceptions( + firestore.sendRequest(request, firestore.getClient().batchWriteCallable())); + + return ApiFutures.transformAsync( + response, + batchWriteResponse -> { + List> pendingUserCallbacks = new ArrayList<>(); + + List writeResults = + batchWriteResponse.getWriteResultsList(); + List statuses = batchWriteResponse.getStatusList(); + + for (int i = 0; i < writeResults.size(); ++i) { + com.google.firestore.v1.WriteResult writeResult = writeResults.get(i); + com.google.rpc.Status status = statuses.get(i); + BulkWriterOperation operation = pendingOperations.get(i); + Status code = Status.fromCodeValue(status.getCode()); + if (code == Status.OK) { + pendingUserCallbacks.add( + operation.onSuccess( + new WriteResult(Timestamp.fromProto(writeResult.getUpdateTime())))); + } else { + pendingUserCallbacks.add( + operation.onException( + FirestoreException.forServerRejection(code, status.getMessage()))); + } + } + return BulkWriter.silenceFuture(ApiFutures.allAsList(pendingUserCallbacks)); + }, + executor); + } + + private BatchWriteRequest buildBatchWriteRequest() { + BatchWriteRequest.Builder builder = BatchWriteRequest.newBuilder(); + builder.setDatabase(firestore.getDatabaseName()); + forEachWrite(builder::addWrites); + return builder.build(); + } + + /** Maps an RPC failure to each individual write's result. */ + private ApiFuture processExceptions(ApiFuture response) { + return ApiFutures.catching( + response, + ApiException.class, + exception -> { + com.google.rpc.Status.Builder status = + com.google.rpc.Status.newBuilder() + .setCode(exception.getStatusCode().getCode().ordinal()) + .setMessage(exception.getMessage()); + BatchWriteResponse.Builder responseBuilder = BatchWriteResponse.newBuilder(); + for (int i = 0; i < pendingOperations.size(); ++i) { + responseBuilder.addWriteResults( + com.google.firestore.v1.WriteResult.getDefaultInstance()); + responseBuilder.addStatus(status); + } + return responseBuilder.build(); + }, + MoreExecutors.directExecutor()); + } + + void enqueueOperation(BulkWriterOperation operation) { + boolean added = documents.add(operation.getDocumentReference()); + Preconditions.checkState(added, "Batch should not contain writes to the same document"); + pendingOperations.add(operation); + } + + boolean has(DocumentReference documentReference) { + return documents.contains(documentReference); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java new file mode 100644 index 000000000000..b0630dac0d9c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriter.java @@ -0,0 +1,1098 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.BulkWriterOperation.DEFAULT_BACKOFF_MAX_DELAY_MS; +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_DOC_COUNT; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +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.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Context; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreSettings; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +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; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.concurrent.GuardedBy; + +/** A Firestore BulkWriter that can be used to perform a large number of writes in parallel. */ +public final class BulkWriter implements AutoCloseable { + /** + * A callback set by `addWriteResultListener()` to be run every time an operation successfully + * completes. + */ + public interface WriteResultCallback { + /** + * @param documentReference The document the operation was performed on. + * @param result The result of the operation. + */ + void onResult(DocumentReference documentReference, WriteResult result); + } + + /** + * A callback set by `addWriteErrorListener()` to be run every time an operation fails and + * determines if an operation should be retried. + */ + public interface WriteErrorCallback { + /** + * @param error The error object from the failed BulkWriter operation attempt. + * @return Whether to retry the operation or not. + */ + boolean onError(BulkWriterException error); + } + + enum OperationType { + CREATE, + SET, + UPDATE, + DELETE + } + + /** The maximum number of writes that can be in a single batch. */ + public static final int MAX_BATCH_SIZE = 20; + + /** The maximum number of writes that can be in a batch containing retries. */ + public static final int RETRY_MAX_BATCH_SIZE = 10; + + /** + * The maximum number of retries that will be attempted with backoff before stopping all retry + * attempts. + */ + public static final int MAX_RETRY_ATTEMPTS = 10; + + /** + * The starting maximum number of operations per second as allowed by the 500/50/5 rule. + * + * @see Ramping + * up traffic + */ + static final int DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND = 500; + + /** + * The rate by which to increase the capacity as specified by the 500/50/5 rule. + * + * @see Ramping + * up traffic + */ + private static final double RATE_LIMITER_MULTIPLIER = 1.5; + + /** + * How often the operations per second capacity should increase in milliseconds as specified by + * the 500/50/5 rule. + * + * @see Ramping + * up traffic + */ + 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. + */ + static final double DEFAULT_JITTER_FACTOR = 0.3; + + private static final WriteResultCallback DEFAULT_SUCCESS_LISTENER = + (documentReference, result) -> {}; + + private static final WriteErrorCallback DEFAULT_ERROR_LISTENER = + error -> { + if (error.getFailedAttempts() > MAX_RETRY_ATTEMPTS) { + return false; + } + Set codes = FirestoreSettings.newBuilder().batchWriteSettings().getRetryableCodes(); + for (Code code : codes) { + if (code.equals(Code.valueOf(error.getStatus().getCode().name()))) { + return true; + } + } + return false; + }; + + private static final Logger logger = Logger.getLogger(BulkWriter.class.getName()); + + private final FirestoreImpl firestore; + + // Executor used to run all BulkWriter operations. BulkWriter uses its own executor since we + // don't want to block a gax/grpc executor while running user error and success callbacks. + private final ScheduledExecutorService bulkWriterExecutor; + + /** + * The BulkWriter will shutdown executor when closed and all writes are done. This is important to + * prevent leaking threads. + */ + boolean autoShutdownBulkWriterExecutor; + + /** The maximum number of writes that can be in a single batch. */ + private int maxBatchSize = MAX_BATCH_SIZE; + + /** + * Lock object for all mutable state in bulk writer. BulkWriter state is accessed from the user + * thread and via {@code bulkWriterExecutor}. + */ + private final Object lock = new Object(); + + /** Rate limiter used to throttle requests as per the 500/50/5 rule. */ + @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. + * + *

Access to the BulkCommitBatch should only occur under lock as it can be accessed by both the + * user thread as well as by the backoff logic in BulkWriter. + */ + @GuardedBy("lock") + private BulkCommitBatch bulkCommitBatch; + + /** + * A pointer to the tail of all active BulkWriter applications. This pointer is advanced every + * time a new write is enqueued. + */ + @GuardedBy("lock") + private ApiFuture lastOperation = ApiFutures.immediateFuture(null); + + /** A pointer to the lastOperation pointer as of last flush operation. */ + @GuardedBy("lock") + private ApiFuture lastFlushOperation = lastOperation; + + /** Whether this BulkWriter instance is closed. Once closed, it cannot be opened again. */ + @GuardedBy("lock") + private boolean closed = false; + + @GuardedBy("lock") + private WriteResultCallback successListener = DEFAULT_SUCCESS_LISTENER; + + @GuardedBy("lock") + private WriteErrorCallback errorListener = DEFAULT_ERROR_LISTENER; + + @GuardedBy("lock") + private Executor successExecutor; + + @GuardedBy("lock") + private Executor errorExecutor; + + private final Context traceContext; + + /** + * Used to track when writes are enqueued. The user handler executors cannot be changed after a + * write has been enqueued. + */ + @GuardedBy("lock") + private boolean writesEnqueued = false; + + BulkWriter(FirestoreImpl firestore, BulkWriterOptions options) { + this.firestore = firestore; + if (options.getExecutor() != null) { + this.bulkWriterExecutor = options.getExecutor(); + this.autoShutdownBulkWriterExecutor = false; + } else { + this.bulkWriterExecutor = Executors.newSingleThreadScheduledExecutor(); + this.autoShutdownBulkWriterExecutor = true; + } + this.successExecutor = MoreExecutors.directExecutor(); + this.errorExecutor = MoreExecutors.directExecutor(); + this.bulkCommitBatch = new BulkCommitBatch(firestore, bulkWriterExecutor, maxBatchSize); + this.traceContext = firestore.getOptions().getTraceUtil().currentContext(); + + if (!options.getThrottlingEnabled()) { + this.rateLimiter = + new RateLimiter( + Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE); + } else { + double startingRate = DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND; + double maxRate = Double.POSITIVE_INFINITY; + + if (options.getInitialOpsPerSecond() != null) { + startingRate = options.getInitialOpsPerSecond(); + } + + if (options.getMaxOpsPerSecond() != null) { + maxRate = options.getMaxOpsPerSecond(); + } + + // The initial validation step ensures that the maxOpsPerSecond is greater than + // initialOpsPerSecond. If this inequality is true, that means initialOpsPerSecond was not + // set and maxOpsPerSecond is less than the default starting rate. + if (maxRate < startingRate) { + startingRate = maxRate; + } + + // Ensure that the batch size is not larger than the number of allowed + // operations per second. + if (startingRate < maxBatchSize) { + this.maxBatchSize = (int) startingRate; + } + + this.rateLimiter = + new RateLimiter( + (int) startingRate, + RATE_LIMITER_MULTIPLIER, + RATE_LIMITER_MULTIPLIER_MILLIS, + (int) maxRate); + } + } + + /** + * Create a document with the provided data. This single operation will fail if a document exists + * at its location. + * + * @param documentReference A reference to the document to be created. + * @param fields A map of the fields and values for the document. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture create( + @Nonnull final DocumentReference documentReference, + @Nonnull final Map fields) { + return executeWrite( + documentReference, OperationType.CREATE, batch -> batch.create(documentReference, fields)); + } + + /** + * Create a document with the provided data. This single operation will fail if a document exists + * at its location. + * + * @param documentReference A reference to the document to be created. + * @param pojo The POJO that will be used to populate the document contents. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture create( + @Nonnull final DocumentReference documentReference, @Nonnull final Object pojo) { + return executeWrite( + documentReference, OperationType.CREATE, batch -> batch.create(documentReference, pojo)); + } + + /** + * Delete a document from the database. + * + * @param documentReference The DocumentReference to delete. + * @return An ApiFuture containing a sentinel value (Timestamp(0)) for the delete operation. + * Contains a {@link BulkWriterException} if the delete fails. + */ + @Nonnull + public ApiFuture delete(@Nonnull final DocumentReference documentReference) { + return executeWrite( + documentReference, OperationType.DELETE, batch -> batch.delete(documentReference)); + } + + /** + * Delete a document from the database. + * + * @param documentReference The DocumentReference to delete. + * @param precondition Precondition to enforce for this delete. + * @return An ApiFuture containing a sentinel value (Timestamp(0)) for the delete operation. + * Contains a {@link BulkWriterException} if the delete fails. + */ + @Nonnull + public ApiFuture delete( + @Nonnull final DocumentReference documentReference, + @Nonnull final Precondition precondition) { + return executeWrite( + documentReference, + OperationType.DELETE, + batch -> batch.delete(documentReference, precondition)); + } + + /** + * Write to the document referred to by the provided DocumentReference. If the document does not + * exist yet, it will be created. + * + * @param documentReference A reference to the document to be set. + * @param fields A map of the fields and values for the document. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture set( + @Nonnull final DocumentReference documentReference, + @Nonnull final Map fields) { + return executeWrite( + documentReference, OperationType.SET, batch -> batch.set(documentReference, fields)); + } + + /** + * Write to the document referred to by the provided DocumentReference. If the document does not + * exist yet, it will be created. If you pass a {@link SetOptions}, the provided data can be + * merged into an existing document. + * + * @param documentReference A reference to the document to be set. + * @param fields A map of the fields and values for the document. + * @param options An object to configure the set behavior. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture set( + @Nonnull final DocumentReference documentReference, + @Nonnull final Map fields, + @Nonnull final SetOptions options) { + return executeWrite( + documentReference, + OperationType.SET, + batch -> batch.set(documentReference, fields, options)); + } + + /** + * Write to the document referred to by the provided DocumentReference. If the document does not + * exist yet, it will be created. If you pass a {@link SetOptions}, the provided data can be + * merged into an existing document. + * + * @param documentReference A reference to the document to be set. + * @param pojo The POJO that will be used to populate the document contents. + * @param options An object to configure the set behavior. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture set( + @Nonnull final DocumentReference documentReference, + @Nonnull final Object pojo, + @Nonnull final SetOptions options) { + return executeWrite( + documentReference, OperationType.SET, batch -> batch.set(documentReference, pojo, options)); + } + + /** + * Write to the document referred to by the provided DocumentReference. If the document does not + * exist yet, it will be created. + * + * @param documentReference A reference to the document to be set. + * @param pojo The POJO that will be used to populate the document contents. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture set( + @Nonnull final DocumentReference documentReference, @Nonnull final Object pojo) { + return executeWrite( + documentReference, OperationType.SET, batch -> batch.set(documentReference, pojo)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param fields A map of the fields and values for the document. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final Map fields) { + return executeWrite( + documentReference, OperationType.UPDATE, batch -> batch.update(documentReference, fields)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param fields A map of the fields and values for the document. + * @param precondition Precondition to enforce on this update. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final Map fields, + @Nonnull final Precondition precondition) { + return executeWrite( + documentReference, + OperationType.UPDATE, + batch -> batch.update(documentReference, fields, precondition)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param field The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final String field, + @Nullable final Object value, + final Object... moreFieldsAndValues) { + return executeWrite( + documentReference, + OperationType.UPDATE, + batch -> batch.update(documentReference, field, value, moreFieldsAndValues)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param fieldPath The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final FieldPath fieldPath, + @Nullable final Object value, + final Object... moreFieldsAndValues) { + return executeWrite( + documentReference, + OperationType.UPDATE, + batch -> batch.update(documentReference, fieldPath, value, moreFieldsAndValues)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param field The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final Precondition precondition, + @Nonnull final String field, + @Nullable final Object value, + final Object... moreFieldsAndValues) { + return executeWrite( + documentReference, + OperationType.UPDATE, + batch -> batch.update(documentReference, precondition, field, value, moreFieldsAndValues)); + } + + /** + * Update fields of the document referred to by the provided {@link DocumentReference}. If the + * document doesn't yet exist, the update will fail. + * + *

The update() method accepts either an object with field paths encoded as keys and field + * values encoded as values, or a variable number of arguments that alternate between field paths + * and field values. Nested fields can be updated by providing dot-separated field path strings or + * by providing FieldPath objects. + * + * @param documentReference A reference to the document to be updated. + * @param precondition Precondition to enforce on this update. + * @param fieldPath The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return An ApiFuture containing the result of the write. Contains a {@link BulkWriterException} + * if the write fails. + */ + @Nonnull + public ApiFuture update( + @Nonnull final DocumentReference documentReference, + @Nonnull final Precondition precondition, + @Nonnull final FieldPath fieldPath, + @Nullable final Object value, + final Object... moreFieldsAndValues) { + return executeWrite( + documentReference, + OperationType.UPDATE, + batch -> + batch.update(documentReference, precondition, fieldPath, value, moreFieldsAndValues)); + } + + /** + * Schedules the provided write operation and runs the user success callback when the write result + * is obtained. + */ + private ApiFuture executeWrite( + final DocumentReference documentReference, + final OperationType operationType, + final ApiFunction> enqueueOperationOnBatchCallback) { + final BulkWriterOperation operation = + new BulkWriterOperation( + documentReference, + operationType, + op -> { + synchronized (lock) { + sendOperationLocked(enqueueOperationOnBatchCallback, op); + } + return null; + }, + writeResult -> { + synchronized (lock) { + return invokeUserSuccessCallbackLocked(documentReference, writeResult); + } + }, + e -> { + synchronized (lock) { + return invokeUserErrorCallbackLocked(e); + } + }); + + synchronized (lock) { + verifyNotClosedLocked(); + writesEnqueued = true; + + // Advance the lastOperation pointer. This ensures that lastOperation only completes when + // both the previous and the current write complete. + lastOperation = + ApiFutures.transformAsync( + lastOperation, + aVoid -> 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( + () -> { + synchronized (lock) { + pendingOpsCount++; + sendOperationLocked(enqueueOperationOnBatchCallback, operation); + } + }); + } + } + + ApiFuture processedOperationFuture = + ApiFutures.transformAsync( + operation.getFuture(), + result -> { + synchronized (lock) { + pendingOpsCount--; + processBufferedOperations(); + } + return ApiFutures.immediateFuture(result); + }, + MoreExecutors.directExecutor()); + + return ApiFutures.catchingAsync( + processedOperationFuture, + ApiException.class, + e -> { + synchronized (lock) { + 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(); + } + } + + /** + * Commits all writes that have been enqueued up to this point in parallel. + * + *

Returns an ApiFuture that completes when all currently queued operations have been + * committed. The ApiFuture will never return an error since the results for each individual + * operation are conveyed via their individual ApiFutures. + * + *

The ApiFuture completes immediately if there are no pending writes. Otherwise, the ApiFuture + * waits for all previously issued writes, but it does not wait for writes that were added after + * the method is called. If you want to wait for additional writes, call `flush()` again. + * + * @return An ApiFuture that completes when all enqueued writes up to this point have been + * committed. + */ + @Nonnull + public ApiFuture flush() { + synchronized (lock) { + return flushLocked(); + } + } + + private ApiFuture flushLocked() { + verifyNotClosedLocked(); + if (!lastOperation.isDone()) { + lastFlushOperation = lastOperation; + scheduleCurrentBatchLocked(); + } + return lastFlushOperation; + } + + /** + * Commits all enqueued writes and marks the BulkWriter instance as closed. + * + *

After calling `close()`, calling any method will return an error. Any retries scheduled with + * `addWriteErrorListener()` will be run before `close()` completes. + * + *

This method completes when there are no more pending writes. Calling this method will send + * all requests. + */ + public void close() throws InterruptedException, ExecutionException { + ApiFuture flushFuture; + synchronized (lock) { + if (!closed) { + flushLocked(); + closed = true; + } + flushFuture = lastFlushOperation; + } + flushFuture.get(); + if (autoShutdownBulkWriterExecutor) { + bulkWriterExecutor.shutdown(); + } + } + + /** + * Used for verifying that the BulkWriter instance isn't closed when calling from outside this + * class. + */ + void verifyNotClosed() { + synchronized (lock) { + verifyNotClosedLocked(); + } + } + + void verifyNotClosedLocked() { + if (this.closed) { + throw new IllegalStateException("BulkWriter has already been closed."); + } + } + + /** + * Attaches a listener that is run every time a BulkWriter operation successfully completes. The + * listener will be run before `close()` completes. + * + *

For example, see the sample code: + * BulkWriter bulkWriter = firestore.bulkWriter(); + * bulkWriter.addWriteResultListener( + * (DocumentReference documentReference, WriteResult result) -> { + * System.out.println( + * "Successfully executed write on document: " + * + documentReference + * + " at: " + * + result.getUpdateTime()); + * } + * ); + * + * + * @param writeResultCallback A callback to be called every time a BulkWriter operation + * successfully completes. + */ + public void addWriteResultListener(WriteResultCallback writeResultCallback) { + synchronized (lock) { + successListener = writeResultCallback; + } + } + + /** + * Attaches a listener that is run every time a BulkWriter operation successfully completes. + * + *

The executor cannot be changed once writes have been enqueued onto the BulkWriter. + * + *

For example, see the sample code: + * + *

{@code
+   * BulkWriter bulkWriter = firestore.bulkWriter();
+   * bulkWriter.addWriteResultListener(
+   *       (DocumentReference documentReference, WriteResult result) -> {
+   *           System.out.println(
+   *               "Successfully executed write on document: "
+   *                   + documentReference
+   *                   + " at: "
+   *                   + result.getUpdateTime());
+   *         }
+   *       );
+   * }
+ * + * @param executor The executor to run the provided callback on. + * @param writeResultCallback A callback to be called every time a BulkWriter operation + * successfully completes. + */ + public void addWriteResultListener( + @Nonnull Executor executor, WriteResultCallback writeResultCallback) { + synchronized (lock) { + if (writesEnqueued) { + throw new IllegalStateException( + "The executor cannot be changed once writes have been enqueued."); + } + successListener = writeResultCallback; + successExecutor = executor; + } + } + + /** + * Attaches an error handler listener that is run every time a BulkWriter operation fails. + * + *

BulkWriter has a default error handler that retries UNAVAILABLE and ABORTED errors up to a + * maximum of 10 failed attempts. When an error handler is specified, the default error handler + * will be overwritten. + * + *

For example, see the sample code: + * + *

{@code
+   * BulkWriter bulkWriter = firestore.bulkWriter();
+   * bulkWriter.addWriteErrorListener(
+   *       (BulkWriterException error) -> {
+   *         if (error.getStatus() == Status.UNAVAILABLE
+   *           && error.getFailedAttempts() < MAX_RETRY_ATTEMPTS) {
+   *           return true;
+   *         } else {
+   *           System.out.println("Failed write at document: " + error.getDocumentReference());
+   *           return false;
+   *         }
+   *       }
+   *     );
+   * }
+ * + * @param onError A callback to be called every time a BulkWriter operation fails. Returning + * `true` will retry the operation. Returning `false` will stop the retry loop. + */ + public void addWriteErrorListener(WriteErrorCallback onError) { + synchronized (lock) { + errorListener = onError; + } + } + + /** + * Attaches an error handler listener that is run every time a BulkWriter operation fails. + * + *

The executor cannot be changed once writes have been enqueued onto the BulkWriter. + * + *

BulkWriter has a default error handler that retries UNAVAILABLE and ABORTED errors up to a + * maximum of 10 failed attempts. When an error handler is specified, the default error handler + * will be overwritten. + * + *

For example, see the sample code: + * + *

{@code
+   * BulkWriter bulkWriter = firestore.bulkWriter();
+   * bulkWriter.addWriteErrorListener(
+   *       (BulkWriterException error) -> {
+   *         if (error.getStatus() == Status.UNAVAILABLE
+   *           && error.getFailedAttempts() < MAX_RETRY_ATTEMPTS) {
+   *           return true;
+   *         } else {
+   *           System.out.println("Failed write at document: " + error.getDocumentReference());
+   *           return false;
+   *         }
+   *       }
+   *     );
+   * }
+ * + * @param executor The executor to run the provided callback on. + * @param onError A callback to be called every time a BulkWriter operation fails. Returning + * `true` will retry the operation. Returning `false` will stop the retry loop. + */ + public void addWriteErrorListener(@Nonnull Executor executor, WriteErrorCallback onError) { + synchronized (lock) { + if (writesEnqueued) { + throw new IllegalStateException( + "The executor cannot be changed once writes have been enqueued."); + } + errorListener = onError; + errorExecutor = executor; + } + } + + /** Sends the current batch and resets {@link #bulkCommitBatch}. */ + private void scheduleCurrentBatchLocked() { + if (bulkCommitBatch.getMutationsSize() == 0) return; + + final BulkCommitBatch pendingBatch = bulkCommitBatch; + bulkCommitBatch = new BulkCommitBatch(firestore, bulkWriterExecutor, maxBatchSize); + + // Use the write with the longest backoff duration when determining backoff. + int highestBackoffDuration = 0; + for (BulkWriterOperation op : pendingBatch.pendingOperations) { + if (op.getBackoffDuration() > highestBackoffDuration) { + highestBackoffDuration = op.getBackoffDuration(); + } + } + final int backoffMsWithJitter = applyJitter(highestBackoffDuration); + + bulkWriterExecutor.schedule( + () -> { + synchronized (lock) { + sendBatchLocked(pendingBatch); + } + }, + backoffMsWithJitter, + TimeUnit.MILLISECONDS); + } + + /** Sends the provided batch once the rate limiter does not require any delay. */ + private void sendBatchLocked(final BulkCommitBatch batch) { + // Send the batch if it does not require any delay, or schedule another attempt after the + // appropriate timeout. + boolean underRateLimit = rateLimiter.tryMakeRequest(batch.getMutationsSize()); + if (underRateLimit) { + TraceUtil.Span span = + firestore + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_BULK_WRITER_COMMIT, traceContext) + .setAttribute(ATTRIBUTE_KEY_DOC_COUNT, batch.getMutationsSize()); + + MetricsContext metricsContext = + firestore + .getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_BULK_WRITER_COMMIT); + + try (Scope ignored = span.makeCurrent()) { + ApiFuture result = batch.bulkCommit(); + if (!lastFlushOperation.isDone()) { + result.addListener( + () -> { + if (!lastFlushOperation.isDone()) { + synchronized (lock) { + scheduleCurrentBatchLocked(); + } + } + }, + MoreExecutors.directExecutor()); + } + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } else { + long delayMs = rateLimiter.getNextRequestDelayMs(batch.getMutationsSize()); + logger.log(Level.FINE, () -> String.format("Backing off for %d seconds", delayMs / 1000)); + bulkWriterExecutor.schedule( + () -> { + synchronized (lock) { + sendBatchLocked(batch); + } + }, + delayMs, + TimeUnit.MILLISECONDS); + } + } + + @VisibleForTesting + void setMaxBatchSize(int size) { + Preconditions.checkState( + bulkCommitBatch.getMutationsSize() == 0, "BulkCommitBatch should be empty"); + maxBatchSize = size; + bulkCommitBatch = new BulkCommitBatch(firestore, bulkWriterExecutor, size); + } + + @VisibleForTesting + 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. + */ + private void sendOperationLocked( + ApiFunction> enqueueOperationOnBatchCallback, + final BulkWriterOperation op) { + // A backoff duration greater than 0 implies that this batch is a retry. + // Retried writes are sent with a batch size of 10 in order to guarantee + // that the batch is under the 10MiB limit. + if (op.getBackoffDuration() > 0) { + if (bulkCommitBatch.getMutationsSize() >= RETRY_MAX_BATCH_SIZE) { + scheduleCurrentBatchLocked(); + } + bulkCommitBatch.setMaxBatchSize(RETRY_MAX_BATCH_SIZE); + } + + if (bulkCommitBatch.has(op.getDocumentReference())) { + // Create a new batch since the backend doesn't support batches with two writes to the same + // document. + scheduleCurrentBatchLocked(); + } + + // Run the operation on the current batch and advance the `lastOperation` pointer. This + // ensures that `lastOperation` only resolves when both the previous and the current write + // resolves. + bulkCommitBatch.enqueueOperation(op); + enqueueOperationOnBatchCallback.apply(bulkCommitBatch); + + if (bulkCommitBatch.getMutationsSize() >= bulkCommitBatch.getMaxBatchSize()) { + scheduleCurrentBatchLocked(); + } + } + + /** Invokes the user error callback on the user callback executor and returns the result. */ + private SettableApiFuture invokeUserErrorCallbackLocked( + final BulkWriterException error) { + final SettableApiFuture callbackResult = SettableApiFuture.create(); + final WriteErrorCallback listener = errorListener; + errorExecutor.execute( + () -> { + try { + boolean shouldRetry = listener.onError(error); + callbackResult.set(shouldRetry); + } catch (Exception e) { + callbackResult.setException(e); + } + }); + return callbackResult; + } + + /** Invokes the user success callback on the user callback executor. */ + private ApiFuture invokeUserSuccessCallbackLocked( + final DocumentReference documentReference, final WriteResult result) { + final SettableApiFuture callbackResult = SettableApiFuture.create(); + final WriteResultCallback listener = successListener; + successExecutor.execute( + () -> { + try { + listener.onResult(documentReference, result); + callbackResult.set(null); + } catch (Exception e) { + callbackResult.setException(e); + } + }); + return callbackResult; + } + + /** Returns an ApiFuture that resolves successfully when the provided future completes. */ + static SettableApiFuture silenceFuture(ApiFuture future) { + final SettableApiFuture flushCallback = SettableApiFuture.create(); + ApiFutures.addCallback( + future, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable throwable) { + flushCallback.set(null); + } + + @Override + public void onSuccess(T writeResult) { + flushCallback.set(null); + } + }, + MoreExecutors.directExecutor()); + return flushCallback; + } + + private int applyJitter(int backoffMs) { + if (backoffMs == 0) return 0; + // Random value in [-0.3, 0.3]. + double jitter = DEFAULT_JITTER_FACTOR * (Math.random() * 2 - 1); + return (int) Math.min(DEFAULT_BACKOFF_MAX_DELAY_MS, backoffMs + jitter * backoffMs); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterException.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterException.java new file mode 100644 index 000000000000..0b9765e535ee --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterException.java @@ -0,0 +1,78 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.firestore.BulkWriter.OperationType; +import io.grpc.Status; + +/** The error thrown when a BulkWriter operation fails. */ +public final class BulkWriterException extends FirestoreException { + private final Status status; + private final String message; + private final DocumentReference documentReference; + private final OperationType operationType; + private final int failedAttempts; + + public BulkWriterException( + Status status, + String message, + DocumentReference documentReference, + OperationType operationType, + int failedAttempts) { + super(message, status); + this.status = status; + this.message = message; + this.documentReference = documentReference; + this.operationType = operationType; + this.failedAttempts = failedAttempts; + } + + /** + * @return The status code of the error. + */ + public Status getStatus() { + return status; + } + + /** + * @return The error message of the error. + */ + public String getMessage() { + return message; + } + + /** + * @return The DocumentReference the operation was performed on. + */ + public DocumentReference getDocumentReference() { + return documentReference; + } + + /** + * @return The type of operation performed. + */ + public OperationType getOperationType() { + return operationType; + } + + /** + * @return How many times this operation has been attempted unsuccessfully. + */ + public int getFailedAttempts() { + return failedAttempts; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOperation.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOperation.java new file mode 100644 index 000000000000..c9b0b872f14a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOperation.java @@ -0,0 +1,162 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.core.SettableApiFuture; +import com.google.common.util.concurrent.MoreExecutors; +import io.grpc.Status; + +/** + * Represents a single write for BulkWriter, encapsulating operation dispatch and error handling. + */ +class BulkWriterOperation { + private final SettableApiFuture operationFuture = SettableApiFuture.create(); + private final DocumentReference documentReference; + private final BulkWriter.OperationType operationType; + private final ApiFunction scheduleWriteCallback; + private final ApiFunction> successListener; + private final ApiFunction> errorListener; + + /** + * The default initial backoff time in milliseconds after an error. Set to 1s according to + * https://cloud.google.com/apis/design/errors. + */ + public static final int DEFAULT_BACKOFF_INITIAL_DELAY_MS = 1000; + + /** The default maximum backoff time in milliseconds when retrying an operation. */ + public static final int DEFAULT_BACKOFF_MAX_DELAY_MS = 60 * 1000; + + /** The default factor to increase the backup by after each failed attempt. */ + public static final double DEFAULT_BACKOFF_FACTOR = 1.5; + + private int failedAttempts = 0; + private Status lastStatus; + + private int backoffDuration = 0; + + /** + * @param documentReference The document reference being written to. + * @param operationType The type of operation that created this write. + * @param scheduleWriteCallback The callback used to schedule a new write. + * @param successListener The user-provided success handler. + * @param errorListener The user-provided error handler. + */ + BulkWriterOperation( + DocumentReference documentReference, + BulkWriter.OperationType operationType, + ApiFunction scheduleWriteCallback, + ApiFunction> successListener, + ApiFunction> errorListener) { + this.documentReference = documentReference; + this.operationType = operationType; + this.scheduleWriteCallback = scheduleWriteCallback; + this.successListener = successListener; + this.errorListener = errorListener; + } + + /** + * Returns an ApiFuture that resolves when the operation completes (either successfully or failed + * after all retry attempts are exhausted). + */ + public ApiFuture getFuture() { + return operationFuture; + } + + public DocumentReference getDocumentReference() { + return documentReference; + } + + public int getBackoffDuration() { + return backoffDuration; + } + + /** Callback invoked when an operation attempt fails. */ + public ApiFuture onException(FirestoreException exception) { + ++failedAttempts; + + final BulkWriterException bulkWriterException = + new BulkWriterException( + exception.getStatus(), + exception.getMessage(), + documentReference, + operationType, + failedAttempts); + + final SettableApiFuture callbackFuture = SettableApiFuture.create(); + + ApiFutures.addCallback( + this.errorListener.apply(bulkWriterException), + new ApiFutureCallback() { + @Override + public void onFailure(Throwable throwable) { + operationFuture.setException(throwable); + callbackFuture.set(null); + } + + @Override + public void onSuccess(Boolean shouldRetry) { + if (shouldRetry) { + lastStatus = bulkWriterException.getStatus(); + updateBackoffDuration(); + scheduleWriteCallback.apply(BulkWriterOperation.this); + } else { + operationFuture.setException(bulkWriterException); + } + callbackFuture.set(null); + } + }, + MoreExecutors.directExecutor()); + + return callbackFuture; + } + + private void updateBackoffDuration() { + if (lastStatus == Status.RESOURCE_EXHAUSTED) { + backoffDuration = DEFAULT_BACKOFF_MAX_DELAY_MS; + } else if (backoffDuration == 0) { + backoffDuration = DEFAULT_BACKOFF_INITIAL_DELAY_MS; + } else { + backoffDuration *= DEFAULT_BACKOFF_FACTOR; + } + } + + /** Callback invoked when the operation succeeds. */ + public ApiFuture onSuccess(final WriteResult result) { + final SettableApiFuture callbackFuture = SettableApiFuture.create(); + ApiFutures.addCallback( + this.successListener.apply(result), + new ApiFutureCallback() { + @Override + public void onFailure(Throwable throwable) { + operationFuture.setException(throwable); + callbackFuture.set(null); + } + + @Override + public void onSuccess(Void aVoid) { + operationFuture.set(result); + callbackFuture.set(null); + } + }, + MoreExecutors.directExecutor()); + return callbackFuture; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOptions.java new file mode 100644 index 000000000000..d0aaca77e0a2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/BulkWriterOptions.java @@ -0,0 +1,157 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.auto.value.AutoValue; +import java.util.concurrent.ScheduledExecutorService; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Options used to configure request throttling in BulkWriter. */ +@AutoValue +public abstract class BulkWriterOptions { + /** + * Return whether throttling is enabled. + * + * @return Whether throttling is enabled. + */ + public abstract boolean getThrottlingEnabled(); + + /** + * Returns the initial maximum number of operations per second allowed by the throttler. + * + * @return The initial maximum number of operations per second allowed by the throttler. + */ + @Nullable + public abstract Double getInitialOpsPerSecond(); + + /** + * Returns the maximum number of operations per second allowed by the throttler. + * + *

The throttler's allowed operations per second does not ramp up past the specified operations + * per second. + * + * @return The maximum number of operations per second allowed by the throttler. + */ + @Nullable + public abstract Double getMaxOpsPerSecond(); + + /** + * @return The {@link ScheduledExecutorService} that BulkWriter uses to schedule all operations. + * If null, the default executor will be used. + */ + @Nullable + public abstract ScheduledExecutorService getExecutor(); + + public static Builder builder() { + return new AutoValue_BulkWriterOptions.Builder() + .setMaxOpsPerSecond(null) + .setInitialOpsPerSecond(null) + .setThrottlingEnabled(true) + .setExecutor(null); + } + + public abstract Builder toBuilder(); + + @AutoValue.Builder + public abstract static class Builder { + /** + * Sets whether throttling should be enabled. By default, throttling is enabled. + * + * @param enabled Whether throttling should be enabled. + */ + public abstract Builder setThrottlingEnabled(boolean enabled); + + /** + * Set the initial maximum number of operations per second allowed by the throttler. + * + * @param initialOpsPerSecond The initial maximum number of operations per second allowed by the + * throttler. + */ + abstract Builder setInitialOpsPerSecond(@Nullable Double initialOpsPerSecond); + + /** + * Set the initial maximum number of operations per second allowed by the throttler. + * + * @param initialOpsPerSecond The initial maximum number of operations per second allowed by the + * throttler. + */ + public Builder setInitialOpsPerSecond(int initialOpsPerSecond) { + return setInitialOpsPerSecond(new Double(initialOpsPerSecond)); + } + + /** + * Set the maximum number of operations per second allowed by the throttler. + * + * @param maxOpsPerSecond The maximum number of operations per second allowed by the throttler. + * The throttler's allowed operations per second does not ramp up past the specified + * operations per second. + */ + abstract Builder setMaxOpsPerSecond(@Nullable Double maxOpsPerSecond); + + /** + * Set the maximum number of operations per second allowed by the throttler. + * + * @param maxOpsPerSecond The maximum number of operations per second allowed by the throttler. + * The throttler's allowed operations per second does not ramp up past the specified + * operations per second. + */ + public Builder setMaxOpsPerSecond(int maxOpsPerSecond) { + return setMaxOpsPerSecond(new Double(maxOpsPerSecond)); + } + + /** + * Set the executor that the BulkWriter instance schedules operations on. + * + * @param executor The executor to schedule BulkWriter operations on. + */ + public abstract Builder setExecutor(@Nullable ScheduledExecutorService executor); + + public abstract BulkWriterOptions autoBuild(); + + @Nonnull + public BulkWriterOptions build() { + BulkWriterOptions options = autoBuild(); + Double initialRate = options.getInitialOpsPerSecond(); + Double maxRate = options.getMaxOpsPerSecond(); + + if (initialRate != null && initialRate < 1) { + throw FirestoreException.forInvalidArgument( + "Value for argument 'initialOpsPerSecond' must be greater than 1, but was: " + + initialRate.intValue()); + } + + if (maxRate != null && maxRate < 1) { + throw FirestoreException.forInvalidArgument( + "Value for argument 'maxOpsPerSecond' must be greater than 1, but was: " + + maxRate.intValue()); + } + + if (maxRate != null && initialRate != null && initialRate > maxRate) { + throw FirestoreException.forInvalidArgument( + "'maxOpsPerSecond' cannot be less than 'initialOpsPerSecond'."); + } + + if (!options.getThrottlingEnabled() && (maxRate != null || initialRate != null)) { + throw FirestoreException.forInvalidArgument( + "Cannot set 'initialOpsPerSecond' or 'maxOpsPerSecond' when 'throttlingEnabled' is set" + + " to false."); + } + return options; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionGroup.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionGroup.java new file mode 100644 index 000000000000..159f7077d830 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionGroup.java @@ -0,0 +1,197 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptions; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.PartitionQueryRequest; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Nullable; + +/** + * A Collection Group query matches all documents that are contained in a collection or + * subcollection with a specific collection ID. + */ +public class CollectionGroup extends Query { + + final Query partitionQuery; + + CollectionGroup(FirestoreRpcContext rpcContext, String collectionId) { + super( + rpcContext, + QueryOptions.builder() + .setParentPath(rpcContext.getResourcePath()) + .setCollectionId(collectionId) + .setAllDescendants(true) + .build()); + + // Partition queries require explicit ordering by __name__. + partitionQuery = orderBy(FieldPath.DOCUMENT_ID); + } + + /** + * 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 as starting/end + * points for the query results. + * + * @deprecated Please use {@link #getPartitions(long)} instead. All cursors will be loaded before + * any value will be provided to {@code observer}. + * @param desiredPartitionCount The desired maximum number of partition points. The number must be + * strictly positive. The actual number of partitions returned may be fewer. + * @param observer a stream observer that receives the result of the Partition request. + */ + public void getPartitions( + long desiredPartitionCount, final ApiStreamObserver observer) { + if (desiredPartitionCount == 1) { + // Short circuit if the user only requested a single partition. + observer.onNext(new QueryPartition(partitionQuery, null, null)); + } else { + PartitionQueryRequest request = buildRequest(desiredPartitionCount); + + final PartitionQueryPagedResponse response; + try { + response = + ApiExceptions.callAndTranslateApiException( + rpcContext.sendRequest( + request, rpcContext.getClient().partitionQueryPagedCallable())); + + consumePartitions( + response, + queryPartition -> { + observer.onNext(queryPartition); + return null; + }); + + observer.onCompleted(); + } catch (ApiException exception) { + throw FirestoreException.forApiException(exception); + } + } + } + + public ApiFuture> getPartitions(long desiredPartitionCount) { + if (desiredPartitionCount == 1) { + // Short circuit if the user only requested a single partition. + return ApiFutures.immediateFuture( + Collections.singletonList(new QueryPartition(partitionQuery, null, null))); + } else { + PartitionQueryRequest request = buildRequest(desiredPartitionCount); + + TraceUtil.Span span = + rpcContext + .getFirestore() + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_PARTITION_QUERY); + + MetricsContext metricsContext = + rpcContext + .getFirestore() + .getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_PARTITION_QUERY); + + try (Scope ignored = span.makeCurrent()) { + ApiFuture> result = + ApiFutures.transform( + rpcContext.sendRequest( + request, rpcContext.getClient().partitionQueryPagedCallable()), + response -> { + final ImmutableList.Builder partitions = ImmutableList.builder(); + consumePartitions( + response, + queryPartition -> { + partitions.add(queryPartition); + return null; + }); + return partitions.build(); + }, + MoreExecutors.directExecutor()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (ApiException exception) { + span.end(exception); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception); + throw FirestoreException.forApiException(exception); + } catch (Throwable throwable) { + span.end(throwable); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable); + throw throwable; + } + } + } + + private PartitionQueryRequest buildRequest(long desiredPartitionCount) { + Preconditions.checkArgument( + desiredPartitionCount > 0, "Desired partition count must be one or greater"); + + PartitionQueryRequest.Builder request = PartitionQueryRequest.newBuilder(); + request.setStructuredQuery(partitionQuery.buildQuery()); + request.setParent(options.getParentPath().toString()); + + // Since we are always returning an extra partition (with en empty endBefore cursor), we + // reduce the desired partition count by one. + request.setPartitionCount(desiredPartitionCount - 1); + return request.build(); + } + + private void consumePartitions( + PartitionQueryPagedResponse response, Function consumer) { + List cursors = new ArrayList<>(); + for (Cursor cursor : response.iterateAll()) { + cursors.add(cursor); + } + + // Sort the partitions as they may not be ordered if responses are paged. + cursors.sort( + (left, right) -> Order.INSTANCE.compareArrays(left.getValuesList(), right.getValuesList())); + + @Nullable Object[] lastCursor = null; + for (Cursor cursor : cursors) { + Object[] decodedCursorValue = new Object[cursor.getValuesCount()]; + for (int i = 0; i < cursor.getValuesCount(); ++i) { + decodedCursorValue[i] = UserDataConverter.decodeValue(rpcContext, cursor.getValues(i)); + } + consumer.apply(new QueryPartition(partitionQuery, lastCursor, decodedCursorValue)); + lastCursor = decodedCursorValue; + } + consumer.apply(new QueryPartition(partitionQuery, lastCursor, null)); + } + + @SuppressWarnings("MethodDoesntCallSuperMethod") + @Override + public String toString() { + return String.format("CollectionGroup{partitionQuery=%s, options=%s}", partitionQuery, options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionReference.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionReference.java new file mode 100644 index 000000000000..75954d82de3a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/CollectionReference.java @@ -0,0 +1,264 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptions; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.ListDocumentsRequest; +import java.util.Iterator; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A CollectionReference can be used for adding documents, getting document references, and querying + * for documents (using the methods inherited from Query). + * + *

Subclassing Note: Firestore classes are not meant to be subclassed except for use in + * test mocks. Subclassing is not supported in production code and new SDK releases may break code + * that does so. + */ +@InternalExtensionOnly +public class CollectionReference extends Query { + + /** + * Creates a CollectionReference from a complete collection path. + * + * @param rpcContext The Firestore client. + * @param collectionPath The Path of this collection. + */ + CollectionReference(FirestoreRpcContext rpcContext, ResourcePath collectionPath) { + super(rpcContext, collectionPath); + } + + /** + * The id of a collection refers to the last component of path pointing to a collection, for + * example "collection-id" in "projects/project-id/databases/database-id/documents/collection-id". + * + * @return The ID of the collection. + */ + @Nonnull + public String getId() { + return options.getCollectionId(); + } + + /** + * Returns a DocumentReference to the containing Document if this is a subcollection, else null. + * + * @return A DocumentReference pointing to the parent document. + */ + @Nullable + public DocumentReference getParent() { + ResourcePath parent = options.getParentPath(); + return parent.isDocument() ? new DocumentReference(rpcContext, parent) : null; + } + + /** + * A string representing the path of the referenced collection (relative to the root of the + * database). + * + * @return The slash-separated path relative to the root of the database. + */ + @Nonnull + public String getPath() { + return getResourcePath().getPath(); + } + + /** + * Returns a DocumentReference pointing to a new document with an auto-generated ID within this + * collection. + * + * @return A DocumentReference pointing to a new document with an auto-generated ID. + */ + @Nonnull + public DocumentReference document() { + return document(FirestoreImpl.autoId()); + } + + /** + * Gets a DocumentReference instance that refers to the document that is a child of this + * Collection. + * + * @param childPath A relative and slash-separated path to a document. + * @return The DocumentReference instance. + */ + @Nonnull + public DocumentReference document(@Nonnull String childPath) { + ResourcePath documentPath = getResourcePath().append(childPath); + Preconditions.checkArgument( + documentPath.isDocument(), "Path should point to a Document Reference: %s", getPath()); + return new DocumentReference(rpcContext, documentPath); + } + + /** + * Retrieves the list of documents in this collection. + * + *

The document references returned may include references to "missing documents", specifically + * document locations that have no document present but which contain subcollections with + * documents. Attempting to read such a document reference (for example via `get()` or + * `onSnapshot()`) will return a `DocumentSnapshot` whose `exists()` method returns false. + * + * @return The list of documents in this collection. + */ + @Nonnull + public Iterable listDocuments() { + TraceUtil.Span span = + rpcContext + .getFirestore() + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_COL_REF_LIST_DOCUMENTS); + + MetricsContext metricsContext = + rpcContext + .getFirestore() + .getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_COL_REF_LIST_DOCUMENTS); + + try (Scope ignored = span.makeCurrent()) { + ListDocumentsRequest.Builder request = ListDocumentsRequest.newBuilder(); + request.setParent(options.getParentPath().toString()); + request.setCollectionId(options.getCollectionId()); + request.setMask(DocumentMask.getDefaultInstance()); + request.setShowMissing(true); + final ListDocumentsPagedResponse response; + FirestoreRpc client = rpcContext.getClient(); + UnaryCallable callable = + client.listDocumentsPagedCallable(); + ListDocumentsRequest build = request.build(); + ApiFuture future = rpcContext.sendRequest(build, callable); + response = ApiExceptions.callAndTranslateApiException(future); + Iterable result = + new Iterable() { + @Override + @Nonnull + public Iterator iterator() { + final Iterator iterator = response.iterateAll().iterator(); + return new Iterator() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public DocumentReference next() { + ResourcePath path = ResourcePath.create(iterator.next().getName()); + return document(path.getId()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove"); + } + }; + } + }; + span.end(); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + return result; + } catch (ApiException exception) { + span.end(exception); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception); + throw FirestoreException.forApiException(exception); + } catch (Throwable throwable) { + span.end(throwable); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable); + throw throwable; + } + } + + /** + * Adds a new document to this collection with the specified data, assigning it a document ID + * automatically. + * + * @param fields A Map containing the data for the new document. + * @return An ApiFuture that will be resolved with the DocumentReference of the newly created + * document. + * @see #document() + */ + @Nonnull + public ApiFuture add(@Nonnull final Map fields) { + TraceUtil.Span span = + rpcContext + .getFirestore() + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_COL_REF_ADD); + + MetricsContext metricsContext = + rpcContext + .getFirestore() + .getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_COL_REF_ADD); + + try (Scope ignored = span.makeCurrent()) { + final DocumentReference documentReference = document(); + ApiFuture createFuture = documentReference.create(fields); + ApiFuture result = + ApiFutures.transform( + createFuture, writeResult -> documentReference, MoreExecutors.directExecutor()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Adds a new document to this collection with the specified POJO as contents, assigning it a + * document ID automatically. + * + * @param pojo The POJO that will be used to populate the contents of the document + * @return An ApiFuture that will be resolved with the DocumentReference of the newly created + * document. + * @see #document() + */ + public ApiFuture add(Object pojo) { + Object converted = CustomClassMapper.convertToPlainJavaTypes(pojo); + if (!(converted instanceof Map)) { + throw FirestoreException.forInvalidArgument( + "Can't set a document's data to an array or primitive"); + } + return add((Map) converted); + } + + /** Returns a resource path pointing to this collection. */ + ResourcePath getResourcePath() { + return options.getParentPath().append(options.getCollectionId()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentChange.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentChange.java new file mode 100644 index 000000000000..5bfe91e740c6 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentChange.java @@ -0,0 +1,124 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import java.util.Objects; +import javax.annotation.Nonnull; + +/** + * A DocumentChange represents a change to the documents matching a query. It contains the document + * affected and a the type of change that occurred (added, modifed, or removed). + */ +public class DocumentChange { + /** An enumeration of snapshot diff types. */ + public enum Type { + /** Indicates a new document was added to the set of documents matching the query. */ + ADDED, + /** Indicates a document within the query was modified. */ + MODIFIED, + /** + * Indicates a document within the query was removed (either deleted or no longer matches the + * query. + */ + REMOVED + } + + private final Type type; + + private final QueryDocumentSnapshot document; + + /** The index in the old snapshot, after processing all previous changes. */ + private final int oldIndex; + + /** The index in the new snapshot, after processing all previous changes. */ + private final int newIndex; + + DocumentChange(QueryDocumentSnapshot document, Type type, int oldIndex, int newIndex) { + this.type = type; + this.document = document; + this.oldIndex = oldIndex; + this.newIndex = newIndex; + } + + @Nonnull + public Type getType() { + return type; + } + + /** + * Returns the newly added or modified document if this DocumentChange is for an updated document. + * Returns the deleted document if this document change represents a removal. + * + * @return A snapshot of the new data (for Type.ADDED or Type.MODIFIED) or the removed data (for + * Type.REMOVED). + */ + @Nonnull + public QueryDocumentSnapshot getDocument() { + return document; + } + + /** + * The index of the changed document in the result set immediately prior to this DocumentChange + * (specifically, supposing that all prior DocumentChange objects have been applied). Returns -1 + * for 'added' events. + */ + public int getOldIndex() { + return oldIndex; + } + + /** + * The index of the changed document in the result set immediately after this DocumentChange + * (specifically, supposing that all prior DocumentChange objects and the current DocumentChange + * object have been applied). Returns -1 for 'removed' events. + */ + public int getNewIndex() { + return newIndex; + } + + /** + * Returns true if this DocumentChange is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this DocumentChange is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + DocumentChange that = (DocumentChange) obj; + return oldIndex == that.oldIndex + && newIndex == that.newIndex + && type == that.type + && Objects.equals(document, that.document); + } + + @Override + public int hashCode() { + return Objects.hash(type, document, oldIndex, newIndex); + } + + @Override + public String toString() { + return String.format( + "DocumentChange{type=%s, document=%s, oldIndex=%d, newIndex=%d}", + type, document, oldIndex, newIndex); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentReference.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentReference.java new file mode 100644 index 000000000000..2b0cc1ddc939 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentReference.java @@ -0,0 +1,729 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptions; +import com.google.cloud.firestore.telemetry.MetricsUtil; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.ListCollectionIdsRequest; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.Executor; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A DocumentReference refers to a document location in a Firestore database and can be used to + * write, read, or listen to the location. There may or may not exist a document at the referenced + * location. A DocumentReference can also be used to create a CollectionReference to a + * subcollection. + * + *

Subclassing Note: Firestore classes are not meant to be subclassed except for use in + * test mocks. Subclassing is not supported in production code and new SDK releases may break code + * that does so. + */ +@InternalExtensionOnly +public class DocumentReference { + + private final ResourcePath path; + private final FirestoreRpcContext rpcContext; + + DocumentReference( + FirestoreRpcContext rpcContext, ResourcePath path) { // Elevated access level for mocking. + this.path = path; + this.rpcContext = rpcContext; + } + + /* + * Gets the Firestore instance associated with this document reference. + * + * @return The Firestore instance. + */ + @Nonnull + public Firestore getFirestore() { + return rpcContext.getFirestore(); + } + + /** + * The id of a document refers to the last component of path pointing to a document, for example + * "document-id" in "projects/project-id/databases/database-id/document-id". + * + * @return The ID of the document. + */ + @Nonnull + public String getId() { + return path.getId(); + } + + /** + * A string representing the path of the referenced document (relative to the root of the + * database). + * + * @return The slash-separated path relative to the root of the database. + */ + @Nonnull + public String getPath() { + return path.getPath(); + } + + /** + * A string representing the fully-qualified path of the referenced document. + * + * @return The fully-qualified path of the document. + */ + @Nonnull + String getName() { + return path.getName(); + } + + /** + * A reference to the Collection to which this DocumentReference belongs to. + * + * @return The parent Collection. + */ + @Nonnull + public CollectionReference getParent() { + return new CollectionReference(rpcContext, path.getParent()); + } + + /** + * Gets a CollectionReference instance that refers to the collection that is a child of this + * document. + * + * @param collectionPath A relative and slash-separated path to a collection. + * @return The CollectionReference instance. + */ + @Nonnull + public CollectionReference collection(@Nonnull String collectionPath) { + return new CollectionReference(rpcContext, path.append(collectionPath)); + } + + /** + * Extracts the first result from an ApiFuture with list of results. + * + * @param results A list with results. + * @return An ApiFuture with the first WriteResult. + */ + private ApiFuture extractFirst(ApiFuture> results) { + return ApiFutures.transform( + results, + results1 -> results1.isEmpty() ? null : results1.get(0), + MoreExecutors.directExecutor()); + } + + /** Gets the TraceUtil object associated with this DocumentReference's Firestore instance. */ + @Nonnull + private TraceUtil getTraceUtil() { + return getFirestore().getOptions().getTraceUtil(); + } + + @Nonnull + private MetricsUtil getMetricsUtil() { + return getFirestore().getOptions().getMetricsUtil(); + } + + /** + * Creates a new Document at the DocumentReference's Location. It fails the write if the document + * exists. + * + * @param fields A map of the fields and values for the document. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture create(@Nonnull Map fields) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_CREATE); + + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_CREATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.create(this, fields).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Creates a new Document at the DocumentReference location. It fails the write if the document + * exists. + * + * @param pojo The POJO that will be used to populate the document contents. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture create(@Nonnull Object pojo) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_CREATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_CREATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.create(this, pojo).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Overwrites the document referred to by this DocumentReference. If no document exists yet, it + * will be created. If a document already exists, it will be overwritten. + * + * @param fields A map of the fields and values for the document. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture set(@Nonnull Map fields) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.set(this, fields).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Writes to the document referred to by this DocumentReference. If the document does not yet + * exist, it will be created. If you pass {@link SetOptions}, the provided data can be merged into + * an existing document. + * + * @param fields A map of the fields and values for the document. + * @param options An object to configure the set behavior. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture set( + @Nonnull Map fields, @Nonnull SetOptions options) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.set(this, fields, options).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Overwrites the document referred to by this DocumentReference. If no document exists yet, it + * will be created. If a document already exists, it will be overwritten. + * + * @param pojo The POJO that will be used to populate the document contents. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture set(@Nonnull Object pojo) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.set(this, pojo).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Writes to the document referred to by this DocumentReference. If the document does not yet + * exist, it will be created. If you pass {@link SetOptions}, the provided data can be merged into + * an existing document. + * + * @param pojo The POJO that will be used to populate the document contents. + * @param options An object to configure the set behavior. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture set(@Nonnull Object pojo, @Nonnull SetOptions options) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_SET); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.set(this, pojo, options).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates fields in the document referred to by this DocumentReference. If the document doesn't + * exist yet, the update will fail. + * + * @param fields A Map containing the fields and values with which to update the document. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update(@Nonnull Map fields) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.update(this, fields).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates fields in the document referred to by this DocumentReference. If the document doesn't + * exist yet, the update will fail. + * + * @param fields A map containing the fields and values with which to update the document. + * @param options Preconditions to enforce on this update. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update(@Nonnull Map fields, Precondition options) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = + extractFirst(writeBatch.update(this, fields, options).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param field The first field to set + * @param value The first value to set + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return An ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update( + @Nonnull String field, @Nullable Object value, Object... moreFieldsAndValues) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = + extractFirst(writeBatch.update(this, field, value, moreFieldsAndValues).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param fieldPath The first field to set + * @param value The first value to set + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return A ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update( + @Nonnull FieldPath fieldPath, @Nullable Object value, Object... moreFieldsAndValues) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = + extractFirst(writeBatch.update(this, fieldPath, value, moreFieldsAndValues).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param options Preconditions to enforce on this update. + * @param field The first field to set + * @param value The first value to set + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return A ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update( + @Nonnull Precondition options, + @Nonnull String field, + @Nullable Object value, + Object... moreFieldsAndValues) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = + extractFirst( + writeBatch.update(this, options, field, value, moreFieldsAndValues).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param options Preconditions to enforce on this update. + * @param fieldPath The first field to set + * @param value The first value to set + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return A ApiFuture that will be resolved when the write finishes. + */ + @Nonnull + public ApiFuture update( + @Nonnull Precondition options, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object... moreFieldsAndValues) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = + extractFirst( + writeBatch.update(this, options, fieldPath, value, moreFieldsAndValues).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Deletes the document referred to by this DocumentReference. + * + * @param options Preconditions to enforce for this delete. + * @return An ApiFuture that will be resolved when the delete completes. + */ + @Nonnull + public ApiFuture delete(@Nonnull Precondition options) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_DELETE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_DELETE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.delete(this, options).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Deletes the document referred to by this DocumentReference. + * + * @return An ApiFuture that will be resolved when the delete completes. + */ + @Nonnull + public ApiFuture delete() { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_DELETE); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_DELETE); + + try (Scope ignored = span.makeCurrent()) { + WriteBatch writeBatch = rpcContext.getFirestore().batch(); + ApiFuture result = extractFirst(writeBatch.delete(this).commit()); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Reads the document referenced by this DocumentReference. If the document doesn't exist, the + * get() will return an empty DocumentSnapshot. + * + * @return An ApiFuture that will be resolved with the contents of the Document at this + * DocumentReference, or a failure if the document does not exist. + */ + @Nonnull + public ApiFuture get() { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_GET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_GET); + + try (Scope ignored = span.makeCurrent()) { + ApiFuture result = extractFirst(rpcContext.getFirestore().getAll(this)); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Reads the document referenced by this DocumentReference. If the document doesn't exist, the + * get(FieldMask fieldMask) will return an empty DocumentSnapshot. + * + * @param fieldMask A FieldMask object to retrieve the field value + * @return An ApiFuture that will be resolved with the contents of the Document at this + * DocumentReference, or a failure if the document does not exist + */ + @Nonnull + public ApiFuture get(FieldMask fieldMask) { + TraceUtil.Span span = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_GET); + MetricsContext metricsContext = + getMetricsUtil().createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_GET); + + try (Scope ignored = span.makeCurrent()) { + ApiFuture result = + extractFirst(rpcContext.getFirestore().getAll(new DocumentReference[] {this}, fieldMask)); + span.endAtFuture(result); + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Fetches the subcollections that are direct children of this document. + * + * @throws FirestoreException if the Iterable could not be initialized. + * @return An Iterable that can be used to fetch all subcollections. + */ + @Nonnull + public Iterable listCollections() { + TraceUtil.Span span = + getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_DOC_REF_LIST_COLLECTIONS); + MetricsContext metricsContext = + getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_DOC_REF_LIST_COLLECTIONS); + + try (Scope ignored = span.makeCurrent()) { + ListCollectionIdsRequest.Builder request = ListCollectionIdsRequest.newBuilder(); + request.setParent(path.toString()); + final ListCollectionIdsPagedResponse response; + response = + ApiExceptions.callAndTranslateApiException( + rpcContext.sendRequest( + request.build(), rpcContext.getClient().listCollectionIdsPagedCallable())); + Iterable result = + new Iterable() { + @Override + @Nonnull + public Iterator iterator() { + final Iterator iterator = response.iterateAll().iterator(); + return new Iterator() { + @Override + public boolean hasNext() { + return iterator.hasNext(); + } + + @Override + public CollectionReference next() { + return DocumentReference.this.collection(iterator.next()); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove"); + } + }; + } + }; + span.end(); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + return result; + } catch (ApiException exception) { + span.end(exception); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, exception); + throw FirestoreException.forApiException(exception); + } + } + + /** + * Starts listening to the document referenced by this DocumentReference. + * + * @param executor The executor to use to call the listener. + * @param listener The event listener that will be called with the snapshots. + * @return A registration object that can be used to remove the listener. + */ + @Nonnull + public ListenerRegistration addSnapshotListener( + @Nonnull Executor executor, @Nonnull final EventListener listener) { + return Watch.forDocument(this) + .runWatch( + executor, + (value, error) -> { + if (value == null) { + listener.onEvent(null, error); + return; + } + + for (DocumentSnapshot doc : value) { + if (doc.getReference().equals(DocumentReference.this)) { + listener.onEvent(value.getDocuments().get(0), null); + return; + } + } + listener.onEvent( + DocumentSnapshot.fromMissing( + rpcContext, DocumentReference.this, value.getReadTime()), + null); + }); + } + + /** + * Starts listening to the document referenced by this DocumentReference. + * + * @param listener The event listener that will be called with the snapshots. + * @return A registration object that can be used to remove the listener. + */ + @Nonnull + public ListenerRegistration addSnapshotListener( + @Nonnull EventListener listener) { + return addSnapshotListener(rpcContext.getClient().getExecutor(), listener); + } + + ResourcePath getResourcePath() { + return path; + } + + @Override + public String toString() { + return String.format("DocumentReference{path=%s}", path); + } + + /** + * Returns true if this DocumentReference is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this DocumentReference is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + DocumentReference that = (DocumentReference) obj; + return Objects.equals(path, that.path) && Objects.equals(rpcContext, that.rpcContext); + } + + @Override + public int hashCode() { + return Objects.hash(path, rpcContext); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSet.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSet.java new file mode 100644 index 000000000000..423070903063 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSet.java @@ -0,0 +1,134 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.firestore.collection.ImmutableSortedMap; +import com.google.cloud.firestore.collection.ImmutableSortedSet; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import javax.annotation.Nullable; + +/** + * An immutable set of documents (unique by key) ordered by the given comparator or ordered by key + * by default if no document is present. + */ +class DocumentSet implements Iterable { + private static final ImmutableSortedMap EMPTY_DOCUMENT_MAP = + ImmutableSortedMap.Builder.emptyMap(ResourcePath.comparator()); + + /** Returns an empty DocumentSet sorted by the given comparator, then by keys. */ + static DocumentSet emptySet(final Comparator comparator) { + return new DocumentSet( + EMPTY_DOCUMENT_MAP, new ImmutableSortedSet<>(Collections.emptyList(), comparator)); + } + + /** + * An index of the documents in the DocumentSet, indexed by document key. The index exists to + * guarantee the uniqueness of document keys in the set and to allow lookup and removal of + * documents by key. + */ + private final ImmutableSortedMap keyIndex; + + /** + * The main collection of documents in the DocumentSet. The documents are ordered by the provided + * comparator. The collection exists in addition to the index to allow ordered traversal of the + * DocumentSet. + */ + private final ImmutableSortedSet sortedSet; + + private DocumentSet( + ImmutableSortedMap keyIndex, + ImmutableSortedSet sortedSet) { + this.keyIndex = keyIndex; + this.sortedSet = sortedSet; + } + + int size() { + return keyIndex.size(); + } + + boolean isEmpty() { + return keyIndex.isEmpty(); + } + + /** Returns true iff this set contains a document with the given key. */ + boolean contains(ResourcePath key) { + return keyIndex.containsKey(key); + } + + /** Returns the document from this set with the given key if it exists or null if it doesn't. */ + @Nullable + QueryDocumentSnapshot getDocument(ResourcePath key) { + return keyIndex.get(key); + } + + /** + * Returns the index of the provided key in the document set, or -1 if the document key is not + * present in the set; + */ + int indexOf(ResourcePath key) { + QueryDocumentSnapshot document = keyIndex.get(key); + if (document == null) { + return -1; + } + return sortedSet.indexOf(document); + } + + /** + * Returns a new DocumentSet that contains the given document, replacing any old document with the + * same key. + */ + DocumentSet add(QueryDocumentSnapshot document) { + // Remove any prior mapping of the document's key before adding, preventing sortedSet from + // accumulating values that aren't in the index. + DocumentSet removed = remove(document.getReference().getResourcePath()); + + ImmutableSortedMap newKeyIndex = + removed.keyIndex.insert(document.getReference().getResourcePath(), document); + ImmutableSortedSet newSortedSet = removed.sortedSet.insert(document); + return new DocumentSet(newKeyIndex, newSortedSet); + } + + /** Returns a new DocumentSet with the document for the provided key removed. */ + DocumentSet remove(ResourcePath key) { + QueryDocumentSnapshot document = keyIndex.get(key); + if (document == null) { + return this; + } + + ImmutableSortedMap newKeyIndex = keyIndex.remove(key); + ImmutableSortedSet newSortedSet = sortedSet.remove(document); + return new DocumentSet(newKeyIndex, newSortedSet); + } + + /** Returns a copy of the documents in this set as array. This is O(n) in the size of the set. */ + List toList() { + List documents = new ArrayList<>(size()); + for (QueryDocumentSnapshot document : this) { + documents.add(document); + } + return documents; + } + + @Override + public Iterator iterator() { + return sortedSet.iterator(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java new file mode 100644 index 000000000000..e1aab1cac519 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java @@ -0,0 +1,471 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.UserDataConverter.EncodingOptions; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A DocumentSnapshot contains data read from a document in a Firestore database. The data can be + * extracted with the {@link #getData()} or {@link #get(String)} methods. + * + *

If the DocumentSnapshot points to a non-existing document, getData() and its corresponding + * methods will return null. You can always explicitly check for a document's existence by calling + * {@link #exists()}. + * + *

Subclassing Note: Firestore classes are not meant to be subclassed except for use in + * test mocks. Subclassing is not supported in production code and new SDK releases may break code + * that does so. + */ +@InternalExtensionOnly +public class DocumentSnapshot { + + private final FirestoreRpcContext rpcContext; + private final DocumentReference docRef; + @Nullable private final Map fields; + @Nullable private final Timestamp readTime; + @Nullable private final Timestamp updateTime; + @Nullable private final Timestamp createTime; + + DocumentSnapshot( + FirestoreRpcContext rpcContext, + DocumentReference docRef, + @Nullable Map fields, + @Nullable Timestamp readTime, + @Nullable Timestamp updateTime, + @Nullable Timestamp createTime) { // Elevated access level for mocking. + this.rpcContext = rpcContext; + this.docRef = docRef; + this.fields = fields; + this.readTime = readTime; + this.updateTime = updateTime; + this.createTime = createTime; + } + + /** + * Returns the ID of the document contained in this snapshot. + * + * @return The id of the document. + */ + @Nonnull + public String getId() { + return docRef.getId(); + } + + static DocumentSnapshot fromObject( + FirestoreRpcContext rpcContext, + DocumentReference docRef, + Map values, + EncodingOptions options) { + Map fields = new HashMap<>(); + for (Map.Entry entry : values.entrySet()) { + Value encodedValue = + UserDataConverter.encodeValue( + FieldPath.of(entry.getKey()), + CustomClassMapper.convertToPlainJavaTypes(entry.getValue()), + options); + if (encodedValue != null) { + fields.put(entry.getKey(), encodedValue); + } + } + return new DocumentSnapshot(rpcContext, docRef, fields, null, null, null); + } + + static DocumentSnapshot fromDocument( + FirestoreRpcContext rpcContext, Timestamp readTime, Document document) { + return new DocumentSnapshot( + rpcContext, + new DocumentReference(rpcContext, ResourcePath.create(document.getName())), + document.getFieldsMap(), + readTime, + Timestamp.fromProto(document.getUpdateTime()), + Timestamp.fromProto(document.getCreateTime())); + } + + static DocumentSnapshot fromMissing( + FirestoreRpcContext rpcContext, DocumentReference documentReference, Timestamp readTime) { + return new DocumentSnapshot(rpcContext, documentReference, null, readTime, null, null); + } + + /** + * Returns the time at which this snapshot was read. + * + * @return The read time of this snapshot. + */ + @Nullable + public Timestamp getReadTime() { + return readTime; + } + + /** + * Returns the time at which this document was last updated. Returns null for non-existing + * documents. + * + * @return The last time the document in the snapshot was updated. Null if the document doesn't + * exist. + */ + @Nullable + public Timestamp getUpdateTime() { + return updateTime; + } + + /** + * Returns the time at which this document was created. Returns null for non-existing documents. + * + * @return The last time the document in the snapshot was created. Null if the document doesn't + * exist. + */ + @Nullable + public Timestamp getCreateTime() { + return createTime; + } + + /** + * Returns whether or not the field exists in the document. Returns false if the document does not + * exist. + * + * @return whether the document existed in this snapshot. + */ + public boolean exists() { + return fields != null; + } + + /** + * Returns the fields of the document as a Map or null if the document doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the document doesn't exist. + */ + @Nullable + public Map getData() { + if (fields == null) { + return null; + } + + Map decodedFields = new HashMap<>(); + for (Map.Entry entry : fields.entrySet()) { + Object decodedValue = UserDataConverter.decodeValue(rpcContext, entry.getValue()); + decodedFields.put(entry.getKey(), decodedValue); + } + return decodedFields; + } + + /** + * Returns the contents of the document converted to a POJO or null if the document doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the document in an object of type T or null if the document doesn't + * exist. + */ + @Nullable + public T toObject(@Nonnull Class valueType) { + Map data = getData(); + return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef); + } + + /** + * Returns whether or not the field exists in the document. Returns false if the document does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + public boolean contains(@Nonnull String field) { + return contains(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Returns whether or not the field exists in the document. Returns false if the document does not + * exist. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + public boolean contains(@Nonnull FieldPath fieldPath) { + return this.extractField(fieldPath) != null; + } + + /** + * Returns the value at the field or null if the field doesn't exist. + * + * @param field The path to the field. + * @return The value at the given field or null. + */ + @Nullable + public Object get(@Nonnull String field) { + return get(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Returns the value at the field, converted to a POJO, or null if the field or document doesn't + * exist. + * + * @param field The path to the field + * @param valueType The Java class to convert the field value to. + * @return The value at the given field or null. + */ + @Nullable + public T get(@Nonnull String field, @Nonnull Class valueType) { + return get(FieldPath.fromDotSeparatedString(field), valueType); + } + + /** + * Returns the value at the field or null if the field doesn't exist. + * + * @param fieldPath The path to the field. + * @return The value at the given field or null. + */ + @Nullable + public Object get(@Nonnull FieldPath fieldPath) { + Value value = extractField(fieldPath); + + if (value == null) { + return null; + } + + return UserDataConverter.decodeValue(rpcContext, value); + } + + /** + * Returns the value at the field, converted to a POJO, or null if the field or document doesn't + * exist. + * + * @param fieldPath The path to the field + * @param valueType The Java class to convert the field value to. + * @return The value at the given field or null. + */ + @Nullable + public T get(@Nonnull FieldPath fieldPath, Class valueType) { + Object data = get(fieldPath); + return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef); + } + + /** Returns the Value Proto at 'fieldPath'. Returns null if the field was not found. */ + @Nullable + Value extractField(@Nonnull FieldPath fieldPath) { + Value value = null; + + if (fields != null) { + Iterator components = fieldPath.getSegments().iterator(); + value = fields.get(components.next()); + + while (value != null && components.hasNext()) { + if (value.getValueTypeCase() != Value.ValueTypeCase.MAP_VALUE) { + return null; + } + value = value.getMapValue().getFieldsOrDefault(components.next(), null); + } + } + + return value; + } + + /** + * Returns the value of the field as a boolean. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Boolean. + * @return The value of the field. + */ + @Nullable + public Boolean getBoolean(@Nonnull String field) { + return (Boolean) get(field); + } + + /** + * Returns the value of the field as a double. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Number. + * @return The value of the field. + */ + @Nullable + public Double getDouble(@Nonnull String field) { + Number number = (Number) get(field); + return number == null ? null : number.doubleValue(); + } + + /** + * Returns the value of the field as a String. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a String. + * @return The value of the field. + */ + @Nullable + public String getString(@Nonnull String field) { + return (String) get(field); + } + + /** + * Returns the value of the field as a long. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Number. + * @return The value of the field. + */ + @Nullable + public Long getLong(@Nonnull String field) { + Number number = (Number) get(field); + return number == null ? null : number.longValue(); + } + + /** + * Returns the value of the field as a Date. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Date. + * @return The value of the field. + */ + @Nullable + public Date getDate(@Nonnull String field) { + Timestamp timestamp = getTimestamp(field); + return timestamp == null ? null : timestamp.toDate(); + } + + /** + * Returns the value of the field as a {@link Timestamp}. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Date. + * @return The value of the field. + */ + @Nullable + public Timestamp getTimestamp(@Nonnull String field) { + return (Timestamp) get(field); + } + + /** + * Returns the value of the field as a Blob. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Blob. + * @return The value of the field. + */ + @Nullable + public Blob getBlob(@Nonnull String field) { + return (Blob) get(field); + } + + /** + * Returns the value of the field as a GeoPoint. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a GeoPoint. + * @return The value of the field. + */ + @Nullable + public GeoPoint getGeoPoint(@Nonnull String field) { + return (GeoPoint) get(field); + } + + /** + * Returns the value of the field as a VectorValue. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a VectorValue. + * @return The value of the field. + */ + @Nullable + public VectorValue getVectorValue(@Nonnull String field) { + return (VectorValue) get(field); + } + + /** + * Gets the reference to the document. + * + * @return The reference to the document. + */ + @Nonnull + public DocumentReference getReference() { + return docRef; + } + + /** Checks whether this DocumentSnapshot contains any fields. */ + boolean isEmpty() { + return fields == null || fields.isEmpty(); + } + + Map getProtoFields() { + return fields; + } + + Write.Builder toPb() { + Preconditions.checkState(exists(), "Can't call toDocument() on a document that doesn't exist"); + Write.Builder write = Write.newBuilder(); + Document.Builder document = write.getUpdateBuilder(); + document.setName(docRef.getName()); + document.putAllFields(fields); + return write; + } + + Document.Builder toDocumentPb() { + Preconditions.checkState(exists(), "Can't call toDocument() on a document that doesn't exist"); + Document.Builder document = Document.newBuilder(); + return document + .setName(docRef.getName()) + .putAllFields(fields) + .setCreateTime(createTime.toProto()) + .setUpdateTime(updateTime.toProto()); + } + + /** + * Returns true if the document's data and path in this DocumentSnapshot equals the provided + * snapshot. + * + * @param obj The object to compare against. + * @return Whether this DocumentSnapshot is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof DocumentSnapshot)) { + return false; + } + DocumentSnapshot that = (DocumentSnapshot) obj; + return Objects.equals(rpcContext, that.rpcContext) + && Objects.equals(docRef, that.docRef) + && Objects.equals(fields, that.fields); + } + + @Override + public int hashCode() { + return Objects.hash(rpcContext, docRef, fields); + } + + @Override + public String toString() { + return String.format( + "%s{doc=%s, fields=%s, readTime=%s, updateTime=%s, createTime=%s}", + getClass().getSimpleName(), docRef, fields, readTime, updateTime, createTime); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentTransform.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentTransform.java new file mode 100644 index 000000000000..f6343a7e2c49 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentTransform.java @@ -0,0 +1,118 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.firestore.v1.DocumentTransform.FieldTransform; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; + +/** + * A DocumentTransform contains pending server-side transforms and their corresponding field paths. + */ +final class DocumentTransform { + + private final SortedMap transforms; // Sorted for testing. + + private DocumentTransform(SortedMap transforms) { + this.transforms = transforms; + } + + static DocumentTransform fromFieldPathMap(Map values) { + SortedMap transforms = new TreeMap<>(); + + for (Map.Entry entry : values.entrySet()) { + FieldPath path = entry.getKey(); + Object value = entry.getValue(); + if (value instanceof FieldValue) { + FieldValue fieldValue = (FieldValue) value; + if (fieldValue.includeInDocumentTransform()) { + transforms.put(path, fieldValue.toProto(path)); + } + } else if (value instanceof Map) { + transforms.putAll( + extractFromMap((Map) value, path, /* allowTransforms= */ true)); + } else if (entry.getValue() instanceof List) { + // DocumentTransforms cannot be contained in Lists. We still process the List for + // validation. + validateArray((List) entry.getValue(), path); + } + } + + return new DocumentTransform(transforms); + } + + private static SortedMap extractFromMap( + Map values, FieldPath path, boolean allowTransforms) { + SortedMap transforms = new TreeMap<>(); + + for (Map.Entry entry : values.entrySet()) { + Object value = entry.getValue(); + path = path.append(FieldPath.of(entry.getKey())); + if (value instanceof FieldValue) { + FieldValue fieldValue = (FieldValue) value; + if (allowTransforms) { + if (fieldValue.includeInDocumentTransform()) { + transforms.put(path, fieldValue.toProto(path)); + } + } else { + throw FirestoreException.forInvalidArgument( + fieldValue.getMethodName() + " is not supported inside of an array."); + } + } else if (value instanceof Map) { + transforms.putAll(extractFromMap((Map) value, path, allowTransforms)); + } else if (entry.getValue() instanceof List) { + validateArray((List) entry.getValue(), path); + } + path = path.getParent(); + } + + return transforms; + } + + private static void validateArray(List values, FieldPath path) { + for (int i = 0; i < values.size(); ++i) { + Object value = values.get(i); + path = path.append(FieldPath.of(Integer.toString(i))); + if (value instanceof FieldValue) { + throw FirestoreException.forInvalidArgument( + ((FieldValue) value).getMethodName() + " is not supported inside of an array."); + } else if (value instanceof Map) { + extractFromMap((Map) value, path, false); + } else if (value instanceof List) { + validateArray((List) value, path); + } + path = path.getParent(); + } + } + + boolean isEmpty() { + return transforms.isEmpty(); + } + + Set getFields() { + return Collections.unmodifiableSet(transforms.keySet()); + } + + Collection toPb() { + return transforms.values(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/EventListener.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/EventListener.java new file mode 100644 index 000000000000..391c6c354623 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/EventListener.java @@ -0,0 +1,32 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import javax.annotation.Nullable; + +/** An interface for event listeners. */ +public interface EventListener { + + /** + * onEvent will be called with the new value or the error if an error occurred. It's guaranteed + * that exactly one of value or error will be non-null. + * + * @param value The value of the event. null if there was an error. + * @param error The error if there was error. null otherwise. + */ + void onEvent(@Nullable T value, @Nullable FirestoreException error); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExecutionStats.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExecutionStats.java new file mode 100644 index 000000000000..933a76ad51be --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExecutionStats.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore; + +import java.time.Duration; +import java.util.Map; +import javax.annotation.Nonnull; + +/** A ExecutionStats contains information about the execution of a query. */ +public final class ExecutionStats { + private final long resultsReturned; + private final @Nonnull Duration executionDuration; + private final long readOperations; + private final @Nonnull Map debugStats; + + ExecutionStats(com.google.firestore.v1.ExecutionStats proto) { + this.resultsReturned = proto.getResultsReturned(); + this.executionDuration = + Duration.ofSeconds( + proto.getExecutionDuration().getSeconds(), proto.getExecutionDuration().getNanos()); + this.readOperations = proto.getReadOperations(); + this.debugStats = UserDataConverter.decodeStruct(proto.getDebugStats()); + } + + /** Returns the number of query results. */ + public long getResultsReturned() { + return resultsReturned; + } + + /** Returns the total execution time of the query. */ + @Nonnull + public Duration getExecutionDuration() { + return executionDuration; + } + + /** Returns the number of read operations that occurred when executing the query. */ + public long getReadOperations() { + return readOperations; + } + + /** + * Returns a map that contains additional statistics related to query execution. Note: The content + * of this map are subject to change. + */ + @Nonnull + public Map getDebugStats() { + return debugStats; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainMetrics.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainMetrics.java new file mode 100644 index 000000000000..4c8474e73961 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainMetrics.java @@ -0,0 +1,49 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ExplainMetrics contains information about planning and execution of a query. */ +public final class ExplainMetrics { + private final @Nonnull PlanSummary planSummary; + private final @Nullable ExecutionStats executionStats; + + ExplainMetrics(@Nonnull com.google.firestore.v1.ExplainMetrics metrics) { + // ExplainMetrics is guaranteed to have a plan summary. + this.planSummary = new PlanSummary(metrics.getPlanSummary()); + + // Depending on explain options, metrics may or may not contain execution stats. + this.executionStats = + metrics.hasExecutionStats() ? new ExecutionStats(metrics.getExecutionStats()) : null; + } + + /** Returns the information about the query plan. */ + @Nonnull + public PlanSummary getPlanSummary() { + return planSummary; + } + + /** + * Returns the information about the execution of the query, or null if the query was not + * executed. + */ + @Nullable + public ExecutionStats getExecutionStats() { + return executionStats; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainOptions.java new file mode 100644 index 000000000000..13526f1dd970 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainOptions.java @@ -0,0 +1,51 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore; + +import com.google.auto.value.AutoValue; + +/** Options used to configure explain queries. */ +@AutoValue +public abstract class ExplainOptions { + /** + * Returns whether analyzing the query is enabled. If enabled, the query will be executed and + * execution statistics will be returned as part of the [ExplainResults]{@link ExplainResults}. + */ + public abstract boolean getAnalyze(); + + public static Builder builder() { + return new AutoValue_ExplainOptions.Builder().setAnalyze(false); + } + + public abstract Builder toBuilder(); + + public com.google.firestore.v1.ExplainOptions toProto() { + return com.google.firestore.v1.ExplainOptions.newBuilder() + .setAnalyze(this.getAnalyze()) + .build(); + } + + @AutoValue.Builder + public abstract static class Builder { + /** + * Sets whether analyzing the query is enabled. If true, the query will be executed and + * execution statistics will be returned as part of the [ExplainResults]{@link ExplainResults}. + */ + public abstract Builder setAnalyze(boolean enabled); + + public abstract ExplainOptions build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainResults.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainResults.java new file mode 100644 index 000000000000..bb84e05d164b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainResults.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** ExplainResults contains information about planning, execution, and results of a query. */ +public final class ExplainResults { + @Nonnull private final ExplainMetrics metrics; + @Nullable private final T snapshot; + + ExplainResults(@Nonnull ExplainMetrics metrics, @Nullable T snapshot) { + this.metrics = metrics; + this.snapshot = snapshot; + } + + /** Returns the information about planning and execution (if any) of the query. */ + @Nonnull + public ExplainMetrics getMetrics() { + return metrics; + } + + /** + * Returns the snapshot that contains the results of executing the query, or null if the query was + * not executed. + */ + @Nullable + public T getSnapshot() { + return snapshot; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainStats.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainStats.java new file mode 100644 index 000000000000..9d255ac73489 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ExplainStats.java @@ -0,0 +1,73 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.BetaApi; +import com.google.protobuf.Any; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.StringValue; +import javax.annotation.Nonnull; + +/** + * A wrapper object to access explain stats if explain or analyze was enabled for the Pipeline query + * execution. + */ +@BetaApi +public final class ExplainStats { + + private final Any explainStatsData; + + /** + * @hideconstructor + * @param explainStatsData The raw proto message of the explain stats. + */ + ExplainStats(@Nonnull Any explainStatsData) { + this.explainStatsData = explainStatsData; + } + + /** + * Returns the explain stats in an encoded proto format, as returned from the Firestore backend. + * The caller is responsible for unpacking this proto message. + */ + @Nonnull + public Any getRawData() { + return explainStatsData; + } + + private StringValue decode() { + try { + return explainStatsData.unpack(StringValue.class); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException( + "Unable to decode explain stats. Did you request an output format that returns a string" + + " value, such as 'text' or 'json'?", + e); + } + } + + /** + * When explain stats were requested with `outputFormat = 'text'`, this returns the explain stats + * string verbatim as returned from the Firestore backend. + * + *

If explain stats were requested with `outputFormat = 'json'`, this returns the explain stats + * as stringified JSON, which was returned from the Firestore backend. + */ + @Nonnull + public String getText() { + return decode().getValue(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldMask.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldMask.java new file mode 100644 index 000000000000..b6147a9243bf --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldMask.java @@ -0,0 +1,102 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; +import javax.annotation.Nonnull; + +/** A FieldMask can be used to limit the number of fields returned by a `getAll()` call. */ +public final class FieldMask { + static final FieldMask EMPTY_MASK = new FieldMask(new TreeSet<>()); + + private final SortedSet fieldPaths; // Sorted for testing. + + FieldMask(Collection fieldPaths) { + this(new TreeSet<>(fieldPaths)); + } + + private FieldMask(SortedSet fieldPaths) { + this.fieldPaths = fieldPaths; + } + + /** + * Creates a FieldMask from the provided field paths. + * + * @param fieldPaths A list of field paths. + * @return A {@code FieldMask} that describes a subset of fields. + */ + @Nonnull + public static FieldMask of(String... fieldPaths) { + TreeSet paths = new TreeSet<>(); + for (String fieldPath : fieldPaths) { + paths.add(FieldPath.fromDotSeparatedString(fieldPath)); + } + return new FieldMask(paths); + } + + /** + * Creates a FieldMask from the provided field paths. + * + * @param fieldPaths A list of field paths. + * @return A {@code FieldMask} that describes a subset of fields. + */ + @Nonnull + public static FieldMask of(FieldPath... fieldPaths) { + TreeSet paths = new TreeSet<>(); + Collections.addAll(paths, fieldPaths); + return new FieldMask(paths); + } + + static FieldMask fromObject(Map values) { + TreeSet fieldPaths = extractFromMap(values, FieldPath.empty()); + return new FieldMask(fieldPaths); + } + + private static TreeSet extractFromMap(Map values, FieldPath path) { + TreeSet fieldPaths = new TreeSet<>(); + + for (Map.Entry entry : values.entrySet()) { + Object value = entry.getValue(); + FieldPath childPath = path.append(FieldPath.of(entry.getKey())); + if (value instanceof FieldValue) { + if (((FieldValue) value).includeInDocumentMask()) { + fieldPaths.add(childPath); + } + } else if (value instanceof Map) { + fieldPaths.addAll(extractFromMap((Map) value, childPath)); + } else { + // We don't need to special case arrays here as we don't support partial array updates. + fieldPaths.add(childPath); + } + } + + return fieldPaths; + } + + com.google.firestore.v1.DocumentMask toPb() { + com.google.firestore.v1.DocumentMask.Builder updateMask = + com.google.firestore.v1.DocumentMask.newBuilder(); + for (FieldPath fieldPath : fieldPaths) { + updateMask.addFieldPaths(fieldPath.getEncodedPath()); + } + return updateMask.build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldPath.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldPath.java new file mode 100644 index 000000000000..c5b9a8173ef4 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldPath.java @@ -0,0 +1,229 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalApi; +import com.google.auto.value.AutoValue; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.StructuredQuery; +import java.util.regex.Pattern; +import javax.annotation.Nonnull; + +/** + * A {@code FieldPath} refers to a field in a document. The path may consist of a single field name + * (referring to a top level field in the document), or a list of field names (referring to a nested + * field in the document). + */ +@AutoValue +public abstract class FieldPath extends BasePath implements Comparable { + + private static final String DOCUMENT_ID_SENTINEL = "__name__"; + + /** + * A special sentinel FieldPath to refer to the ID of a document. It can be used in queries to + * sort or filter by the document ID. + */ + static final FieldPath DOCUMENT_ID = FieldPath.of(DOCUMENT_ID_SENTINEL); + + /** Regular expression to verify that dot-separated field paths do not contain ~*[]/. */ + private static final Pattern PROHIBITED_CHARACTERS = Pattern.compile(".*[~*/\\[\\]].*"); + + private static FieldPath EMPTY = null; + + /** + * Creates a FieldPath from the provided field names. If more than one field name is provided, the + * path will point to a nested field in a document. + * + * @param fieldNames A list of field names. + * @return A {@code FieldPath} that points to a field location in a document. + */ + public static FieldPath of(@Nonnull String... fieldNames) { + Preconditions.checkArgument( + fieldNames.length > 0, "Invalid field path. Provided path must not be empty."); + + for (int i = 0; i < fieldNames.length; ++i) { + Preconditions.checkArgument( + fieldNames[i] != null && !fieldNames[i].isEmpty(), + "Invalid field name at argument %s. Field names must not be null or empty.", + (i + 1)); + } + + return new AutoValue_FieldPath(ImmutableList.copyOf(fieldNames)); + } + + /** + * A special sentinel to refer to the ID of a document. It can be used in queries to sort or + * filter by the document ID. + */ + public static FieldPath documentId() { + return DOCUMENT_ID; + } + + /** Verifies if the provided path matches the path that is used for the Document ID sentinel. */ + static boolean isDocumentId(String path) { + return DOCUMENT_ID_SENTINEL.equals(path); + } + + /** Returns a field path from a dot separated string. Does not support escaping. */ + @InternalApi + public static FieldPath fromDotSeparatedString(String field) { + if (PROHIBITED_CHARACTERS.matcher(field).matches()) { + throw new IllegalArgumentException("Use FieldPath.of() for field names containing '˜*/[]'."); + } + return empty().append(field); + } + + /** + * Creates a {@code FieldPath} from a server-encoded field path. + * + *

Copied from Firebase Android SDK: + * https://github.com/firebase/firebase-android-sdk/blob/2d3b2be7d2d00d693eb74986f20a6265c918848f/firebase-firestore/src/main/java/com/google/firebase/firestore/model/FieldPath.java#L47 + */ + public static FieldPath fromServerFormat(String path) { + ImmutableList.Builder res = ImmutableList.builder(); + StringBuilder builder = new StringBuilder(); + + int i = 0; + + // If we're inside '`' backticks, then we should ignore '.' dots. + boolean inBackticks = false; + + int length = path.length(); + while (i < length) { + char c = path.charAt(i); + if (c == '\\') { + if (i + 1 == length) { + throw new IllegalArgumentException("Trailing escape character is not allowed"); + } + i++; + builder.append(path.charAt(i)); + } else if (c == '.') { + if (!inBackticks) { + String elem = builder.toString(); + if (elem.isEmpty()) { + throw new IllegalArgumentException( + "Invalid field path (" + + path + + "). Paths must not be empty, begin with '.', end with '.', or contain '..'"); + } + builder = new StringBuilder(); + res.add(elem); + } else { + // escaped, append to current segment + builder.append(c); + } + } else if (c == '`') { + inBackticks = !inBackticks; + } else { + builder.append(c); + } + i++; + } + String lastElem = builder.toString(); + if (lastElem.isEmpty()) { + throw new IllegalArgumentException( + "Invalid field path (" + + path + + "). Paths must not be empty, begin with '.', end with '.', or contain '..'"); + } + res.add(lastElem); + return new AutoValue_FieldPath(res.build()); + } + + /** Returns an empty field path. */ + static FieldPath empty() { + // NOTE: This static is lazy evaluated since otherwise it would create a + // circular class dependency during initialization. + return EMPTY == null ? (EMPTY = new AutoValue_FieldPath(ImmutableList.of())) : EMPTY; + } + + private String encodedPath; + + String getEncodedPath() { + if (encodedPath == null) { + encodedPath = canonicalString(); + } + return encodedPath; + } + + /** Parses a field path string into a FieldPath, treating dots as separators. */ + @Override + String[] splitChildPath(String path) { + // By default, split() doesn't return empty leading and trailing segments. This can be enabled + // by passing "-1" as the limit. + return path.split("\\.", -1); + } + + /** + * Return true if the string could be used as a segment in a field path without escaping. Valid + * identifies follow the regex [a-zA-Z_][a-zA-Z0-9_]* + */ + private static boolean isValidIdentifier(String identifier) { + if (identifier.isEmpty()) { + return false; + } + + char first = identifier.charAt(0); + if (first != '_' && (first < 'a' || first > 'z') && (first < 'A' || first > 'Z')) { + return false; + } + for (int i = 1; i < identifier.length(); i++) { + char c = identifier.charAt(i); + if (c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && (c < '0' || c > '9')) { + return false; + } + } + return true; + } + + /** Encodes a list of field name segments in the server-accepted format. */ + private String canonicalString() { + ImmutableList segments = getSegments(); + + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < segments.size(); i++) { + if (i > 0) { + builder.append("."); + } + // Escape backslashes and backticks. + String escaped = segments.get(i); + escaped = escaped.replace("\\", "\\\\").replace("`", "\\`"); + + if (!isValidIdentifier(escaped)) { + escaped = '`' + escaped + '`'; + } + + builder.append(escaped); + } + return builder.toString(); + } + + @Override + FieldPath createPathWithSegments(ImmutableList segments) { + return new AutoValue_FieldPath(segments); + } + + @Override + public String toString() { + return getEncodedPath(); + } + + StructuredQuery.FieldReference toProto() { + return StructuredQuery.FieldReference.newBuilder().setFieldPath(getEncodedPath()).build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldValue.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldValue.java new file mode 100644 index 000000000000..2cfc41acf3f5 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FieldValue.java @@ -0,0 +1,361 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.DocumentTransform.FieldTransform; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** Sentinel values that can be used when writing document fields with set() or update(). */ +public abstract class FieldValue { + + private static final FieldValue SERVER_TIMESTAMP_SENTINEL = + new FieldValue() { + @Override + boolean includeInDocumentMask() { + return false; + } + + @Override + boolean includeInDocumentTransform() { + return true; + } + + @Override + String getMethodName() { + return "FieldValue.serverTimestamp()"; + } + + @Override + FieldTransform toProto(FieldPath path) { + FieldTransform.Builder fieldTransform = FieldTransform.newBuilder(); + fieldTransform.setFieldPath(path.getEncodedPath()); + fieldTransform.setSetToServerValue(FieldTransform.ServerValue.REQUEST_TIME); + return fieldTransform.build(); + } + }; + + static final FieldValue DELETE_SENTINEL = + new FieldValue() { + @Override + boolean includeInDocumentMask() { + return true; + } + + @Override + boolean includeInDocumentTransform() { + return false; + } + + @Override + String getMethodName() { + return "FieldValue.delete()"; + } + + @Override + FieldTransform toProto(FieldPath path) { + throw new IllegalStateException( + "FieldValue.delete() should not be included in a FieldTransform"); + } + }; + + static class NumericIncrementFieldValue extends FieldValue { + final Number operand; + + NumericIncrementFieldValue(Number operand) { + this.operand = operand; + } + + @Override + boolean includeInDocumentMask() { + return false; + } + + @Override + boolean includeInDocumentTransform() { + return true; + } + + @Override + String getMethodName() { + return "FieldValue.increment()"; + } + + @Override + FieldTransform toProto(FieldPath path) { + FieldTransform.Builder fieldTransform = FieldTransform.newBuilder(); + fieldTransform.setFieldPath(path.getEncodedPath()); + fieldTransform.setIncrement( + UserDataConverter.encodeValue(path, operand, UserDataConverter.ARGUMENT)); + return fieldTransform.build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumericIncrementFieldValue that = (NumericIncrementFieldValue) o; + return Objects.equals(operand, that.operand); + } + + @Override + public int hashCode() { + return Objects.hash(operand); + } + } + + static class ArrayUnionFieldValue extends FieldValue { + final List elements; + + ArrayUnionFieldValue(List elements) { + this.elements = elements; + } + + @Override + boolean includeInDocumentMask() { + return false; + } + + @Override + boolean includeInDocumentTransform() { + return true; + } + + @Override + String getMethodName() { + return "FieldValue.arrayUnion()"; + } + + @Override + FieldTransform toProto(FieldPath path) { + ArrayValue.Builder encodedElements = ArrayValue.newBuilder(); + + for (Object element : elements) { + Object data = CustomClassMapper.convertToPlainJavaTypes(element); + encodedElements.addValues( + UserDataConverter.encodeValue(path, data, UserDataConverter.ARGUMENT)); + } + + FieldTransform.Builder fieldTransform = FieldTransform.newBuilder(); + fieldTransform.setFieldPath(path.getEncodedPath()); + fieldTransform.setAppendMissingElements(encodedElements); + return fieldTransform.build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayUnionFieldValue that = (ArrayUnionFieldValue) o; + return Objects.equals(elements, that.elements); + } + + @Override + public int hashCode() { + return Objects.hash(elements); + } + } + + static class ArrayRemoveFieldValue extends FieldValue { + final List elements; + + ArrayRemoveFieldValue(List elements) { + this.elements = elements; + } + + @Override + boolean includeInDocumentMask() { + return false; + } + + @Override + boolean includeInDocumentTransform() { + return true; + } + + @Override + String getMethodName() { + return "FieldValue.arrayRemove()"; + } + + @Override + FieldTransform toProto(FieldPath path) { + ArrayValue.Builder encodedElements = ArrayValue.newBuilder(); + + for (Object element : elements) { + Object data = CustomClassMapper.convertToPlainJavaTypes(element); + encodedElements.addValues( + UserDataConverter.encodeValue(path, data, UserDataConverter.ARGUMENT)); + } + + FieldTransform.Builder fieldTransform = FieldTransform.newBuilder(); + fieldTransform.setFieldPath(path.getEncodedPath()); + fieldTransform.setRemoveAllFromArray(encodedElements); + return fieldTransform.build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayRemoveFieldValue that = (ArrayRemoveFieldValue) o; + return Objects.equals(elements, that.elements); + } + + @Override + public int hashCode() { + return Objects.hash(elements); + } + } + + private FieldValue() {} + + /** + * Returns a sentinel used with set() or update() to include a server-generated timestamp in the + * written data. + */ + @Nonnull + public static FieldValue serverTimestamp() { + return SERVER_TIMESTAMP_SENTINEL; + } + + /** Returns a sentinel used with update() to mark a field for deletion. */ + @Nonnull + public static FieldValue delete() { + return DELETE_SENTINEL; + } + + /** + * Returns a special value that can be used with set(), create() or update() that tells the server + * to increment the field's current value by the given value. + * + *

If the current field value is an integer, possible integer overflows are resolved to + * Long.MAX_VALUE or Long.MIN_VALUE. If the current field value is a double, both values will be + * interpreted as doubles and the arithmetic will follow IEEE 754 semantics. + * + *

If the current field is not an integer or double, or if the field does not yet exist, the + * transformation will set the field to the given value. + * + * @return The FieldValue sentinel for use in a call to set(), create() or update(). + */ + @Nonnull + public static FieldValue increment(long l) { + return new NumericIncrementFieldValue(l); + } + + /** + * Returns a special value that can be used with set(), create() or update() that tells the server + * to increment the field's current value by the given value. + * + *

If the current value is an integer or a double, both the current and the given value will be + * interpreted as doubles and all arithmetic will follow IEEE 754 semantics. Otherwise, the + * transformation will set the field to the given value. + * + * @return The FieldValue sentinel for use in a call to set(), create() or update(). + */ + @Nonnull + public static FieldValue increment(double d) { + return new NumericIncrementFieldValue(d); + } + + /** + * Returns a special value that can be used with set(), create() or update() that tells the server + * to union the given elements with any array value that already exists on the server. Each + * specified element that doesn't already exist in the array will be added to the end. If the + * field being modified is not already an array it will be overwritten with an array containing + * exactly the specified elements. + * + * @param elements The elements to union into the array. + * @return The FieldValue sentinel for use in a call to set() or update(). + */ + @Nonnull + public static FieldValue arrayUnion(@Nonnull Object... elements) { + Preconditions.checkArgument(elements.length > 0, "arrayUnion() expects at least 1 element"); + return new ArrayUnionFieldValue(Arrays.asList(elements)); + } + + /** + * Returns a special value that can be used with set(), create() or update() that tells the server + * to remove the given elements from any array value that already exists on the server. All + * instances of each element specified will be removed from the array. If the field being modified + * is not already an array it will be overwritten with an empty array. + * + * @param elements The elements to remove from the array. + * @return The FieldValue sentinel for use in a call to set() or update(). + */ + @Nonnull + public static FieldValue arrayRemove(@Nonnull Object... elements) { + Preconditions.checkArgument(elements.length > 0, "arrayRemove() expects at least 1 element"); + return new ArrayRemoveFieldValue(Arrays.asList(elements)); + } + + /** + * Creates a new {@link VectorValue} constructed with a copy of the given array of doubles. + * + * @param values Create a {@link VectorValue} instance with a copy of this array of doubles. + * @return A new {@link VectorValue} constructed with a copy of the given array of doubles. + */ + @Nonnull + public static VectorValue vector(@Nonnull double[] values) { + return new VectorValue(values); + } + + /** Whether this FieldTransform should be included in the document mask. */ + abstract boolean includeInDocumentMask(); + + /** Whether this FieldTransform should be included in the list of document transforms. */ + abstract boolean includeInDocumentTransform(); + + /** The name of the method that returned this FieldValue instance. */ + abstract String getMethodName(); + + /** Generates the field transform proto. */ + abstract FieldTransform toProto(FieldPath path); + + /** + * Returns true if this FieldValue is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this FieldValue is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + return this == obj; + } + + @Override + public int hashCode() { + return super.hashCode(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Filter.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Filter.java new file mode 100644 index 000000000000..6bd93582c699 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Filter.java @@ -0,0 +1,339 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.StructuredQuery.FieldFilter.Operator; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class Filter { + static class UnaryFilter extends Filter { + private final FieldPath field; + private final Operator operator; + private final Object value; + + public UnaryFilter(FieldPath field, Operator operator, @Nullable Object value) { + this.field = field; + this.operator = operator; + this.value = value; + } + + public FieldPath getField() { + return field; + } + + public Operator getOperator() { + return operator; + } + + @Nullable + public Object getValue() { + return value; + } + } + + static class CompositeFilter extends Filter { + private final List filters; + private final StructuredQuery.CompositeFilter.Operator operator; + + public CompositeFilter( + @Nonnull List filters, StructuredQuery.CompositeFilter.Operator operator) { + this.filters = filters; + this.operator = operator; + } + + public List getFilters() { + return filters; + } + + public StructuredQuery.CompositeFilter.Operator getOperator() { + return operator; + } + } + + /** + * Creates a new filter for checking that the given field is equal to the given value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter equalTo(@Nonnull String field, @Nullable Object value) { + return equalTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is equal to the given value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter equalTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.EQUAL, value); + } + + /** + * Creates a new filter for checking that the given field is not equal to the given value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter notEqualTo(@Nonnull String field, @Nullable Object value) { + return notEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is not equal to the given value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter notEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.NOT_EQUAL, value); + } + + /** + * Creates a new filter for checking that the given field is greater than the given value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter greaterThan(@Nonnull String field, @Nullable Object value) { + return greaterThan(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is greater than the given value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter greaterThan(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.GREATER_THAN, value); + } + + /** + * Creates a new filter for checking that the given field is greater than or equal to the given + * value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter greaterThanOrEqualTo(@Nonnull String field, @Nullable Object value) { + return greaterThanOrEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is greater than or equal to the given + * value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter greaterThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.GREATER_THAN_OR_EQUAL, value); + } + + /** + * Creates a new filter for checking that the given field is less than the given value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter lessThan(@Nonnull String field, @Nullable Object value) { + return lessThan(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is less than the given value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter lessThan(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.LESS_THAN, value); + } + + /** + * Creates a new filter for checking that the given field is less than or equal to the given + * value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter lessThanOrEqualTo(@Nonnull String field, @Nullable Object value) { + return lessThanOrEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field is less than or equal to the given + * value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter lessThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.LESS_THAN_OR_EQUAL, value); + } + + /** + * Creates a new filter for checking that the given array field contains the given value. + * + * @param field The field used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter arrayContains(@Nonnull String field, @Nullable Object value) { + return arrayContains(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given array field contains the given value. + * + * @param fieldPath The field path used for the filter. + * @param value The value used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter arrayContains(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.ARRAY_CONTAINS, value); + } + + /** + * Creates a new filter for checking that the given array field contains any of the given values. + * + * @param field The field used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter arrayContainsAny(@Nonnull String field, @Nullable Object value) { + return arrayContainsAny(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given array field contains any of the given values. + * + * @param fieldPath The field path used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter arrayContainsAny(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.ARRAY_CONTAINS_ANY, value); + } + + /** + * Creates a new filter for checking that the given field equals any of the given values. + * + * @param field The field used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter inArray(@Nonnull String field, @Nullable Object value) { + return inArray(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field equals any of the given values. + * + * @param fieldPath The field path used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter inArray(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.IN, value); + } + + /** + * Creates a new filter for checking that the given field does not equal any of the given values. + * + * @param field The field path used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter notInArray(@Nonnull String field, @Nullable Object value) { + return notInArray(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates a new filter for checking that the given field does not equal any of the given values. + * + * @param fieldPath The field path used for the filter. + * @param value The list of values used for the filter. + * @return The newly created filter. + */ + @Nonnull + public static Filter notInArray(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return new UnaryFilter(fieldPath, Operator.NOT_IN, value); + } + + /** + * Creates a new filter that is a disjunction of the given filters. A disjunction filter includes + * a document if it satisfies any of the given filters. + * + * @param filters The list of filters to perform a disjunction for. + * @return The newly created filter. + */ + @Nonnull + public static Filter or(Filter... filters) { + return new CompositeFilter(Arrays.asList(filters), StructuredQuery.CompositeFilter.Operator.OR); + } + + /** + * Creates a new filter that is a conjunction of the given filters. A conjunction filter includes + * a document if it satisfies all of the given filters. + * + * @param filters The list of filters to perform a conjunction for. + * @return The newly created filter. + */ + @Nonnull + public static Filter and(Filter... filters) { + return new CompositeFilter( + Arrays.asList(filters), StructuredQuery.CompositeFilter.Operator.AND); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java new file mode 100644 index 000000000000..a5a4caad5144 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Firestore.java @@ -0,0 +1,337 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.cloud.Service; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Represents a Firestore Database and is the entry point for all Firestore operations */ +@InternalExtensionOnly +public interface Firestore extends Service, AutoCloseable { + + /** + * Gets a {@link CollectionReference} that refers to the collection at the specified path. + * + * @param path A slash-separated path to a collection. + * @return The CollectionReference instance. + */ + @Nonnull + CollectionReference collection(@Nonnull String path); + + /** + * Gets a {@link DocumentReference} that refers to the document at the specified path. + * + * @param path A slash-separated path to a document. + * @return The DocumentReference instance. + */ + @Nonnull + DocumentReference document(@Nonnull String path); + + /** + * Fetches the root collections that are associated with this Firestore database. + * + * @throws FirestoreException if the Iterable could not be initialized. + * @return An Iterable that can be used to fetch all collections. + */ + @Nonnull + Iterable listCollections(); + + /** + * Creates and returns a new {@link CollectionGroup} that includes all documents in the database + * that are contained in a collection or subcollection with the given @code{collectionId}. + * + * @param collectionId Identifies the collections to query over. Every collection or subcollection + * with this ID as the last segment of its path will be included. Cannot contain a slash. + * @return The created Query. + */ + CollectionGroup collectionGroup(@Nonnull String collectionId); + + /** + * Creates a new {@link PipelineSource} to build and execute a data pipeline. + * + *

A pipeline is composed of a sequence of stages. Each stage processes the output from the + * previous one, and the final stage's output is the result of the pipeline's execution. + * + *

Example usage: + * + *

{@code
+   * Pipeline pipeline = firestore.pipeline()
+   * .collection("books")
+   * .where(Field("rating").isGreaterThan(4.5))
+   * .sort(Field("rating").descending())
+   * .limit(2);
+   * }
+ * + *

Note on Execution: The stages are conceptual. The Firestore backend may optimize + * execution (e.g., reordering or merging stages) as long as the final result remains the same. + * + *

Important Limitations: + * + *

    + *
  • Pipelines operate on a request/response basis only. + *
  • They do not utilize or update the local SDK cache. + *
  • They do not support realtime snapshot listeners. + *
+ * + * @return A {@code PipelineSource} to begin defining the pipeline's stages. + */ + PipelineSource pipeline(); + + /** + * Executes the given updateFunction and then attempts to commit the changes applied within the + * transaction. If any document read within the transaction has changed, the updateFunction will + * be retried. If it fails to commit after 5 attempts, the transaction will fail. + * + * @param updateFunction The function to execute within the transaction context. + * @return An ApiFuture that will be resolved with the result from updateFunction. + */ + @Nonnull + ApiFuture runTransaction(@Nonnull final Transaction.Function updateFunction); + + /** + * Executes the given updateFunction and then attempts to commit the changes applied within the + * transaction. If any document read within the transaction has changed, the updateFunction will + * be retried. If it fails to commit after the maxmimum number of attemps specified in + * transactionOptions, the transaction will fail. + * + * @param updateFunction The function to execute within the transaction context. + * @return An ApiFuture that will be resolved with the result from updateFunction. + */ + @Nonnull + ApiFuture runTransaction( + @Nonnull final Transaction.Function updateFunction, + @Nonnull TransactionOptions transactionOptions); + + /** + * Executes the given updateFunction and then attempts to commit the changes applied within the + * transaction. If any document read within the transaction has changed, the updateFunction will + * be retried. If it fails to commit after 5 attempts, the transaction will fail.
+ *
+ * Running a transaction places locks all consumed documents. To unblock other clients, the + * Firestore backend automatically releases all locks after 60 seconds of inactivity and fails all + * transactions that last longer than 270 seconds (see Firestore + * Quotas). + * + * @param updateFunction The function to execute within the transaction context. + * @return An ApiFuture that will be resolved with the result from updateFunction. + */ + @Nonnull + ApiFuture runAsyncTransaction(@Nonnull final Transaction.AsyncFunction updateFunction); + + /** + * Executes the given updateFunction and then attempts to commit the changes applied within the + * transaction. If any document read within the transaction has changed, the updateFunction will + * be retried. If it fails to commit after the maxmimum number of attemps specified in + * transactionOptions, the transaction will fail.
+ *
+ * Running a transaction places locks all consumed documents. To unblock other clients, the + * Firestore backend automatically releases all locks after 60 seconds of inactivity and fails all + * transactions that last longer than 270 seconds (see Firestore + * Quotas). + * + * @param updateFunction The function to execute within the transaction context. + * @return An ApiFuture that will be resolved with the result from updateFunction. + */ + @Nonnull + ApiFuture runAsyncTransaction( + @Nonnull final Transaction.AsyncFunction updateFunction, + @Nonnull TransactionOptions transactionOptions); + + /** + * Retrieves multiple documents from Firestore. + * + * @param documentReferences List of Document References to fetch. + */ + @Nonnull + ApiFuture> getAll(@Nonnull DocumentReference... documentReferences); + + /** + * Retrieves multiple documents from Firestore, while optionally applying a field mask to reduce + * the amount of data transmitted. + * + * @param documentReferences Array with Document References to fetch. + * @param fieldMask If set, specifies the subset of fields to return. + */ + @Nonnull + ApiFuture> getAll( + @Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask); + + /** + * Retrieves multiple documents from Firestore while optionally applying a field mask to reduce + * the amount of data transmitted. Returned documents will be out of order. + * + * @param documentReferences Array with Document References to fetch. + * @param fieldMask If not null, specifies the subset of fields to return. + * @param responseObserver The observer to be notified when {@link DocumentSnapshot} details + * arrive. + */ + void getAll( + @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + final ApiStreamObserver responseObserver); + + /** + * Gets a Firestore {@link WriteBatch} instance that can be used to combine multiple writes. + * + * @return A WriteBatch that operates on this Firestore client. + */ + @Nonnull + WriteBatch batch(); + + /** + * Creates a {@link BulkWriter} instance, used for performing multiple writes in parallel. + * Gradually ramps up writes as specified by the 500/50/5 rule. + * + * @see Ramping + * up traffic + */ + @Nonnull + BulkWriter bulkWriter(); + + /** + * Creates a {@link BulkWriter} instance, used for performing multiple writes in parallel. + * Gradually ramps up writes as specified by the 500/50/5 rule unless otherwise configured by a + * BulkWriterOptions object. + * + * @see Ramping + * up traffic + * @param options An options object to configure BulkWriter. + */ + @Nonnull + BulkWriter bulkWriter(BulkWriterOptions options); + + /** + * Recursively deletes all documents and subcollections at and under the specified level. + * + *

If any delete fails, the ApiFuture contains an error with an error message containing the + * number of failed deletes and the stack trace of the last failed delete. The provided reference + * is deleted regardless of whether all deletes succeeded. + * + *

recursiveDelete() uses a {@link BulkWriter} instance with default settings to perform the + * deletes. To customize throttling rates or add success/error callbacks, pass in a custom + * BulkWriter instance. + * + * @param reference The reference of the collection to delete. + * @return An ApiFuture that completes when all deletes have been performed. The future fails with + * an error if any of the deletes fail. + */ + @BetaApi + @Nonnull + ApiFuture recursiveDelete(CollectionReference reference); + + /** + * Recursively deletes all documents and subcollections at and under the specified level. + * + *

If any delete fails, the ApiFuture contains an error with an error message containing the + * number of failed deletes and the stack trace of the last failed delete. The provided reference + * is deleted regardless of whether all deletes succeeded. + * + *

recursiveDelete() uses a {@link BulkWriter} instance with default settings to perform the + * deletes. To customize throttling rates or add success/error callbacks, pass in a custom + * BulkWriter instance. + * + * @param reference The reference of the collection to delete. + * @param bulkWriter A custom BulkWriter instance used to perform the deletes. + * @return An ApiFuture that completes when all deletes have been performed. The future fails with + * an error if any of the deletes fail. + */ + @BetaApi + @Nonnull + ApiFuture recursiveDelete(CollectionReference reference, BulkWriter bulkWriter); + + /** + * Recursively deletes all documents and subcollections at and under the specified level. + * + *

If any delete fails, the ApiFuture contains an error with an error message containing the + * number of failed deletes and the stack trace of the last failed delete. The provided reference + * is deleted regardless of whether all deletes succeeded. + * + *

recursiveDelete() uses a {@link BulkWriter} instance with default settings to perform the + * deletes. To customize throttling rates or add success/error callbacks, pass in a custom + * BulkWriter instance. + * + * @param reference The reference of the document to delete. + * @return An ApiFuture that completes when all deletes have been performed. The future fails with + * an error if any of the deletes fail. + */ + @BetaApi + @Nonnull + ApiFuture recursiveDelete(DocumentReference reference); + + /** + * Recursively deletes all documents and subcollections at and under the specified level. + * + *

If any delete fails, the ApiFuture contains an error with an error message containing the + * number of failed deletes and the stack trace of the last failed delete. The provided reference + * is deleted regardless of whether all deletes succeeded. + * + *

recursiveDelete() uses a {@link BulkWriter} instance with default settings to perform the + * deletes. To customize throttling rates or add success/error callbacks, pass in a custom + * BulkWriter instance. + * + * @param reference The reference of the document to delete. + * @param bulkWriter A custom BulkWriter instance used to perform the deletes. + * @return An ApiFuture that completes when all deletes have been performed. The future fails with + * an error if any of the deletes fail. + */ + @BetaApi + @Nonnull + ApiFuture recursiveDelete(DocumentReference reference, BulkWriter bulkWriter); + + /** + * Returns a FirestoreBundle.Builder {@link FirestoreBundle.Builder} instance using an + * automatically generated bundle ID. When loaded on clients, client SDKs use the bundle ID and + * the timestamp associated with the built bundle to tell if it has been loaded already. + */ + @Nonnull + FirestoreBundle.Builder bundleBuilder(); + + /** + * Returns a FirestoreBundle.Builder {@link FirestoreBundle.Builder} instance for the given bundle + * ID. + * + * @param bundleId The ID of the bundle. When loaded on clients, client SDKs use this id and the + * timestamp associated with the built bundle to tell if it has been loaded already. + */ + @Nonnull + FirestoreBundle.Builder bundleBuilder(@Nonnull String bundleId); + + /** + * Closes the gRPC channels associated with this instance and frees up their resources. This + * method blocks until all channels are closed. Once this method is called, this Firestore client + * is no longer usable. + */ + @Override + void close() throws Exception; + + /** + * Initiates an orderly shutdown in which previously submitted work is finished, but no new work + * will be accepted. + */ + void shutdown(); + + /** Attempts to stop all actively executing work and halts the processing of waiting work. */ + void shutdownNow(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreBundle.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreBundle.java new file mode 100644 index 000000000000..35a2ef96efbd --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreBundle.java @@ -0,0 +1,238 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import com.google.common.collect.Lists; +import com.google.firestore.bundle.BundleElement; +import com.google.firestore.bundle.BundleMetadata; +import com.google.firestore.bundle.BundledDocumentMetadata; +import com.google.firestore.bundle.BundledQuery; +import com.google.firestore.bundle.NamedQuery; +import com.google.firestore.v1.Document; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.util.JsonFormat; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +/** Represents a Firestore data bundle with results from the given document and query snapshots. */ +public final class FirestoreBundle { + + static final int BUNDLE_SCHEMA_VERSION = 1; + // Printer to encode protobuf objects into JSON string. + private static final JsonFormat.Printer PRINTER = JsonFormat.printer(); + private static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + + // Raw byte array to hold the content of the bundle. + private final byte[] bundleData; + + /** Builds a Firestore data bundle with results from the given document and query snapshots. */ + public static final class Builder { + // Id of the bundle. + private final String id; + // Resulting documents for the bundle, keyed by full document path. + private final Map documents = new HashMap<>(); + // Named queries saved in the bundle, keyed by query name. + private final Map namedQueries = new HashMap<>(); + // The latest read time among all bundled documents and queries. + private Timestamp latestReadTime = Timestamp.MIN_VALUE; + + Builder(String id) { + this.id = id; + } + + /** Returns the ID for this bundle. */ + public String getId() { + return this.id; + } + + /** + * Adds a Firestore document snapshot to the bundle. Both the document data and the document + * read time will be included in the bundle. + * + * @param documentSnapshot A document snapshot to add. + * @return This instance. + */ + public Builder add(DocumentSnapshot documentSnapshot) { + return add(documentSnapshot, Optional.empty()); + } + + private Builder add(DocumentSnapshot documentSnapshot, Optional queryName) { + String documentName = documentSnapshot.getReference().getName(); + BundledDocument originalDocument = documents.get(documentSnapshot.getReference().getName()); + List queries = + originalDocument == null + ? Lists.newArrayList() + : Lists.newArrayList(originalDocument.getMetadata().getQueriesList()); + + // Update with document built from `documentSnapshot` because it is newer. + Timestamp snapReadTime = + documentSnapshot.getReadTime() == null + ? Timestamp.MIN_VALUE + : documentSnapshot.getReadTime(); + if (originalDocument == null + || originalDocument.getMetadata().getReadTime() == null + || snapReadTime.compareTo( + Timestamp.fromProto(originalDocument.getMetadata().getReadTime())) + > 0) { + BundledDocumentMetadata metadata = + BundledDocumentMetadata.newBuilder() + .setName(documentName) + .setReadTime(snapReadTime.toProto()) + .setExists(documentSnapshot.exists()) + .build(); + Document document = + documentSnapshot.exists() ? documentSnapshot.toDocumentPb().build() : null; + documents.put(documentName, new BundledDocument(metadata, document)); + } + + // Update queries to include all queries whose results include this document. + if (queryName.isPresent()) { + queries.add(queryName.get()); + } + documents + .get(documentName) + .setMetadata( + documents.get(documentName).getMetadata().toBuilder() + .clearQueries() + .addAllQueries(queries) + .build()); + + if (documentSnapshot.getReadTime().compareTo(latestReadTime) > 0) { + latestReadTime = documentSnapshot.getReadTime(); + } + + return this; + } + + /** + * Adds a Firestore query snapshot to the bundle. Both the documents in the query snapshot and + * the query read time will be included in the bundle. + * + * @param queryName The name of the query to add. + * @param querySnap The query snapshot to add. + * @return This instance. + */ + public Builder add(String queryName, QuerySnapshot querySnap) { + BundledQuery query = querySnap.getQuery().toBundledQuery(); + NamedQuery namedQuery = + NamedQuery.newBuilder() + .setName(queryName) + .setReadTime(querySnap.getReadTime().toProto()) + .setBundledQuery(query) + .build(); + namedQueries.put(queryName, namedQuery); + + for (QueryDocumentSnapshot snapshot : querySnap.getDocuments()) { + add(snapshot, Optional.of(queryName)); + } + + if (querySnap.getReadTime().compareTo(latestReadTime) > 0) { + latestReadTime = querySnap.getReadTime(); + } + + return this; + } + + public FirestoreBundle build() { + StringBuilder buffer = new StringBuilder(); + + for (NamedQuery namedQuery : namedQueries.values()) { + buffer.append( + elementToLengthPrefixedStringBuilder( + BundleElement.newBuilder().setNamedQuery(namedQuery).build())); + } + + for (BundledDocument bundledDocument : documents.values()) { + buffer.append( + elementToLengthPrefixedStringBuilder( + BundleElement.newBuilder() + .setDocumentMetadata(bundledDocument.getMetadata()) + .build())); + if (bundledDocument.getDocument() != null) { + buffer.append( + elementToLengthPrefixedStringBuilder( + BundleElement.newBuilder().setDocument(bundledDocument.getDocument()).build())); + } + } + + BundleMetadata metadata = + BundleMetadata.newBuilder() + .setId(id) + .setCreateTime(latestReadTime.toProto()) + .setVersion(BUNDLE_SCHEMA_VERSION) + .setTotalDocuments(documents.size()) + .setTotalBytes(buffer.toString().getBytes(DEFAULT_CHARSET).length) + .build(); + BundleElement element = BundleElement.newBuilder().setMetadata(metadata).build(); + buffer.insert(0, elementToLengthPrefixedStringBuilder(element)); + + return new FirestoreBundle(buffer.toString().getBytes(DEFAULT_CHARSET)); + } + + private StringBuilder elementToLengthPrefixedStringBuilder(BundleElement element) { + String elementJson = null; + try { + elementJson = PRINTER.print(element); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + return new StringBuilder() + .append(elementJson.getBytes(DEFAULT_CHARSET).length) + .append(elementJson); + } + } + + private FirestoreBundle(byte[] data) { + bundleData = data; + } + + /** Returns the bundle content as a readonly {@link ByteBuffer}. */ + public ByteBuffer toByteBuffer() { + return ByteBuffer.wrap(bundleData).asReadOnlyBuffer(); + } + + /** + * Convenient class to hold both the metadata and the actual content of a document to be bundled. + */ + private static class BundledDocument { + private BundledDocumentMetadata metadata; + private final Document document; + + BundledDocument(BundledDocumentMetadata metadata, Document document) { + this.metadata = metadata; + this.document = document; + } + + public BundledDocumentMetadata getMetadata() { + return metadata; + } + + void setMetadata(BundledDocumentMetadata metadata) { + this.metadata = metadata; + } + + public Document getDocument() { + return document; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreException.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreException.java new file mode 100644 index 000000000000..00f7236ca04d --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreException.java @@ -0,0 +1,143 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.BetaApi; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.StatusCode; +import com.google.cloud.grpc.BaseGrpcServiceException; +import io.grpc.Status; +import java.io.IOException; +import javax.annotation.Nullable; + +/** A Firestore Service exception. */ +public class FirestoreException extends BaseGrpcServiceException { + private Status status; + + FirestoreException(String reason, Status status) { + this(reason, status, null); + } + + private FirestoreException(String reason, Status status, @Nullable Throwable cause) { + super(reason, cause, status.getCode().value(), false); + + this.status = status; + } + + private FirestoreException(String reason, ApiException exception) { + super( + reason, + exception, + exception.getStatusCode().getCode().getHttpStatusCode(), + exception.isRetryable()); + + this.status = FirestoreException.toStatus(exception.getStatusCode()); + } + + private FirestoreException(IOException exception, boolean retryable) { + super(exception, retryable); + } + + /** + * Creates a FirestoreException with an {@code INVALID_ARGUMENT} status code and the provided + * message in a nested exception. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forInvalidArgument(String message, Object... params) { + return new FirestoreException(String.format(message, params), Status.INVALID_ARGUMENT); + } + + /** + * Creates a FirestoreException with the provided GRPC Status code and message in a nested + * exception. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forServerRejection( + Status status, String message, Object... params) { + return forServerRejection(status, null, message, params); + } + + /** + * Creates a FirestoreException with the provided GRPC Status code and message in a nested + * exception. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forServerRejection( + Status status, @Nullable Throwable cause, String message, Object... params) { + return new FirestoreException(String.format(message, params), status, cause); + } + + /** + * Creates a FirestoreException from an IOException. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forIOException(IOException exception, boolean retryable) { + return new FirestoreException(exception, retryable); + } + + /** + * Creates a FirestoreException from an ApiException. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forApiException(ApiException exception) { + return new FirestoreException(exception.getMessage(), exception); + } + + /** + * Creates a FirestoreException from an ApiException. + * + * @return The FirestoreException + */ + @BetaApi + public static FirestoreException forApiException(ApiException exception, String message) { + return new FirestoreException(message, exception); + } + + @BetaApi + @Nullable + public Status getStatus() { + return status; + } + + /** + * Converts a GAX {@code StatusCode} to a corresponding gRPC {@code Status} object. This method + * assumes that the names of the enum values in {@code com.google.api.gax.rpc.StatusCode.Code} + * directly correspond to the names of the enum values in {@code io.grpc.Status.Code}. + * + *

If the provided {@code StatusCode.Code} name does not have a direct matching {@code + * io.grpc.Status.Code}, {@code Status.UNKNOWN} with a descriptive message is returned. + */ + private static Status toStatus(StatusCode statusCode) { + try { + Status.Code code = Status.Code.valueOf(statusCode.getCode().name()); + return code.toStatus(); + } catch (IllegalArgumentException e) { + return Status.UNKNOWN.withDescription( + "Unrecognized StatusCode.code: " + statusCode.getCode()); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreFactory.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreFactory.java new file mode 100644 index 000000000000..c8cbb37f9fc8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreFactory.java @@ -0,0 +1,22 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.ServiceFactory; + +/** An interface for Firestore factories. */ +public interface FirestoreFactory extends ServiceFactory {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java new file mode 100644 index 000000000000..ce0fd67363d3 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -0,0 +1,602 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; +import static com.google.cloud.firestore.telemetry.TraceUtil.*; + +import com.google.api.core.ApiClock; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.NanoClock; +import com.google.api.core.ObsoleteApi; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StreamController; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.DatabaseRootName; +import com.google.protobuf.ByteString; +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Main implementation of the Firestore client. This is the entry point for all Firestore + * operations. + */ +class FirestoreImpl implements Firestore, FirestoreRpcContext { + + private static final Random RANDOM = new SecureRandom(); + private static final int AUTO_ID_LENGTH = 20; + private static final String AUTO_ID_ALPHABET = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; + + private final FirestoreRpc firestoreClient; + private final FirestoreOptions firestoreOptions; + private final ResourcePath databasePath; + + /** + * A lazy-loaded BulkWriter instance to be used with recursiveDelete() if no BulkWriter instance + * is provided. + */ + @Nullable private BulkWriter bulkWriterInstance; + + private boolean closed; + + FirestoreImpl(FirestoreOptions options) { + this(options, options.getFirestoreRpc()); + } + + FirestoreImpl(FirestoreOptions options, FirestoreRpc firestoreRpc) { + this.firestoreClient = firestoreRpc; + this.firestoreOptions = options; + Preconditions.checkNotNull( + options.getProjectId(), + "Failed to detect Project ID. " + + "Please explicitly set your Project ID in FirestoreOptions."); + this.databasePath = + ResourcePath.create(DatabaseRootName.of(options.getProjectId(), options.getDatabaseId())); + } + + /** Gets the TraceUtil object associated with this Firestore instance. */ + @Nonnull + private TraceUtil getTraceUtil() { + return getOptions().getTraceUtil(); + } + + /** Lazy-load the Firestore's default BulkWriter. */ + private BulkWriter getBulkWriter() { + if (bulkWriterInstance == null) { + bulkWriterInstance = bulkWriter(); + } + return bulkWriterInstance; + } + + /** Creates a pseudo-random 20-character ID that can be used for Firestore documents. */ + static String autoId() { + StringBuilder builder = new StringBuilder(); + int maxRandom = AUTO_ID_ALPHABET.length(); + for (int i = 0; i < AUTO_ID_LENGTH; i++) { + builder.append(AUTO_ID_ALPHABET.charAt(RANDOM.nextInt(maxRandom))); + } + return builder.toString(); + } + + @Nonnull + @Override + public WriteBatch batch() { + return new WriteBatch(this); + } + + @Nonnull + public BulkWriter bulkWriter() { + return new BulkWriter(this, BulkWriterOptions.builder().setThrottlingEnabled(true).build()); + } + + @Nonnull + public BulkWriter bulkWriter(BulkWriterOptions options) { + return new BulkWriter(this, options); + } + + @Nonnull + public ApiFuture recursiveDelete(CollectionReference reference) { + BulkWriter writer = getBulkWriter(); + return recursiveDelete(reference.getResourcePath(), writer); + } + + @Nonnull + public ApiFuture recursiveDelete(CollectionReference reference, BulkWriter bulkWriter) { + return recursiveDelete(reference.getResourcePath(), bulkWriter); + } + + @Nonnull + public ApiFuture recursiveDelete(DocumentReference reference) { + BulkWriter writer = getBulkWriter(); + return recursiveDelete(reference.getResourcePath(), writer); + } + + @Nonnull + public ApiFuture recursiveDelete( + DocumentReference reference, @Nonnull BulkWriter bulkWriter) { + return recursiveDelete(reference.getResourcePath(), bulkWriter); + } + + @Nonnull + public ApiFuture recursiveDelete(ResourcePath path, BulkWriter bulkWriter) { + return recursiveDelete( + path, bulkWriter, RecursiveDelete.MAX_PENDING_OPS, RecursiveDelete.MIN_PENDING_OPS); + } + + /** + * This overload is not private in order to test the query resumption with startAfter() once the + * RecursiveDelete instance has MAX_PENDING_OPS pending. + */ + @Nonnull + @VisibleForTesting + ApiFuture recursiveDelete( + ResourcePath path, @Nonnull BulkWriter bulkWriter, int maxLimit, int minLimit) { + RecursiveDelete deleter = new RecursiveDelete(this, bulkWriter, path, maxLimit, minLimit); + return deleter.run(); + } + + @Nonnull + @Override + public CollectionReference collection(@Nonnull String collectionPath) { + ResourcePath path = databasePath.append(collectionPath); + Preconditions.checkArgument( + path.isCollection(), "Invalid path specified. Path should point to a collection"); + return new CollectionReference(this, path); + } + + @Nonnull + @Override + public DocumentReference document(@Nonnull String documentPath) { + ResourcePath document = databasePath.append(documentPath); + Preconditions.checkArgument( + document.isDocument(), "Path should point to a Document Reference: %s", documentPath); + return new DocumentReference(this, document); + } + + @Nonnull + @Override + public Iterable listCollections() { + DocumentReference rootDocument = new DocumentReference(this, this.databasePath); + return rootDocument.listCollections(); + } + + @Nonnull + @Override + public ApiFuture> getAll( + @Nonnull DocumentReference... documentReferences) { + return this.getAll(documentReferences, null, (ByteString) null); + } + + @Nonnull + @Override + public ApiFuture> getAll( + @Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask) { + return this.getAll(documentReferences, fieldMask, (ByteString) null); + } + + @Override + public void getAll( + final @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + @Nonnull final ApiStreamObserver apiStreamObserver) { + this.getAll(documentReferences, fieldMask, null, null, apiStreamObserver); + } + + void getAll( + final @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + @Nullable ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime, + final ApiStreamObserver apiStreamObserver) { + // To reduce the size of traces, we only register one event for every 100 responses + // that we receive from the server. + final int NUM_RESPONSES_PER_TRACE_EVENT = 100; + + MetricsContext metricsContext = + getOptions() + .getMetricsUtil() + .createMetricsContext( + transactionId == null + ? TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS_GET_ALL + : TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS_TRANSACTIONAL); + + ResponseObserver responseObserver = + new ResponseObserver() { + int numResponses = 0; + boolean hasCompleted = false; + + @Override + public void onStart(StreamController streamController) { + getTraceUtil() + .currentSpan() + .addEvent( + TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS + ": Start", + new ImmutableMap.Builder() + .put(ATTRIBUTE_KEY_DOC_COUNT, documentReferences.length) + .put(ATTRIBUTE_KEY_IS_TRANSACTIONAL, transactionId != null) + .build()); + } + + @Override + public void onResponse(BatchGetDocumentsResponse response) { + DocumentReference documentReference; + DocumentSnapshot documentSnapshot; + + numResponses++; + if (numResponses == 1) { + getTraceUtil() + .currentSpan() + .addEvent( + TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS + + ": First response received"); + metricsContext.recordLatency(MetricType.FIRST_RESPONSE_LATENCY); + } else if (numResponses % NUM_RESPONSES_PER_TRACE_EVENT == 0) { + getTraceUtil() + .currentSpan() + .addEvent( + TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS + + ": Received " + + numResponses + + " responses"); + } + + switch (response.getResultCase()) { + case FOUND: + documentSnapshot = + DocumentSnapshot.fromDocument( + FirestoreImpl.this, + Timestamp.fromProto(response.getReadTime()), + response.getFound()); + break; + case MISSING: + documentReference = + new DocumentReference( + FirestoreImpl.this, ResourcePath.create(response.getMissing())); + documentSnapshot = + DocumentSnapshot.fromMissing( + FirestoreImpl.this, + documentReference, + Timestamp.fromProto(response.getReadTime())); + break; + default: + return; + } + apiStreamObserver.onNext(documentSnapshot); + + // Logical termination: if we have already received as many documents as we had + // requested, we can + // raise the results without waiting for the termination from the server. + if (numResponses == documentReferences.length) { + onComplete(); + } + } + + @Override + public void onError(Throwable throwable) { + getTraceUtil().currentSpan().end(throwable); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable); + apiStreamObserver.onError(throwable); + } + + @Override + public void onComplete() { + if (hasCompleted) return; + hasCompleted = true; + getTraceUtil() + .currentSpan() + .addEvent( + TelemetryConstants.METHOD_NAME_BATCH_GET_DOCUMENTS + + ": Completed with " + + numResponses + + " responses.", + Collections.singletonMap(ATTRIBUTE_KEY_NUM_RESPONSES, numResponses)); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + apiStreamObserver.onCompleted(); + } + }; + + BatchGetDocumentsRequest.Builder request = BatchGetDocumentsRequest.newBuilder(); + request.setDatabase(getDatabaseName()); + + if (fieldMask != null) { + request.setMask(fieldMask.toPb()); + } + + if (transactionId != null) { + request.setTransaction(transactionId); + } + + if (readTime != null) { + request.setReadTime(readTime); + } + + for (DocumentReference docRef : documentReferences) { + request.addDocuments(docRef.getName()); + } + + streamRequest(request.build(), responseObserver, firestoreClient.batchGetDocumentsCallable()); + } + + final ApiFuture> getAll( + final @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + @Nullable com.google.protobuf.Timestamp readTime) { + return getAll(documentReferences, fieldMask, null, readTime); + } + + private ApiFuture> getAll( + final @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + @Nullable ByteString transactionId) { + return getAll(documentReferences, fieldMask, transactionId, null); + } + + /** Internal getAll() method that accepts an optional transaction id. */ + ApiFuture> getAll( + final @Nonnull DocumentReference[] documentReferences, + @Nullable FieldMask fieldMask, + @Nullable ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime) { + final SettableApiFuture> futureList = SettableApiFuture.create(); + final Map documentSnapshotMap = new HashMap<>(); + getAll( + documentReferences, + fieldMask, + transactionId, + readTime, + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + documentSnapshotMap.put(documentSnapshot.getReference(), documentSnapshot); + } + + @Override + public void onError(Throwable throwable) { + futureList.setException(throwable); + } + + @Override + public void onCompleted() { + List documentSnapshotsList = new ArrayList<>(); + for (DocumentReference documentReference : documentReferences) { + documentSnapshotsList.add(documentSnapshotMap.get(documentReference)); + } + futureList.set(documentSnapshotsList); + } + }); + return futureList; + } + + @Nonnull + @Override + public CollectionGroup collectionGroup(@Nonnull final String collectionId) { + Preconditions.checkArgument( + !collectionId.contains("/"), + "Invalid collectionId '%s'. Collection IDs must not contain '/'.", + collectionId); + return new CollectionGroup(this, collectionId); + } + + @Nonnull + @Override + @BetaApi + public PipelineSource pipeline() { + return new PipelineSource(this); + } + + @Nonnull + @Override + public ApiFuture runTransaction(@Nonnull final Transaction.Function updateFunction) { + return runAsyncTransaction( + new TransactionAsyncAdapter<>(updateFunction), TransactionOptions.create()); + } + + @Nonnull + @Override + public ApiFuture runTransaction( + @Nonnull final Transaction.Function updateFunction, + @Nonnull TransactionOptions transactionOptions) { + return runAsyncTransaction(new TransactionAsyncAdapter<>(updateFunction), transactionOptions); + } + + @Nonnull + @Override + public ApiFuture runAsyncTransaction( + @Nonnull final Transaction.AsyncFunction updateFunction) { + return runAsyncTransaction(updateFunction, TransactionOptions.create()); + } + + @Nonnull + @Override + public ApiFuture runAsyncTransaction( + @Nonnull final Transaction.AsyncFunction updateFunction, + @Nonnull TransactionOptions transactionOptions) { + + MetricsContext metricsContext = + getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_RUN_TRANSACTION); + ApiFuture result; + + try { + if (transactionOptions.getReadTime() != null) { + // READ_ONLY transactions with readTime have no retry, nor transaction state, so we don't + // need a runner. + result = + updateFunction.updateCallback( + new ReadTimeTransaction(this, transactionOptions.getReadTime())); + } else { + // For READ_ONLY transactions without readTime, there is still strong consistency applied, + // that cannot be tracked client side. + result = new ServerSideTransactionRunner<>(this, updateFunction, transactionOptions).run(); + } + metricsContext.recordLatencyAtFuture(MetricType.END_TO_END_LATENCY, result); + } catch (Exception error) { + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + return result; + } + + @Nonnull + @Override + public FirestoreBundle.Builder bundleBuilder() { + return bundleBuilder(null); + } + + @Nonnull + @Override + public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) { + String id = bundleId == null ? autoId() : bundleId; + return new FirestoreBundle.Builder(id); + } + + /** Returns the name of the Firestore project associated with this client. */ + @Override + public String getDatabaseName() { + return databasePath.getDatabaseName().toString(); + } + + /** Returns a path to the Firestore project associated with this client. */ + @Override + public ResourcePath getResourcePath() { + return databasePath; + } + + /** Returns the underlying RPC client. */ + @Override + public FirestoreRpc getClient() { + return firestoreClient; + } + + /** This method is obsolete. Use {@link #getTotalRequestTimeoutDuration()} instead. */ + @ObsoleteApi("Use getTotalRequestTimeoutDuration() instead") + @Override + public org.threeten.bp.Duration getTotalRequestTimeout() { + return toThreetenDuration(getTotalRequestTimeoutDuration()); + } + + @Override + public java.time.Duration getTotalRequestTimeoutDuration() { + return firestoreOptions.getRetrySettings().getTotalTimeoutDuration(); + } + + @Override + public ApiClock getClock() { + return NanoClock.getDefaultClock(); + } + + /** Request funnel for all read/write requests. */ + @Override + public ApiFuture sendRequest( + RequestT requestT, UnaryCallable callable) { + Preconditions.checkState(!closed, "Firestore client has already been closed"); + return callable.futureCall(requestT); + } + + /** Request funnel for all unidirectional streaming requests. */ + @Override + public void streamRequest( + RequestT requestT, + ResponseObserver responseObserverT, + ServerStreamingCallable callable) { + Preconditions.checkState(!closed, "Firestore client has already been closed"); + callable.call(requestT, responseObserverT); + } + + /** Request funnel for all bidirectional streaming requests. */ + @Override + public ClientStream streamRequest( + BidiStreamObserver responseObserverT, + BidiStreamingCallable callable) { + Preconditions.checkState(!closed, "Firestore client has already been closed"); + return callable.splitCall(responseObserverT); + } + + @Override + public FirestoreImpl getFirestore() { + return this; + } + + @Override + public FirestoreOptions getOptions() { + return firestoreOptions; + } + + @Override + public void close() throws Exception { + firestoreClient.close(); + closed = true; + } + + @Override + public void shutdown() { + firestoreClient.shutdown(); + closed = true; + } + + @Override + public void shutdownNow() { + firestoreClient.shutdownNow(); + closed = true; + } + + private static class TransactionAsyncAdapter implements Transaction.AsyncFunction { + private final Transaction.Function syncFunction; + + public TransactionAsyncAdapter(Transaction.Function syncFunction) { + this.syncFunction = syncFunction; + } + + @Override + public ApiFuture updateCallback(Transaction transaction) { + SettableApiFuture callbackResult = SettableApiFuture.create(); + try { + callbackResult.set(syncFunction.updateCallback(transaction)); + } catch (Throwable e) { + callbackResult.setException(e); + } + return callbackResult; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOpenTelemetryOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOpenTelemetryOptions.java new file mode 100644 index 000000000000..6fe0c4375a36 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOpenTelemetryOptions.java @@ -0,0 +1,106 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.BetaApi; +import io.opentelemetry.api.OpenTelemetry; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents the options that are used to configure the use of OpenTelemetry for telemetry + * collection in the Firestore SDK. + */ +@BetaApi +public class FirestoreOpenTelemetryOptions { + private final boolean exportBuiltinMetricsToGoogleCloudMonitoring; + private final @Nullable OpenTelemetry openTelemetry; + + FirestoreOpenTelemetryOptions(Builder builder) { + this.exportBuiltinMetricsToGoogleCloudMonitoring = + builder.exportBuiltinMetricsToGoogleCloudMonitoring; + this.openTelemetry = builder.openTelemetry; + } + + public boolean exportBuiltinMetricsToGoogleCloudMonitoring() { + return exportBuiltinMetricsToGoogleCloudMonitoring; + } + + public OpenTelemetry getOpenTelemetry() { + return openTelemetry; + } + + @Nonnull + public FirestoreOpenTelemetryOptions.Builder toBuilder() { + return new FirestoreOpenTelemetryOptions.Builder(this); + } + + @Nonnull + public static FirestoreOpenTelemetryOptions.Builder newBuilder() { + return new FirestoreOpenTelemetryOptions.Builder(); + } + + public static class Builder { + private boolean exportBuiltinMetricsToGoogleCloudMonitoring; + @Nullable private OpenTelemetry openTelemetry; + + private Builder() { + // TODO(metrics): default this to true when feature is ready + exportBuiltinMetricsToGoogleCloudMonitoring = false; + openTelemetry = null; + } + + private Builder(FirestoreOpenTelemetryOptions options) { + this.exportBuiltinMetricsToGoogleCloudMonitoring = + options.exportBuiltinMetricsToGoogleCloudMonitoring; + this.openTelemetry = options.openTelemetry; + } + + @Nonnull + public FirestoreOpenTelemetryOptions build() { + return new FirestoreOpenTelemetryOptions(this); + } + + // TODO(metrics): make this public when feature is ready. + /** + * Sets whether built-in metrics should be exported to Google Cloud Monitoring + * + * @param exportBuiltinMetrics Whether built-in metrics should be exported to Google Cloud + * Monitoring. + */ + @Nonnull + private FirestoreOpenTelemetryOptions.Builder exportBuiltinMetricsToGoogleCloudMonitoring( + boolean exportBuiltinMetrics) { + this.exportBuiltinMetricsToGoogleCloudMonitoring = exportBuiltinMetrics; + return this; + } + + /** + * Sets the {@link OpenTelemetry} to use with this Firestore instance. If telemetry collection + * is enabled, but an `OpenTelemetry` is not provided, the Firestore SDK will attempt to use the + * `GlobalOpenTelemetry`. + * + * @param openTelemetry The OpenTelemetry that should be used by this Firestore instance. + */ + @Nonnull + public FirestoreOpenTelemetryOptions.Builder setOpenTelemetry( + @Nonnull OpenTelemetry openTelemetry) { + this.openTelemetry = openTelemetry; + return this; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java new file mode 100644 index 000000000000..e8df452a4557 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreOptions.java @@ -0,0 +1,476 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.auth.Credentials; +import com.google.cloud.ServiceDefaults; +import com.google.cloud.ServiceOptions; +import com.google.cloud.TransportOptions; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.cloud.firestore.spi.v1.GrpcFirestoreRpc; +import com.google.cloud.firestore.telemetry.CompositeApiTracerFactory; +import com.google.cloud.firestore.telemetry.MetricsUtil; +import com.google.cloud.firestore.v1.FirestoreSettings; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** A Factory class to create new Firestore instances. */ +public final class FirestoreOptions extends ServiceOptions { + + private static final String API_SHORT_NAME = "Firestore"; + private static final Set SCOPES = + ImmutableSet.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/datastore") + .build(); + private static final long serialVersionUID = -5853552236134770090L; + + private static final String FIRESTORE_EMULATOR_SYSTEM_VARIABLE = "FIRESTORE_EMULATOR_HOST"; + + private final String databaseId; + private final TransportChannelProvider channelProvider; + private final CredentialsProvider credentialsProvider; + private final String emulatorHost; + private final transient @Nonnull FirestoreOpenTelemetryOptions openTelemetryOptions; + private final transient @Nonnull com.google.cloud.firestore.telemetry.TraceUtil traceUtil; + private final transient @Nonnull com.google.cloud.firestore.telemetry.MetricsUtil metricsUtil; + + public static class DefaultFirestoreFactory implements FirestoreFactory { + + private static final FirestoreFactory INSTANCE = new DefaultFirestoreFactory(); + + @Nonnull + @Override + public Firestore create(@Nonnull FirestoreOptions options) { + return new FirestoreImpl(options); + } + } + + /** Returns a default {@code FirestoreOptions} instance. */ + public static FirestoreOptions getDefaultInstance() { + return newBuilder().build(); + } + + public static class DefaultFirestoreRpcFactory implements FirestoreRpcFactory { + + private static final FirestoreRpcFactory INSTANCE = new DefaultFirestoreRpcFactory(); + + @Nonnull + @Override + public FirestoreRpc create(@Nonnull FirestoreOptions options) { + try { + return new GrpcFirestoreRpc(options); + } catch (IOException e) { + throw FirestoreException.forIOException(e, false); + } + } + } + + @Override + protected boolean projectIdRequired() { + return false; + } + + @Override + protected String getDefaultHost() { + return FirestoreDefaults.INSTANCE.getHost(); + } + + @InternalApi + @Override + public ApiTracerFactory getApiTracerFactory() { + List apiTracerFactories = new ArrayList<>(); + // Prefer any direct ApiTracerFactory that might have been set on the builder. + if (super.getApiTracerFactory() != null) { + apiTracerFactories.add(super.getApiTracerFactory()); + } + // Add Metrics Tracer factory if built-in metrics are enabled. + metricsUtil.addMetricsTracerFactory(apiTracerFactories); + + if (apiTracerFactories.isEmpty()) { + return null; + } + return new CompositeApiTracerFactory(apiTracerFactories); + } + + public String getDatabaseId() { + return databaseId; + } + + public CredentialsProvider getCredentialsProvider() { + return credentialsProvider; + } + + public TransportChannelProvider getTransportChannelProvider() { + return channelProvider; + } + + public String getEmulatorHost() { + return emulatorHost; + } + + @Nonnull + com.google.cloud.firestore.telemetry.TraceUtil getTraceUtil() { + return traceUtil; + } + + @Nonnull + com.google.cloud.firestore.telemetry.MetricsUtil getMetricsUtil() { + return metricsUtil; + } + + @BetaApi + @Nonnull + public FirestoreOpenTelemetryOptions getOpenTelemetryOptions() { + return openTelemetryOptions; + } + + public static class Builder extends ServiceOptions.Builder { + + @Nullable private String databaseId = null; + @Nullable private TransportChannelProvider channelProvider = null; + @Nullable private CredentialsProvider credentialsProvider = null; + @Nullable private String emulatorHost = null; + @Nullable private FirestoreOpenTelemetryOptions openTelemetryOptions = null; + + private Builder() {} + + private Builder(FirestoreOptions options) { + super(options); + this.databaseId = options.databaseId; + this.channelProvider = options.channelProvider; + this.credentialsProvider = options.credentialsProvider; + this.emulatorHost = options.emulatorHost; + this.openTelemetryOptions = options.openTelemetryOptions; + } + + /** + * Sets the {@link TransportOptions} to use with this Firestore client. + * + * @param transportOptions A GrpcTransportOptions object that defines the transport options for + * this client. + */ + @Nonnull + @Override + public Builder setTransportOptions(@Nonnull TransportOptions transportOptions) { + if (!(transportOptions instanceof GrpcTransportOptions)) { + throw new IllegalArgumentException( + "Only GRPC transport is allowed for " + API_SHORT_NAME + "."); + } + super.setTransportOptions(transportOptions); + return this; + } + + /** + * Sets the {@link TransportChannelProvider} to use with this Firestore client. + * + * @param channelProvider A InstantiatingGrpcChannelProvider object that defines the transport + * provider for this client. + */ + @Nonnull + public Builder setChannelProvider(@Nonnull TransportChannelProvider channelProvider) { + if (!(channelProvider instanceof InstantiatingGrpcChannelProvider)) { + throw new IllegalArgumentException( + "Only GRPC channels are allowed for " + API_SHORT_NAME + "."); + } + this.channelProvider = channelProvider; + return this; + } + + /** + * Sets the {@link CredentialsProvider} to use with this Firestore client. + * + * @param credentialsProvider A CredentialsProvider object that defines the credential provider + * for this client. + */ + @Nonnull + public Builder setCredentialsProvider(@Nonnull CredentialsProvider credentialsProvider) { + this.credentialsProvider = credentialsProvider; + return this; + } + + /** + * Sets the emulator host to use with this Firestore client. The value passed to this method + * will take precedent if the {@code FIRESTORE_EMULATOR_HOST} environment variable is also set. + * + * @param emulatorHost The Firestore emulator host to use with this client. + */ + public Builder setEmulatorHost(@Nonnull String emulatorHost) { + this.emulatorHost = emulatorHost; + return this; + } + + /** + * Sets the database ID to use with this Firestore client. + * + * @param databaseId The Firestore database ID to use with this client. + */ + public Builder setDatabaseId(@Nonnull String databaseId) { + this.databaseId = databaseId; + return this; + } + + /** + * Sets the {@link FirestoreOpenTelemetryOptions} to be used for this Firestore instance. + * + * @param openTelemetryOptions The `FirestoreOpenTelemetryOptions` to use. + */ + @BetaApi + @Nonnull + public Builder setOpenTelemetryOptions( + @Nonnull FirestoreOpenTelemetryOptions openTelemetryOptions) { + this.openTelemetryOptions = openTelemetryOptions; + return this; + } + + @Override + @Nonnull + public FirestoreOptions build() { + if (this.credentials == null && this.credentialsProvider != null) { + try { + this.setCredentials(credentialsProvider.getCredentials()); + } catch (IOException e) { + throw new RuntimeException("Failed to obtain credentials", e); + } + } + + if (this.openTelemetryOptions == null) { + this.setOpenTelemetryOptions(FirestoreOpenTelemetryOptions.newBuilder().build()); + } + + // Override credentials and channel provider if we are using the emulator. + if (emulatorHost == null) { + emulatorHost = System.getenv(FIRESTORE_EMULATOR_SYSTEM_VARIABLE); + } + if (emulatorHost != null) { + // Try creating a host in order to validate that the host name is valid. + try { + String hostUrlString = "http://" + emulatorHost; + URI.create(hostUrlString); + } catch (Exception e) { + throw new IllegalArgumentException( + "Value: '" + + emulatorHost + + "' for property " + + FIRESTORE_EMULATOR_SYSTEM_VARIABLE + + " is not a valid host", + e); + } + + // Setting the channel provider to use plaintext turns off SSL. + this.setChannelProvider( + InstantiatingGrpcChannelProvider.newBuilder() + .setEndpoint(emulatorHost) + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()); + // Use a `CredentialProvider` to match the Firebase Admin SDK, which prevents the Admin SDK + // from overwriting the Emulator credentials. + this.setCredentialsProvider(FixedCredentialsProvider.create(new EmulatorCredentials())); + } + + return new FirestoreOptions(this); + } + } + + public static class EmulatorCredentials extends Credentials { + private final Map> HEADERS = + ImmutableMap.of("Authorization", Collections.singletonList("Bearer owner")); + + @Override + public String getAuthenticationType() { + return "Unauthenticated"; + } + + @Override + public Map> getRequestMetadata(URI uri) { + return HEADERS; + } + + @Override + public boolean hasRequestMetadata() { + return true; + } + + @Override + public boolean hasRequestMetadataOnly() { + return true; + } + + @Override + public void refresh() {} + } + + @InternalApi("This class should only be extended within google-cloud-java") + protected FirestoreOptions(Builder builder) { + super(FirestoreFactory.class, FirestoreRpcFactory.class, builder, new FirestoreDefaults()); + + // FirestoreOptions must contain non-null open-telemetry options. + // If the builder doesn't have any open-telemetry options, use a default (disabled) one. + this.openTelemetryOptions = + builder.openTelemetryOptions != null + ? builder.openTelemetryOptions + : FirestoreOpenTelemetryOptions.newBuilder().build(); + this.traceUtil = com.google.cloud.firestore.telemetry.TraceUtil.getInstance(this); + + this.databaseId = + builder.databaseId != null + ? builder.databaseId + : FirestoreDefaults.INSTANCE.getDatabaseId(); + + // Set up the `MetricsUtil` instance after the database ID has been set. + this.metricsUtil = MetricsUtil.getInstance(this); + + if (builder.channelProvider == null) { + ApiFunction channelConfigurator = + this.traceUtil.getChannelConfigurator(); + if (channelConfigurator == null) { + this.channelProvider = + GrpcTransportOptions.setUpChannelProvider( + FirestoreSettings.defaultGrpcTransportProviderBuilder(), this); + } else { + // Intercept the grpc channel calls to add telemetry info. + this.channelProvider = + GrpcTransportOptions.setUpChannelProvider( + FirestoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(channelConfigurator), + this); + } + } else { + this.channelProvider = builder.channelProvider; + } + + this.credentialsProvider = + builder.credentialsProvider != null + ? builder.credentialsProvider + : GrpcTransportOptions.setUpCredentialsProvider(this); + + this.emulatorHost = builder.emulatorHost; + } + + private static class FirestoreDefaults implements ServiceDefaults { + private static final FirestoreDefaults INSTANCE = new FirestoreDefaults(); + + private final String HOST = FirestoreSettings.getDefaultEndpoint(); + private final String DATABASE_ID = "(default)"; + private final TransportOptions TRANSPORT_OPTIONS = getDefaultTransportOptionsBuilder().build(); + + @Nonnull + String getHost() { + return HOST; + } + + @Nonnull + String getDatabaseId() { + return DATABASE_ID; + } + + @Nonnull + @Override + public FirestoreFactory getDefaultServiceFactory() { + return DefaultFirestoreFactory.INSTANCE; + } + + @Nonnull + @Override + public FirestoreRpcFactory getDefaultRpcFactory() { + return DefaultFirestoreRpcFactory.INSTANCE; + } + + @Nonnull + @Override + public TransportOptions getDefaultTransportOptions() { + return TRANSPORT_OPTIONS; + } + } + + @Nonnull + public static GrpcTransportOptions.Builder getDefaultTransportOptionsBuilder() { + return GrpcTransportOptions.newBuilder(); + } + + @Nonnull + public static InstantiatingGrpcChannelProvider.Builder + getDefaultTransportChannelProviderBuilder() { + return FirestoreSettings.defaultGrpcTransportProviderBuilder(); + } + + @Nonnull + public static GoogleCredentialsProvider.Builder getDefaultCredentialsProviderBuilder() { + return FirestoreSettings.defaultCredentialsProviderBuilder(); + } + + @Override + protected Set getScopes() { + return SCOPES; + } + + FirestoreRpc getFirestoreRpc() { + return (FirestoreRpc) getRpc(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FirestoreOptions that = (FirestoreOptions) o; + return Objects.equals(databaseId, that.databaseId) + && Objects.equals(channelProvider, that.channelProvider) + && baseEquals(that); + } + + @Override + public int hashCode() { + return Objects.hash(databaseId, channelProvider, baseHashCode()); + } + + @Nonnull + @SuppressWarnings("unchecked") + @Override + public Builder toBuilder() { + return new Builder(this); + } + + @Nonnull + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java new file mode 100644 index 000000000000..e25b47a43966 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcContext.java @@ -0,0 +1,67 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + +import com.google.api.core.ApiClock; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.core.ObsoleteApi; +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; + +@InternalApi +@InternalExtensionOnly +interface FirestoreRpcContext { + + FS getFirestore(); + + String getDatabaseName(); + + ResourcePath getResourcePath(); + + FirestoreRpc getClient(); + + /** This method is obsolete. Use {@link #getTotalRequestTimeoutDuration()} instead. */ + @ObsoleteApi("Use getTotalRequestTimeoutDuration() instead") + org.threeten.bp.Duration getTotalRequestTimeout(); + + default java.time.Duration getTotalRequestTimeoutDuration() { + return toJavaTimeDuration(getTotalRequestTimeout()); + } + + ApiClock getClock(); + + ApiFuture sendRequest( + RequestT requestT, UnaryCallable callable); + + void streamRequest( + RequestT requestT, + ResponseObserver responseObserverT, + ServerStreamingCallable callable); + + ClientStream streamRequest( + BidiStreamObserver responseObserverT, + BidiStreamingCallable callable); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcFactory.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcFactory.java new file mode 100644 index 000000000000..3b0231e27cfe --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreRpcFactory.java @@ -0,0 +1,25 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.spi.ServiceRpcFactory; + +/** + * An interface for Firestore RPC factory. Implementation will be loaded via {@link + * java.util.ServiceLoader}. + */ +public interface FirestoreRpcFactory extends ServiceRpcFactory {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GenericQuerySnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GenericQuerySnapshot.java new file mode 100644 index 000000000000..cd7348de4f26 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GenericQuerySnapshot.java @@ -0,0 +1,172 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** + * Abstract. A GenericQuerySnapshot represents the results of a query that returns documents. It can + * contain zero or more DocumentSnapshot objects. + */ +public abstract class GenericQuerySnapshot implements Iterable { + protected final QueryT query; + protected final Timestamp readTime; + + private List documentChanges; + private final List documents; + + // Elevated access level for mocking. + protected GenericQuerySnapshot( + QueryT query, + Timestamp readTime, + @Nonnull final List documents, + final List documentChanges) { + this.query = query; + this.readTime = readTime; + this.documentChanges = + documentChanges != null ? Collections.unmodifiableList(documentChanges) : documentChanges; + this.documents = Collections.unmodifiableList(documents); + } + + /** + * Returns the query for the snapshot. + * + * @return The backing query that produced this snapshot. + */ + @Nonnull + public QueryT getQuery() { + return query; + } + + /** + * Returns the time at which this snapshot was read. + * + * @return The read time of this snapshot. + */ + @Nonnull + public Timestamp getReadTime() { + return readTime; + } + + /** + * Returns the documents in this QuerySnapshot as a List in order of the query. + * + * @return The list of documents. + */ + @Nonnull + public List getDocuments() { + return this.documents; + } + + /** Returns true if there are no documents in the QuerySnapshot. */ + public boolean isEmpty() { + return this.size() == 0; + } + + @Nonnull + public Iterator iterator() { + return getDocuments().iterator(); + } + + /** + * Returns the contents of the documents in the QuerySnapshot, converted to the provided class, as + * a list. + * + * @param clazz The POJO type used to convert the documents in the list. + */ + @Nonnull + public List toObjects(@Nonnull Class clazz) { + List documents = getDocuments(); + List results = new ArrayList<>(documents.size()); + for (DocumentSnapshot documentSnapshot : documents) { + results.add( + CustomClassMapper.convertToCustomClass( + documentSnapshot.getData(), clazz, documentSnapshot.getReference())); + } + + return results; + } + + /** + * Returns the list of documents that changed since the last snapshot. If it's the first snapshot + * all documents will be in the list as added changes. + * + * @return The list of documents that changed since the last snapshot. + */ + @Nonnull + public List getDocumentChanges() { + if (documentChanges == null) { + synchronized (documents) { + if (documentChanges == null) { + int size = documents.size(); + ImmutableList.Builder builder = + ImmutableList.builderWithExpectedSize(size); + for (int i = 0; i < size; ++i) { + builder.add(new DocumentChange(documents.get(i), DocumentChange.Type.ADDED, -1, i)); + } + documentChanges = builder.build(); + } + } + } + + return documentChanges; + } + + /** Returns the number of DocumentSnapshots in this snapshot. */ + public int size() { + return getDocuments().size(); + } + + /** + * Tests for equality with this object. + * + * @param o is tested for equality with this object. + * @return `true` if equal, otherwise `false` + */ + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GenericQuerySnapshot that = (GenericQuerySnapshot) o; + return Objects.equals(query, that.query) + && Objects.equals(this.getDocumentChanges(), that.getDocumentChanges()) + && Objects.equals(this.getDocuments(), that.getDocuments()); + } + + @Override + public int hashCode() { + return Objects.hash(query, this.getDocumentChanges(), this.getDocuments()); + } + + @Override + public String toString() { + return String.format( + "%s{query=%s, readTime=%s, documentChanges=%s, documents=%s}", + getClass().getSimpleName(), query, readTime, documentChanges, documents); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GeoPoint.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GeoPoint.java new file mode 100644 index 000000000000..a4e2627e823b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/GeoPoint.java @@ -0,0 +1,103 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.common.base.Preconditions; +import com.google.type.LatLng; +import java.io.Serializable; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** Immutable class representing a geographic location in Firestore */ +public class GeoPoint implements Serializable { + + private static final long serialVersionUID = 7871890086202168339L; + private final double latitude; + private final double longitude; + + /** + * Construct a new GeoPoint using the provided latitude and longitude values. + * + * @param latitude The latitude of this GeoPoint in the range [-90, 90]. + * @param longitude The longitude of this GeoPoint in the range [-180, 180]. + */ + public GeoPoint(double latitude, double longitude) { + Preconditions.checkArgument( + latitude >= -90 && latitude <= 90, "Latitude must be in the range of [-90, 90] degrees"); + Preconditions.checkArgument( + longitude >= -180 && longitude <= 180, + "Longitude must be in the range of [-180, 180] degrees"); + + this.latitude = latitude; + this.longitude = longitude; + } + + /** + * Returns the latitude. + * + * @return The latitude value of this GeoPoint. + */ + public double getLatitude() { + return this.latitude; + } + + /** + * Returns the longitude. + * + * @return The longitude value of this GeoPoint. + */ + public double getLongitude() { + return this.longitude; + } + + LatLng toProto() { + LatLng.Builder latLngBuilder = LatLng.newBuilder(); + latLngBuilder.setLatitude(latitude); + latLngBuilder.setLongitude(longitude); + return latLngBuilder.build(); + } + + @Nonnull + @Override + public String toString() { + return "GeoPoint { latitude=" + this.latitude + ", longitude=" + this.longitude + " }"; + } + + /** + * Returns true if this GeoPoint is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this GeoPoint is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + GeoPoint geoPoint = (GeoPoint) obj; + return Double.compare(geoPoint.latitude, latitude) == 0 + && Double.compare(geoPoint.longitude, longitude) == 0; + } + + @Override + public int hashCode() { + return Objects.hash(latitude, longitude); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Internal.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Internal.java new file mode 100644 index 000000000000..b257010755cd --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Internal.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.UserDataConverter.NO_DELETES; + +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.Value; +import java.util.Map; + +@InternalApi +public class Internal { + private final FirestoreImpl firestore; + + @InternalApi + public Internal(FirestoreImpl firestore) { + this.firestore = firestore; + } + + @InternalApi + public Internal(FirestoreOptions firestoreOptions, FirestoreRpc firestoreRpc) { + this.firestore = new FirestoreImpl(firestoreOptions, firestoreRpc); + } + + @InternalApi + public DocumentSnapshot snapshotFromObject(String documentPath, Object pojo) { + DocumentReference documentReference = firestore.document(documentPath); + Object data = CustomClassMapper.convertToPlainJavaTypes(pojo); + Preconditions.checkArgument( + data instanceof Map, "Can't create a document from an array or primitive"); + return DocumentSnapshot.fromObject( + firestore, documentReference, (Map) data, NO_DELETES); + } + + @InternalApi + public DocumentSnapshot snapshotFromMap(String documentPath, Map data) { + DocumentReference documentReference = firestore.document(documentPath); + return DocumentSnapshot.fromObject(firestore, documentReference, data, NO_DELETES); + } + + @InternalApi + public DocumentSnapshot snapshotFromProto(Timestamp readTime, Document document) { + return DocumentSnapshot.fromDocument(firestore, readTime, document); + } + + @InternalApi + public Map protoFromSnapshot(DocumentSnapshot snapshot) { + return snapshot.getProtoFields(); + } + + @InternalApi + public static String autoId() { + return FirestoreImpl.autoId(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ListenerRegistration.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ListenerRegistration.java new file mode 100644 index 000000000000..f16398459af4 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ListenerRegistration.java @@ -0,0 +1,27 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +/** Represents a listener that can be removed by calling remove(). */ +public interface ListenerRegistration { + + /** + * Removes the listener being tracked by this ListenerRegistration. After the initial call, + * subsequent calls have no effect. + */ + void remove(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/MapType.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/MapType.java new file mode 100644 index 000000000000..d04b77f96f4d --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/MapType.java @@ -0,0 +1,23 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +abstract class MapType { + static final String RESERVED_MAP_KEY = "__type__"; + static final String RESERVED_MAP_KEY_VECTOR_VALUE = "__vector__"; + static final String VECTOR_MAP_VECTORS_KEY = "value"; +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Order.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Order.java new file mode 100644 index 000000000000..c382140227ad --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Order.java @@ -0,0 +1,368 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static java.lang.Character.isSurrogate; + +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Value.ValueTypeCase; +import com.google.protobuf.ByteString; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.SortedMap; +import java.util.TreeMap; +import javax.annotation.Nonnull; + +/** Order implements the ordering semantics of the backend. */ +class Order implements Comparator { + enum TypeOrder implements Comparable { + // NOTE: This order is defined by the backend and cannot be changed. + NULL, + BOOLEAN, + NUMBER, + TIMESTAMP, + STRING, + BLOB, + REF, + GEO_POINT, + ARRAY, + VECTOR, + OBJECT; + + static TypeOrder fromValue(Value value) { + switch (value.getValueTypeCase()) { + case NULL_VALUE: + return NULL; + case BOOLEAN_VALUE: + return BOOLEAN; + case INTEGER_VALUE: + return NUMBER; + case DOUBLE_VALUE: + return NUMBER; + case TIMESTAMP_VALUE: + return TIMESTAMP; + case STRING_VALUE: + return STRING; + case BYTES_VALUE: + return BLOB; + case REFERENCE_VALUE: + return REF; + case GEO_POINT_VALUE: + return GEO_POINT; + case ARRAY_VALUE: + return ARRAY; + case MAP_VALUE: + return fromMapValue(value.getMapValue()); + default: + throw new IllegalArgumentException("Could not detect value type for " + value); + } + } + } + + static TypeOrder fromMapValue(MapValue mapValue) { + switch (UserDataConverter.detectMapRepresentation(mapValue)) { + case VECTOR_VALUE: + return TypeOrder.VECTOR; + case UNKNOWN: + case NONE: + default: + return TypeOrder.OBJECT; + } + } + + static final Order INSTANCE = new Order(); + + private Order() {} + + /** + * Main comparison function for all Firestore types. + * + * @return -1 is left < right, 0 if left == right, otherwise 1 + */ + public int compare(@Nonnull Value left, @Nonnull Value right) { + // First compare the types. + TypeOrder leftType = TypeOrder.fromValue(left); + TypeOrder rightType = TypeOrder.fromValue(right); + int typeComparison = leftType.compareTo(rightType); + if (typeComparison != 0) { + return typeComparison; + } + + // So they are the same type. + switch (leftType) { + case NULL: + return 0; // Nulls are all equal. + case BOOLEAN: + return Boolean.compare(left.getBooleanValue(), right.getBooleanValue()); + case NUMBER: + return compareNumbers(left, right); + case TIMESTAMP: + return compareTimestamps(left, right); + case STRING: + return compareUtf8Strings(left.getStringValue(), right.getStringValue()); + case BLOB: + return compareBlobs(left, right); + case REF: + return compareResourcePaths(left, right); + case GEO_POINT: + return compareGeoPoints(left, right); + case ARRAY: + return compareArrays( + left.getArrayValue().getValuesList(), right.getArrayValue().getValuesList()); + case OBJECT: + return compareObjects(left, right); + case VECTOR: + return compareVectors(left, right); + default: + throw new IllegalArgumentException("Cannot compare " + leftType); + } + } + + /** Compare strings in UTF-8 encoded byte order */ + public static int compareUtf8Strings(String left, String right) { + // noinspection StringEquality + if (left == right) { + return 0; + } + + // Find the first differing character (a.k.a. "UTF-16 code unit") in the two strings and, + // if found, use that character to determine the relative ordering of the two strings as a + // whole. Comparing UTF-16 strings in UTF-8 byte order can be done simply and efficiently by + // comparing the UTF-16 code units (chars). This serendipitously works because of the way UTF-8 + // and UTF-16 happen to represent Unicode code points. + // + // After finding the first pair of differing characters, there are two cases: + // + // Case 1: Both characters are non-surrogates (code points less than or equal to 0xFFFF) or + // both are surrogates from a surrogate pair (that collectively represent code points greater + // than 0xFFFF). In this case their numeric order as UTF-16 code units is the same as the + // lexicographical order of their corresponding UTF-8 byte sequences. A direct comparison is + // sufficient. + // + // Case 2: One character is a surrogate and the other is not. In this case the surrogate- + // containing string is always ordered after the non-surrogate. This is because surrogates are + // used to represent code points greater than 0xFFFF which have 4-byte UTF-8 representations + // and are lexicographically greater than the 1, 2, or 3-byte representations of code points + // less than or equal to 0xFFFF. + // + // An example of why Case 2 is required is comparing the following two Unicode code points: + // + // |-----------------------|------------|---------------------|-----------------| + // | Name | Code Point | UTF-8 Encoding | UTF-16 Encoding | + // |-----------------------|------------|---------------------|-----------------| + // | Replacement Character | U+FFFD | 0xEF 0xBF 0xBD | 0xFFFD | + // | Grinning Face | U+1F600 | 0xF0 0x9F 0x98 0x80 | 0xD83D 0xDE00 | + // |-----------------------|------------|---------------------|-----------------| + // + // A lexicographical comparison of the UTF-8 encodings of these code points would order + // "Replacement Character" _before_ "Grinning Face" because 0xEF is less than 0xF0. However, a + // direct comparison of the UTF-16 code units, as would be done in case 1, would erroneously + // produce the _opposite_ ordering, because 0xFFFD is _greater than_ 0xD83D. As it turns out, + // this relative ordering holds for all comparisons of UTF-16 code points requiring a surrogate + // pair with those that do not. + final int length = Math.min(left.length(), right.length()); + for (int i = 0; i < length; i++) { + final char leftChar = left.charAt(i); + final char rightChar = right.charAt(i); + if (leftChar != rightChar) { + return (isSurrogate(leftChar) == isSurrogate(rightChar)) + ? Character.compare(leftChar, rightChar) + : isSurrogate(leftChar) ? 1 : -1; + } + } + + // Use the lengths of the strings to determine the overall comparison result since either the + // strings were equal or one is a prefix of the other. + return Integer.compare(left.length(), right.length()); + } + + private int compareBlobs(Value left, Value right) { + ByteString leftBytes = left.getBytesValue(); + ByteString rightBytes = right.getBytesValue(); + return compareByteStrings(leftBytes, rightBytes); + } + + static int compareByteStrings(ByteString leftBytes, ByteString rightBytes) { + int size = Math.min(leftBytes.size(), rightBytes.size()); + for (int i = 0; i < size; i++) { + // Make sure the bytes are unsigned + int thisByte = leftBytes.byteAt(i) & 0xff; + int otherByte = rightBytes.byteAt(i) & 0xff; + if (thisByte < otherByte) { + return -1; + } else if (thisByte > otherByte) { + return 1; + } + // Byte values are equal, continue with comparison + } + return Integer.compare(leftBytes.size(), rightBytes.size()); + } + + private static int compareTimestamps(Value left, Value right) { + int cmp = + Long.compare(left.getTimestampValue().getSeconds(), right.getTimestampValue().getSeconds()); + + if (cmp != 0) { + return cmp; + } else { + return Integer.compare( + left.getTimestampValue().getNanos(), right.getTimestampValue().getNanos()); + } + } + + private static int compareGeoPoints(Value left, Value right) { + int cmp = + Double.compare( + left.getGeoPointValue().getLatitude(), right.getGeoPointValue().getLatitude()); + + if (cmp != 0) { + return cmp; + } else { + return Double.compare( + left.getGeoPointValue().getLongitude(), right.getGeoPointValue().getLongitude()); + } + } + + private int compareResourcePaths(Value left, Value right) { + ResourcePath leftPath = ResourcePath.create(left.getReferenceValue()); + ResourcePath rightPath = ResourcePath.create(right.getReferenceValue()); + return leftPath.compareTo(rightPath); + } + + public int compareArrays(List left, List right) { + int minLength = Math.min(left.size(), right.size()); + for (int i = 0; i < minLength; i++) { + int cmp = compare(left.get(i), right.get(i)); + if (cmp != 0) { + return cmp; + } + } + return Integer.compare(left.size(), right.size()); + } + + private int compareObjects(Value left, Value right) { + // This requires iterating over the keys in the object in order and doing a + // deep comparison. + SortedMap leftMap = new TreeMap<>(left.getMapValue().getFieldsMap()); + SortedMap rightMap = new TreeMap<>(right.getMapValue().getFieldsMap()); + + Iterator> leftIterator = leftMap.entrySet().iterator(); + Iterator> rightIterator = rightMap.entrySet().iterator(); + + while (leftIterator.hasNext() && rightIterator.hasNext()) { + Entry leftEntry = leftIterator.next(); + Entry rightEntry = rightIterator.next(); + int keyCompare = compareUtf8Strings(leftEntry.getKey(), rightEntry.getKey()); + if (keyCompare != 0) { + return keyCompare; + } + int valueCompare = compare(leftEntry.getValue(), rightEntry.getValue()); + if (valueCompare != 0) { + return valueCompare; + } + } + + // Only equal if both iterators are exhausted. + return Boolean.compare(leftIterator.hasNext(), rightIterator.hasNext()); + } + + private int compareVectors(Value left, Value right) { + // The vector is a map, but only vector value is compared. + Value leftValueField = + left.getMapValue().getFieldsOrDefault(MapType.VECTOR_MAP_VECTORS_KEY, null); + Value rightValueField = + right.getMapValue().getFieldsOrDefault(MapType.VECTOR_MAP_VECTORS_KEY, null); + + List leftArray = + (leftValueField != null) + ? leftValueField.getArrayValue().getValuesList() + : Collections.emptyList(); + List rightArray = + (rightValueField != null) + ? rightValueField.getArrayValue().getValuesList() + : Collections.emptyList(); + + Integer lengthCompare = Long.compare(leftArray.size(), rightArray.size()); + if (lengthCompare != 0) { + return lengthCompare; + } + + return compareArrays(leftArray, rightArray); + } + + private int compareNumbers(Value left, Value right) { + // NaN is smaller than any other numbers + if (isNaN(left)) { + return isNaN(right) ? 0 : -1; + } else if (isNaN(right)) { + return 1; + } + + if (left.getValueTypeCase() == ValueTypeCase.DOUBLE_VALUE) { + if (right.getValueTypeCase() == ValueTypeCase.DOUBLE_VALUE) { + return compareDoubles(left.getDoubleValue(), right.getDoubleValue()); + } else { + return compareDoubleAndLong(left.getDoubleValue(), right.getIntegerValue()); + } + } else { + if (right.getValueTypeCase() == ValueTypeCase.INTEGER_VALUE) { + return Long.compare(left.getIntegerValue(), right.getIntegerValue()); + } else { + return -compareDoubleAndLong(right.getDoubleValue(), left.getIntegerValue()); + } + } + } + + private boolean isNaN(Value value) { + return value.hasDoubleValue() && Double.isNaN(value.getDoubleValue()); + } + + private int compareDoubles(double left, double right) { + // Firestore treats -0.0, 0.0 and +0.0 as equal. + return Double.compare(left == -0.0 ? 0 : left, right == -0.0 ? 0 : right); + } + + /** + * The maximum integer absolute number that can be represented as a double without loss of + * precision. This is 2^53 because double-precision floating point numbers have 53 bits + * significand precision (52 explicit bit + 1 hidden bit). + */ + private static final long MAX_INTEGER_TO_DOUBLE_PRECISION = 1L << 53; + + private int compareDoubleAndLong(double doubleValue, long longValue) { + if (Math.abs(longValue) <= MAX_INTEGER_TO_DOUBLE_PRECISION) { + // Enough precision to compare as double, the cast will not be lossy. + return compareDoubles(doubleValue, (double) longValue); + } else if (doubleValue < ((double) Long.MAX_VALUE) + && doubleValue >= ((double) Long.MIN_VALUE)) { + // The above condition captures all doubles that belong to [min long, max long] inclusive. + // Java long to double conversion rounds-to-nearest, so Long.MAX_VALUE casts to 2^63, hence + // the use of "<" operator. + // The cast to long below may be lossy, but only for absolute values < 2^52 so the loss of + // precision does not affect the comparison, as longValue is outside that range. + return Long.compare((long) doubleValue, longValue); + } else { + // doubleValue is outside the representable range for longs, so always smaller if negative, + // and always greater otherwise. + return doubleValue < 0 ? -1 : 1; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java new file mode 100644 index 000000000000..c0f4c1c46112 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java @@ -0,0 +1,1381 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.pipeline.expressions.Expression.field; +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_DOC_COUNT; +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_IS_TRANSACTIONAL; + +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.StreamController; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.pipeline.expressions.AggregateFunction; +import com.google.cloud.firestore.pipeline.expressions.AliasedAggregate; +import com.google.cloud.firestore.pipeline.expressions.AliasedExpression; +import com.google.cloud.firestore.pipeline.expressions.BooleanExpression; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.expressions.FunctionExpression; +import com.google.cloud.firestore.pipeline.expressions.Ordering; +import com.google.cloud.firestore.pipeline.expressions.Selectable; +import com.google.cloud.firestore.pipeline.stages.AddFields; +import com.google.cloud.firestore.pipeline.stages.Aggregate; +import com.google.cloud.firestore.pipeline.stages.AggregateOptions; +import com.google.cloud.firestore.pipeline.stages.Distinct; +import com.google.cloud.firestore.pipeline.stages.FindNearest; +import com.google.cloud.firestore.pipeline.stages.FindNearestOptions; +import com.google.cloud.firestore.pipeline.stages.Limit; +import com.google.cloud.firestore.pipeline.stages.Offset; +import com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions; +import com.google.cloud.firestore.pipeline.stages.RawStage; +import com.google.cloud.firestore.pipeline.stages.RemoveFields; +import com.google.cloud.firestore.pipeline.stages.ReplaceWith; +import com.google.cloud.firestore.pipeline.stages.Sample; +import com.google.cloud.firestore.pipeline.stages.Select; +import com.google.cloud.firestore.pipeline.stages.Sort; +import com.google.cloud.firestore.pipeline.stages.Stage; +import com.google.cloud.firestore.pipeline.stages.StageUtils; +import com.google.cloud.firestore.pipeline.stages.Union; +import com.google.cloud.firestore.pipeline.stages.Unnest; +import com.google.cloud.firestore.pipeline.stages.UnnestOptions; +import com.google.cloud.firestore.pipeline.stages.Where; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.common.collect.FluentIterable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.StructuredPipeline; +import com.google.firestore.v1.Value; +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * The Pipeline class provides a flexible and expressive framework for building complex data + * transformation and query pipelines for Firestore. + * + *

A pipeline takes data sources, such as Firestore collections or collection groups, and applies + * a series of stages that are chained together. Each stage takes the output from the previous stage + * (or the data source) and produces an output for the next stage (or as the final output of the + * pipeline). + * + *

Expressions from {@link com.google.cloud.firestore.pipeline.expressions} can be used within + * each stages to filter and transform data through the stage. + * + *

NOTE: The chained stages do not prescribe exactly how Firestore will execute the pipeline. + * Instead, Firestore only guarantees that the result is the same as if the chained stages were + * executed in order. + * + *

Usage Examples: + * + *

{@code
+ * Firestore firestore; // A valid firestore instance.
+ *
+ * // Example 1: Select specific fields and rename 'rating' to 'bookRating'
+ * Snapshot results1 = firestore.pipeline()
+ *     .collection("books")
+ *     .select(field("title"), field("author"), field("rating").as("bookRating"))
+ *     .execute()
+ *     .get();
+ *
+ * // Example 2: Filter documents where 'genre' is "Science Fiction" and
+ * // 'published' is after 1950
+ * Snapshot results2 = firestore.pipeline()
+ *     .collection("books")
+ *     .where(and(equal("genre", "Science Fiction"), greaterThan("published", 1950)))
+ *     .execute()
+ *     .get();
+ * // Same as above but using methods on expressions as opposed to static
+ * // functions.
+ * results2 = firestore.pipeline()
+ *     .collection("books")
+ *     .where(and(field("genre").equal("Science Fiction"), field("published").greaterThan(1950)))
+ *     .execute()
+ *     .get();
+ *
+ * // Example 3: Calculate the average rating of books published after 1980
+ * Snapshot results3 = firestore.pipeline()
+ *     .collection("books")
+ *     .where(greaterThan("published", 1980))
+ *     .aggregate(average("rating").as("averageRating"))
+ *     .execute()
+ *     .get();
+ * }
+ */ +@BetaApi +public final class Pipeline { + /** + * A Snapshot contains the results of a pipeline execution. It can be used to access the + * documents, execution time, and explain stats. + */ + @BetaApi + public static final class Snapshot { + + private final Pipeline pipeline; + private final Timestamp executionTime; + private final List results; + private final ExplainStats explainStats; + + Snapshot( + @Nonnull Pipeline pipeline, + @Nonnull List results, + @Nonnull Timestamp executionTime, + @Nullable ExplainStats explainStats) { + this.pipeline = pipeline; + this.results = results; + this.executionTime = executionTime; + this.explainStats = explainStats; + } + + /** + * The Pipeline on which you called `execute()` in order to get this `Snapshot`. + * + * @return The pipeline that was executed. + */ + @Nonnull + Pipeline getPipeline() { + return pipeline; + } + + /** + * An array of all the results in the `Snapshot`. + * + * @return The list of results. + */ + @Nonnull + public List getResults() { + return results; + } + + /** + * The time at which the pipeline producing this result is executed. + * + * @return The execution time of the pipeline. + */ + @Nonnull + public Timestamp getExecutionTime() { + return executionTime; + } + + /** + * Return stats from query explain. + * + *

If `explainOptions.mode` was set to `execute` or left unset, then this returns `null`. + * + * @return The explain stats, or `null` if not available. + */ + @Nullable + public ExplainStats getExplainStats() { + return explainStats; + } + } + + private static Logger logger = Logger.getLogger(Pipeline.class.getName()); + private final FluentIterable stages; + private final FirestoreRpcContext rpcContext; + + private Pipeline(FirestoreRpcContext rpcContext, FluentIterable stages) { + this.rpcContext = rpcContext; + this.stages = stages; + } + + @InternalApi + Pipeline(FirestoreRpcContext rpcContext, Stage stage) { + this(rpcContext, FluentIterable.of(stage)); + } + + private Pipeline append(Stage stage) { + return new Pipeline(this.rpcContext, stages.append(stage)); + } + + /** + * Adds new fields to outputs from previous stages. + * + *

This stage allows you to compute values on-the-fly based on existing data from previous + * stages or constants. You can use this to create new fields or overwrite existing ones (if there + * is name overlaps). + * + *

The added fields are defined using {@link Selectable} expressions, which can be: + * + *

    + *
  • {@link Field}: References an existing document field. + *
  • {@link FunctionExpression}: Performs a calculation using functions like `add`, `multiply` + * with assigned aliases using {@link Expression#as(String)}. + *
+ * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *     .addFields(
+   *         field("rating").as("bookRating"), // Rename 'rating' to 'bookRating'
+   *         add(5, field("quantity")).as("totalCost") // Calculate 'totalCost'
+   *     );
+   * }
+ * + * @param field The field to add to the documents, specified as {@link Selectable} expressions. + * @param additionalFields The additional fields to add to the documents, specified as {@link + * Selectable} expressions. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline addFields(Selectable field, Selectable... additionalFields) { + return append( + new AddFields( + PipelineUtils.selectablesToMap( + ImmutableList.builder() + .add(field) + .add(additionalFields) + .build() + .toArray(new Selectable[0])))); + } + + /** + * Remove fields from outputs of previous stages. + * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *     .removeFields(
+   *         "rating", "cost");
+   * }
+ * + * @param field The fields to remove. + * @param additionalFields The additional fields to remove. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline removeFields(String field, String... additionalFields) { + return append( + new RemoveFields( + ImmutableList.builder() + .add(Field.ofUserPath(field)) + .addAll(Arrays.stream(additionalFields).map(f -> Field.ofUserPath(f)).iterator()) + .build())); + } + + /** + * Remove fields from outputs of previous stages. + * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *     .removeFields(
+   *         field("rating"), field("cost"));
+   * }
+ * + * @param field The field to remove. + * @param additionalFields The additional fields to remove. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline removeFields(Field field, Field... additionalFields) { + return append( + new RemoveFields( + ImmutableList.builder() + .add(field) + .addAll(Arrays.stream(additionalFields).iterator()) + .build())); + } + + /** + * Selects or creates a set of fields from the outputs of previous stages. + * + *

The selected fields are defined using {@link Selectable} expressions, which can be: + * + *

    + *
  • {@link Field}: References an existing document field. + *
  • {@link FunctionExpression}: Represents the result of a function with an assigned alias + * name using {@link Expression#as(String)} + *
+ * + *

If no selections are provided, the output of this stage is empty. Use {@link + * com.google.cloud.firestore.Pipeline#addFields(Selectable, Selectable...)} instead if only + * additions are desired. + * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *   .select(
+   *     field("name"),
+   *     field("address").toUppercase().as("upperAddress"),
+   *   );
+   * }
+ * + * @param selection The field to include in the output documents, specified as {@link Selectable} + * expressions. + * @param additionalSelections The additional fields to include in the output documents, + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline select(Selectable selection, Selectable... additionalSelections) { + return append( + new Select( + PipelineUtils.selectablesToMap( + ImmutableList.builder() + .add(selection) + .add(additionalSelections) + .build() + .toArray(new Selectable[0])))); + } + + /** + * Selects a set of fields from the outputs of previous stages. + * + *

If no selections are provided, the output of this stage is empty. Use {@link + * com.google.cloud.firestore.Pipeline#addFields(Selectable, Selectable...)} instead if only + * additions are desired. + * + *

Example: + * + *

{@code
+   * firestore.collection("books")
+   *     .select("name", "address");
+   *
+   * // The above is a shorthand of this:
+   * firestore.pipeline().collection("books")
+   *     .select(field("name"), field("address"));
+   * }
+ * + * @param field The name of the field to include in the output documents. + * @param additionalFields The additional fields to include in the output documents. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline select(String field, String... additionalFields) { + return append( + new Select( + PipelineUtils.fieldNamesToMap( + ImmutableList.builder() + .add(field) + .add(additionalFields) + .build() + .toArray(new String[0])))); + } + + /** + * Filters the documents from previous stages to only include those matching the specified {@link + * BooleanExpression}. + * + *

This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. + * You can filter documents based on their field values, using implementions of {@link + * BooleanExpression}, typically including but not limited to: + * + *

    + *
  • field comparators: {@link FunctionExpression#equal}, {@link FunctionExpression#lessThan} + * (less than), {@link FunctionExpression#greaterThan} (greater than), etc. + *
  • logical operators: {@link FunctionExpression#and}, {@link FunctionExpression#or}, {@link + * FunctionExpression#not}, etc. + *
  • advanced functions: {@link FunctionExpression#regexMatch(String, String)}, {@link + * FunctionExpression#arrayContains(Expression, Expression)}, etc. + *
+ * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *   .where(
+   *     and(
+   *         gt("rating", 4.0),   // Filter for ratings greater than 4.0
+   *         field("genre").eq("Science Fiction") // Equivalent to eq("genre", "Science Fiction")
+   *     )
+   *   );
+   * }
+ * + * @param condition The {@link BooleanExpression} to apply. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline where(BooleanExpression condition) { + return append(new Where(condition)); + } + + /** + * Skips the first `offset` number of documents from the results of previous stages. + * + *

This stage is useful for implementing pagination in your pipelines, allowing you to retrieve + * results in chunks. It is typically used in conjunction with {@link #limit(int)} to control the + * size of each page. + * + *

Example: + * + *

{@code
+   * // Retrieve the second page of 20 results
+   * firestore.pipeline().collection("books")
+   *     .sort(field("published").descending())
+   *     .offset(20)  // Skip the first 20 results
+   *     .limit(20);   // Take the next 20 results
+   * }
+ * + * @param offset The number of documents to skip. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline offset(int offset) { + return append(new Offset(offset)); + } + + /** + * Limits the maximum number of documents returned by previous stages to `limit`. + * + *

This stage is particularly useful when you want to retrieve a controlled subset of data from + * a potentially large result set. It's often used for: + * + *

    + *
  • **Pagination:** In combination with {@link #offset(int)} to retrieve specific pages of + * results. + *
  • **Limiting Data Retrieval:** To prevent excessive data transfer and improve performance, + * especially when dealing with large collections. + *
+ * + *

Example: + * + *

{@code
+   * // Limit the results to the top 10 highest-rated books
+   * firestore.pipeline().collection("books")
+   *     .sort(field("rating").descending())
+   *     .limit(10);
+   * }
+ * + * @param limit The maximum number of documents to return. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline limit(int limit) { + return append(new Limit(limit)); + } + + /** + * Performs aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents. You define the + * aggregations to perform using {@link AliasedExpression} expressions which are typically results + * of calling {@link Expression#as(String)} on {@link AggregateFunction} instances. + * + *

Example: + * + *

{@code
+   * // Calculate the average rating and the total number of books
+   * firestore.pipeline().collection("books")
+   *     .aggregate(
+   *         field("rating").average().as("averageRating"),
+   *         countAll().as("totalBooks"));
+   * }
+ * + * @param accumulators The {@link AliasedExpression} expressions, each wrapping an {@link + * AggregateFunction} and provide a name for the accumulated results. + * @return A new Pipeline object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline aggregate(AliasedAggregate... accumulators) { + return append(Aggregate.withAccumulators(accumulators)); + } + + /** + * Performs optionally grouped aggregation operations on the documents from previous stages. + * + *

This stage allows you to calculate aggregate values over a set of documents, optionally + * grouped by one or more fields or functions. You can specify: + * + *

    + *
  • **Grouping Fields or Functions:** One or more fields or functions to group the documents + * by. For each distinct combination of values in these fields, a separate group is created. + * If no grouping fields are provided, a single group containing all documents is used. Not + * specifying groups is the same as putting the entire inputs into one group. + *
  • **Accumulators:** One or more accumulation operations to perform within each group. These + * are defined using {@link AliasedExpression} expressions, which are typically created by + * calling {@link Expression#as(String)} on {@link AggregateFunction} instances. Each + * aggregation calculates a value (e.g., sum, average, count) based on the documents within + * its group. + *
+ * + *

Example: + * + *

{@code
+   * // Calculate the average rating for each genre.
+   * firestore.pipeline().collection("books")
+   *     .aggregate(
+   *         Aggregate
+   *             .withAccumulators(average("rating").as("avg_rating"))
+   *             .withGroups("genre"));
+   * }
+ * + * @param aggregate An {@link Aggregate} object that specifies the grouping fields (if any) and + * the aggregation operations to perform. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline aggregate(Aggregate aggregate) { + return append(aggregate); + } + + @BetaApi + public Pipeline aggregate(Aggregate aggregate, AggregateOptions options) { + return append(aggregate.withOptions(options)); + } + + /** + * Returns a set of distinct field values from the inputs to this stage. + * + *

This stage run through the results from previous stages to include only results with unique + * combinations of values for the specified fields and produce these fields as the output. + * + *

Example: + * + *

{@code
+   * // Get a list of unique genres.
+   * firestore.pipeline().collection("books")
+   *     .distinct("genre");
+   * }
+ * + * @param fields The fields to consider when determining distinct values. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline distinct(String... fields) { + return append(new Distinct(PipelineUtils.fieldNamesToMap(fields))); + } + + /** + * Returns a set of distinct {@link Expression} values from the inputs to this stage. + * + *

This stage run through the results from previous stages to include only results with unique + * combinations of {@link Expression} values ({@link Field}, {@link FunctionExpression}, etc). + * + *

The parameters to this stage are defined using {@link Selectable} expressions, which can be: + * + *

    + *
  • {@link Field}: References an existing document field. + *
  • {@link FunctionExpression}: Represents the result of a function with an assigned alias + * name using {@link Expression#as(String)} + *
+ * + *

Example: + * + *

{@code
+   * // Get a list of unique author names in uppercase and genre combinations.
+   * firestore.pipeline().collection("books")
+   *     .distinct(toUppercase(field("author")).as("authorName"), field("genre"))
+   *     .select("authorName");
+   * }
+ * + * @param selectables The {@link Selectable} expressions to consider when determining distinct + * value combinations. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline distinct(Selectable... selectables) { + return append(new Distinct(PipelineUtils.selectablesToMap(selectables))); + } + + /** + * Performs vector distance (similarity) search with given parameters to the stage inputs. + * + *

This stage adds a "nearest neighbor search" capability to your pipelines. Given a field that + * stores vectors and a target vector, this stage will identify and return the inputs whose vector + * field is closest to the target vector, using the parameters specified in `options`. + * + *

Example: + * + *

{@code
+   * // Find books with similar "topicVectors" to the given targetVector
+   * firestore.pipeline().collection("books")
+   *     .findNearest("topicVectors", targetVector, FindNearest.DistanceMeasure.COSINE,
+   *        new FindNearestOptions()
+   *          .withLimit(10)
+   *          .withDistanceField("distance"));
+   * }
+ * + * @param fieldName The name of the field containing the vector data. This field should store + * {@link VectorValue}. + * @param vector The target vector to compare against. + * @param distanceMeasure The distance measure to use: cosine, euclidean, etc. + * @param options Configuration options for the nearest neighbor search, such as limit and output + * distance field name. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline findNearest( + String fieldName, + double[] vector, + FindNearest.DistanceMeasure distanceMeasure, + FindNearestOptions options) { + return findNearest(field(fieldName), vector, distanceMeasure, options); + } + + /** + * Performs vector distance (similarity) search with given parameters to the stage inputs. + * + *

This stage adds a "nearest neighbor search" capability to your pipelines. Given an + * expression that evaluates to a vector and a target vector, this stage will identify and return + * the inputs whose vector expression is closest to the target vector, using the parameters + * specified in `options`. + * + *

Example: + * + *

{@code
+   * // Find books with similar "topicVectors" to the given targetVector
+   * firestore.pipeline().collection("books")
+   *     .findNearest(
+   *        field("topicVectors"),
+   *        targetVector,
+   *        FindNearest.DistanceMeasure.COSINE,
+   *        new FindNearestOptions()
+   *          .withLimit(10)
+   *          .withDistanceField("distance"));
+   * }
+ * + * @param property The expression that evaluates to a vector value using the stage inputs. + * @param vector The target vector to compare against. + * @param distanceMeasure The distance measure to use: cosine, euclidean, etc. + * @param options Configuration options for the nearest neighbor search, such as limit and output + * distance field name. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline findNearest( + Expression property, + double[] vector, + FindNearest.DistanceMeasure distanceMeasure, + FindNearestOptions options) { + // Implementation for findNearest (add the FindNearest stage if needed) + return append(new FindNearest(property, new VectorValue(vector), distanceMeasure, options)); + } + + /** + * Sorts the documents from previous stages based on one or more {@link Ordering} criteria. + * + *

This stage allows you to order the results of your pipeline. You can specify multiple {@link + * Ordering} instances to sort by multiple fields in ascending or descending order. If documents + * have the same value for a field used for sorting, the next specified ordering will be used. If + * all orderings result in equal comparison, the documents are considered equal and the order is + * unspecified. + * + *

Example: + * + *

{@code
+   * // Sort books by rating in descending order, and then by title in ascending order for books with the same rating
+   * firestore.pipeline().collection("books")
+   *     .sort(
+   *         Ordering.of("rating").descending(),
+   *         Ordering.of("title")  // Ascending order is the default
+   *     );
+   * }
+ * + * @param orders One or more {@link Ordering} instances specifying the sorting criteria. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline sort(Ordering... orders) { + return append(new Sort(ImmutableList.copyOf(orders))); + } + + /** + * Fully overwrites all fields in a document with those coming from a nested map. + * + *

This stage allows you to emit a map value as a document. Each key of the map becomes a field + * on the document that contains the corresponding value. + * + *

Example: + * + *

{@code
+   * // Input.
+   * // {
+   * //  "name": "John Doe Jr.",
+   * //  "parents": {
+   * //    "father": "John Doe Sr.",
+   * //    "mother": "Jane Doe"
+   * //   }
+   * // }
+   *
+   * // Emit parents as document.
+   * firestore.pipeline().collection("people").replaceWith("parents");
+   *
+   * // Output
+   * // {
+   * //  "father": "John Doe Sr.",
+   * //  "mother": "Jane Doe"
+   * // }
+   * }
+ * + * @param fieldName The name of the field containing the nested map. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline replaceWith(String fieldName) { + return replaceWith(field(fieldName)); + } + + /** + * Fully overwrites all fields in a document with those coming from a nested map. + * + *

This stage allows you to emit a map value as a document. Each key of the map becomes a field + * on the document that contains the corresponding value. + * + *

Example: + * + *

{@code
+   * // Input.
+   * // {
+   * //  "name": "John Doe Jr.",
+   * //  "parents": {
+   * //    "father": "John Doe Sr.",
+   * //    "mother": "Jane Doe"
+   * //  }
+   * // }
+   *
+   * // Emit parents as document.
+   * firestore.pipeline().collection("people").replaceWith(field("parents"));
+   *
+   * // Output
+   * // {
+   * //  "father": "John Doe Sr.",
+   * //  "mother": "Jane Doe"
+   * // }
+   * }
+ * + * @param expr The {@link Expression} field containing the nested map. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline replaceWith(Expression expr) { + return append(new ReplaceWith(expr)); + } + + /** + * Performs a pseudo-random sampling of the documents from the previous stage. + * + *

This stage will filter documents pseudo-randomly. The 'limit' parameter specifies the number + * of documents to emit from this stage, but if there are fewer documents from previous stage than + * the 'limit' parameter, then no filtering will occur and all documents will pass through. + * + *

Example: + * + *

{@code
+   * // Sample 10 books, if available.
+   * firestore.pipeline().collection("books")
+   *     .sample(10);
+   * }
+ * + * @param limit The number of documents to emit, if possible. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline sample(int limit) { + return sample(Sample.withDocLimit(limit)); + } + + /** + * Performs a pseudo-random sampling of the documents from the previous stage. + * + *

This stage will filter documents pseudo-randomly. The 'options' parameter specifies how + * sampling will be performed. See {@code SampleOptions} for more information. + * + *

Examples: + * + *

{@code
+   * // Sample 10 books, if available.
+   * firestore.pipeline().collection("books")
+   *     .sample(Sample.withDocLimit(10));
+   *
+   * // Sample 50% of books.
+   * firestore.pipeline().collection("books")
+   *     .sample(Sample.withPercentage(0.5));
+   * }
+ * + * @param sample The {@code Sample} specifies how sampling is performed. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline sample(Sample sample) { + return append(sample); + } + + /** + * Performs union of all documents from two pipelines, including duplicates. + * + *

This stage will pass through documents from previous stage, and also pass through documents + * from previous stage of the `other` {@code Pipeline} given in parameter. The order of documents + * emitted from this stage is undefined. + * + *

Example: + * + *

{@code
+   * // Emit documents from books collection and magazines collection.
+   * firestore.pipeline().collection("books")
+   *     .union(firestore.pipeline().collection("magazines"));
+   * }
+ * + * @param other The other {@code Pipeline} that is part of union. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline union(Pipeline other) { + return append(new Union(other)); + } + + /** + * Produces a document for each element in array found in previous stage document. + * + *

For each previous stage document, this stage will emit zero or more augmented documents. The + * input array found in the previous stage document field specified by the `fieldName` parameter, + * will for each input array element produce an augmented document. The input array element will + * augment the previous stage document by replacing the field specified by `fieldName` parameter + * with the element value. + * + *

In other words, the field containing the input array will be removed from the augmented + * document and replaced by the corresponding array element. + * + *

Example: + * + *

{@code
+   * // Input:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space", "adventure" ], ... }
+   *
+   * // Emit a book document for each tag of the book.
+   * firestore.pipeline().collection("books")
+   *     .unnest("tags", "tag");
+   *
+   * // Output:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "comedy", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "space", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tag": "adventure", ... }
+   * }
+ * + * @param fieldName The name of the field containing the array. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline unnest(String fieldName, String alias) { + // return unnest(field(fieldName)); + return append(new Unnest(field(fieldName), alias)); + } + + /** + * Produces a document for each element in array found in previous stage document. + * + *

For each previous stage document, this stage will emit zero or more augmented documents. The + * input array found in the previous stage document field specified by the `fieldName` parameter, + * will for each input array element produce an augmented document. The input array element will + * augment the previous stage document by replacing the field specified by `fieldName` parameter + * with the element value. + * + *

In other words, the field containing the input array will be removed from the augmented + * document and replaced by the corresponding array element. + * + *

Example: + * + *

{@code
+   * // Input:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space", "adventure" ], ... }
+   *
+   * // Emit a book document for each tag of the book.
+   * firestore.pipeline().collection("books")
+   *     .unnest("tags", "tag", new UnnestOptions().withIndexField("tagIndex"));
+   *
+   * // Output:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 0, "tag": "comedy", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 1, "tag": "space", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 2, "tag": "adventure", ... }
+   * }
+ * + * @param fieldName The name of the field containing the array. + * @param options The {@code UnnestOptions} options. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline unnest(String fieldName, String alias, UnnestOptions options) { + return append(new Unnest(field(fieldName), alias, options)); + } + + /** + * Produces a document for each element in array found in previous stage document. + * + *

For each previous stage document, this stage will emit zero or more augmented documents. The + * input array found in the previous stage document field specified by the `fieldName` parameter, + * will for each input array element produce an augmented document. The input array element will + * augment the previous stage document by replacing the field specified by `fieldName` parameter + * with the element value. + * + *

In other words, the field containing the input array will be removed from the augmented + * document and replaced by the corresponding array element. + * + *

Example: + * + *

{@code
+   * // Input:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space", "adventure" ], ... }
+   *
+   * // Emit a book document for each tag of the book.
+   * firestore.pipeline().collection("books")
+   *     .unnest(field("tags").as("tag"));
+   *
+   * // Output:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 0, "tag": "comedy", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 1, "tag": "space", ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 2, "tag": "adventure", ... }
+   * }
+ * + * @param expr The name of the expression containing the array. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline unnest(Selectable expr) { + return append(new Unnest(expr)); + } + + /** + * Produces a document for each element in array found in previous stage document. + * + *

For each previous stage document, this stage will emit zero or more augmented documents. The + * input array found in the specified by {@code Selectable} expression parameter, will for each + * input array element produce an augmented document. The input array element will augment the + * previous stage document by assigning the {@code Selectable} alias the element value. + * + *

Example: + * + *

{@code
+   * // Input:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tags": [ "comedy", "space",
+   * "adventure" ], ... }
+   *
+   * // Emit a book document for each tag of the book.
+   * firestore.pipeline().collection("books")
+   *     .unnest(field("tags").as("tag"), UnnestOptions.indexField("tagIndex"));
+   *
+   * // Output:
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 0, "tag": "comedy",
+   * "tags": [ "comedy", "space", "adventure" ], ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 1, "tag": "space", "tags":
+   * [ "comedy", "space", "adventure" ], ... }
+   * // { "title": "The Hitchhiker's Guide to the Galaxy", "tagIndex": 2, "tag": "adventure",
+   * "tags": [ "comedy", "space", "adventure" ], ... }
+   * }
+ * + * @param field The expression that evaluates to the input array. + * @param options The {@code UnnestOptions} options. + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline unnest(Selectable field, UnnestOptions options) { + return append(new Unnest(field, options)); + } + + /** + * Adds a generic stage to the pipeline. + * + *

This method provides a flexible way to extend the pipeline's functionality by adding custom + * stages. Each generic stage is defined by a unique `name` and a set of `params` that control its + * behavior. + * + *

Example (Assuming there is no "where" stage available in SDK): + * + *

{@code
+   * // Assume we don't have a built-in "where" stage
+   * Map whereParams = new HashMap<>();
+   * whereParams.put("condition", field("published").lt(1900));
+   *
+   * firestore.pipeline().collection("books")
+   *     .genericStage("where", Lists.newArrayList(field("published").lt(1900)), new RawOptions()) // Custom "where" stage
+   *     .select("title", "author");
+   * }
+ * + * @return A new {@code Pipeline} object with this stage appended to the stage list. + */ + @BetaApi + public Pipeline rawStage(RawStage stage) { + return append(stage); + } + + /** + * Executes this pipeline and returns a future to represent the asynchronous operation. + * + *

The returned {@link ApiFuture} can be used to track the progress of the pipeline execution + * and retrieve the results (or handle any errors) asynchronously. + * + *

The pipeline results are returned as a list of {@link PipelineResult} objects. Each {@link + * PipelineResult} typically represents a single key/value map that has passed through all the + * stages of the pipeline, however this might differ depends on the stages involved in the + * pipeline. For example: + * + *

    + *
  • If there are no stages or only transformation stages, each {@link PipelineResult} + * represents a single document. + *
  • If there is an aggregation, only a single {@link PipelineResult} is returned, + * representing the aggregated results over the entire dataset . + *
  • If there is an aggregation stage with grouping, each {@link PipelineResult} represents a + * distinct group and its associated aggregated values. + *
+ * + *

Example: + * + *

{@code
+   * ApiFuture futureResults = firestore.pipeline().collection("books")
+   *     .where(gt("rating", 4.5))
+   *     .select("title", "author", "rating")
+   *     .execute();
+   * }
+ * + * @return An {@link ApiFuture} representing the asynchronous pipeline execution. + */ + @BetaApi + public ApiFuture execute() { + return execute(new PipelineExecuteOptions(), null, null); + } + + @BetaApi + public ApiFuture execute(PipelineExecuteOptions options) { + return execute(options, null, null); + } + + MetricsContext createMetricsContext(String methodName) { + return rpcContext.getFirestore().getOptions().getMetricsUtil().createMetricsContext(methodName); + } + + /** + * Executes this pipeline, providing results to the given {@link ApiStreamObserver} as they become + * available. + * + *

This method allows you to process pipeline results in a streaming fashion, rather than + * waiting for the entire pipeline execution to complete. The provided {@link ApiStreamObserver} + * will receive: + * + *

    + *
  • **onNext(PipelineResult):** Called for each {@link PipelineResult} produced by the + * pipeline. Each {@link PipelineResult} typically represents a single key/value map that + * has passed through all the stages. However, the exact structure might differ based on the + * stages involved in the pipeline (as described in {@link #execute()}). + *
  • **onError(Throwable):** Called if an error occurs during pipeline execution. + *
  • **onCompleted():** Called when the pipeline has finished processing all documents. + *
+ * + *

Example: + * + *

{@code
+   * firestore.pipeline().collection("books")
+   *     .where(gt("rating", 4.5))
+   *     .select("title", "author", "rating")
+   *     .execute(new ApiStreamObserver() {
+   *         @Override
+   *         public void onNext(PipelineResult result) {
+   *             // Process each result as it arrives
+   *             System.out.println(result.getData());
+   *         }
+   *
+   *         @Override
+   *         public void onError(Throwable t) {
+   *             // Handle errors during execution
+   *             t.printStackTrace();
+   *         }
+   *
+   *         @Override
+   *         public void onCompleted() {
+   *             System.out.println("Pipeline execution completed.");
+   *         }
+   *     });
+   * }
+ * + * @param observer The {@link ApiStreamObserver} to receive pipeline results and events. + */ + @BetaApi + public void execute(ApiStreamObserver observer) { + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE_EXECUTE); + + executeInternal( + new PipelineExecuteOptions(), + null, + null, + new PipelineResultObserver() { + @Override + public void onNext(PipelineResult result) { + observer.onNext(result); + } + + @Override + public void onError(Throwable t) { + observer.onError(t); + } + + @Override + public void onCompleted() { + observer.onCompleted(); + } + }, + metricsContext); + } + + ApiFuture execute( + @Nonnull PipelineExecuteOptions options, + @Nullable final ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime) { + TraceUtil.Span span = + rpcContext + .getFirestore() + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_PIPELINE_EXECUTE); + + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE_EXECUTE); + + try (Scope ignored = span.makeCurrent()) { + SettableApiFuture futureResult = SettableApiFuture.create(); + + executeInternal( + options, + transactionId, + readTime, + new PipelineResultObserver() { + final List results = new ArrayList<>(); + + @Override + public void onCompleted() { + futureResult.set( + new Snapshot(Pipeline.this, results, getExecutionTime(), getExplainStats())); + } + + @Override + public void onNext(PipelineResult result) { + results.add(result); + } + + @Override + public void onError(Throwable t) { + futureResult.setException(t); + } + }, + metricsContext); + + span.endAtFuture(futureResult); + return futureResult; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + void executeInternal( + @Nonnull PipelineExecuteOptions options, + @Nullable final ByteString transactionId, + @Nullable com.google.protobuf.Timestamp readTime, + PipelineResultObserver observer, + MetricsContext metricsContext) { + ExecutePipelineRequest.Builder request = + ExecutePipelineRequest.newBuilder() + .setDatabase(rpcContext.getDatabaseName()) + .setStructuredPipeline( + StructuredPipeline.newBuilder() + .setPipeline(toProto()) + .putAllOptions(StageUtils.toMap(options)) + .build()); + + if (transactionId != null) { + request.setTransaction(transactionId); + } + + if (readTime != null) { + request.setReadTime(readTime); + } + + pipelineInternalStream( + request.build(), + new PipelineResultObserver() { + @Override + public void onCompleted() { + observer.setExplainStats(getExplainStats()); + observer.setExecutionTime(getExecutionTime()); + observer.onCompleted(); + } + + @Override + public void onNext(PipelineResult result) { + observer.onNext(result); + } + + @Override + public void onError(Throwable t) { + observer.onError(t); + } + }, + metricsContext); + } + + @InternalApi + private com.google.firestore.v1.Pipeline toProto() { + return com.google.firestore.v1.Pipeline.newBuilder() + .addAllStages(stages.transform(StageUtils::toStageProto)) + .build(); + } + + @InternalApi + public com.google.firestore.v1.Value toProtoValue() { + return Value.newBuilder().setPipelineValue(toProto()).build(); + } + + private void pipelineInternalStream( + ExecutePipelineRequest request, + PipelineResultObserver resultObserver, + MetricsContext metricsContext) { + TraceUtil traceUtil = rpcContext.getFirestore().getOptions().getTraceUtil(); + + // To reduce the size of traces, we only register one event for every 100 responses + // that we receive from the server. + final int NUM_RESPONSES_PER_TRACE_EVENT = 100; + + TraceUtil.Span currentSpan = traceUtil.currentSpan(); + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE, + new ImmutableMap.Builder() + .put(ATTRIBUTE_KEY_IS_TRANSACTIONAL, request.hasTransaction()) + .build()); + + ResponseObserver observer = + new ResponseObserver() { + Timestamp executionTime = null; + boolean firstResponse = false; + int numDocuments = 0; + boolean hasCompleted = false; + + @Override + public void onStart(StreamController controller) { + // No action needed in onStart + } + + @Override + public void onResponse(ExecutePipelineResponse response) { + if (!firstResponse) { + firstResponse = true; + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE + ": First Response"); + metricsContext.recordLatency(MetricType.FIRST_RESPONSE_LATENCY); + } + + if (response.hasExplainStats()) { + resultObserver.setExplainStats( + new ExplainStats(response.getExplainStats().getData())); + } + + if (response.hasExecutionTime()) { + executionTime = Timestamp.fromProto(response.getExecutionTime()); + } + + if (response.getResultsCount() > 0) { + numDocuments += response.getResultsCount(); + if (numDocuments % NUM_RESPONSES_PER_TRACE_EVENT == 0) { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE + + ": Received " + + numDocuments + + " results"); + } + + for (Document doc : response.getResultsList()) { + resultObserver.onNext(PipelineResult.fromDocument(rpcContext, executionTime, doc)); + } + } + } + + @Override + public void onError(Throwable throwable) { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE + ": Error", + ImmutableMap.of("error.message", throwable.toString())); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, throwable); + resultObserver.onError(throwable); + } + + @Override + public void onComplete() { + if (hasCompleted) { + return; + } + hasCompleted = true; + + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_EXECUTE_PIPELINE + ": Completed", + ImmutableMap.of(ATTRIBUTE_KEY_DOC_COUNT, numDocuments)); + resultObserver.onCompleted(executionTime); + } + }; + + logger.log(Level.FINEST, "Sending pipeline request: " + request.getStructuredPipeline()); + + rpcContext.streamRequest(request, observer, rpcContext.getClient().executePipelineCallable()); + } + + private interface ResultObserver extends ApiStreamObserver { + void onCompleted(Timestamp executionTime); + + void setExplainStats(ExplainStats explainStats); + + void setExecutionTime(Timestamp executionTime); + } + + @InternalExtensionOnly + abstract static class PipelineResultObserver implements ResultObserver { + private Timestamp executionTime; + private ExplainStats explainStats; + + @Override + public void onCompleted(Timestamp executionTime) { + this.executionTime = executionTime; + this.onCompleted(); + } + + public Timestamp getExecutionTime() { + return executionTime; + } + + public ExplainStats getExplainStats() { + return explainStats; + } + + @Override + public void setExplainStats(ExplainStats explainStats) { + this.explainStats = explainStats; + } + + @Override + public void setExecutionTime(Timestamp executionTime) { + this.executionTime = executionTime; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.java new file mode 100644 index 000000000000..b459e5a8a0b3 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineResult.java @@ -0,0 +1,456 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A PipelineResult contains data read from a Firestore Pipeline. The data can be extracted with the + * {@link #getData()} or {@link #get(String)} methods. + * + *

If the PipelineResult represents a non-document result, getReference() will return a null + * value. + * + *

Subclassing Note: Firestore classes are not meant to be subclassed except for use in + * test mocks. Subclassing is not supported in production code and new SDK releases may break code + * that does so. + */ +@InternalExtensionOnly +@BetaApi +public final class PipelineResult { + + private final FirestoreRpcContext rpcContext; + @Nullable private final DocumentReference docRef; + @Nullable private final Map fields; + @Nonnull private final Timestamp executionTime; + @Nullable private final Timestamp updateTime; + @Nullable private final Timestamp createTime; + + PipelineResult( + FirestoreRpcContext rpcContext, + @Nullable DocumentReference docRef, + @Nullable Map fields, + @Nonnull Timestamp executionTime, + @Nullable Timestamp updateTime, + @Nullable Timestamp createTime) { // Elevated access level for mocking. + this.rpcContext = rpcContext; + this.docRef = docRef; + this.fields = fields; + this.executionTime = executionTime; + if (updateTime != null && updateTime.equals(Timestamp.ofTimeMicroseconds(0))) { + updateTime = null; + } + this.updateTime = updateTime; + + if (createTime != null && createTime.equals(Timestamp.ofTimeMicroseconds(0))) { + createTime = null; + } + this.createTime = createTime; + } + + /** + * Returns the ID of the document represented by this result. Returns null if this result is not + * corresponding to a Firestore document. + */ + @Nullable + @BetaApi + public String getId() { + return docRef.getId(); + } + + static PipelineResult fromDocument( + FirestoreRpcContext rpcContext, Timestamp executionTime, Document document) { + return new PipelineResult( + rpcContext, + document.getName().isEmpty() + ? null + : new DocumentReference(rpcContext, ResourcePath.create(document.getName())), + document.getFieldsMap(), + executionTime, + Timestamp.fromProto(document.getUpdateTime()), + Timestamp.fromProto(document.getCreateTime())); + } + + /** Returns the time at which the pipeline producing this result is executed. */ + @Nullable + @BetaApi + public Timestamp getExecutionTime() { + return executionTime; + } + + /** + * Returns the time at which this document was last updated. Returns null if this result is not + * corresponding to a Firestore document. + */ + @Nullable + @BetaApi + public Timestamp getUpdateTime() { + return updateTime; + } + + /** + * Returns the time at which this document was created. Returns null if this result is not + * corresponding to a Firestore document. + */ + @Nullable + @BetaApi + public Timestamp getCreateTime() { + return createTime; + } + + /** + * Returns whether or not the field exists in the document. Returns false if the document does not + * exist. + * + * @return whether the document existed in this snapshot. + */ + @BetaApi + public boolean exists() { + return fields != null; + } + + /** + * Returns the fields of the result as a Map or null if the result doesn't exist. Field values + * will be converted to their native Java representation. + * + * @return The fields of the document as a Map or null if the result doesn't exist. + */ + @Nonnull + @BetaApi + public Map getData() { + if (fields == null) { + return null; + } + + Map decodedFields = new HashMap<>(); + for (Map.Entry entry : fields.entrySet()) { + Object decodedValue = UserDataConverter.decodeValue(rpcContext, entry.getValue()); + decodedFields.put(entry.getKey(), decodedValue); + } + return decodedFields; + } + + /** + * Returns the contents of the document converted to a POJO or null if the result doesn't exist. + * + * @param valueType The Java class to create + * @return The contents of the document in an object of type T or null if the result doesn't + * exist. + */ + @Nullable + @BetaApi + T toObject(@Nonnull Class valueType) { + Map data = getData(); + return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef); + } + + /** + * Returns whether or not the field exists in the document. Returns false if the result does not + * exist. + * + * @param field the path to the field. + * @return true iff the field exists. + */ + @BetaApi + public boolean contains(@Nonnull String field) { + return contains(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Returns whether or not the field exists in the document. Returns false if the result does not + * exist. + * + * @param fieldPath the path to the field. + * @return true iff the field exists. + */ + @BetaApi + public boolean contains(@Nonnull FieldPath fieldPath) { + return this.extractField(fieldPath) != null; + } + + /** + * Returns the value at the field or null if the field doesn't exist. + * + * @param field The path to the field. + * @return The value at the given field or null. + */ + @Nullable + @BetaApi + public Object get(@Nonnull String field) { + return get(FieldPath.fromDotSeparatedString(field)); + } + + /** + * Returns the value at the field, converted to a POJO, or null if the field or result doesn't + * exist. + * + * @param field The path to the field + * @param valueType The Java class to convert the field value to. + * @return The value at the given field or null. + */ + @Nullable + @BetaApi + public T get(@Nonnull String field, @Nonnull Class valueType) { + return get(FieldPath.fromDotSeparatedString(field), valueType); + } + + /** + * Returns the value at the field or null if the field doesn't exist. + * + * @param fieldPath The path to the field. + * @return The value at the given field or null. + */ + @Nullable + @BetaApi + public Object get(@Nonnull FieldPath fieldPath) { + Value value = extractField(fieldPath); + + if (value == null) { + return null; + } + + return UserDataConverter.decodeValue(rpcContext, value); + } + + /** + * Returns the value at the field, converted to a POJO, or null if the field or result doesn't + * exist. + * + * @param fieldPath The path to the field + * @param valueType The Java class to convert the field value to. + * @return The value at the given field or null. + */ + @Nullable + @BetaApi + public T get(@Nonnull FieldPath fieldPath, Class valueType) { + Object data = get(fieldPath); + return data == null ? null : CustomClassMapper.convertToCustomClass(data, valueType, docRef); + } + + /** Returns the Value Proto at 'fieldPath'. Returns null if the field was not found. */ + @Nullable + Value extractField(@Nonnull FieldPath fieldPath) { + Value value = null; + + if (fields != null) { + Iterator components = fieldPath.getSegments().iterator(); + value = fields.get(components.next()); + + while (value != null && components.hasNext()) { + if (value.getValueTypeCase() != Value.ValueTypeCase.MAP_VALUE) { + return null; + } + value = value.getMapValue().getFieldsOrDefault(components.next(), null); + } + } + + return value; + } + + /** + * Returns the value of the field as a boolean. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Boolean. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Boolean getBoolean(@Nonnull String field) { + return (Boolean) get(field); + } + + /** + * Returns the value of the field as a double. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Number. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Double getDouble(@Nonnull String field) { + Number number = (Number) get(field); + return number == null ? null : number.doubleValue(); + } + + /** + * Returns the value of the field as a String. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a String. + * @return The value of the field. + */ + @Nullable + @BetaApi + public String getString(@Nonnull String field) { + return (String) get(field); + } + + /** + * Returns the value of the field as a long. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Number. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Long getLong(@Nonnull String field) { + Number number = (Number) get(field); + return number == null ? null : number.longValue(); + } + + /** + * Returns the value of the field as a Date. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Date. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Date getDate(@Nonnull String field) { + Timestamp timestamp = getTimestamp(field); + return timestamp == null ? null : timestamp.toDate(); + } + + /** + * Returns the value of the field as a {@link Timestamp}. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Date. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Timestamp getTimestamp(@Nonnull String field) { + return (Timestamp) get(field); + } + + /** + * Returns the value of the field as a Blob. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a Blob. + * @return The value of the field. + */ + @Nullable + @BetaApi + public Blob getBlob(@Nonnull String field) { + return (Blob) get(field); + } + + /** + * Returns the value of the field as a GeoPoint. + * + * @param field The path to the field. + * @throws RuntimeException if the value is not a GeoPoint. + * @return The value of the field. + */ + @Nullable + @BetaApi + public GeoPoint getGeoPoint(@Nonnull String field) { + return (GeoPoint) get(field); + } + + /** + * Gets the reference to the document. + * + * @return The reference to the document. + */ + @BetaApi + public DocumentReference getReference() { + return docRef; + } + + /** Checks whether this DocumentSnapshot contains any fields. */ + boolean isEmpty() { + return fields == null || fields.isEmpty(); + } + + Map getProtoFields() { + return fields; + } + + Write.Builder toPb() { + Preconditions.checkState(exists(), "Can't call toDocument() on a document that doesn't exist"); + Write.Builder write = Write.newBuilder(); + Document.Builder document = write.getUpdateBuilder(); + document.setName(docRef.getName()); + document.putAllFields(fields); + return write; + } + + Document.Builder toDocumentPb() { + Preconditions.checkState(exists(), "Can't call toDocument() on a document that doesn't exist"); + Document.Builder document = Document.newBuilder(); + return document + .setName(docRef.getName()) + .putAllFields(fields) + .setCreateTime(createTime.toProto()) + .setUpdateTime(updateTime.toProto()); + } + + /** + * Returns true if the document's data and path in this DocumentSnapshot equals the provided + * snapshot. + * + * @param obj The object to compare against. + * @return Whether this DocumentSnapshot is equal to the provided object. + */ + @Override + @BetaApi + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof PipelineResult)) { + return false; + } + PipelineResult that = (PipelineResult) obj; + return Objects.equals(rpcContext, that.rpcContext) + && Objects.equals(docRef, that.docRef) + && Objects.equals(fields, that.fields); + } + + @Override + public int hashCode() { + return Objects.hash(rpcContext, docRef, fields); + } + + @Override + public String toString() { + return String.format( + "%s{doc=%s, fields=%s, executionTime=%s, updateTime=%s, createTime=%s}", + getClass().getSimpleName(), docRef, fields, executionTime, updateTime, createTime); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineSource.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineSource.java new file mode 100644 index 000000000000..207ddd7f808b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineSource.java @@ -0,0 +1,185 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.stages.Collection; +import com.google.cloud.firestore.pipeline.stages.CollectionGroup; +import com.google.cloud.firestore.pipeline.stages.CollectionGroupOptions; +import com.google.cloud.firestore.pipeline.stages.CollectionOptions; +import com.google.cloud.firestore.pipeline.stages.Database; +import com.google.cloud.firestore.pipeline.stages.Documents; +import com.google.common.base.Preconditions; +import java.util.Arrays; +import javax.annotation.Nonnull; + +/** + * A factory for creating {@link Pipeline} instances, which provide a framework for building data + * transformation and query pipelines for Firestore. + * + *

Start by calling {@link Firestore#pipeline()} to obtain an instance of {@code PipelineSource}. + * From there, you can use the provided methods (like {@link #collection(String)}) to specify the + * data source for your pipeline. + * + *

This class is typically used to start building Firestore pipelines. It allows you to define + * the initial data source for a pipeline. + * + *

Example Usage: + * + *

{@code
+ * firestore.pipeline() // Get a PipelineSource instance
+ *   .collection("users") // Create a pipeline that operates on a collection
+ *   .select("name"); // Add stages to the pipeline
+ * }
+ */ +@BetaApi +public final class PipelineSource { + private final FirestoreRpcContext rpcContext; + + @InternalApi + PipelineSource(FirestoreRpcContext rpcContext) { + this.rpcContext = rpcContext; + } + + /** + * Creates a new {@link Pipeline} that operates on the specified Firestore collection. + * + * @param path The path to the Firestore collection (e.g., "users"). + * @return A new {@code Pipeline} instance targeting the specified collection. + */ + @Nonnull + @BetaApi + public Pipeline collection(@Nonnull String path) { + return collection(path, new CollectionOptions()); + } + + @Nonnull + @BetaApi + public Pipeline collection(@Nonnull String path, CollectionOptions options) { + return new Pipeline(this.rpcContext, new Collection(path, options)); + } + + @Nonnull + @BetaApi + public Pipeline collection(@Nonnull CollectionReference ref) { + if (!this.rpcContext.getFirestore().equals(ref.getFirestore())) { + throw new IllegalArgumentException( + "Invalid CollectionReference. The Firestore instance of the CollectionReference must" + + " match the Firestore instance of the PipelineSource."); + } + + return collection(ref.getPath(), new CollectionOptions()); + } + + /** + * Creates a new {@link Pipeline} that operates on all documents in a collection group. + * + *

A collection group consists of all collections with the same ID. For example, if you have + * collections named "users" under different documents, you can query them together using a + * collection group query. + * + * @param collectionId The ID of the collection group. + * @return A new {@code Pipeline} instance targeting the specified collection group. + */ + @Nonnull + @BetaApi + public Pipeline collectionGroup(@Nonnull String collectionId) { + return collectionGroup(collectionId, new CollectionGroupOptions()); + } + + @Nonnull + @BetaApi + public Pipeline collectionGroup(@Nonnull String collectionId, CollectionGroupOptions options) { + Preconditions.checkArgument( + !collectionId.contains("/"), + "Invalid collectionId '%s'. Collection IDs must not contain '/'.", + collectionId); + return new Pipeline(this.rpcContext, new CollectionGroup(collectionId, options)); + } + + /** + * Creates a new {@link Pipeline} that operates on all documents in the Firestore database. + * + *

Use this method with caution as it can lead to very large result sets. It is usually only + * useful at development stage. + * + * @return A new {@code Pipeline} instance targeting all documents in the database. + */ + @Nonnull + @BetaApi + public Pipeline database() { + return new Pipeline(this.rpcContext, new Database()); + } + + /** + * Creates a new {@link Pipeline} that operates on a specific set of Firestore documents. + * + * @param docs The {@link DocumentReference} instances representing the documents to include in + * the pipeline. + * @return A new {@code Pipeline} instance targeting the specified documents. + */ + @Nonnull + @BetaApi + public Pipeline documents(DocumentReference... docs) { + return new Pipeline(this.rpcContext, Documents.of(docs)); + } + + /** + * Creates a new {@link Pipeline} that operates on a specific set of Firestore documents. + * + * @param docs The {@link DocumentReference} instances representing the documents to include in + * the pipeline. + * @return A new {@code Pipeline} instance targeting the specified documents. + */ + @Nonnull + @BetaApi + public Pipeline documents(String... docs) { + return new Pipeline( + this.rpcContext, + Documents.of( + Arrays.stream(docs) + .map(d -> this.rpcContext.getFirestore().document(d)) + .toArray(DocumentReference[]::new))); + } + + /** + * Creates a new {@link Pipeline} from the given {@link Query}. Under the hood, this will + * translate the query semantics (order by document ID, etc.) to an equivalent pipeline. + * + * @param query The {@link Query} to translate into the resulting pipeline. + * @return A new {@code Pipeline} that is equivalent to the given query. + */ + @Nonnull + @BetaApi + public Pipeline createFrom(Query query) { + return query.pipeline(); + } + + /** + * Creates a new {@link Pipeline} from the given {@link AggregateQuery}. Under the hood, this will + * translate the query semantics (order by document ID, etc.) to an equivalent pipeline. + * + * @param query The {@link AggregateQuery} to translate into the resulting pipeline. + * @return A new {@code Pipeline} that is equivalent to the given query. + */ + @Nonnull + @BetaApi + public Pipeline createFrom(AggregateQuery query) { + return query.pipeline(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.java new file mode 100644 index 000000000000..b04f368a64e9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PipelineUtils.java @@ -0,0 +1,233 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.countAll; +import static com.google.cloud.firestore.pipeline.expressions.Expression.and; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayContainsAny; +import static com.google.cloud.firestore.pipeline.expressions.Expression.field; +import static com.google.cloud.firestore.pipeline.expressions.Expression.not; +import static com.google.cloud.firestore.pipeline.expressions.Expression.nullValue; +import static com.google.cloud.firestore.pipeline.expressions.Expression.or; +import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.aggregateFunctionToValue; +import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.exprToValue; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.Query.ComparisonFilterInternal; +import com.google.cloud.firestore.Query.CompositeFilterInternal; +import com.google.cloud.firestore.Query.FilterInternal; +import com.google.cloud.firestore.Query.UnaryFilterInternal; +import com.google.cloud.firestore.pipeline.expressions.AggregateFunction; +import com.google.cloud.firestore.pipeline.expressions.AliasedAggregate; +import com.google.cloud.firestore.pipeline.expressions.AliasedExpression; +import com.google.cloud.firestore.pipeline.expressions.BooleanExpression; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.expressions.Selectable; +import com.google.common.collect.Lists; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +@InternalApi +public class PipelineUtils { + @InternalApi + public static Value encodeValue(Object value) { + return UserDataConverter.encodeValue(FieldPath.empty(), value, UserDataConverter.ARGUMENT); + } + + @InternalApi + public static Value encodeValue(Expression value) { + return exprToValue(value); + } + + @InternalApi + public static Value encodeValue(AggregateFunction value) { + return aggregateFunctionToValue(value); + } + + @InternalApi + public static Value encodeValue(String value) { + return Value.newBuilder().setStringValue(value).build(); + } + + @InternalApi + public static Value encodeValue(boolean value) { + return Value.newBuilder().setBooleanValue(value).build(); + } + + @InternalApi + public static Value encodeValue(long value) { + return Value.newBuilder().setIntegerValue(value).build(); + } + + @InternalApi + public static Value encodeValue(double value) { + return Value.newBuilder().setDoubleValue(value).build(); + } + + @InternalApi + public static Value encodeValue(Map options) { + return Value.newBuilder() + .setMapValue(MapValue.newBuilder().putAllFields(options).build()) + .build(); + } + + @InternalApi + static BooleanExpression toPipelineBooleanExpr(FilterInternal f) { + if (f instanceof ComparisonFilterInternal) { + ComparisonFilterInternal comparisonFilter = (ComparisonFilterInternal) f; + Field field = Field.ofServerPath(comparisonFilter.fieldReference.getFieldPath()); + Value value = comparisonFilter.value; + switch (comparisonFilter.operator) { + case LESS_THAN: + return and(field.exists(), field.lessThan(value)); + case LESS_THAN_OR_EQUAL: + return and(field.exists(), field.lessThanOrEqual(value)); + case GREATER_THAN: + return and(field.exists(), field.greaterThan(value)); + case GREATER_THAN_OR_EQUAL: + return and(field.exists(), field.greaterThanOrEqual(value)); + case EQUAL: + return and(field.exists(), field.equal(value)); + case NOT_EQUAL: + return field.notEqual(value); + case ARRAY_CONTAINS: + return and(field.exists(), field.arrayContains(value)); + case IN: + List valuesList = value.getArrayValue().getValuesList(); + return and(field.exists(), Expression.equalAny(field, Lists.newArrayList(valuesList))); + case ARRAY_CONTAINS_ANY: + List valuesListAny = value.getArrayValue().getValuesList(); + return and(field.exists(), arrayContainsAny(field, Lists.newArrayList(valuesListAny))); + case NOT_IN: + List notInValues = value.getArrayValue().getValuesList(); + return not(Expression.equalAny(field, Lists.newArrayList(notInValues))); + default: + // Handle OPERATOR_UNSPECIFIED and UNRECOGNIZED cases as needed + throw new IllegalArgumentException("Unsupported operator: " + comparisonFilter.operator); + } + } else if (f instanceof CompositeFilterInternal) { + CompositeFilterInternal compositeFilter = (CompositeFilterInternal) f; + switch (compositeFilter.getOperator()) { + case AND: + List conditions = + compositeFilter.getFilters().stream() + .map(PipelineUtils::toPipelineBooleanExpr) + .collect(Collectors.toList()); + return and( + conditions.get(0), + conditions.subList(1, conditions.size()).toArray(new BooleanExpression[0])); + case OR: + List orConditions = + compositeFilter.getFilters().stream() + .map(PipelineUtils::toPipelineBooleanExpr) + .collect(Collectors.toList()); + return or( + orConditions.get(0), + orConditions.subList(1, orConditions.size()).toArray(new BooleanExpression[0])); + default: + // Handle OPERATOR_UNSPECIFIED and UNRECOGNIZED cases as needed + throw new IllegalArgumentException( + "Unsupported operator: " + compositeFilter.getOperator()); + } + } else if (f instanceof UnaryFilterInternal) { + UnaryFilterInternal unaryFilter = (UnaryFilterInternal) f; + Field field = Field.ofServerPath(unaryFilter.fieldReference.getFieldPath()); + switch (unaryFilter.getOperator()) { + case IS_NAN: + return and(field.exists(), field.equal(Double.NaN)); + case IS_NULL: + return and(field.exists(), field.equal(nullValue())); + case IS_NOT_NAN: + return and(field.exists(), field.notEqual(Double.NaN)); + case IS_NOT_NULL: + return and(field.exists(), field.notEqual(nullValue())); + default: + // Handle OPERATOR_UNSPECIFIED and UNRECOGNIZED cases as needed + throw new IllegalArgumentException("Unsupported operator: " + unaryFilter.getOperator()); + } + } else { + // Handle other FilterInternal types as needed + throw new IllegalArgumentException("Unsupported filter type: " + f.getClass().getName()); + } + } + + @InternalApi + static AliasedAggregate toPipelineAggregatorTarget(AggregateField f) { + String operator = f.getOperator(); + String fieldPath = f.getFieldPath(); + + switch (operator) { + case "sum": + return Field.ofServerPath(fieldPath).sum().as(f.getAlias()); + + case "count": + return countAll().as(f.getAlias()); + case "average": + return Field.ofServerPath(fieldPath).average().as(f.getAlias()); + default: + // Handle the 'else' case appropriately in your Java code + throw new IllegalArgumentException("Unsupported operator: " + operator); + } + } + + @InternalApi + static BooleanExpression toPipelineExistsExpr(AggregateField f) { + String fieldPath = f.getFieldPath(); + + if (fieldPath.isEmpty()) { + return null; + } + return Field.ofServerPath(fieldPath).exists(); + } + + @InternalApi + public static Map selectablesToMap(Selectable... selectables) { + Map projMap = new HashMap<>(); + for (Selectable proj : selectables) { + if (proj instanceof Field) { + Field fieldProj = (Field) proj; + if (projMap.containsKey(fieldProj.getPath().getEncodedPath())) { + throw new IllegalArgumentException( + "Duplicate alias or field name: " + fieldProj.getPath().getEncodedPath()); + } + projMap.put(fieldProj.getPath().getEncodedPath(), fieldProj); + } else if (proj instanceof AliasedExpression) { + AliasedExpression aliasedExpr = (AliasedExpression) proj; + if (projMap.containsKey(aliasedExpr.getAlias())) { + throw new IllegalArgumentException( + "Duplicate alias or field name: " + aliasedExpr.getAlias()); + } + projMap.put(aliasedExpr.getAlias(), aliasedExpr.getExpr()); + } + } + return projMap; + } + + @InternalApi + public static Map fieldNamesToMap(String... fields) { + Map projMap = new HashMap<>(); + for (String field : fields) { + projMap.put(field, field(field)); + } + return projMap; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PlanSummary.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PlanSummary.java new file mode 100644 index 000000000000..b55ff7f38e36 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/PlanSummary.java @@ -0,0 +1,38 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore; + +import com.google.common.collect.Lists; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; + +/** A Plan contains information about the planning stage of a query. */ +public final class PlanSummary { + private final @Nonnull List> indexesUsed; + + PlanSummary(com.google.firestore.v1.PlanSummary proto) { + indexesUsed = Lists.transform(proto.getIndexesUsedList(), UserDataConverter::decodeStruct); + } + + /* + * Returns the indexes used to serve the query. + */ + @Nonnull + public List> getIndexesUsed() { + return this.indexesUsed; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Precondition.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Precondition.java new file mode 100644 index 000000000000..fb8be8778c8e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Precondition.java @@ -0,0 +1,106 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** Preconditions that can be used to restrict update() calls. */ +public final class Precondition { + + /** An empty Precondition that adds no enforcements */ + public static final Precondition NONE = new Precondition(null, null); + + private final Boolean exists; + private final Timestamp updateTime; + + private Precondition(Boolean exists, Timestamp updateTime) { + this.exists = exists; + this.updateTime = updateTime; + } + + /** + * Creates a Precondition that enforces that a document exists. + * + * @param exists Whether the document should exist. + * @return A new Precondition + */ + // TODO: Make public once backend supports verify. + @Nonnull + static Precondition exists(Boolean exists) { + return new Precondition(exists, null); + } + + /** + * Creates a Precondition that enforces that the existing document was written at the specified + * time. + * + * @param updateTime The write time to enforce on the existing document. + * @return A new Precondition + */ + @Nonnull + public static Precondition updatedAt(Timestamp updateTime) { + return new Precondition(null, updateTime); + } + + boolean isEmpty() { + return exists == null && updateTime == null; + } + + Boolean getExists() { + return exists; + } + + com.google.firestore.v1.Precondition toPb() { + com.google.firestore.v1.Precondition.Builder precondition = + com.google.firestore.v1.Precondition.newBuilder(); + + if (exists != null) { + precondition.setExists(exists); + } + + if (updateTime != null) { + precondition.setUpdateTime(updateTime.toProto()); + } + + return precondition.build(); + } + + /** + * Returns true if this Precondition is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this Precondition is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + Precondition that = (Precondition) obj; + return Objects.equals(exists, that.exists) && Objects.equals(updateTime, that.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(exists, updateTime); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java new file mode 100644 index 000000000000..b266e3b6cba9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -0,0 +1,2211 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.PipelineUtils.toPipelineBooleanExpr; +import static com.google.cloud.firestore.pipeline.expressions.Expression.and; +import static com.google.cloud.firestore.pipeline.expressions.Expression.or; +import static com.google.cloud.firestore.telemetry.TraceUtil.*; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.EQUAL; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.GREATER_THAN; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.IN; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.LESS_THAN; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.NOT_EQUAL; +import static com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.NOT_IN; + +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalExtensionOnly; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.auto.value.AutoValue; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Query.QueryOptions.Builder; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.pipeline.expressions.BooleanExpression; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.expressions.Ordering; +import com.google.cloud.firestore.pipeline.expressions.Selectable; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.firestore.bundle.BundledQuery; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.StructuredQuery.CollectionSelector; +import com.google.firestore.v1.StructuredQuery.CompositeFilter; +import com.google.firestore.v1.StructuredQuery.FieldFilter.Operator; +import com.google.firestore.v1.StructuredQuery.FieldReference; +import com.google.firestore.v1.StructuredQuery.Filter; +import com.google.firestore.v1.StructuredQuery.Order; +import com.google.firestore.v1.StructuredQuery.UnaryFilter; +import com.google.firestore.v1.Value; +import com.google.protobuf.ByteString; +import com.google.protobuf.Int32Value; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.concurrent.Executor; +import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A Query which you can read or listen to. You can also construct refined Query objects by adding + * filters and ordering. + */ +@InternalExtensionOnly +public class Query extends StreamableQuery { + + static final Comparator DOCUMENT_ID_COMPARATOR = + QueryDocumentSnapshot::compareDocumentId; + private static final Logger LOGGER = Logger.getLogger(Query.class.getName()); + + /** The direction of a sort. */ + public enum Direction { + ASCENDING(StructuredQuery.Direction.ASCENDING, DOCUMENT_ID_COMPARATOR), + DESCENDING(StructuredQuery.Direction.DESCENDING, DOCUMENT_ID_COMPARATOR.reversed()); + + private final StructuredQuery.Direction direction; + private final Comparator documentIdComparator; + + Direction( + StructuredQuery.Direction direction, + Comparator documentIdComparator) { + this.direction = direction; + this.documentIdComparator = documentIdComparator; + } + + StructuredQuery.Direction getDirection() { + return direction; + } + } + + abstract static class FilterInternal { + /** Returns a list of all field filters that are contained within this filter */ + abstract List getFlattenedFilters(); + + /** Returns a list of all filters that are contained within this filter */ + abstract List getFilters(); + + /** Returns the field of the first filter that's an inequality, or null if none. */ + @Nullable + abstract FieldReference getFirstInequalityField(); + + /** Returns the proto representation of this filter */ + abstract Filter toProto(); + + static FilterInternal fromProto(StructuredQuery.Filter filter) { + if (filter.hasUnaryFilter()) { + return new UnaryFilterInternal( + filter.getUnaryFilter().getField(), filter.getUnaryFilter().getOp()); + } + + if (filter.hasFieldFilter()) { + return new ComparisonFilterInternal( + filter.getFieldFilter().getField(), + filter.getFieldFilter().getOp(), + filter.getFieldFilter().getValue()); + } + + // `filter` must be a composite filter. + Preconditions.checkArgument(filter.hasCompositeFilter(), "Unknown filter type."); + CompositeFilter compositeFilter = filter.getCompositeFilter(); + // A composite filter with only 1 sub-filter should be reduced to its sub-filter. + if (compositeFilter.getFiltersCount() == 1) { + return FilterInternal.fromProto(compositeFilter.getFiltersList().get(0)); + } + List filters = new ArrayList<>(); + for (StructuredQuery.Filter subfilter : compositeFilter.getFiltersList()) { + filters.add(FilterInternal.fromProto(subfilter)); + } + return new CompositeFilterInternal(filters, compositeFilter.getOp()); + } + } + + static class CompositeFilterInternal extends FilterInternal { + private final List filters; + private final StructuredQuery.CompositeFilter.Operator operator; + + // Memoized list of all field filters that can be found by traversing the tree of filters + // contained in this composite filter. + private List memoizedFlattenedFilters; + + public CompositeFilterInternal( + List filters, StructuredQuery.CompositeFilter.Operator operator) { + this.filters = filters; + this.operator = operator; + } + + @Override + public List getFilters() { + return filters; + } + + @Nonnull + CompositeFilter.Operator getOperator() { + return this.operator; + } + + @Nullable + @Override + public FieldReference getFirstInequalityField() { + for (FieldFilterInternal fieldFilter : getFlattenedFilters()) { + if (fieldFilter.isInequalityFilter()) { + return fieldFilter.fieldReference; + } + } + return null; + } + + public boolean isConjunction() { + return operator == CompositeFilter.Operator.AND; + } + + @Override + public List getFlattenedFilters() { + if (memoizedFlattenedFilters != null) { + return memoizedFlattenedFilters; + } + memoizedFlattenedFilters = new ArrayList<>(); + for (FilterInternal subfilter : filters) { + memoizedFlattenedFilters.addAll(subfilter.getFlattenedFilters()); + } + return memoizedFlattenedFilters; + } + + @Override + Filter toProto() { + // A composite filter that contains one sub-filter is equivalent to the sub-filter. + if (filters.size() == 1) { + return filters.get(0).toProto(); + } + + Filter.Builder protoFilter = Filter.newBuilder(); + StructuredQuery.CompositeFilter.Builder compositeFilter = + StructuredQuery.CompositeFilter.newBuilder(); + compositeFilter.setOp(operator); + for (FilterInternal filter : filters) { + compositeFilter.addFilters(filter.toProto()); + } + protoFilter.setCompositeFilter(compositeFilter.build()); + return protoFilter.build(); + } + } + + abstract static class FieldFilterInternal extends FilterInternal { + protected final FieldReference fieldReference; + + FieldFilterInternal(FieldReference fieldReference) { + this.fieldReference = fieldReference; + } + + abstract boolean isInequalityFilter(); + + public List getFilters() { + return Collections.singletonList(this); + } + + @Override + public List getFlattenedFilters() { + return Collections.singletonList(this); + } + } + + static class UnaryFilterInternal extends FieldFilterInternal { + + private final StructuredQuery.UnaryFilter.Operator operator; + + UnaryFilterInternal( + FieldReference fieldReference, StructuredQuery.UnaryFilter.Operator operator) { + super(fieldReference); + this.operator = operator; + } + + @Override + boolean isInequalityFilter() { + return false; + } + + @Nullable + @Override + public FieldReference getFirstInequalityField() { + return null; + } + + Filter toProto() { + Filter.Builder result = Filter.newBuilder(); + result.getUnaryFilterBuilder().setField(fieldReference).setOp(operator); + return result.build(); + } + + @Nonnull + UnaryFilter.Operator getOperator() { + return this.operator; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof UnaryFilterInternal)) { + return false; + } + UnaryFilterInternal other = (UnaryFilterInternal) o; + return Objects.equals(fieldReference, other.fieldReference) + && Objects.equals(operator, other.operator); + } + } + + static class ComparisonFilterInternal extends FieldFilterInternal { + final StructuredQuery.FieldFilter.Operator operator; + final Value value; + + ComparisonFilterInternal( + FieldReference fieldReference, StructuredQuery.FieldFilter.Operator operator, Value value) { + super(fieldReference); + this.value = value; + this.operator = operator; + } + + @Override + boolean isInequalityFilter() { + return operator.equals(GREATER_THAN) + || operator.equals(GREATER_THAN_OR_EQUAL) + || operator.equals(LESS_THAN) + || operator.equals(LESS_THAN_OR_EQUAL) + || operator.equals(NOT_EQUAL) + || operator.equals(NOT_IN); + } + + @Nullable + @Override + public FieldReference getFirstInequalityField() { + if (isInequalityFilter()) { + return fieldReference; + } + return null; + } + + Filter toProto() { + Filter.Builder result = Filter.newBuilder(); + result.getFieldFilterBuilder().setField(fieldReference).setValue(value).setOp(operator); + return result.build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ComparisonFilterInternal)) { + return false; + } + ComparisonFilterInternal other = (ComparisonFilterInternal) o; + return Objects.equals(fieldReference, other.fieldReference) + && Objects.equals(operator, other.operator) + && Objects.equals(value, other.value); + } + } + + static final class FieldOrder implements Comparator { + private final FieldReference fieldReference; + private final Direction direction; + + FieldOrder(FieldReference fieldReference, Direction direction) { + this.fieldReference = fieldReference; + this.direction = direction; + } + + FieldOrder(String field, Direction direction) { + this.fieldReference = FieldPath.fromServerFormat(field).toProto(); + this.direction = direction; + } + + Order toProto() { + Order.Builder result = Order.newBuilder(); + result.setField(fieldReference); + result.setDirection(direction.getDirection()); + return result.build(); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof FieldOrder)) { + return false; + } + FieldOrder filter = (FieldOrder) o; + if (direction != filter.direction) { + return false; + } + return Objects.equals(fieldReference, filter.fieldReference); + } + + @Override + public int compare(QueryDocumentSnapshot left, QueryDocumentSnapshot right) { + Value leftValue = + left.extractField(FieldPath.fromDotSeparatedString(fieldReference.getFieldPath())); + Value rightValue = + right.extractField(FieldPath.fromDotSeparatedString(fieldReference.getFieldPath())); + + // If the field isn't present, we treat it as a null value. + if (leftValue == null) { + leftValue = + Value.newBuilder().setNullValue(com.google.protobuf.NullValue.NULL_VALUE).build(); + } + if (rightValue == null) { + rightValue = + Value.newBuilder().setNullValue(com.google.protobuf.NullValue.NULL_VALUE).build(); + } + + int cmp = com.google.cloud.firestore.Order.INSTANCE.compare(leftValue, rightValue); + + if (direction == Direction.DESCENDING) { + cmp = -cmp; + } + + return cmp; + } + } + + /** Denotes whether a provided limit is applied to the beginning or the end of the result set. */ + enum LimitType { + First, + Last + } + + /** Options that define a Firestore Query. */ + @AutoValue + abstract static class QueryOptions { + + abstract ResourcePath getParentPath(); + + abstract String getCollectionId(); + + abstract boolean getAllDescendants(); + + abstract @Nullable Integer getLimit(); + + abstract LimitType getLimitType(); + + abstract @Nullable Integer getOffset(); + + abstract @Nullable Cursor getStartCursor(); + + abstract @Nullable Cursor getEndCursor(); + + abstract ImmutableList getFilters(); + + abstract ImmutableList getFieldOrders(); + + abstract ImmutableList getFieldProjections(); + + // Whether to select all documents under `parentPath`. By default, only + // collections that match `collectionId` are selected. + abstract boolean isKindless(); + + // Whether to require consistent documents when restarting the query. By + // default, restarting the query uses the readTime offset of the original + // query to provide consistent results. + abstract boolean getRequireConsistency(); + + static Builder builder() { + return new AutoValue_Query_QueryOptions.Builder() + .setAllDescendants(false) + .setLimitType(LimitType.First) + .setFieldOrders(ImmutableList.of()) + .setFilters(ImmutableList.of()) + .setFieldProjections(ImmutableList.of()) + .setKindless(false) + .setRequireConsistency(true); + } + + abstract Builder toBuilder(); + + @AutoValue.Builder + abstract static class Builder { + abstract Builder setParentPath(ResourcePath value); + + abstract Builder setCollectionId(String value); + + abstract Builder setAllDescendants(boolean value); + + abstract Builder setLimit(Integer value); + + abstract Builder setLimitType(LimitType value); + + abstract Builder setOffset(Integer value); + + abstract Builder setStartCursor(@Nullable Cursor value); + + abstract Builder setEndCursor(@Nullable Cursor value); + + abstract Builder setFilters(ImmutableList value); + + abstract Builder setFieldOrders(ImmutableList value); + + abstract Builder setFieldProjections(ImmutableList value); + + abstract Builder setKindless(boolean value); + + abstract Builder setRequireConsistency(boolean value); + + abstract QueryOptions build(); + } + } + + /** Creates a query for documents in a single collection */ + Query(FirestoreRpcContext rpcContext, ResourcePath path) { + this( + rpcContext, + QueryOptions.builder() + .setParentPath(path.getParent()) + .setCollectionId(path.getId()) + .build()); + } + + protected Query(FirestoreRpcContext rpcContext, QueryOptions queryOptions) { + super(rpcContext, queryOptions); + } + + @Override + QuerySnapshot createSnaphot(Timestamp readTime, final List documents) { + return QuerySnapshot.withDocuments(this, readTime, documents); + } + + /** Checks whether the provided object is NULL or NaN. */ + private static boolean isUnaryComparison(@Nullable Object value) { + return value == null || value.equals(Double.NaN) || value.equals(Float.NaN); + } + + /** Returns the sorted set of inequality filter fields used in this query. */ + private SortedSet getInequalityFilterFields() { + SortedSet result = new TreeSet<>(); + + for (FilterInternal filter : options.getFilters()) { + for (FieldFilterInternal subFilter : filter.getFlattenedFilters()) { + if (subFilter.isInequalityFilter()) { + result.add(FieldPath.fromServerFormat(subFilter.fieldReference.getFieldPath())); + } + } + } + + return result; + } + + /** Computes the backend ordering semantics for DocumentSnapshot cursors. */ + ImmutableList createImplicitOrderBy() { + // Any explicit order by fields should be added as is. + List result = new ArrayList<>(options.getFieldOrders()); + + HashSet fieldsNormalized = new HashSet<>(); + for (FieldOrder order : result) { + fieldsNormalized.add(order.fieldReference.getFieldPath()); + } + + /** The order of the implicit ordering always matches the last explicit order by. */ + Direction lastDirection = + result.isEmpty() ? Direction.ASCENDING : result.get(result.size() - 1).direction; + + /** + * Any inequality fields not explicitly ordered should be implicitly ordered in a + * lexicographical order. When there are multiple inequality filters on the same field, the + * field should be added only once. + * + *

Note: `SortedSet` sorts the key field before other fields. However, we want the + * key field to be sorted last. + */ + SortedSet inequalityFields = getInequalityFilterFields(); + for (FieldPath field : inequalityFields) { + if (!fieldsNormalized.contains(field.toString()) + && !FieldPath.isDocumentId(field.toString())) { + result.add(new FieldOrder(field.toProto(), lastDirection)); + } + } + + // Add the document key field to the last if it is not explicitly ordered. + if (!fieldsNormalized.contains(FieldPath.documentId().toString())) { + result.add(new FieldOrder(FieldPath.documentId().toProto(), lastDirection)); + } + + return ImmutableList.builder().addAll(result).build(); + } + + private Cursor createCursor( + ImmutableList order, DocumentSnapshot documentSnapshot, boolean before) { + List fieldValues = new ArrayList<>(); + + for (FieldOrder fieldOrder : order) { + String path = fieldOrder.fieldReference.getFieldPath(); + if (FieldPath.isDocumentId(path)) { + fieldValues.add(documentSnapshot.getReference()); + } else { + FieldPath fieldPath = FieldPath.fromServerFormat(path); + Preconditions.checkArgument( + documentSnapshot.contains(fieldPath), + "Field '%s' is missing in the provided DocumentSnapshot. Please provide a document " + + "that contains values for all specified orderBy() and where() constraints.", + fieldPath); + fieldValues.add(documentSnapshot.get(fieldPath)); + } + } + + return createCursor(order, fieldValues.toArray(), before); + } + + private Cursor createCursor(List order, Object[] fieldValues, boolean before) { + Cursor.Builder result = Cursor.newBuilder(); + + Preconditions.checkState( + fieldValues.length != 0, "At least one cursor value must be specified."); + + Preconditions.checkState( + fieldValues.length <= order.size(), + "Too many cursor values specified. The specified values must match the " + + "orderBy() constraints of the query."); + + Iterator fieldOrderIterator = order.iterator(); + + for (Object fieldValue : fieldValues) { + Object sanitizedValue; + + FieldReference fieldReference = fieldOrderIterator.next().fieldReference; + + if (FieldPath.isDocumentId(fieldReference.getFieldPath())) { + sanitizedValue = convertReference(fieldValue); + } else { + sanitizedValue = CustomClassMapper.serialize(fieldValue); + } + + Value encodedValue = encodeValue(fieldReference, sanitizedValue); + + if (encodedValue == null) { + throw FirestoreException.forInvalidArgument( + "Cannot use FieldValue.delete() or FieldValue.serverTimestamp() in a query boundary"); + } + result.addValues(encodedValue); + } + + result.setBefore(before); + + return result.build(); + } + + /** + * Validates that a value used with FieldValue.documentId() is either a string or a + * DocumentReference that is part of the query`s result set. Throws a validation error or returns + * a DocumentReference that can directly be used in the Query. + */ + private Object convertReference(Object fieldValue) { + ResourcePath basePath = + options.getAllDescendants() + ? options.getParentPath() + : options.getParentPath().append(options.getCollectionId()); + + DocumentReference reference; + if (fieldValue instanceof String) { + reference = new DocumentReference(rpcContext, basePath.append((String) fieldValue)); + } else if (fieldValue instanceof DocumentReference) { + reference = (DocumentReference) fieldValue; + } else { + throw new IllegalArgumentException( + String.format( + "The corresponding value for FieldPath.documentId() must be a String or a " + + "DocumentReference, but was: %s.", + fieldValue.toString())); + } + + if (!basePath.isPrefixOf(reference.getResourcePath())) { + throw new IllegalArgumentException( + String.format( + "'%s' is not part of the query result set and cannot be used as a query boundary.", + reference.getPath())); + } + + if (!options.getAllDescendants() && !reference.getParent().getResourcePath().equals(basePath)) { + throw new IllegalArgumentException( + String.format( + "Only a direct child can be used as a query boundary. Found: '%s'", + reference.getPath())); + } + + return reference; + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be equal to the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereEqualTo(@Nonnull String field, @Nullable Object value) { + return whereEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be equal to the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, EQUAL, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and its value does not equal the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereNotEqualTo(@Nonnull String field, @Nullable Object value) { + return whereNotEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value does not equal the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereNotEqualTo(@Nonnull FieldPath fieldPath, @Nullable Object value) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, NOT_EQUAL, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be less than the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereLessThan(@Nonnull String field, @Nonnull Object value) { + return whereLessThan(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be less than the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereLessThan(@Nonnull FieldPath fieldPath, @Nonnull Object value) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, LESS_THAN, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be less or equal to the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereLessThanOrEqualTo(@Nonnull String field, @Nonnull Object value) { + return whereLessThanOrEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be less or equal to the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereLessThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nonnull Object value) { + return where( + new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, LESS_THAN_OR_EQUAL, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be greater than the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereGreaterThan(@Nonnull String field, @Nonnull Object value) { + return whereGreaterThan(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be greater than the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereGreaterThan(@Nonnull FieldPath fieldPath, @Nonnull Object value) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, GREATER_THAN, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be greater than or equal to the specified value. + * + * @param field The name of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereGreaterThanOrEqualTo(@Nonnull String field, @Nonnull Object value) { + return whereGreaterThanOrEqualTo(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value should be greater than or equal to the specified value. + * + * @param fieldPath The path of the field to compare. + * @param value The value for comparison. + * @return The created Query. + */ + @Nonnull + public Query whereGreaterThanOrEqualTo(@Nonnull FieldPath fieldPath, @Nonnull Object value) { + return where( + new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, GREATER_THAN_OR_EQUAL, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field, the value must be an array, and that the array must contain the provided + * value. + * + *

A Query can have only one whereArrayContains() filter and it cannot be combined with + * whereArrayContainsAny(). + * + * @param field The name of the field containing an array to search + * @param value The value that must be contained in the array + * @return The created Query. + */ + @Nonnull + public Query whereArrayContains(@Nonnull String field, @Nonnull Object value) { + return whereArrayContains(FieldPath.fromDotSeparatedString(field), value); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field, the value must be an array, and that the array must contain the provided + * value. + * + *

A Query can have only one whereArrayContains() filter and it cannot be combined with + * whereArrayContainsAny(). + * + * @param fieldPath The path of the field containing an array to search + * @param value The value that must be contained in the array + * @return The created Query. + */ + @Nonnull + public Query whereArrayContains(@Nonnull FieldPath fieldPath, @Nonnull Object value) { + return where( + new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, ARRAY_CONTAINS, value)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field, the value must be an array, and that the array must contain at least one value + * from the provided list. + * + *

A Query can have only one whereArrayContainsAny() filter and it cannot be combined with + * whereArrayContains() or whereIn(). + * + * @param field The name of the field containing an array to search. + * @param values A list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereArrayContainsAny( + @Nonnull String field, @Nonnull List values) { + return whereArrayContainsAny(FieldPath.fromDotSeparatedString(field), values); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field, the value must be an array, and that the array must contain at least one value + * from the provided list. + * + *

A Query can have only one whereArrayContainsAny() filter and it cannot be combined with + * whereArrayContains() or whereIn(). + * + * @param fieldPath The path of the field containing an array to search. + * @param values A list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereArrayContainsAny( + @Nonnull FieldPath fieldPath, @Nonnull List values) { + return where( + new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, ARRAY_CONTAINS_ANY, values)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value must equal one of the values from the provided list. + * + *

A Query can have only one whereIn() filter, and it cannot be combined with + * whereArrayContainsAny(). + * + * @param field The name of the field to search. + * @param values A list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereIn(@Nonnull String field, @Nonnull List values) { + return whereIn(FieldPath.fromDotSeparatedString(field), values); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value must equal one of the values from the provided list. + * + *

A Query can have only one whereIn() filter, and it cannot be combined with + * whereArrayContainsAny(). + * + * @param fieldPath The path of the field to search. + * @param values A list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereIn(@Nonnull FieldPath fieldPath, @Nonnull List values) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, IN, values)); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value does not equal any of the values from the provided list. + * + *

A Query can have only one whereNotIn() filter and it cannot be combined with + * whereArrayContains(), whereArrayContainsAny(), whereIn(), or whereNotEqualTo(). + * + * @param field The name of the field to search. + * @param values The list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereNotIn(@Nonnull String field, @Nonnull List values) { + return whereNotIn(FieldPath.fromDotSeparatedString(field), values); + } + + /** + * Creates and returns a new Query with the additional filter that documents must contain the + * specified field and the value does not equal any of the values from the provided list. + * + *

A Query can have only one whereNotIn() filter, and it cannot be combined with + * whereArrayContains(), whereArrayContainsAny(), whereIn(), or whereNotEqualTo(). + * + * @param fieldPath The path of the field to search. + * @param values The list that contains the values to match. + * @return The created Query. + */ + @Nonnull + public Query whereNotIn(@Nonnull FieldPath fieldPath, @Nonnull List values) { + return where(new com.google.cloud.firestore.Filter.UnaryFilter(fieldPath, NOT_IN, values)); + } + + /** + * Creates and returns a new Query with the additional filter. + * + * @param filter The new filter to apply to the existing query. + * @return The newly created Query. + */ + public Query where(com.google.cloud.firestore.Filter filter) { + Preconditions.checkState( + options.getStartCursor() == null && options.getEndCursor() == null, + "Cannot call a where() clause after defining a boundary with startAt(), " + + "startAfter(), endBefore() or endAt()."); + FilterInternal parsedFilter = parseFilter(filter); + if (parsedFilter.getFilters().isEmpty()) { + // Return the existing query if not adding any more filters (for example an empty composite + // filter). + return this; + } + Builder newOptions = options.toBuilder(); + newOptions.setFilters(append(options.getFilters(), parsedFilter)); + return new Query(rpcContext, newOptions.build()); + } + + FilterInternal parseFilter(com.google.cloud.firestore.Filter filter) { + if (filter instanceof com.google.cloud.firestore.Filter.UnaryFilter) { + return parseFieldFilter((com.google.cloud.firestore.Filter.UnaryFilter) filter); + } + return parseCompositeFilter((com.google.cloud.firestore.Filter.CompositeFilter) filter); + } + + private FieldFilterInternal parseFieldFilter( + com.google.cloud.firestore.Filter.UnaryFilter fieldFilterData) { + Object value = fieldFilterData.getValue(); + Operator operator = fieldFilterData.getOperator(); + FieldPath fieldPath = fieldFilterData.getField(); + + if (isUnaryComparison(value)) { + if (operator.equals(EQUAL) || operator.equals(NOT_EQUAL)) { + StructuredQuery.UnaryFilter.Operator unaryOp = + operator.equals(EQUAL) + ? (value == null + ? StructuredQuery.UnaryFilter.Operator.IS_NULL + : StructuredQuery.UnaryFilter.Operator.IS_NAN) + : (value == null + ? StructuredQuery.UnaryFilter.Operator.IS_NOT_NULL + : StructuredQuery.UnaryFilter.Operator.IS_NOT_NAN); + return new UnaryFilterInternal(fieldPath.toProto(), unaryOp); + } else { + throw new IllegalArgumentException( + String.format( + "Cannot use '%s' in field comparison. Use an equality filter instead.", value)); + } + } else { + if (fieldPath.equals(FieldPath.DOCUMENT_ID)) { + if (operator.equals(ARRAY_CONTAINS) || operator.equals(ARRAY_CONTAINS_ANY)) { + throw new IllegalArgumentException( + String.format( + "Invalid query. You cannot perform '%s' queries on FieldPath.documentId().", + operator.toString())); + } else if (operator.equals(IN) || operator.equals(NOT_IN)) { + if (!(value instanceof List) || ((List) value).isEmpty()) { + throw new IllegalArgumentException( + String.format( + "Invalid Query. A non-empty array is required for '%s' filters.", + operator.toString())); + } + List referenceList = new ArrayList<>(); + for (Object arrayValue : (List) value) { + Object convertedValue = this.convertReference(arrayValue); + referenceList.add(convertedValue); + } + value = referenceList; + } else { + value = this.convertReference(value); + } + } + return new ComparisonFilterInternal( + fieldPath.toProto(), operator, encodeValue(fieldPath, value)); + } + } + + private FilterInternal parseCompositeFilter( + com.google.cloud.firestore.Filter.CompositeFilter compositeFilterData) { + List parsedFilters = new ArrayList<>(); + for (com.google.cloud.firestore.Filter filter : compositeFilterData.getFilters()) { + FilterInternal parsedFilter = parseFilter(filter); + if (!parsedFilter.getFilters().isEmpty()) { + parsedFilters.add(parsedFilter); + } + } + + // For composite filters containing 1 filter, return the only filter. + // For example: AND(FieldFilter1) == FieldFilter1 + if (parsedFilters.size() == 1) { + return parsedFilters.get(0); + } + return new CompositeFilterInternal(parsedFilters, compositeFilterData.getOperator()); + } + + /** + * Creates and returns a new Query that's additionally sorted by the specified field. + * + * @param field The field to sort by. + * @return The created Query. + */ + @Nonnull + public Query orderBy(@Nonnull String field) { + return orderBy(FieldPath.fromDotSeparatedString(field), Direction.ASCENDING); + } + + /** + * Creates and returns a new Query that's additionally sorted by the specified field. + * + * @param fieldPath The field to sort by. + * @return The created Query. + */ + @Nonnull + public Query orderBy(@Nonnull FieldPath fieldPath) { + return orderBy(fieldPath, Direction.ASCENDING); + } + + /** + * Creates and returns a new Query that's additionally sorted by the specified field, optionally + * in descending order instead of ascending. + * + * @param field The field to sort by. + * @param direction The direction to sort. + * @return The created Query. + */ + @Nonnull + public Query orderBy(@Nonnull String field, @Nonnull Direction direction) { + return orderBy(FieldPath.fromDotSeparatedString(field), direction); + } + + /** + * Creates and returns a new Query that's additionally sorted by the specified field, optionally + * in descending order instead of ascending. + * + * @param fieldPath The field to sort by. + * @param direction The direction to sort. + * @return The created Query. + */ + @Nonnull + public Query orderBy(@Nonnull FieldPath fieldPath, @Nonnull Direction direction) { + Preconditions.checkState( + options.getStartCursor() == null && options.getEndCursor() == null, + "Cannot specify an orderBy() constraint after calling startAt(), " + + "startAfter(), endBefore() or endAt()."); + + Builder newOptions = options.toBuilder(); + FieldOrder newFieldOrder = new FieldOrder(fieldPath.toProto(), direction); + newOptions.setFieldOrders(append(options.getFieldOrders(), newFieldOrder)); + + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that only returns the first matching documents. + * + * @param limit The maximum number of items to return. + * @return The created Query. + */ + @Nonnull + public Query limit(int limit) { + return new Query( + rpcContext, options.toBuilder().setLimit(limit).setLimitType(LimitType.First).build()); + } + + /** + * Creates and returns a new Query that only returns the last matching documents. + * + *

You must specify at least one orderBy clause for limitToLast queries. Otherwise, an {@link + * java.lang.IllegalStateException} is thrown during execution. + * + *

Results for limitToLast() queries are only available once all documents are received. Hence, + * limitToLast() queries cannot be streamed via the {@link #stream(ApiStreamObserver)} API. + * + * @param limit the maximum number of items to return + * @return the created Query + */ + @Nonnull + public Query limitToLast(int limit) { + return new Query( + rpcContext, options.toBuilder().setLimit(limit).setLimitType(LimitType.Last).build()); + } + + /** + * Creates and returns a new Query that skips the first n results. + * + * @param offset The number of items to skip. + * @return The created Query. + */ + @Nonnull + public Query offset(int offset) { + return new Query(rpcContext, options.toBuilder().setOffset(offset).build()); + } + + /** + * Creates and returns a new Query that starts at the provided document (inclusive). The starting + * position is relative to the order of the query. The document must contain all of the fields + * provided in the orderBy of this query. + * + * @param snapshot The snapshot of the document to start at. + * @return The created Query. + */ + @Nonnull + public Query startAt(@Nonnull DocumentSnapshot snapshot) { + ImmutableList fieldOrders = createImplicitOrderBy(); + Cursor cursor = createCursor(fieldOrders, snapshot, true); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setStartCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that starts at the provided fields relative to the order of the + * query. The order of the field values must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to start this query at, in order of the query's order by. + * @return The created Query. + */ + @Nonnull + public Query startAt(Object... fieldValues) { + // TODO(b/296435819): Remove this warning message. + warningOnSingleDocumentReference(fieldValues); + + ImmutableList fieldOrders = + fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference + ? createImplicitOrderBy() + : options.getFieldOrders(); + Cursor cursor = createCursor(fieldOrders, fieldValues, true); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setStartCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query instance that applies a field mask to the result and returns + * the specified subset of fields. You can specify a list of field paths to return, or use an + * empty list to only return the references of matching documents. + * + * @param fields The fields to include. + * @return The created Query. + */ + @Nonnull + public Query select(String... fields) { + FieldPath[] fieldPaths = new FieldPath[fields.length]; + + for (int i = 0; i < fields.length; ++i) { + fieldPaths[i] = FieldPath.fromDotSeparatedString(fields[i]); + } + + return select(fieldPaths); + } + + /** + * Creates and returns a new Query instance that applies a field mask to the result and returns + * the specified subset of fields. You can specify a list of field paths to return, or use an + * empty list to only return the references of matching documents. + * + * @param fieldPaths The field paths to include. + * @return The created Query. + */ + @Nonnull + public Query select(FieldPath... fieldPaths) { + if (fieldPaths.length == 0) { + fieldPaths = new FieldPath[] {FieldPath.DOCUMENT_ID}; + } + + ImmutableList.Builder fieldProjections = + ImmutableList.builderWithExpectedSize(fieldPaths.length); + for (FieldPath path : fieldPaths) { + FieldReference fieldReference = + FieldReference.newBuilder().setFieldPath(path.getEncodedPath()).build(); + fieldProjections.add(fieldReference); + } + + Builder newOptions = options.toBuilder().setFieldProjections(fieldProjections.build()); + return new Query(rpcContext, newOptions.build()); + } + + @Override + boolean isRetryableWithCursor() { + return true; + } + + /** + * Creates and returns a new Query that starts after the provided document (exclusive). The + * starting position is relative to the order of the query. The document must contain all of the + * fields provided in the orderBy of this query. + * + * @param snapshot The snapshot of the document to start after. + * @return The created Query. + */ + @Nonnull + @Override + public Query startAfter(@Nonnull DocumentSnapshot snapshot) { + ImmutableList fieldOrders = createImplicitOrderBy(); + Cursor cursor = createCursor(fieldOrders, snapshot, false); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setStartCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that starts after the provided fields relative to the order of + * the query. The order of the field values must match the order of the order by clauses of the + * query. + * + * @param fieldValues The field values to start this query after, in order of the query's order + * by. + * @return The created Query. + */ + public Query startAfter(Object... fieldValues) { + // TODO(b/296435819): Remove this warning message. + warningOnSingleDocumentReference(fieldValues); + + ImmutableList fieldOrders = + fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference + ? createImplicitOrderBy() + : options.getFieldOrders(); + Cursor cursor = createCursor(fieldOrders, fieldValues, false); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setStartCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that ends before the provided document (exclusive). The end + * position is relative to the order of the query. The document must contain all of the fields + * provided in the orderBy of this query. + * + * @param snapshot The snapshot of the document to end before. + * @return The created Query. + */ + @Nonnull + public Query endBefore(@Nonnull DocumentSnapshot snapshot) { + ImmutableList fieldOrders = createImplicitOrderBy(); + Cursor cursor = createCursor(fieldOrders, snapshot, true); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setEndCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that ends before the provided fields relative to the order of + * the query. The order of the field values must match the order of the order by clauses of the + * query. + * + * @param fieldValues The field values to end this query before, in order of the query's order by. + * @return The created Query. + */ + @Nonnull + public Query endBefore(Object... fieldValues) { + // TODO(b/296435819): Remove this warning message. + warningOnSingleDocumentReference(fieldValues); + + ImmutableList fieldOrders = + fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference + ? createImplicitOrderBy() + : options.getFieldOrders(); + Cursor cursor = createCursor(fieldOrders, fieldValues, true); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setEndCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** + * Creates and returns a new Query that ends at the provided fields relative to the order of the + * query. The order of the field values must match the order of the order by clauses of the query. + * + * @param fieldValues The field values to end this query at, in order of the query's order by. + * @return The created Query. + */ + @Nonnull + public Query endAt(Object... fieldValues) { + // TODO(b/296435819): Remove this warning message. + warningOnSingleDocumentReference(fieldValues); + + ImmutableList fieldOrders = + fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference + ? createImplicitOrderBy() + : options.getFieldOrders(); + Cursor cursor = createCursor(fieldOrders, fieldValues, false); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setEndCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + private void warningOnSingleDocumentReference(Object... fieldValues) { + if (options.getFieldOrders().isEmpty() + && fieldValues.length == 1 + && fieldValues[0] instanceof DocumentReference) { + LOGGER.warning( + "Warning: Passing DocumentReference into a cursor without orderBy clause is not an" + + " intended behavior. Please use DocumentSnapshot or add an explicit orderBy on" + + " document key field."); + } + } + + /** + * Creates and returns a new Query that ends at the provided document (inclusive). The end + * position is relative to the order of the query. The document must contain all of the fields + * provided in the orderBy of this query. + * + * @param snapshot The snapshot of the document to end at. + * @return The created Query. + */ + @Nonnull + public Query endAt(@Nonnull DocumentSnapshot snapshot) { + ImmutableList fieldOrders = createImplicitOrderBy(); + Cursor cursor = createCursor(fieldOrders, snapshot, false); + + Builder newOptions = options.toBuilder(); + newOptions.setFieldOrders(fieldOrders); + newOptions.setEndCursor(cursor); + return new Query(rpcContext, newOptions.build()); + } + + /** Build the final Firestore query. */ + StructuredQuery.Builder buildQuery() { + StructuredQuery.Builder structuredQuery = buildWithoutClientTranslation(); + if (options.getLimitType().equals(LimitType.Last)) { + structuredQuery.clearOrderBy(); + structuredQuery.clearStartAt(); + structuredQuery.clearEndAt(); + + // Apply client translation for limitToLast. + if (!options.getFieldOrders().isEmpty()) { + for (FieldOrder order : options.getFieldOrders()) { + // Flip the orderBy directions since we want the last results + order = + new FieldOrder( + order.fieldReference, + order.direction.equals(Direction.ASCENDING) + ? Direction.DESCENDING + : Direction.ASCENDING); + structuredQuery.addOrderBy(order.toProto()); + } + } + + if (options.getStartCursor() != null) { + // Swap the cursors to match the flipped query ordering. + Cursor cursor = + options.getStartCursor().toBuilder() + .setBefore(!options.getStartCursor().getBefore()) + .build(); + structuredQuery.setEndAt(cursor); + } + + if (options.getEndCursor() != null) { + // Swap the cursors to match the flipped query ordering. + Cursor cursor = + options.getEndCursor().toBuilder() + .setBefore(!options.getEndCursor().getBefore()) + .build(); + structuredQuery.setStartAt(cursor); + } + } + + return structuredQuery; + } + + /** + * Builds a {@link BundledQuery} that is able to be saved in a bundle file. + * + *

This will not perform any limitToLast order flip, as {@link BundledQuery} has first class + * representation via {@link BundledQuery.LimitType}. + */ + BundledQuery toBundledQuery() { + StructuredQuery.Builder structuredQuery = buildWithoutClientTranslation(); + + return BundledQuery.newBuilder() + .setStructuredQuery(structuredQuery) + .setParent(options.getParentPath().toString()) + .setLimitType( + options.getLimitType().equals(LimitType.Last) + ? BundledQuery.LimitType.LAST + : BundledQuery.LimitType.FIRST) + .build(); + } + + private StructuredQuery.Builder buildWithoutClientTranslation() { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + CollectionSelector.Builder collectionSelector = CollectionSelector.newBuilder(); + + // Kindless queries select all descendant documents, so we don't add the collectionId field. + if (!options.isKindless()) { + collectionSelector.setCollectionId(options.getCollectionId()); + } + + collectionSelector.setAllDescendants(options.getAllDescendants()); + structuredQuery.addFrom(collectionSelector); + + // There's an implicit AND operation between the top-level query filters. + if (!options.getFilters().isEmpty()) { + FilterInternal filter = + new CompositeFilterInternal(options.getFilters(), CompositeFilter.Operator.AND); + structuredQuery.setWhere(filter.toProto()); + } + + if (!options.getFieldOrders().isEmpty()) { + for (FieldOrder order : options.getFieldOrders()) { + structuredQuery.addOrderBy(order.toProto()); + } + } else if (LimitType.Last.equals(options.getLimitType())) { + throw new IllegalStateException( + "limitToLast() queries require specifying at least one orderBy() clause."); + } + + if (!options.getFieldProjections().isEmpty()) { + structuredQuery.getSelectBuilder().addAllFields(options.getFieldProjections()); + } + + if (options.getLimit() != null) { + structuredQuery.setLimit(Int32Value.newBuilder().setValue(options.getLimit())); + } + + if (options.getOffset() != null) { + structuredQuery.setOffset(options.getOffset()); + } + + if (options.getStartCursor() != null) { + structuredQuery.setStartAt(options.getStartCursor()); + } + + if (options.getEndCursor() != null) { + structuredQuery.setEndAt(options.getEndCursor()); + } + + return structuredQuery; + } + + /** + * Executes the query and streams the results as a StreamObserver of DocumentSnapshots. + * + * @param responseObserver The observer to be notified when results arrive. + */ + public void stream(@Nonnull final ApiStreamObserver responseObserver) { + Preconditions.checkState( + !LimitType.Last.equals(Query.this.options.getLimitType()), + "Query results for queries that include limitToLast() constraints cannot be streamed. " + + "Use Query.get() instead."); + + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_RUN_QUERY_GET); + + ApiStreamObserver observer = + new ApiStreamObserver() { + @Override + public void onNext(RunQueryResponse runQueryResponse) { + if (runQueryResponse.hasDocument()) { + Document document = runQueryResponse.getDocument(); + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + rpcContext, Timestamp.fromProto(runQueryResponse.getReadTime()), document); + responseObserver.onNext(documentSnapshot); + } + } + + @Override + public void onError(Throwable throwable) { + responseObserver.onError(throwable); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + + internalStream( + new MonitoredStreamResponseObserver(observer, metricsContext), + /* startTimeNanos= */ rpcContext.getClock().nanoTime(), + /* transactionId= */ null, + /* readTime= */ null, + /* explainOptions= */ null, + /* isRetryRequestWithCursor= */ false); + } + + /** + * Executes the query, streams the results as a StreamObserver of DocumentSnapshots, and returns + * an ApiFuture that will be resolved with the associated {@link ExplainMetrics}. + * + * @param options The options that configure the explain request. + * @param documentObserver The observer to be notified every time a new document arrives. + */ + @Nonnull + public ApiFuture explainStream( + @Nonnull ExplainOptions options, + @Nonnull ApiStreamObserver documentObserver) { + Preconditions.checkState( + !LimitType.Last.equals(Query.this.options.getLimitType()), + "Query results for queries that include limitToLast() constraints cannot be streamed. " + + "Use Query.explain() instead."); + + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_RUN_QUERY_EXPLAIN); + + final SettableApiFuture metricsFuture = SettableApiFuture.create(); + + ApiStreamObserver observer = + new ApiStreamObserver() { + @Override + public void onNext(RunQueryResponse runQueryResponse) { + if (runQueryResponse.hasDocument()) { + Document document = runQueryResponse.getDocument(); + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + rpcContext, Timestamp.fromProto(runQueryResponse.getReadTime()), document); + documentObserver.onNext(documentSnapshot); + } + + if (runQueryResponse.hasExplainMetrics()) { + metricsFuture.set(new ExplainMetrics(runQueryResponse.getExplainMetrics())); + } + } + + @Override + public void onError(Throwable throwable) { + metricsFuture.setException(throwable); + documentObserver.onError(throwable); + } + + @Override + public void onCompleted() { + documentObserver.onCompleted(); + if (!metricsFuture.isDone()) { + // This means the gRPC stream completed without any metrics. + metricsFuture.setException( + new RuntimeException("Did not receive any explain results.")); + } + } + }; + + internalStream( + new MonitoredStreamResponseObserver(observer, metricsContext), + /* startTimeNanos= */ rpcContext.getClock().nanoTime(), + /* transactionId= */ null, + /* readTime= */ null, + /* explainOptions= */ options, + /* isRetryRequestWithCursor= */ false); + + return metricsFuture; + } + + /** + * Returns the {@link RunQueryRequest} that this Query instance represents. The request contains + * the serialized form of all Query constraints. + * + *

Runtime metadata (as required for `limitToLast()` queries) is not serialized and as such, + * the serialized request will return the results in the original backend order. + * + * @return the serialized RunQueryRequest + */ + public RunQueryRequest toProto() { + return toRunQueryRequestBuilder(null, null, null).build(); + } + + @Override + protected RunQueryRequest.Builder toRunQueryRequestBuilder( + @Nullable final ByteString transactionId, + @Nullable final Timestamp readTime, + @Nullable ExplainOptions explainOptions) { + + // Builder for RunQueryRequest + RunQueryRequest.Builder request = RunQueryRequest.newBuilder(); + request.setStructuredQuery(buildQuery()); + request.setParent(options.getParentPath().toString()); + if (explainOptions != null) { + request.setExplainOptions(explainOptions.toProto()); + } + if (transactionId != null) { + request.setTransaction(transactionId); + } + if (readTime != null) { + request.setReadTime(readTime.toProto()); + } + + return request; + } + + /** + * Returns a Query instance that can be used to execute the provided {@link RunQueryRequest}. + * + *

Only RunQueryRequests that pertain to the same project as the Firestore instance can be + * deserialized. + * + *

Runtime metadata (as required for `limitToLast()` queries) is not restored and as such, the + * results for limitToLast() queries will be returned in the original backend order. + * + * @param firestore a Firestore instance to apply the query to + * @param proto the serialized RunQueryRequest + * @return a Query instance that can be used to execute the RunQueryRequest + */ + public static Query fromProto(Firestore firestore, RunQueryRequest proto) { + Preconditions.checkState( + FirestoreRpcContext.class.isAssignableFrom(firestore.getClass()), + "The firestore instance passed to this method must also implement FirestoreRpcContext."); + return fromProto((FirestoreRpcContext) firestore, proto); + } + + private static Query fromProto(FirestoreRpcContext rpcContext, RunQueryRequest proto) { + QueryOptions.Builder queryOptions = QueryOptions.builder(); + StructuredQuery structuredQuery = proto.getStructuredQuery(); + + ResourcePath parentPath = ResourcePath.create(proto.getParent()); + if (!rpcContext.getDatabaseName().equals(parentPath.getDatabaseName().toString())) { + throw new IllegalArgumentException( + String.format( + "Cannot deserialize query from different Firestore project (\"%s\" vs \"%s\")", + rpcContext.getDatabaseName(), parentPath.getDatabaseName())); + } + queryOptions.setParentPath(parentPath); + + Preconditions.checkArgument( + structuredQuery.getFromCount() == 1, + "Can only deserialize query with exactly one collection selector."); + queryOptions.setCollectionId(structuredQuery.getFrom(0).getCollectionId()); + queryOptions.setAllDescendants(structuredQuery.getFrom(0).getAllDescendants()); + + if (structuredQuery.hasWhere()) { + FilterInternal filter = FilterInternal.fromProto(structuredQuery.getWhere()); + + // There's an implicit AND operation between the top-level query filters. + if (filter instanceof CompositeFilterInternal + && ((CompositeFilterInternal) filter).isConjunction()) { + queryOptions.setFilters( + new ImmutableList.Builder().addAll(filter.getFilters()).build()); + } else { + queryOptions.setFilters(ImmutableList.of(filter)); + } + } + + ImmutableList.Builder fieldOrders = + ImmutableList.builderWithExpectedSize(structuredQuery.getOrderByCount()); + for (Order order : structuredQuery.getOrderByList()) { + fieldOrders.add( + new FieldOrder(order.getField(), Direction.valueOf(order.getDirection().name()))); + } + queryOptions.setFieldOrders(fieldOrders.build()); + + if (structuredQuery.hasLimit()) { + queryOptions.setLimit(structuredQuery.getLimit().getValue()); + } + + if (structuredQuery.getOffset() != 0) { + queryOptions.setOffset(structuredQuery.getOffset()); + } + + if (structuredQuery.hasSelect()) { + queryOptions.setFieldProjections( + ImmutableList.copyOf(structuredQuery.getSelect().getFieldsList())); + } + + if (structuredQuery.hasStartAt()) { + queryOptions.setStartCursor(structuredQuery.getStartAt()); + } + + if (structuredQuery.hasEndAt()) { + queryOptions.setEndCursor(structuredQuery.getEndAt()); + } + + return new Query(rpcContext, queryOptions.build()); + } + + private Value encodeValue(FieldReference fieldReference, Object value) { + return encodeValue(FieldPath.fromDotSeparatedString(fieldReference.getFieldPath()), value); + } + + private Value encodeValue(FieldPath fieldPath, Object value) { + Object sanitizedObject = CustomClassMapper.serialize(value); + Value encodedValue = + UserDataConverter.encodeValue(fieldPath, sanitizedObject, UserDataConverter.ARGUMENT); + if (encodedValue == null) { + throw FirestoreException.forInvalidArgument( + "Cannot use Firestore sentinels in FieldFilter or cursors"); + } + return encodedValue; + } + + /** + * Executes the query and returns the results as QuerySnapshot. + * + * @return An ApiFuture that will be resolved with the results of the Query. + */ + @Override + @Nonnull + public ApiFuture get() { + return get(null, null); + } + + /** + * Plans and optionally executes this query. Returns an ApiFuture that will be resolved with the + * planner information, statistics from the query execution (if any), and the query results (if + * any). + * + * @return An ApiFuture that will be resolved with the planner information, statistics from the + * query execution (if any), and the query results (if any). + */ + @Override + @Nonnull + public ApiFuture> explain(ExplainOptions options) { + return super.explain(options); + } + + /** + * Starts listening to this query. + * + * @param listener The event listener that will be called with the snapshots. + * @return A registration object that can be used to remove the listener. + */ + @Nonnull + public ListenerRegistration addSnapshotListener(@Nonnull EventListener listener) { + return addSnapshotListener(rpcContext.getClient().getExecutor(), listener); + } + + /** + * Starts listening to this query. + * + * @param executor The executor to use to call the listener. + * @param listener The event listener that will be called with the snapshots. + * @return A registration object that can be used to remove the listener. + */ + @Nonnull + public ListenerRegistration addSnapshotListener( + @Nonnull Executor executor, @Nonnull EventListener listener) { + return Watch.forQuery(this).runWatch(executor, listener); + } + + Comparator comparator() { + Iterator iterator = options.getFieldOrders().iterator(); + if (!iterator.hasNext()) { + return DOCUMENT_ID_COMPARATOR; + } + FieldOrder fieldOrder = iterator.next(); + Comparator comparator = fieldOrder; + while (iterator.hasNext()) { + fieldOrder = iterator.next(); + comparator = comparator.thenComparing(fieldOrder); + } + // Add implicit sorting by name, using the last specified direction. + Direction lastDirection = fieldOrder.direction; + return comparator.thenComparing(lastDirection.documentIdComparator); + } + + /** + * Helper method to append an element to an existing ImmutableList. Returns the newly created + * list. + */ + private ImmutableList append(ImmutableList existingList, T newElement) { + ImmutableList.Builder builder = + ImmutableList.builderWithExpectedSize(existingList.size() + 1); + builder.addAll(existingList); + builder.add(newElement); + return builder.build(); + } + + /** + * Returns a query that counts the documents in the result set of this query. + * + *

The returned query, when executed, counts the documents in the result set of this query + * without actually downloading the documents. + * + *

Using the returned query to count the documents is efficient because only the final count, + * not the documents' data, is downloaded. The returned query can count the documents in cases + * where the result set is prohibitively large to download entirely (thousands of documents). + * + * @return a query that counts the documents in the result set of this query. + */ + @Nonnull + public AggregateQuery count() { + return new AggregateQuery(this, Collections.singletonList(AggregateField.count())); + } + + /** + * Calculates the specified aggregations over the documents in the result set of the given query + * without actually downloading the documents. + * + *

Using the returned query to perform aggregations is efficient because only the final + * aggregation values, not the documents' data, is downloaded. The returned query can perform + * aggregations of the documents in cases where the result set is prohibitively large to download + * entirely (thousands of documents). + * + * @return an {@link AggregateQuery} that performs aggregations on the documents in the result set + * of this query. + */ + @Nonnull + public AggregateQuery aggregate( + @Nonnull AggregateField aggregateField1, @Nonnull AggregateField... aggregateFields) { + List aggregateFieldList = new ArrayList<>(); + aggregateFieldList.add(aggregateField1); + aggregateFieldList.addAll(Arrays.asList(aggregateFields)); + return new AggregateQuery(this, aggregateFieldList); + } + + /** + * Returns a VectorQuery that can perform vector distance (similarity) search with given + * parameters. + * + *

The returned query, when executed, performs a distance (similarity) search on the specified + * `vectorField` against the given `queryVector` and returns the top documents that are closest to + * the `queryVector`. + * + *

Only documents whose `vectorField` field is a {@link VectorValue} of the same dimension as + * `queryVector` participate in the query, all other documents are ignored. + * + *

{@code VectorQuery vectorQuery = col.findNearest("embedding", new double[] {41, 42}, 10, + * VectorQuery.DistanceMeasure.EUCLIDEAN); QuerySnapshot querySnapshot = await + * vectorQuery.get().get(); DocumentSnapshot mostSimilarDocument = + * querySnapshot.getDocuments().get(0);} + * + * @param vectorField A string specifying the vector field to search on. + * @param queryVector A representation of the vector used to measure the distance from + * `vectorField` values in the documents. + * @param limit The upper bound of documents to return, must be a positive integer with a maximum + * value of 1000. + * @param distanceMeasure What type of distance is calculated when performing the query. See + * {@link VectorQuery.DistanceMeasure}. + * @return an {@link VectorQuery} that performs vector distance (similarity) search with the given + * parameters. + */ + public VectorQuery findNearest( + String vectorField, + double[] queryVector, + int limit, + VectorQuery.DistanceMeasure distanceMeasure) { + return findNearest( + FieldPath.fromDotSeparatedString(vectorField), + FieldValue.vector(queryVector), + limit, + distanceMeasure, + VectorQueryOptions.getDefaultInstance()); + } + + /** + * Returns a VectorQuery that can perform vector distance (similarity) search with given + * parameters. + * + *

The returned query, when executed, performs a distance (similarity) search on the specified + * `vectorField` against the given `queryVector` and returns the top documents that are closest to + * the `queryVector`. + * + *

Only documents whose `vectorField` field is a {@link VectorValue} of the same dimension as + * `queryVector` participate in the query, all other documents are ignored. + * + *

{@code VectorQuery vectorQuery = col.findNearest( "embedding", new double[] {41, 42}, 10, + * VectorQuery.DistanceMeasure.EUCLIDEAN, + * FindNearestOptions.newBuilder().setDistanceThreshold(0.11).setDistanceResultField("foo").build()); + * QuerySnapshot querySnapshot = await vectorQuery.get().get(); DocumentSnapshot + * mostSimilarDocument = querySnapshot.getDocuments().get(0);} + * + * @param vectorField A string specifying the vector field to search on. + * @param queryVector A representation of the vector used to measure the distance from + * `vectorField` values in the documents. + * @param limit The upper bound of documents to return, must be a positive integer with a maximum + * value of 1000. + * @param distanceMeasure What type of distance is calculated when performing the query. See + * {@link VectorQuery.DistanceMeasure}. + * @param vectorQueryOptions Optional arguments for VectorQueries, see {@link VectorQueryOptions}. + * @return an {@link VectorQuery} that performs vector distance (similarity) search with the given + * parameters. + */ + public VectorQuery findNearest( + String vectorField, + double[] queryVector, + int limit, + VectorQuery.DistanceMeasure distanceMeasure, + VectorQueryOptions vectorQueryOptions) { + return findNearest( + FieldPath.fromDotSeparatedString(vectorField), + FieldValue.vector(queryVector), + limit, + distanceMeasure, + vectorQueryOptions); + } + + /** + * Returns a VectorQuery that can perform vector distance (similarity) search with given + * parameters. + * + *

The returned query, when executed, performs a distance (similarity) search on the specified + * `vectorField` against the given `queryVector` and returns the top documents that are closest to + * the `queryVector`. + * + *

Only documents whose `vectorField` field is a {@link VectorValue} of the same dimension as + * `queryVector` participate in the query, all other documents are ignored. + * + *

{@code VectorValue queryVector = FieldValue.vector(new double[] {41, 42}); VectorQuery + * vectorQuery = col.findNearest( FieldPath.of("embedding"), queryVector, 10, + * VectorQuery.DistanceMeasure.EUCLIDEAN); QuerySnapshot querySnapshot = await + * vectorQuery.get().get(); DocumentSnapshot mostSimilarDocument = + * querySnapshot.getDocuments().get(0);} + * + * @param vectorField A {@link FieldPath} specifying the vector field to search on. + * @param queryVector The {@link VectorValue} used to measure the distance from `vectorField` + * values in the documents. + * @param limit The upper bound of documents to return, must be a positive integer with a maximum + * value of 1000. + * @param distanceMeasure What type of distance is calculated when performing the query. See + * {@link VectorQuery.DistanceMeasure}. + * @return an {@link VectorQuery} that performs vector distance (similarity) search with the given + * parameters. + */ + public VectorQuery findNearest( + FieldPath vectorField, + VectorValue queryVector, + int limit, + VectorQuery.DistanceMeasure distanceMeasure) { + return findNearest( + vectorField, queryVector, limit, distanceMeasure, VectorQueryOptions.getDefaultInstance()); + } + + /** + * Returns a VectorQuery that can perform vector distance (similarity) search with given + * parameters. + * + *

The returned query, when executed, performs a distance (similarity) search on the specified + * `vectorField` against the given `queryVector` and returns the top documents that are closest to + * the `queryVector`. + * + *

Only documents whose `vectorField` field is a {@link VectorValue} of the same dimension as + * `queryVector` participate in the query, all other documents are ignored. + * + *

{@code VectorQuery vectorQuery = col.findNearest( FieldPath.of("embedding"), queryVector, + * 10, VectorQuery.DistanceMeasure.EUCLIDEAN, + * FindNearestOptions.newBuilder().setDistanceThreshold(0.11).setDistanceResultField("foo").build()); + * QuerySnapshot querySnapshot = await vectorQuery.get().get(); DocumentSnapshot + * mostSimilarDocument = querySnapshot.getDocuments().get(0);} + * + * @param vectorField A {@link FieldPath} specifying the vector field to search on. + * @param queryVector The {@link VectorValue} used to measure the distance from `vectorField` + * values in the documents. + * @param limit The upper bound of documents to return, must be a positive integer with a maximum + * value of 1000. + * @param distanceMeasure What type of distance is calculated when performing the query. See + * {@link VectorQuery.DistanceMeasure}. + * @param vectorQueryOptions Optional arguments for VectorQueries, see {@link VectorQueryOptions}. + * @return an {@link VectorQuery} that performs vector distance (similarity) search with the given + * parameters. + */ + public VectorQuery findNearest( + FieldPath vectorField, + VectorValue queryVector, + int limit, + VectorQuery.DistanceMeasure distanceMeasure, + VectorQueryOptions vectorQueryOptions) { + if (limit <= 0) { + throw FirestoreException.forInvalidArgument( + "Not a valid positive `limit` number. `limit` must be larger than 0."); + } + + if (queryVector.size() == 0) { + throw FirestoreException.forInvalidArgument( + "Not a valid vector size. `queryVector` size must be larger than 0."); + } + + return new VectorQuery( + this, vectorField, queryVector, limit, distanceMeasure, vectorQueryOptions); + } + + Pipeline pipeline() { + // From + Pipeline ppl = + this.options.getAllDescendants() + ? new PipelineSource(this.rpcContext).collectionGroup(this.options.getCollectionId()) + : new PipelineSource(this.rpcContext) + .collection( + this.options.getParentPath().append(this.options.getCollectionId()).getPath()); + + // Filters + for (FilterInternal f : this.options.getFilters()) { + ppl = ppl.where(toPipelineBooleanExpr(f)); + } + + // Projections + if (this.options.getFieldProjections() != null + && !this.options.getFieldProjections().isEmpty()) { + Selectable[] fields = + this.options.getFieldProjections().stream() + .map(fieldReference -> Field.ofServerPath(fieldReference.getFieldPath())) + .toArray(Selectable[]::new); + if (fields.length > 0) { + ppl = ppl.select(fields[0], Arrays.copyOfRange(fields, 1, fields.length)); + } else { + ppl = ppl.select(fields[0]); + } + } + + // Orders + List explicitSortOrder = this.options.getFieldOrders(); + List normalizedOrderBy = createImplicitOrderBy(); + int size = normalizedOrderBy.size(); + List fields = new ArrayList<>(size); + List orderings = new ArrayList<>(size); + for (FieldOrder order : normalizedOrderBy) { + Field field = Field.ofServerPath(order.fieldReference.getFieldPath()); + fields.add(field); + if (order.direction == Direction.ASCENDING) { + orderings.add(field.ascending()); + } else { + orderings.add(field.descending()); + } + } + + // Only add existence filters for fields that are explicitly ordered. + // Implicit order bys (e.g. from inequality filters) should not generate + // existence filters + // because the inequality filter itself will already generate an existence + // filter if needed, + // or arguably should not if it's a NOT_IN / NOT_EQUAL filter. + List existenceCheckFields = new ArrayList<>(); + for (FieldOrder order : explicitSortOrder) { + existenceCheckFields.add(Field.ofServerPath(order.fieldReference.getFieldPath())); + } + + if (existenceCheckFields.size() == 1) { + ppl = ppl.where(existenceCheckFields.get(0).exists()); + } else if (existenceCheckFields.size() > 1) { + ppl = + ppl.where( + and( + existenceCheckFields.get(0).exists(), + existenceCheckFields.subList(1, existenceCheckFields.size()).stream() + .map((Field field) -> field.exists()) + .toArray(BooleanExpression[]::new))); + } + + // Cursors, Limit, Offset + if (this.options.getStartCursor() != null) { + ppl = ppl.where(whereConditionsFromCursor(options.getStartCursor(), orderings, true)); + } + + if (this.options.getEndCursor() != null) { + ppl = ppl.where(whereConditionsFromCursor(options.getEndCursor(), orderings, false)); + } + + if (options.getLimit() != null) { + // TODO: Handle situation where user enters limit larger than integer. + if (options.getLimitType() == LimitType.First) { + ppl = ppl.sort(orderings.toArray(new Ordering[0])); + ppl = ppl.limit(options.getLimit()); + } else { + if (options.getFieldOrders().isEmpty()) { + throw new IllegalStateException( + "limitToLast() queries require specifying at least one orderBy() clause"); + } + + List reversedOrderings = new ArrayList<>(); + for (Ordering ordering : orderings) { + reversedOrderings.add(reverseOrdering(ordering)); + } + ppl = ppl.sort(reversedOrderings.toArray(new Ordering[0])); + ppl = ppl.limit(options.getLimit()); + ppl = ppl.sort(orderings.toArray(new Ordering[0])); + } + } else { + ppl = ppl.sort(orderings.toArray(new Ordering[0])); + } + + return ppl; + } + + private static Ordering reverseOrdering(Ordering ordering) { + if (ordering.getDir() == Ordering.Direction.ASCENDING) { + return ordering.getExpr().descending(); + } else { + return ordering.getExpr().ascending(); + } + } + + private static BooleanExpression getCursorExclusiveCondition( + boolean isStart, Ordering ordering, Value value) { + if (isStart && ordering.getDir() == Ordering.Direction.ASCENDING + || !isStart && ordering.getDir() == Ordering.Direction.DESCENDING) { + return ordering.getExpr().greaterThan(value); + } else { + return ordering.getExpr().lessThan(value); + } + } + + private static BooleanExpression whereConditionsFromCursor( + Cursor bound, List orderings, boolean isStart) { + List boundPosition = bound.getValuesList(); + int size = boundPosition.size(); + if (size > orderings.size()) { + throw new IllegalArgumentException("Bound positions must not exceed order fields."); + } + + int last = size - 1; + BooleanExpression condition = + getCursorExclusiveCondition(isStart, orderings.get(last), boundPosition.get(last)); + if (isBoundInclusive(bound, isStart)) { + condition = + or(condition, Expression.equal(orderings.get(last).getExpr(), boundPosition.get(last))); + } + for (int i = size - 2; i >= 0; i--) { + final Ordering ordering = orderings.get(i); + final Value value = boundPosition.get(i); + condition = + or( + getCursorExclusiveCondition(isStart, ordering, value), + and(ordering.getExpr().equal(value), condition)); + } + return condition; + } + + private static boolean isBoundInclusive(Cursor bound, boolean isStart) { + if (isStart) { + return bound.getBefore(); + } else { + return !bound.getBefore(); + } + } + + /** + * Returns true if this Query is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this Query is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof Query)) { + return false; + } + Query query = (Query) obj; + return Objects.equals(rpcContext, query.rpcContext) && Objects.equals(options, query.options); + } + + @Override + public int hashCode() { + return Objects.hash(rpcContext, options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryDocumentSnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryDocumentSnapshot.java new file mode 100644 index 000000000000..ab3442415d41 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryDocumentSnapshot.java @@ -0,0 +1,94 @@ +/* + * Copyright 2018 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.Timestamp; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.Value; +import java.util.Map; +import javax.annotation.Nonnull; + +/** + * A QueryDocumentSnapshot contains data read from a document in a Firestore database as part of a + * query. The document is guaranteed to exist and its data can be extracted using the {@link + * #getData()} or {@link #get(String)} methods. + * + *

QueryDocumentSnapshot offers the same API surface as {@link DocumentSnapshot}. Since query + * results contain only existing documents, the {@link #exists()} method will always return true and + * {@code getData()} will never be null. + * + *

Subclassing Note: Firestore classes are not meant to be subclassed except for use in + * test mocks. Subclassing is not supported in production code and new SDK releases may break code + * that does so. + */ +@InternalExtensionOnly +public class QueryDocumentSnapshot extends DocumentSnapshot { + QueryDocumentSnapshot( + FirestoreRpcContext rpcContext, + DocumentReference docRef, + Map fields, + Timestamp readTime, + Timestamp updateTime, + Timestamp createTime) { // Elevated access level for mocking. + super(rpcContext, docRef, fields, readTime, updateTime, createTime); + } + + static QueryDocumentSnapshot fromDocument( + FirestoreRpcContext rpcContext, Timestamp readTime, Document document) { + return new QueryDocumentSnapshot( + rpcContext, + new DocumentReference(rpcContext, ResourcePath.create(document.getName())), + document.getFieldsMap(), + readTime, + Timestamp.fromProto(document.getUpdateTime()), + Timestamp.fromProto(document.getCreateTime())); + } + + /** + * Returns the fields of the document as a Map. Field values will be converted to their native + * Java representation. + * + * @return The fields of the document as a Map. + */ + @Nonnull + @Override + public Map getData() { + Map result = super.getData(); + Preconditions.checkNotNull(result, "Data in a QueryDocumentSnapshot should be non-null"); + return result; + } + + /** + * Returns the contents of the document converted to a POJO. + * + * @param valueType The Java class to create + * @return The contents of the document in an object of type T + */ + @Nonnull + @Override + public T toObject(@Nonnull Class valueType) { + T result = super.toObject(valueType); + Preconditions.checkNotNull(result, "Object in a QueryDocumentSnapshot should be non-null"); + return result; + } + + static int compareDocumentId(QueryDocumentSnapshot doc1, QueryDocumentSnapshot doc2) { + return doc1.getReference().getResourcePath().compareTo(doc2.getReference().getResourcePath()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryPartition.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryPartition.java new file mode 100644 index 000000000000..b87f625c4304 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QueryPartition.java @@ -0,0 +1,97 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import java.util.Arrays; +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * A split point that can be used in a query as a starting and/or end point for the query results. + * The cursors returned by {@link #getStartAt()} and {@link #getEndBefore()} can only be used in a + * query that matches the constraint of query that produced this partition. + */ +public class QueryPartition { + private final Query query; + @Nullable private final Object[] startAt; + @Nullable private final Object[] endBefore; + + public QueryPartition(Query query, @Nullable Object[] startAt, @Nullable Object[] endBefore) { + this.query = query; + this.startAt = startAt; + this.endBefore = endBefore; + } + + /** + * The cursor that defines the first result for this partition. {@code null} if this is the first + * partition. + * + * @return a cursor value that can be used with {@link Query#startAt(Object...)} or {@code null} + * if this is the first partition. + */ + @Nullable + public Object[] getStartAt() { + return startAt; + } + + /** + * The cursor that defines the first result after this partition. {@code null} if this is the last + * partition. + * + * @return a cursor value that can be used with {@link Query#endBefore(Object...)} or {@code null} + * if this is the last partition. + */ + @Nullable + public Object[] getEndBefore() { + return endBefore; + } + + /** + * Returns a query that only returns the documents for this partition. + * + * @return a query partitioned by a {@link Query#startAt(Object...)} and {@link + * Query#endBefore(Object...)} cursor. + */ + public Query createQuery() { + Query baseQuery = query; + if (startAt != null) { + baseQuery = baseQuery.startAt(startAt); + } + if (endBefore != null) { + baseQuery = baseQuery.endBefore(endBefore); + } + return baseQuery; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof QueryPartition)) return false; + QueryPartition partition = (QueryPartition) o; + return query.equals(partition.query) + && Arrays.equals(startAt, partition.startAt) + && Arrays.equals(endBefore, partition.endBefore); + } + + @Override + public int hashCode() { + int result = Objects.hash(query); + result = 31 * result + Arrays.hashCode(startAt); + result = 31 * result + Arrays.hashCode(endBefore); + return result; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QuerySnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QuerySnapshot.java new file mode 100644 index 000000000000..1b1c0cbf9155 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/QuerySnapshot.java @@ -0,0 +1,53 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import java.util.List; + +/** + * A QuerySnapshot contains the results of a query. It can contain zero or more DocumentSnapshot + * objects. + */ +public class QuerySnapshot extends GenericQuerySnapshot { + protected QuerySnapshot(Query query, Timestamp readTime) { + super(query, readTime, null, null); + } + + protected QuerySnapshot( + Query query, + Timestamp readTime, + final List documents, + final List documentChanges) { + super(query, readTime, documents, documentChanges); + } + + /** Creates a new QuerySnapshot representing the results of a Query with added documents. */ + public static QuerySnapshot withDocuments( + final Query query, Timestamp readTime, final List documents) { + return new QuerySnapshot(query, readTime, documents, null); + } + + /** Creates a new QuerySnapshot representing a snapshot of a Query with changed documents. */ + public static QuerySnapshot withChanges( + final Query query, + Timestamp readTime, + final DocumentSet documentSet, + final List documentChanges) { + return new QuerySnapshot(query, readTime, documentSet.toList(), documentChanges); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RateLimiter.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RateLimiter.java new file mode 100644 index 000000000000..bf0e05dce886 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RateLimiter.java @@ -0,0 +1,158 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.common.base.Preconditions; +import java.util.Date; + +/** + * A helper that uses the Token Bucket algorithm to rate limit the number of operations that can be + * made in a second. + * + *

Before a given request containing a number of operations can proceed, RateLimiter determines + * doing so stays under the provided rate limits. It can also determine how much time is required + * before a request can be made. + * + *

RateLimiter can also implement a gradually increasing rate limit. This is used to enforce the + * 500/50/5 rule. + * + * @see Ramping up + * traffic + */ +class RateLimiter { + private final int initialCapacity; + private final double multiplier; + private final int multiplierMillis; + private final long startTimeMillis; + private final int maximumRate; + + private int availableTokens; + private long lastRefillTimeMillis; + + RateLimiter(int initialCapacity, double multiplier, int multiplierMillis, int maximumRate) { + this(initialCapacity, multiplier, multiplierMillis, maximumRate, new Date().getTime()); + } + + /** + * @param initialCapacity Initial maximum number of operations per second. + * @param multiplier Rate by which to increase the capacity. + * @param multiplierMillis How often the capacity should increase in milliseconds. + * @param maximumRate Maximum number of allowed operations per second. The number of tokens added + * per second will never exceed this number. + * @param startTimeMillis The starting time in epoch milliseconds that the rate limit is based on. + * Used for testing the limiter. + */ + RateLimiter( + int initialCapacity, + double multiplier, + int multiplierMillis, + int maximumRate, + long startTimeMillis) { + this.initialCapacity = initialCapacity; + this.multiplier = multiplier; + this.multiplierMillis = multiplierMillis; + this.maximumRate = maximumRate; + this.startTimeMillis = startTimeMillis; + + this.availableTokens = initialCapacity; + this.lastRefillTimeMillis = startTimeMillis; + } + + public int getInitialCapacity() { + return initialCapacity; + } + + public int getMaximumRate() { + return maximumRate; + } + + public boolean tryMakeRequest(int numOperations) { + return tryMakeRequest(numOperations, new Date().getTime()); + } + + /** + * Tries to make the number of operations. Returns true if the request succeeded and false + * otherwise. + * + * @param requestTimeMillis The time used to calculate the number of available tokens. Used for + * testing the limiter. + */ + public boolean tryMakeRequest(int numOperations, long requestTimeMillis) { + refillTokens(requestTimeMillis); + if (numOperations <= availableTokens) { + availableTokens -= numOperations; + return true; + } + return false; + } + + public long getNextRequestDelayMs(int numOperations) { + return getNextRequestDelayMs(numOperations, new Date().getTime()); + } + + /** + * Returns the number of ms needed to make a request with the provided number of operations. + * Returns 0 if the request can be made with the existing capacity. Returns -1 if the request is + * not possible with the current capacity. + * + * @param requestTimeMillis The time used to calculate the number of available tokens. Used for + * testing the limiter. + */ + public long getNextRequestDelayMs(int numOperations, long requestTimeMillis) { + if (numOperations < availableTokens) { + return 0; + } + + int capacity = calculateCapacity(requestTimeMillis); + if (capacity < numOperations) { + return -1; + } + + int requiredTokens = numOperations - availableTokens; + return (long) Math.ceil((double) (requiredTokens * 1000) / capacity); + } + + /** + * Refills the number of available tokens based on how much time has elapsed since the last time + * the tokens were refilled. + * + * @param requestTimeMillis The time used to calculate the number of available tokens. Used for + * testing the limiter. + */ + private void refillTokens(long requestTimeMillis) { + Preconditions.checkArgument( + requestTimeMillis >= lastRefillTimeMillis, + "Request time should not be before the last token refill time"); + long elapsedTime = requestTimeMillis - lastRefillTimeMillis; + int capacity = calculateCapacity(requestTimeMillis); + int tokensToAdd = (int) ((elapsedTime * capacity) / 1000); + if (tokensToAdd > 0) { + availableTokens = Math.min(capacity, availableTokens + tokensToAdd); + lastRefillTimeMillis = requestTimeMillis; + } + } + + public int calculateCapacity(long requestTimeMillis) { + long millisElapsed = requestTimeMillis - startTimeMillis; + int operationsPerSecond = + Math.min( + (int) + (Math.pow(multiplier, (int) (millisElapsed / multiplierMillis)) * initialCapacity), + maximumRate); + return operationsPerSecond; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ReadTimeTransaction.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ReadTimeTransaction.java new file mode 100644 index 000000000000..4c30caa4d14e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ReadTimeTransaction.java @@ -0,0 +1,267 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.protobuf.Timestamp; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * The ReadTimeTransaction is a ready-only Transaction that specifies a ReadTime. Unlike a + * `ServerSideTransaction`, we do not need a `transactionId` since we provide a `readTime` on all + * requests. No concurrency control is required, since data in the past is immutable. As with all + * `read-only` transactions, we do not allow any write request. + * + * @see Transaction + */ +final class ReadTimeTransaction extends Transaction { + + public static final String WRITE_EXCEPTION_MSG = + "Firestore ready-only transactions do not support writes"; + private final Timestamp readTime; + + ReadTimeTransaction(FirestoreImpl firestore, Timestamp readTime) { + super(firestore); + Preconditions.checkNotNull(readTime, "readTime cannot be null"); + this.readTime = readTime; + } + + @Override + public boolean hasTransactionId() { + return false; + } + + @Nonnull + @Override + public ApiFuture get(@Nonnull DocumentReference documentRef) { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENT, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + ApiFuture result = + ApiFutures.transform( + firestore.getAll( + new DocumentReference[] {documentRef}, /* fieldMask= */ null, readTime), + snapshots -> snapshots.isEmpty() ? null : snapshots.get(0), + MoreExecutors.directExecutor()); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + @Nonnull + @Override + public ApiFuture> getAll( + @Nonnull DocumentReference... documentReferences) { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENTS, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + ApiFuture> result = + firestore.getAll(documentReferences, /* fieldMask= */ null, readTime); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + @Nonnull + @Override + public ApiFuture> getAll( + @Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask) { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENTS, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + ApiFuture> result = + firestore.getAll(documentReferences, /* fieldMask= */ null, readTime); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + @Nonnull + @Override + public ApiFuture get(@Nonnull Query query) { + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return query.get(null, com.google.cloud.Timestamp.fromProto(readTime)); + } + } + + @Nonnull + @Override + public ApiFuture get(@Nonnull AggregateQuery query) { + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return query.get(null, readTime); + } + } + + @Nonnull + @Override + public ApiFuture execute(@Nonnull Pipeline pipeline) { + return execute(pipeline, new PipelineExecuteOptions()); + } + + @Nonnull + @Override + public ApiFuture execute( + @Nonnull Pipeline pipeline, @Nonnull PipelineExecuteOptions options) { + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return pipeline.execute(options, null, readTime); + } + } + + @Nonnull + @Override + public Transaction create( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction create(@Nonnull DocumentReference documentReference, @Nonnull Object pojo) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction set( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction set( + @Nonnull DocumentReference documentReference, + @Nonnull Map fields, + @Nonnull SetOptions options) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction set(@Nonnull DocumentReference documentReference, @Nonnull Object pojo) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction set( + @Nonnull DocumentReference documentReference, + @Nonnull Object pojo, + @Nonnull SetOptions options) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, + @Nonnull Map fields, + Precondition precondition) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, + @Nonnull String field, + @Nullable Object value, + Object... moreFieldsAndValues) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object... moreFieldsAndValues) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, + @Nonnull Precondition precondition, + @Nonnull String field, + @Nullable Object value, + Object... moreFieldsAndValues) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction update( + @Nonnull DocumentReference documentReference, + @Nonnull Precondition precondition, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object... moreFieldsAndValues) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction delete( + @Nonnull DocumentReference documentReference, @Nonnull Precondition precondition) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Nonnull + @Override + public Transaction delete(@Nonnull DocumentReference documentReference) { + throw new IllegalStateException(WRITE_EXCEPTION_MSG); + } + + @Override + public String toString() { + return String.format("%s{readTime=%s}", getClass().getSimpleName(), readTime); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RecursiveDelete.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RecursiveDelete.java new file mode 100644 index 000000000000..eba64e769089 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/RecursiveDelete.java @@ -0,0 +1,327 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiAsyncFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.BetaApi; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.cloud.firestore.Query.QueryOptions; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import io.grpc.Status; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nullable; +import javax.annotation.concurrent.GuardedBy; + +/** + * Class used to store state required for running a recursive delete operation. Each recursive + * delete call should use a new instance of the class. + */ +@BetaApi +public final class RecursiveDelete { + /** + * Datastore allowed numeric IDs where Firestore only allows strings. Numeric IDs are exposed to + * Firestore as __idNUM__, so this is the lowest possible negative numeric value expressed in that + * format. + * + *

This constant is used to specify startAt/endAt values when querying for all descendants in a + * single collection. + */ + public static final String REFERENCE_NAME_MIN_ID = "__id-9223372036854775808__"; + + /** + * The query limit used for recursive deletes when fetching all descendants of the specified + * reference to delete. This is done to prevent the query stream from streaming documents faster + * than Firestore can delete. + */ + public static final int MAX_PENDING_OPS = 5000; + + /** + * The number of pending BulkWriter operations at which RecursiveDelete starts the next limit + * query to fetch descendants. By starting the query while there are pending operations, Firestore + * can improve BulkWriter throughput. This helps prevent BulkWriter from idling while Firestore + * fetches the next query. + */ + public static final int MIN_PENDING_OPS = 1000; + + private final FirestoreRpcContext firestoreRpcContext; + private final BulkWriter writer; + + /** The resource path of the reference to recursively delete */ + private final ResourcePath path; + + /** Lock object for all BulkWriter operations and callbacks. */ + private final Object lock = new Object(); + + /** The number of deletes that failed with a permanent error. */ + @GuardedBy("lock") + private int errorCount = 0; + + /** + * The most recently thrown error. Used to populate the developer-facing error message when the + * recursive delete operation completes. + */ + @GuardedBy("lock") + @Nullable + private Throwable lastError; + + /** Whether there are still documents to delete that still need to be fetched. */ + @GuardedBy("lock") + private boolean documentsPending = true; + + /** A deferred promise that resolves when the recursive delete operation is completed. */ + private final SettableApiFuture completionFuture = SettableApiFuture.create(); + + /** Whether a query stream is currently in progress. Only one stream can be run at a time. */ + @GuardedBy("lock") + private boolean streamInProgress = false; + + /** Whether run() has been called. */ + private boolean started = false; + + /** Query limit to use when fetching all descendants. */ + private final int maxPendingOps; + + /** + * The number of pending BulkWriter operations at which RecursiveDelete starts the next limit + * query to fetch descendants. + */ + private final int minPendingOps; + + /** + * The last document snapshot returned by the stream. Used to set the startAfter() field in the + * subsequent stream. + */ + @Nullable private DocumentSnapshot lastDocumentSnap; + + /** + * The number of pending BulkWriter operations. Used to determine when the next query can be run. + */ + private int pendingOperationsCount = 0; + + RecursiveDelete( + FirestoreRpcContext firestoreRpcContext, + BulkWriter writer, + ResourcePath path, + int maxLimit, + int minLimit) { + this.firestoreRpcContext = firestoreRpcContext; + this.writer = writer; + this.path = path; + this.maxPendingOps = maxLimit; + this.minPendingOps = minLimit; + } + + public ApiFuture run() { + Preconditions.checkState(!started, "RecursiveDelete.run() should only be called once"); + started = true; + + writer.verifyNotClosed(); + + streamDescendants(); + return completionFuture; + } + + private void streamDescendants() { + Query query = getAllDescendantsQuery(); + synchronized (lock) { + streamInProgress = true; + } + final int[] streamedDocsCount = {0}; + final ApiStreamObserver responseObserver = + new ApiStreamObserver() { + public void onNext(DocumentSnapshot snapshot) { + streamedDocsCount[0]++; + lastDocumentSnap = snapshot; + deleteReference(snapshot.getReference()); + } + + public void onError(Throwable throwable) { + String message = "Failed to fetch children documents"; + synchronized (lock) { + lastError = + FirestoreException.forServerRejection(Status.UNAVAILABLE, throwable, message); + } + onQueryEnd(); + } + + public void onCompleted() { + synchronized (lock) { + streamInProgress = false; + } + // If there are fewer than the number of documents specified in the limit() field, we + // know that the query is complete. + if (streamedDocsCount[0] < maxPendingOps) { + onQueryEnd(); + } else if (pendingOperationsCount == 0) { + // Start a new stream if all documents from this stream were deleted before the + // `onCompleted()` handler was called. + streamDescendants(); + } + } + }; + + query.stream(responseObserver); + } + + private Query getAllDescendantsQuery() { + ResourcePath parentPath; + String collectionId; + if (path.isDocument()) { + // The parent is the closest ancestor document to the location we're deleting. Since we are + // deleting a document, the parent is the path of that document. + parentPath = path; + Preconditions.checkState( + path.getParent() != null, "Parent of a document should not be null."); + collectionId = path.getParent().getId(); + } else { + // The parent is the closest ancestor document to the location we're deleting. Since we are + // deleting a collection, the parent is the path of the document containing that collection + // (or the database root, if it is a root collection). + parentPath = path.popLast(); + collectionId = path.getId(); + } + + Query query = + new Query( + firestoreRpcContext, + QueryOptions.builder() + .setParentPath(parentPath) + .setCollectionId(collectionId) + .setAllDescendants(true) + .setKindless(true) + .setRequireConsistency(false) + .build()); + + // Query for names only to fetch empty snapshots. + query = query.select(FieldPath.documentId()).limit(maxPendingOps); + + // To find all descendants of a collection reference, we need to use a + // composite filter that captures all documents that start with the + // collection prefix. The MIN_ID constant represents the minimum key in + // this collection, and a null byte + the MIN_ID represents the minimum + // key is the next possible collection. + if (path.isCollection()) { + char nullChar = '\0'; + String startAt = collectionId + "/" + REFERENCE_NAME_MIN_ID; + String endAt = collectionId + nullChar + "/" + REFERENCE_NAME_MIN_ID; + query = + query + .whereGreaterThanOrEqualTo(FieldPath.documentId(), startAt) + .whereLessThan(FieldPath.documentId(), endAt); + } + + // startAfter() needs to be added after the where() filters since it creates an implicit + // orderBy. + if (lastDocumentSnap != null) { + query = query.startAfter(lastDocumentSnap); + } + + return query; + } + + /** + * Called when all descendants of the provided reference have been streamed or if a permanent + * error occurs during the stream. Deletes the developer provided reference and wraps any errors + * that occurred. + */ + private void onQueryEnd() { + synchronized (lock) { + documentsPending = false; + } + + // Used to aggregate flushFuture and deleteFuture to use with ApiFutures.allAsList(), in order + // to ensure that the delete catchingAsync() callback is run before the flushFuture callback. + List> pendingFutures = new ArrayList<>(); + + // Delete the provided document reference if one was provided. + if (path.isDocument()) { + pendingFutures.add(deleteReference(new DocumentReference(firestoreRpcContext, path))); + } + + pendingFutures.add(writer.flush()); + + // Completes the future returned by run() and sets the exception if an error occurred. + ApiFutures.transformAsync( + ApiFutures.allAsList(pendingFutures), + (ApiAsyncFunction, Void>) + unused -> { + synchronized (lock) { + if (lastError == null) { + completionFuture.set(null); + } else { + String message = + errorCount + + (errorCount != 1 ? " deletes" : " delete") + + " failed. " + + lastError.getMessage(); + if (lastError instanceof FirestoreException) { + lastError = + new FirestoreException( + message, ((FirestoreException) lastError).getStatus()); + } else { + lastError = new Throwable(message, lastError); + } + completionFuture.setException(lastError); + } + return ApiFutures.immediateFuture(null); + } + }, + MoreExecutors.directExecutor()); + } + + /** Deletes the provided reference and starts the next stream if conditions are met. */ + private ApiFuture deleteReference(final DocumentReference reference) { + synchronized (lock) { + pendingOperationsCount++; + } + + ApiFuture catchingDeleteFuture = + ApiFutures.catchingAsync( + writer.delete(reference), + Throwable.class, + e -> { + synchronized (lock) { + errorCount++; + lastError = e; + return ApiFutures.immediateFuture(null); + } + }, + MoreExecutors.directExecutor()); + + return ApiFutures.transformAsync( + catchingDeleteFuture, + result -> { + synchronized (lock) { + pendingOperationsCount--; + // We wait until the previous stream has ended in order to ensure the + // startAfter document is correct. Starting the next stream while + // there are pending operations allows Firestore to maximize + // BulkWriter throughput. + if (documentsPending && !streamInProgress && pendingOperationsCount < minPendingOps) { + streamDescendants(); + } + return ApiFutures.immediateFuture(null); + } + }, + MoreExecutors.directExecutor()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java new file mode 100644 index 000000000000..614a87b63c77 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java @@ -0,0 +1,183 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.DatabaseRootName; +import java.util.Arrays; +import java.util.Comparator; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** An immutable representation of a Firestore path to a Document or Collection. */ +@AutoValue +abstract class ResourcePath extends BasePath { + + /** + * Creates a new Path. + * + * @param databaseName The Firestore database name. + * @param segments The segments of the path relative to the root collections. + */ + static ResourcePath create(DatabaseRootName databaseName, ImmutableList segments) { + return new AutoValue_ResourcePath(segments, databaseName); + } + + /** + * Creates a new Path to the root. + * + * @param databaseName The Firestore database name. + */ + static ResourcePath create(DatabaseRootName databaseName) { + return new AutoValue_ResourcePath(ImmutableList.of(), databaseName); + } + + /** + * Create a new Path from its string representation. + * + * @param resourceName The Firestore resource name of this path. + */ + static ResourcePath create(String resourceName) { + String[] parts = resourceName.split("/"); + + if (parts.length >= 5 && parts[0].equals("projects") && parts[2].equals("databases")) { + String[] path = Arrays.copyOfRange(parts, 5, parts.length); + return create( + DatabaseRootName.of(parts[1], parts[3]), + ImmutableList.builder().add(path).build()); + } + + return create(DatabaseRootName.parse(resourceName)); + } + + /** + * Returns the database name. + * + * @return The Firestore database name. + */ + abstract DatabaseRootName getDatabaseName(); + + /** Returns whether this path points to a document. */ + boolean isDocument() { + int size = getSegments().size(); + return size > 0 && size % 2 == 0; + } + + /** Returns whether this path points to a collection. */ + boolean isCollection() { + return getSegments().size() % 2 == 1; + } + + /** + * The Path's id (last component). + * + * @return The last component of the Path or null if the path points to the root. + */ + @Nullable + String getId() { + ImmutableList parts = getSegments(); + + if (!parts.isEmpty()) { + return parts.get(parts.size() - 1); + } else { + return null; + } + } + + /** + * The Path's name (the location relative to the root of the database). + * + * @return The resource path relative to the root of the database. + */ + String getPath() { + return String.join("/", getSegments()); + } + + /** + * String representation as expected by the Firestore API. + * + * @return The formatted name of the resource. + */ + String getName() { + String path = getPath(); + if (path.isEmpty()) { + return getDatabaseName() + "/documents"; + } else { + return getDatabaseName() + "/documents/" + path; + } + } + + /** + * Compare the current path against another ResourcePath object. + * + * @param other The path to compare to. + * @return -1 if current < other, 1 if current > other, 0 if equal + */ + @Override + public int compareTo(@Nonnull ResourcePath other) { + DatabaseRootName thisDatabaseName = this.getDatabaseName(); + DatabaseRootName otherDatabaseName = other.getDatabaseName(); + + if (thisDatabaseName != otherDatabaseName) { + int cmp = thisDatabaseName.getProject().compareTo(otherDatabaseName.getProject()); + + if (cmp != 0) { + return cmp; + } + + cmp = thisDatabaseName.getDatabase().compareTo(otherDatabaseName.getDatabase()); + + if (cmp != 0) { + return cmp; + } + } + + return super.compareTo(other); + } + + /** + * Pops the last segment from this `ResourcePath` and returns a newly constructed `ResourcePath` + * without the last segment. This does not change the ResourcePath, since `ResourcePath` is + * immutable. + * + * @return The newly created Path. + */ + ResourcePath popLast() { + ImmutableList segments = getSegments(); + return createPathWithSegments(segments.subList(0, segments.size() - 1)); + } + + @Override + public String toString() { + return getName(); + } + + @Override + String[] splitChildPath(String name) { + return name.split("/"); + } + + @Override + ResourcePath createPathWithSegments(ImmutableList segments) { + return create(getDatabaseName(), segments); + } + + public static Comparator comparator() { + return Comparator.naturalOrder(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransaction.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransaction.java new file mode 100644 index 000000000000..1c89b2461e0c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransaction.java @@ -0,0 +1,285 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.cloud.firestore.TransactionOptions.TransactionOptionsType; +import com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.TransactionOptions.ReadOnly; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A `ServerSideTransaction` is a `Transaction` that uses server generated `transactionId` on + * requests. The implementation starts with a `beginTransaction` request that receives a + * `transactionId` from server. The `ServerSideTransactionRunner` must either `commit()` or + * `rollback()` when done. + * + * @see Transaction + * @see ServerSideTransactionRunner + */ +final class ServerSideTransaction extends Transaction { + + private static final Logger LOGGER = Logger.getLogger(ServerSideTransaction.class.getName()); + + private static final String READ_BEFORE_WRITE_ERROR_MSG = + "Firestore transactions require all reads to be executed before all writes"; + + private final FirestoreImpl firestore; + + final ByteString transactionId; + + private ServerSideTransaction(FirestoreImpl firestore, ByteString transactionId) { + super(firestore); + this.firestore = firestore; + this.transactionId = transactionId; + } + + public ByteString getTransactionId() { + return transactionId; + } + + public static ApiFuture begin( + FirestoreImpl firestore, + TransactionOptions transactionOptions, + @Nullable ServerSideTransaction previousTransaction) { + BeginTransactionRequest.Builder beginTransaction = BeginTransactionRequest.newBuilder(); + beginTransaction.setDatabase(firestore.getDatabaseName()); + ByteString previousTransactionId = + previousTransaction != null ? previousTransaction.transactionId : null; + + if (TransactionOptionsType.READ_WRITE.equals(transactionOptions.getType()) + && previousTransactionId != null) { + beginTransaction + .getOptionsBuilder() + .getReadWriteBuilder() + .setRetryTransaction(previousTransactionId); + } else if (TransactionOptionsType.READ_ONLY.equals(transactionOptions.getType())) { + final ReadOnly.Builder readOnlyBuilder = ReadOnly.newBuilder(); + if (transactionOptions.getReadTime() != null) { + readOnlyBuilder.setReadTime(transactionOptions.getReadTime()); + } + beginTransaction.getOptionsBuilder().setReadOnly(readOnlyBuilder); + } + + ApiFuture transactionBeginFuture = + firestore.sendRequest( + beginTransaction.build(), firestore.getClient().beginTransactionCallable()); + + return ApiFutures.transform( + transactionBeginFuture, + beginTransactionResponse -> + new ServerSideTransaction(firestore, beginTransactionResponse.getTransaction()), + MoreExecutors.directExecutor()); + } + + /** Commits a transaction. */ + ApiFuture> commit() { + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return super.commit(transactionId); + } + } + + /** Rolls a transaction back and releases all read locks. */ + ApiFuture rollback() { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_ROLLBACK, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + RollbackRequest req = + RollbackRequest.newBuilder() + .setTransaction(transactionId) + .setDatabase(firestore.getDatabaseName()) + .build(); + + ApiFuture rollbackFuture = + firestore.sendRequest(req, firestore.getClient().rollbackCallable()); + + ApiFuture transform = + ApiFutures.transform(rollbackFuture, resp -> null, MoreExecutors.directExecutor()); + + ApiFuture result = + ApiFutures.catching( + transform, + Throwable.class, + (error) -> { + LOGGER.log( + Level.WARNING, + "Failed best effort to rollback of transaction " + transactionId, + error); + return null; + }, + MoreExecutors.directExecutor()); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + @Override + public boolean hasTransactionId() { + return true; + } + + /** + * Reads the document referred to by the provided DocumentReference. Holds a pessimistic lock on + * the returned document. + * + * @return The contents of the Document at this DocumentReference. + */ + @Override + @Nonnull + public ApiFuture get(@Nonnull DocumentReference documentRef) { + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENT, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG); + ApiFuture result = + ApiFutures.transform( + firestore.getAll( + new DocumentReference[] {documentRef}, + /* fieldMask= */ null, + transactionId, + /* readTime= */ null), + snapshots -> snapshots.isEmpty() ? null : snapshots.get(0), + MoreExecutors.directExecutor()); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + /** + * Retrieves multiple documents from Firestore. Holds a pessimistic lock on all returned + * documents. + * + * @param documentReferences List of Document References to fetch. + */ + @Override + @Nonnull + public ApiFuture> getAll( + @Nonnull DocumentReference... documentReferences) { + Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG); + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENTS, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + ApiFuture> result = + firestore.getAll( + documentReferences, /* fieldMask= */ null, transactionId, /* readTime= */ null); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + /** + * Retrieves multiple documents from Firestore, while optionally applying a field mask to reduce + * the amount of data transmitted from the backend. Holds a pessimistic lock on all returned + * documents. + * + * @param documentReferences Array with Document References to fetch. + * @param fieldMask If set, specifies the subset of fields to return. + */ + @Override + @Nonnull + public ApiFuture> getAll( + @Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask) { + Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG); + TraceUtil.Span span = + getTraceUtil() + .startSpan( + TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENTS, transactionTraceContext); + try (TraceUtil.Scope ignored = span.makeCurrent()) { + ApiFuture> result = + firestore.getAll(documentReferences, fieldMask, transactionId, /* readTime= */ null); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + /** + * Returns the result set from the provided query. Holds a pessimistic lock on all returned + * documents. + * + * @return The contents of the Document at this DocumentReference. + */ + @Override + @Nonnull + public ApiFuture get(@Nonnull Query query) { + Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG); + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return query.get(transactionId, /* readTime= */ null); + } + } + + /** + * Returns the result from the provided aggregate query. Holds a pessimistic lock on all accessed + * documents. + * + * @return The result of the aggregation. + */ + @Override + @Nonnull + public ApiFuture get(@Nonnull AggregateQuery query) { + Preconditions.checkState(isEmpty(), READ_BEFORE_WRITE_ERROR_MSG); + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return query.get(transactionId, null); + } + } + + @Nonnull + @Override + public ApiFuture execute(@Nonnull Pipeline pipeline) { + return execute(pipeline, new PipelineExecuteOptions()); + } + + @Nonnull + @Override + public ApiFuture execute( + @Nonnull Pipeline pipeline, @Nonnull PipelineExecuteOptions options) { + try (TraceUtil.Scope ignored = transactionTraceContext.makeCurrent()) { + return pipeline.execute(new PipelineExecuteOptions(), transactionId, null); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransactionRunner.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransactionRunner.java new file mode 100644 index 000000000000..839d549a595b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ServerSideTransactionRunner.java @@ -0,0 +1,316 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.telemetry.TraceUtil.*; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.core.CurrentMillisClock; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.retrying.ExponentialRetryAlgorithm; +import com.google.api.gax.retrying.TimedAttemptSettings; +import com.google.api.gax.rpc.ApiException; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.telemetry.TraceUtil.Span; +import com.google.common.util.concurrent.MoreExecutors; +import io.grpc.Context; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; + +/** + * Implements backoff and retry semantics for Firestore transactions. + * + *

A TransactionRunner is instantiated with a `userCallback`, a `userCallbackExecutor` and + * `numberOfAttempts`. Upon invoking {@link #run()}, the class invokes the provided callback on the + * specified executor at most `numberOfAttempts` times. {@link #run()} returns an ApiFuture that + * resolves when all retries complete. + * + *

TransactionRunner uses exponential backoff to increase the chance that retries succeed. To + * customize the backoff settings, you can specify custom settings via {@link FirestoreOptions}. + */ +final class ServerSideTransactionRunner { + private final Transaction.AsyncFunction userCallback; + private final FirestoreImpl firestore; + private final ScheduledExecutorService firestoreExecutor; + private final Executor userCallbackExecutor; + private final ExponentialRetryAlgorithm backoffAlgorithm; + private final TransactionOptions transactionOptions; + private TimedAttemptSettings nextBackoffAttempt; + private ServerSideTransaction transaction; + private int attemptsRemaining; + private Span runTransactionSpan; + private TraceUtil.Context runTransactionContext; + private MetricsContext metricsContext; + + /** + * @param firestore The active Firestore instance + * @param userCallback The user provided transaction callback + * @param transactionOptions The options determining which executor the {@code userCallback} is + * run on and whether the transaction is read-write or read-only + */ + ServerSideTransactionRunner( + FirestoreImpl firestore, + Transaction.AsyncFunction userCallback, + TransactionOptions transactionOptions) { + this.transactionOptions = transactionOptions; + this.firestore = firestore; + this.firestoreExecutor = firestore.getClient().getExecutor(); + this.userCallback = userCallback; + this.attemptsRemaining = transactionOptions.getNumberOfAttempts(); + this.userCallbackExecutor = + Context.currentContextExecutor( + transactionOptions.getExecutor() != null + ? transactionOptions.getExecutor() + : this.firestore.getClient().getExecutor()); + + this.backoffAlgorithm = + new ExponentialRetryAlgorithm( + firestore.getOptions().getRetrySettings(), CurrentMillisClock.getDefaultClock()); + this.nextBackoffAttempt = backoffAlgorithm.createFirstAttempt(); + this.metricsContext = + firestore + .getOptions() + .getMetricsUtil() + .createMetricsContext(TelemetryConstants.METHOD_NAME_TRANSACTION_RUN); + } + + @Nonnull + private TraceUtil getTraceUtil() { + return firestore.getOptions().getTraceUtil(); + } + + ApiFuture run() { + ApiFuture result = runInternally(); + metricsContext.recordLatencyAtFuture(MetricType.TRANSACTION_LATENCY, result); + metricsContext.recordCounterAtFuture(MetricType.TRANSACTION_ATTEMPT_COUNT, result); + return result; + } + + ApiFuture runInternally() { + runTransactionSpan = getTraceUtil().startSpan(TelemetryConstants.METHOD_NAME_TRANSACTION_RUN); + runTransactionSpan.setAttribute( + ATTRIBUTE_KEY_TRANSACTION_TYPE, transactionOptions.getType().name()); + runTransactionSpan.setAttribute( + ATTRIBUTE_KEY_ATTEMPTS_ALLOWED, transactionOptions.getNumberOfAttempts()); + runTransactionSpan.setAttribute(ATTRIBUTE_KEY_ATTEMPTS_REMAINING, attemptsRemaining); + try (Scope ignored = runTransactionSpan.makeCurrent()) { + runTransactionContext = getTraceUtil().currentContext(); + --attemptsRemaining; + metricsContext.incrementCounter(); + ApiFuture result = + ApiFutures.catchingAsync( + ApiFutures.transformAsync( + maybeRollback(), this::rollbackCallback, MoreExecutors.directExecutor()), + Throwable.class, + this::restartTransactionCallback, + MoreExecutors.directExecutor()); + runTransactionSpan.endAtFuture(result); + return result; + } catch (Exception error) { + runTransactionSpan.end(error); + throw error; + } + } + + ApiFuture begin() { + TraceUtil.Span span = + getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_TRANSACTION_BEGIN, runTransactionContext); + try (Scope ignored = span.makeCurrent()) { + ServerSideTransaction previousTransaction = this.transaction; + this.transaction = null; + ApiFuture result = + ServerSideTransaction.begin(firestore, transactionOptions, previousTransaction); + result = + ApiFutures.transform( + result, + serverSideTransaction -> { + serverSideTransaction.setTransactionTraceContext(runTransactionContext); + return serverSideTransaction; + }); + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + private ApiFuture maybeRollback() { + return hasTransaction() ? transaction.rollback() : ApiFutures.immediateFuture(null); + } + + private boolean hasTransaction() { + return transaction != null; + } + + /** A callback that invokes the BeginTransaction callback. */ + private ApiFuture rollbackCallback(Void input) { + final SettableApiFuture backoff = SettableApiFuture.create(); + // Add a backoff delay. At first, this is 0. + firestoreExecutor.schedule( + () -> backoff.set(null), + nextBackoffAttempt.getRandomizedRetryDelay().toMillis(), + TimeUnit.MILLISECONDS); + + nextBackoffAttempt = backoffAlgorithm.createNextAttempt(nextBackoffAttempt); + return ApiFutures.transformAsync( + backoff, this::backoffCallback, MoreExecutors.directExecutor()); + } + + /** + * Invokes the user callback on the user callback executor and returns the user-provided result. + */ + private SettableApiFuture invokeUserCallback() { + final SettableApiFuture returnedResult = SettableApiFuture.create(); + + userCallbackExecutor.execute( + () -> { + ApiFuture userCallbackResult; + try { + userCallbackResult = userCallback.updateCallback(transaction); + } catch (Exception e) { + userCallbackResult = ApiFutures.immediateFailedFuture(e); + } + ApiFutures.addCallback( + userCallbackResult, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable t) { + returnedResult.setException(t); + } + + @Override + public void onSuccess(T result) { + returnedResult.set(result); + } + }, + firestoreExecutor); + }); + return returnedResult; + } + + /** A callback that invokes the BeginTransaction callback. */ + private ApiFuture backoffCallback(Void input) { + return ApiFutures.transformAsync( + begin(), this::beginTransactionCallback, MoreExecutors.directExecutor()); + } + + /** + * The callback for the BeginTransaction RPC, which invokes the user callback and handles all + * errors thereafter. + */ + private ApiFuture beginTransactionCallback(ServerSideTransaction serverSideTransaction) { + this.transaction = serverSideTransaction; + return ApiFutures.transformAsync( + invokeUserCallback(), this::userFunctionCallback, MoreExecutors.directExecutor()); + } + + /** + * The callback that is invoked after the user function finishes execution. It invokes the Commit + * RPC. + */ + private ApiFuture userFunctionCallback(T userFunctionResult) { + return ApiFutures.transform( + transaction.commit(), + // The callback that is invoked after the Commit RPC returns. It returns the user result. + input -> userFunctionResult, + MoreExecutors.directExecutor()); + } + + /** A callback that restarts a transaction after an ApiException. It invokes the Rollback RPC. */ + private ApiFuture restartTransactionCallback(Throwable throwable) { + if (!(throwable instanceof ApiException)) { + // This is likely a failure in the user callback. + return rollbackAndReject(throwable); + } + + ApiException apiException = (ApiException) throwable; + if (isRetryableTransactionError(apiException)) { + if (attemptsRemaining > 0) { + getTraceUtil() + .currentSpan() + .addEvent("Initiating transaction retry. Attempts remaining: " + attemptsRemaining); + return runInternally(); + } else { + final FirestoreException firestoreException = + FirestoreException.forApiException( + apiException, "Transaction was cancelled because of too many retries."); + return rollbackAndReject(firestoreException); + } + } else { + final FirestoreException firestoreException = + FirestoreException.forApiException( + apiException, "Transaction failed with non-retryable error"); + return rollbackAndReject(firestoreException); + } + } + + /** Determines whether the provided error is considered retryable. */ + private static boolean isRetryableTransactionError(ApiException exception) { + switch (exception.getStatusCode().getCode()) { + // This list is based on + // https://github.com/firebase/firebase-js-sdk/blob/c822e78b00dd3420dcc749beb2f09a947aa4a344/packages/firestore/src/core/transaction_runner.ts#L112 + case ABORTED: + case CANCELLED: + case UNKNOWN: + case DEADLINE_EXCEEDED: + case INTERNAL: + case UNAVAILABLE: + case UNAUTHENTICATED: + case RESOURCE_EXHAUSTED: + return true; + case INVALID_ARGUMENT: + // The Firestore backend uses "INVALID_ARGUMENT" for transactions IDs that have expired. + // While INVALID_ARGUMENT is generally not retryable, we retry this specific case. + return exception.getMessage().contains("transaction has expired"); + default: + return false; + } + } + + /** Rolls the transaction back and returns the error. */ + private ApiFuture rollbackAndReject(final Throwable throwable) { + final SettableApiFuture failedTransaction = SettableApiFuture.create(); + + if (hasTransaction()) { + // We use `addListener()` since we want to return the original exception regardless of + // whether rollback() succeeds. + transaction + .rollback() + .addListener( + () -> { + runTransactionSpan.end(throwable); + failedTransaction.setException(throwable); + }, + MoreExecutors.directExecutor()); + } else { + runTransactionSpan.end(throwable); + failedTransaction.setException(throwable); + } + + return failedTransaction; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SetOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SetOptions.java new file mode 100644 index 000000000000..64e964cf8142 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SetOptions.java @@ -0,0 +1,165 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.firestore.UserDataConverter.EncodingOptions; +import com.google.common.base.Preconditions; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * An options object that configures the behavior of set() calls. By providing one of the SetOptions + * objects returned by {@link #merge}, {@link #mergeFields} and {@link #mergeFieldPaths}, the set() + * calls in {@link DocumentReference}, {@link WriteBatch} and {@link Transaction} can be configured + * to perform granular merges instead of overwriting the target documents in their entirety. + */ +public final class SetOptions { + + static final SetOptions OVERWRITE = new SetOptions(false, null); + private static final SetOptions MERGE_ALL_FIELDS = new SetOptions(true, null); + + private final boolean merge; + @Nullable private final List fieldMask; + + private SetOptions(boolean merge, @Nullable List fieldMask) { + Preconditions.checkArgument( + fieldMask == null || merge, "Cannot specify a fieldMask for non-merge sets()"); + this.merge = merge; + this.fieldMask = fieldMask; + } + + boolean isMerge() { + return merge; + } + + @Nullable + List getFieldMask() { + return fieldMask; + } + + /** + * Changes the behavior of set() calls to only replace the values specified in its data argument. + * Fields with no corresponding values in the data passed to set() will remain untouched. + */ + @Nonnull + public static SetOptions merge() { + return MERGE_ALL_FIELDS; + } + + /** + * Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that + * is not specified in fieldPaths is ignored and remains untouched. + * + *

It is an error to pass a SetOptions object to a set() call that is missing a value for any + * of the fields specified here. + * + * @param fields The list of fields to merge. Fields can contain dots to reference nested fields + * within the document. + */ + @Nonnull + public static SetOptions mergeFields(List fields) { + List fieldPaths = new ArrayList<>(); + + for (String field : fields) { + fieldPaths.add(FieldPath.fromDotSeparatedString(field)); + } + + return new SetOptions(true, fieldPaths); + } + + /** + * Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that + * is not specified in fieldPaths is ignored and remains untouched. + * + *

It is an error to pass a SetOptions object to a set() call that is missing a value for any + * of the fields specified here. + * + * @param fields The list of fields to merge. Fields can contain dots to reference nested fields + * within the document. + */ + @Nonnull + public static SetOptions mergeFields(String... fields) { + List fieldPaths = new ArrayList<>(); + + for (String field : fields) { + fieldPaths.add(FieldPath.fromDotSeparatedString(field)); + } + + return new SetOptions(true, fieldPaths); + } + + /** + * Changes the behavior of set() calls to only replace the fields under fieldPaths. Any field that + * is not specified in fieldPaths is ignored and remains untouched. + * + *

It is an error to pass a SetOptions object to a set() call that is missing a value for any + * of the fields specified here in its to data argument. + * + * @param fields The list of fields to merge. + */ + @Nonnull + public static SetOptions mergeFieldPaths(List fields) { + return new SetOptions(true, fields); + } + + /** Returns the EncodingOptions to use for a set() call. */ + EncodingOptions getEncodingOptions() { + if (!merge) { + return UserDataConverter.NO_DELETES; + } else if (fieldMask == null) { + return UserDataConverter.ALLOW_ALL_DELETES; + } else { + return new EncodingOptions() { + @Override + public boolean allowDelete(FieldPath fieldPath) { + return fieldMask.contains(fieldPath); + } + + @Override + public boolean allowTransform() { + return true; + } + }; + } + } + + /** + * Returns true if this SetOptions is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this SetOptions is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + SetOptions that = (SetOptions) obj; + return merge == that.merge && Objects.equals(fieldMask, that.fieldMask); + } + + @Override + public int hashCode() { + return Objects.hash(merge, fieldMask); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SilenceableBidiStream.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SilenceableBidiStream.java new file mode 100644 index 000000000000..c0361061b543 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/SilenceableBidiStream.java @@ -0,0 +1,125 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.StreamController; +import java.util.function.Function; +import java.util.logging.Logger; + +/** + * Conditionally pass through callbacks to wrapped `BidiStreamObserver`. + * + *

Due to the asynchronous nature of a stream, there can be a delay between closing a stream and + * the upstream no longer sending responses. Receiving callbacks after closing upstream can have + * undesirable consequences. + * + *

The underlying `ClientStream` can be called through the `SilenceableBidiStream`. Methods such + * as `send()` and `closeSend()` are exposed. + * + *

The `SilenceableBidiStream` wraps a `BidiStreamObserver`. This is helpful for situations where + * the observer should be detached from a stream. Instead of calling the `closeSend()` method, the + * `closeSendAndSilence()` method will silence the stream by preventing further callbacks including + * `onError` and `onComplete`. + * + *

If silenced, the observer could be safely attached to a new stream. This is useful for error + * handling where upstream must be stopped, but a new stream can continue to service the observer. + * In these cases, the old stream cannot be allowed to send more responses, and especially cannot be + * allowed to send `onError` or `onComplete` since that would signal the downstream that the stream + * is finished. + */ +final class SilenceableBidiStream + implements BidiStreamObserver { + private static final Logger LOGGER = Logger.getLogger(SilenceableBidiStream.class.getName()); + + private final ClientStream stream; + private final BidiStreamObserver delegate; + private boolean silence = false; + + SilenceableBidiStream( + BidiStreamObserver responseObserverT, + Function, ClientStream> streamSupplier) { + this.delegate = responseObserverT; + stream = streamSupplier.apply(this); + } + + public boolean isSilenced() { + return silence; + } + + public void send(RequestT request) { + LOGGER.fine(stream::toString); + stream.send(request); + } + + public void closeSend() { + LOGGER.fine(stream::toString); + stream.closeSend(); + } + + public void closeSendAndSilence() { + LOGGER.fine(stream::toString); + silence = true; + stream.closeSend(); + } + + @Override + public void onReady(ClientStream stream) { + if (silence) { + LOGGER.info(() -> String.format("Silenced: %s", stream)); + } else { + delegate.onReady(stream); + } + } + + @Override + public void onStart(StreamController controller) { + if (silence) { + LOGGER.info(() -> String.format("Silenced: %s", stream)); + } else { + delegate.onStart(controller); + } + } + + @Override + public void onResponse(ResponseT response) { + if (silence) { + LOGGER.info(() -> String.format("Silenced: %s", stream)); + } else { + delegate.onResponse(response); + } + } + + @Override + public void onError(Throwable t) { + if (silence) { + LOGGER.info(() -> String.format("Silenced: %s", stream)); + } else { + delegate.onError(t); + } + } + + @Override + public void onComplete() { + if (silence) { + LOGGER.info(() -> String.format("Silenced: %s", stream)); + } else { + delegate.onComplete(); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java new file mode 100644 index 000000000000..6e331af22ebe --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/StreamableQuery.java @@ -0,0 +1,477 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.telemetry.TraceUtil.*; +import static com.google.common.collect.Lists.reverse; + +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamController; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.telemetry.MetricsUtil.MetricsContext; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.cloud.firestore.v1.FirestoreSettings; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.protobuf.ByteString; +import io.grpc.Status; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents a query whose results can be streamed. If the stream fails with a retryable error, + * implementations of StreamableQuery can optionally support retries with a cursor, as indicated by + * `isRetryableWithCursor`. Retrying with a cursor means that the StreamableQuery can be resumed + * where it failed by first calling `startAfter(lastDocumentReceived)`. + */ +@InternalApi +public abstract class StreamableQuery { + final Query.QueryOptions options; + final FirestoreRpcContext rpcContext; + + StreamableQuery(FirestoreRpcContext rpcContext, Query.QueryOptions options) { + this.rpcContext = rpcContext; + this.options = options; + } + + abstract RunQueryRequest.Builder toRunQueryRequestBuilder( + @Nullable final ByteString transactionId, + @Nullable final Timestamp readTime, + @Nullable ExplainOptions explainOptions); + + abstract boolean isRetryableWithCursor(); + + abstract StreamableQuery startAfter(@Nonnull DocumentSnapshot snapshot); + + abstract SnapshotType createSnaphot( + Timestamp readTime, final List documents); + + /** + * Gets the Firestore instance associated with this query. + * + * @return The Firestore instance associated with this query. + */ + @Nonnull + public Firestore getFirestore() { + return rpcContext.getFirestore(); + } + + MetricsContext createMetricsContext(String methodName) { + return getFirestore().getOptions().getMetricsUtil().createMetricsContext(methodName); + } + + /** + * Executes the query and returns the results as QuerySnapshot. + * + * @return An ApiFuture that will be resolved with the results of the Query. + */ + @Nonnull + public abstract ApiFuture get(); + + /** + * Executes the query and returns the results as QuerySnapshot. + * + * @return An ApiFuture that will be resolved with the results of the Query. + */ + ApiFuture get( + @Nullable ByteString transactionId, @Nullable Timestamp requestReadTime) { + TraceUtil.Span span = + getFirestore() + .getOptions() + .getTraceUtil() + .startSpan( + transactionId == null + ? TelemetryConstants.METHOD_NAME_QUERY_GET + : TelemetryConstants.METHOD_NAME_TRANSACTION_GET_QUERY); + + MetricsContext metricsContext = + createMetricsContext( + transactionId != null + ? TelemetryConstants.METHOD_NAME_RUN_QUERY_TRANSACTIONAL + : TelemetryConstants.METHOD_NAME_RUN_QUERY_GET); + + try (Scope ignored = span.makeCurrent()) { + final SettableApiFuture result = SettableApiFuture.create(); + + ApiStreamObserver observer = + new ApiStreamObserver() { + final List documentSnapshots = new ArrayList<>(); + Timestamp responseReadTime; + + @Override + public void onNext(RunQueryResponse runQueryResponse) { + if (runQueryResponse.hasDocument()) { + Document document = runQueryResponse.getDocument(); + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + rpcContext, Timestamp.fromProto(runQueryResponse.getReadTime()), document); + documentSnapshots.add(documentSnapshot); + } + if (responseReadTime == null) { + responseReadTime = Timestamp.fromProto(runQueryResponse.getReadTime()); + } + } + + @Override + public void onError(Throwable throwable) { + result.setException(throwable); + } + + @Override + public void onCompleted() { + // The results for limitToLast queries need to be flipped since we reversed the + // ordering constraints before sending the query to the backend. + List resultView = + Query.LimitType.Last.equals(options.getLimitType()) + ? reverse(documentSnapshots) + : documentSnapshots; + SnapshotType querySnapshot = createSnaphot(responseReadTime, resultView); + result.set(querySnapshot); + } + }; + + internalStream( + new MonitoredStreamResponseObserver(observer, metricsContext), + /* startTimeNanos= */ rpcContext.getClock().nanoTime(), + transactionId, + /* readTime= */ requestReadTime, + /* explainOptions= */ null, + /* isRetryRequestWithCursor= */ false); + + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + /** + * Plans and optionally executes this query. Returns an ApiFuture that will be resolved with the + * planner information, statistics from the query execution (if any), and the query results (if + * any). + * + * @return An ApiFuture that will be resolved with the planner information, statistics from the + * query execution (if any), and the query results (if any). + */ + @Nonnull + public ApiFuture> explain(ExplainOptions options) { + TraceUtil.Span span = + getFirestore() + .getOptions() + .getTraceUtil() + .startSpan(TelemetryConstants.METHOD_NAME_QUERY_GET); + + MetricsContext metricsContext = + createMetricsContext(TelemetryConstants.METHOD_NAME_RUN_QUERY_EXPLAIN); + + try (Scope ignored = span.makeCurrent()) { + final SettableApiFuture> result = SettableApiFuture.create(); + + ApiStreamObserver observer = + new ApiStreamObserver() { + @Nullable List documentSnapshots = null; + Timestamp readTime; + ExplainMetrics metrics; + + @Override + public void onNext(RunQueryResponse runQueryResponse) { + if (runQueryResponse.hasDocument()) { + if (documentSnapshots == null) { + documentSnapshots = new ArrayList<>(); + } + + Document document = runQueryResponse.getDocument(); + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + rpcContext, Timestamp.fromProto(runQueryResponse.getReadTime()), document); + documentSnapshots.add(documentSnapshot); + } + + if (readTime == null) { + readTime = Timestamp.fromProto(runQueryResponse.getReadTime()); + } + + if (runQueryResponse.hasExplainMetrics()) { + metrics = new ExplainMetrics(runQueryResponse.getExplainMetrics()); + if (documentSnapshots == null && metrics.getExecutionStats() != null) { + // This indicates that the query was executed, but no documents + // had matched the query. Create an empty list. + documentSnapshots = Collections.emptyList(); + } + } + } + + @Override + public void onError(Throwable throwable) { + result.setException(throwable); + } + + @Override + public void onCompleted() { + @Nullable SnapshotType snapshot = null; + if (documentSnapshots != null) { + // The results for limitToLast queries need to be flipped since we reversed the + // ordering constraints before sending the query to the backend. + List resultView = + Query.LimitType.Last.equals(StreamableQuery.this.options.getLimitType()) + ? reverse(documentSnapshots) + : documentSnapshots; + snapshot = createSnaphot(readTime, resultView); + } + result.set(new ExplainResults<>(metrics, snapshot)); + } + }; + + internalStream( + new MonitoredStreamResponseObserver(observer, metricsContext), + /* startTimeNanos= */ rpcContext.getClock().nanoTime(), + /* transactionId= */ null, + /* readTime= */ null, + /* explainOptions= */ options, + /* isRetryRequestWithCursor= */ false); + + span.endAtFuture(result); + return result; + } catch (Exception error) { + span.end(error); + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, error); + throw error; + } + } + + class MonitoredStreamResponseObserver implements ApiStreamObserver { + private final ApiStreamObserver observer; + private final MetricsContext metricsContext; + private boolean receivedFirstResponse = false; + + // Constructor to initialize with the delegate and MetricsContext + public MonitoredStreamResponseObserver( + ApiStreamObserver observer, MetricsContext metricsContext) { + this.observer = observer; + this.metricsContext = metricsContext; + } + + @Override + public void onNext(RunQueryResponse value) { + if (!receivedFirstResponse) { + receivedFirstResponse = true; + metricsContext.recordLatency(MetricType.FIRST_RESPONSE_LATENCY); + } + observer.onNext(value); + } + + @Override + public void onError(Throwable t) { + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY, t); + observer.onError(t); + } + + @Override + public void onCompleted() { + metricsContext.recordLatency(MetricType.END_TO_END_LATENCY); + observer.onCompleted(); + } + } + + void internalStream( + final MonitoredStreamResponseObserver streamResponseObserver, + final long startTimeNanos, + @Nullable final ByteString transactionId, + @Nullable final Timestamp readTime, + @Nullable final ExplainOptions explainOptions, + final boolean isRetryRequestWithCursor) { + TraceUtil traceUtil = getFirestore().getOptions().getTraceUtil(); + + // To reduce the size of traces, we only register one event for every 100 responses + // that we receive from the server. + final int NUM_RESPONSES_PER_TRACE_EVENT = 100; + + TraceUtil.Span currentSpan = traceUtil.currentSpan(); + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY, + new ImmutableMap.Builder() + .put(ATTRIBUTE_KEY_IS_TRANSACTIONAL, transactionId != null) + .put(ATTRIBUTE_KEY_IS_RETRY_WITH_CURSOR, isRetryRequestWithCursor) + .build()); + + final AtomicReference lastReceivedDocument = new AtomicReference<>(); + + ResponseObserver observer = + new ResponseObserver() { + Timestamp readTime; + boolean firstResponse = false; + int numDocuments = 0; + + // The stream's `onComplete()` could be called more than once, + // this flag makes sure only the first one is actually processed. + boolean hasCompleted = false; + + @Override + public void onStart(StreamController streamController) {} + + @Override + public void onResponse(RunQueryResponse response) { + if (!firstResponse) { + firstResponse = true; + currentSpan.addEvent(TelemetryConstants.METHOD_NAME_RUN_QUERY + ": First Response"); + } + + streamResponseObserver.onNext(response); + + if (response.hasDocument()) { + numDocuments++; + if (numDocuments % NUM_RESPONSES_PER_TRACE_EVENT == 0) { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY + + ": Received " + + numDocuments + + " documents"); + } + Document document = response.getDocument(); + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + rpcContext, Timestamp.fromProto(response.getReadTime()), document); + lastReceivedDocument.set(documentSnapshot); + } + + if (response.getDone()) { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY + ": Received RunQueryResponse.Done"); + onComplete(); + } + } + + @Override + public void onError(Throwable throwable) { + QueryDocumentSnapshot cursor = lastReceivedDocument.get(); + if (isRetryableWithCursor() && shouldRetry(cursor, throwable)) { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY + ": Retryable Error", + Collections.singletonMap("error.message", throwable.toString())); + + startAfter(cursor) + .internalStream( + streamResponseObserver, + startTimeNanos, + /* transactionId= */ null, + options.getRequireConsistency() ? cursor.getReadTime() : null, + explainOptions, + /* isRetryRequestWithCursor= */ true); + } else { + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY + ": Error", + Collections.singletonMap("error.message", throwable.toString())); + streamResponseObserver.onError(throwable); + } + } + + @Override + public void onComplete() { + if (hasCompleted) return; + hasCompleted = true; + currentSpan.addEvent( + TelemetryConstants.METHOD_NAME_RUN_QUERY + ": Completed", + Collections.singletonMap(ATTRIBUTE_KEY_DOC_COUNT, numDocuments)); + streamResponseObserver.onCompleted(); + } + + boolean shouldRetry(DocumentSnapshot lastDocument, Throwable t) { + if (lastDocument == null) { + // Only retry if we have received a single result. Retries for RPCs with initial + // failure are handled by Google Gax, which also implements backoff. + return false; + } + + // Do not retry EXPLAIN requests because it'd be executing + // multiple queries. This means stats would have to be aggregated, + // and that may not even make sense for many statistics. + if (explainOptions != null) { + return false; + } + + Set retryableCodes = + FirestoreSettings.newBuilder().runQuerySettings().getRetryableCodes(); + return shouldRetryQuery(t, transactionId, startTimeNanos, retryableCodes); + } + }; + + rpcContext.streamRequest( + toRunQueryRequestBuilder(transactionId, readTime, explainOptions).build(), + observer, + rpcContext.getClient().runQueryCallable()); + } + + /** Returns whether a query that failed in the given scenario should be retried. */ + boolean shouldRetryQuery( + Throwable throwable, + @Nullable ByteString transactionId, + long startTimeNanos, + Set retryableCodes) { + if (transactionId != null) { + // Transactional queries are retried via the transaction runner. + return false; + } + + if (!isRetryableError(throwable, retryableCodes)) { + return false; + } + + if (rpcContext.getTotalRequestTimeout().isZero()) { + return true; + } + + Duration duration = Duration.ofNanos(rpcContext.getClock().nanoTime() - startTimeNanos); + return duration.compareTo(rpcContext.getTotalRequestTimeoutDuration()) < 0; + } + + /** Verifies whether the given exception is retryable based on the RunQuery configuration. */ + private boolean isRetryableError(Throwable throwable, Set retryableCodes) { + if (!(throwable instanceof FirestoreException)) { + return false; + } + Status status = ((FirestoreException) throwable).getStatus(); + for (StatusCode.Code code : retryableCodes) { + if (code.equals(StatusCode.Code.valueOf(status.getCode().name()))) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return String.format("%s{options=%s}", getClass().getSimpleName(), options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Transaction.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Transaction.java new file mode 100644 index 000000000000..af7ee6a29464 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Transaction.java @@ -0,0 +1,165 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions; +import com.google.cloud.firestore.telemetry.MetricsUtil; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Context; +import java.util.List; +import java.util.logging.Logger; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A Transaction is passed to a Function to provide the methods to read and write data within the + * transaction context. + * + * @see Firestore#runTransaction(Function) + */ +@InternalExtensionOnly +public abstract class Transaction extends UpdateBuilder { + + private static final Logger LOGGER = Logger.getLogger(Transaction.class.getName()); + private static final String READ_BEFORE_WRITE_ERROR_MSG = + "Firestore transactions require all reads to be executed before all writes"; + protected @Nonnull Context transactionTraceContext; + + protected Transaction(FirestoreImpl firestore) { + super(firestore); + this.transactionTraceContext = firestore.getOptions().getTraceUtil().currentContext(); + } + + @Nonnull + TraceUtil getTraceUtil() { + return firestore.getOptions().getTraceUtil(); + } + + // TODO(Metrics): implement transaction latency and attempt count metrics + @Nonnull + MetricsUtil getMetricsUtil() { + return firestore.getOptions().getMetricsUtil(); + } + + @Nonnull + Context setTransactionTraceContext(Context context) { + return transactionTraceContext = context; + } + + /** + * User callback that takes a Firestore Transaction. + * + * @param The result type of the user callback. + */ + public interface Function { + + T updateCallback(Transaction transaction) throws Exception; + } + + /** + * User callback that takes a Firestore Async Transaction. + * + * @param The result type of the user async callback. + */ + public interface AsyncFunction { + + ApiFuture updateCallback(Transaction transaction); + } + + @Override + protected String className() { + return "Transaction"; + } + + public abstract boolean hasTransactionId(); + + @Override + Transaction wrapResult(int writeIndex) { + return this; + } + + /** + * Reads the document referred to by the provided DocumentReference. Holds a pessimistic lock on + * the returned document. + * + * @return The contents of the Document at this DocumentReference. + */ + @Nonnull + public abstract ApiFuture get(@Nonnull DocumentReference documentRef); + + /** + * Retrieves multiple documents from Firestore. Holds a pessimistic lock on all returned + * documents. + * + * @param documentReferences List of Document References to fetch. + */ + @Nonnull + public abstract ApiFuture> getAll( + @Nonnull DocumentReference... documentReferences); + + /** + * Retrieves multiple documents from Firestore, while optionally applying a field mask to reduce + * the amount of data transmitted from the backend. Holds a pessimistic lock on all returned + * documents. + * + * @param documentReferences Array with Document References to fetch. + * @param fieldMask If set, specifies the subset of fields to return. + */ + @Nonnull + public abstract ApiFuture> getAll( + @Nonnull DocumentReference[] documentReferences, @Nullable FieldMask fieldMask); + + /** + * Returns the result set from the provided query. Holds a pessimistic lock on all returned + * documents. + * + * @return The contents of the Document at this DocumentReference. + */ + @Nonnull + public abstract ApiFuture get(@Nonnull Query query); + + /** + * Returns the result from the provided aggregate query. Holds a pessimistic lock on all accessed + * documents. + * + * @return The result of the aggregation. + */ + @Nonnull + public abstract ApiFuture get(@Nonnull AggregateQuery query); + + /** + * Executes the provided pipeline within the transaction context. + * + * @return The result of the execution. + */ + @Nonnull + @BetaApi + public abstract ApiFuture execute(@Nonnull Pipeline pipeline); + + /** + * Executes the provided pipeline with specified options, within the transaction context. + * + * @return The result of the execution. + */ + @Nonnull + @BetaApi + public abstract ApiFuture execute( + @Nonnull Pipeline pipeline, @Nonnull PipelineExecuteOptions options); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/TransactionOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/TransactionOptions.java new file mode 100644 index 000000000000..3c1575c8ad12 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/TransactionOptions.java @@ -0,0 +1,325 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.InternalExtensionOnly; +import com.google.common.base.Preconditions; +import com.google.protobuf.Timestamp; +import com.google.protobuf.TimestampOrBuilder; +import java.util.concurrent.Executor; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Options specifying the behavior of Firestore Transactions. + * + *

A transaction in Firestore can be either read-write or read-only. + * + *

The default set of options is a read-write transaction with a maximum number of 5 attempts. + * This attempt count can be customized via the {@link + * ReadWriteOptionsBuilder#setNumberOfAttempts(int)} method. A new instance of a builder can be + * created by calling {@link #createReadWriteOptionsBuilder()}. + * + *

A read-only transaction can be configured via the {@link ReadOnlyOptionsBuilder} class. A new + * instance can be created by calling {@link #createReadOnlyOptionsBuilder()}. + * + * @see com.google.firestore.v1.TransactionOptions + */ +public final class TransactionOptions { + + private static final TransactionOptions DEFAULT_READ_WRITE_TRANSACTION_OPTIONS = + createReadWriteOptionsBuilder().build(); + + private static final int DEFAULT_NUM_ATTEMPTS = 5; + + private final Executor executor; + private final TransactionOptionsType type; + private final int numberOfAttempts; + @Nullable private final Timestamp readTime; + + TransactionOptions( + Executor executor, + TransactionOptionsType type, + int numberOfAttempts, + @Nullable Timestamp readTime) { + this.executor = executor; + this.type = type; + this.numberOfAttempts = numberOfAttempts; + this.readTime = readTime; + } + + /** + * Returns the maximum number of times a transaction will be attempted before resulting in an + * error. + * + * @return The max number of attempts to try and commit the transaction. + */ + public int getNumberOfAttempts() { + return numberOfAttempts; + } + + /** + * @return Executor to be used to run user callbacks on + */ + @Nullable + public Executor getExecutor() { + return executor; + } + + /** + * A type flag indicating the type of transaction represented. + * + * @return The type of transaction this represents. Either read-only or read-write. + */ + @Nonnull + public TransactionOptionsType getType() { + return type; + } + + /** + * A {@link Timestamp} specifying the time documents are to be read at. If null, the server will + * read documents at the most up to date available. If non-null, the specified {@code Timestamp} + * may not be more than 60 minutes in the past (evaluated when the request is processed by the + * server). + * + * @return The specific time to read documents at. A null value means reading the most up to date + * data. + */ + @Nullable + public Timestamp getReadTime() { + // This if statement is not strictly necessary, however is kept here for clarity sake to show + // that readTime is only applicable to a read-only transaction type. + if (TransactionOptionsType.READ_ONLY.equals(type)) { + return readTime; + } else { + return null; + } + } + + /** + * Create a default set of options suitable for most use cases. Transactions will be opened as + * ReadWrite transactions and attempted up to 5 times. + * + * @return The TransactionOptions object. + * @see #createReadWriteOptionsBuilder() + */ + @Nonnull + public static TransactionOptions create() { + return DEFAULT_READ_WRITE_TRANSACTION_OPTIONS; + } + + /** + * Create a default set of options with a custom number of retry attempts. + * + * @param numberOfAttempts The number of execution attempts. + * @return The TransactionOptions object. + * @deprecated as of 2.0.0, replaced by {@link ReadWriteOptionsBuilder#setNumberOfAttempts(int)} + * @see #createReadWriteOptionsBuilder() + */ + @Nonnull + @Deprecated + public static TransactionOptions create(int numberOfAttempts) { + return createReadWriteOptionsBuilder().setNumberOfAttempts(numberOfAttempts).build(); + } + + /** + * Create a default set of options with a custom executor. + * + * @param executor The executor to run the user callback code on. + * @return The TransactionOptions object. + * @deprecated as of 2.0.0, replaced by {@link ReadWriteOptionsBuilder#setExecutor(Executor)} + * @see #createReadWriteOptionsBuilder() + */ + @Nonnull + @Deprecated + public static TransactionOptions create(@Nullable Executor executor) { + return createReadWriteOptionsBuilder().setExecutor(executor).build(); + } + + /** + * Create a default set of options with a custom executor and a custom number of retry attempts. + * + * @param executor The executor to run the user callback code on. + * @param numberOfAttempts The number of execution attempts. + * @return The TransactionOptions object. + * @deprecated as of 2.0.0, replaced by {@link ReadWriteOptionsBuilder#setExecutor(Executor)} and + * {@link ReadWriteOptionsBuilder#setNumberOfAttempts(int)} + * @see #createReadWriteOptionsBuilder() + */ + @Nonnull + @Deprecated + public static TransactionOptions create(@Nullable Executor executor, int numberOfAttempts) { + return createReadWriteOptionsBuilder() + .setExecutor(executor) + .setNumberOfAttempts(numberOfAttempts) + .build(); + } + + /** + * @return a new Builder with default values applicable to configuring options for a read-write + * transaction. + */ + @Nonnull + public static ReadWriteOptionsBuilder createReadWriteOptionsBuilder() { + return new ReadWriteOptionsBuilder(null, DEFAULT_NUM_ATTEMPTS); + } + + /** + * @return a new Builder with default values applicable to configuring options for a read-only + * transaction. + */ + @Nonnull + public static ReadOnlyOptionsBuilder createReadOnlyOptionsBuilder() { + return new ReadOnlyOptionsBuilder(null, null); + } + + @InternalExtensionOnly + public abstract static class Builder> { + @Nullable protected Executor executor; + + protected Builder(@Nullable Executor executor) { + this.executor = executor; + } + + /** + * @return The {@link Executor} user callbacks will execute on, If null, the default executor + * will be used. + */ + @Nullable + public Executor getExecutor() { + return executor; + } + + /** + * @param executor The {@link Executor} user callbacks will executed on. If null, the default + * executor will be used. + * @return {@code this} builder + */ + @Nonnull + @SuppressWarnings("unchecked") + public B setExecutor(@Nullable Executor executor) { + this.executor = executor; + return (B) this; + } + + /** + * @return an instance of {@link TransactionOptions} from the values passed to this builder + */ + @Nonnull + public abstract TransactionOptions build(); + } + + /** + * A typesafe builder class representing those options that are applicable when configuring a + * transaction to be read-only. All methods function as "set" rather than returning a new copy + * with a value set on it. + */ + public static final class ReadOnlyOptionsBuilder extends Builder { + @Nullable private TimestampOrBuilder readTime; + + private ReadOnlyOptionsBuilder(@Nullable Executor executor, @Nullable Timestamp readTime) { + super(executor); + this.readTime = readTime; + } + + /** + * @return the currently set value that will be used as the readTime. + */ + @Nullable + public TimestampOrBuilder getReadTime() { + return readTime; + } + + /** + * Specify to read documents at the given time. This may not be more than 60 minutes in the past + * from when the request is processed by the server. + * + * @param readTime The specific time to read documents at. Must not be older than 60 minutes. A + * null value means read most up to date data. + * @return {@code this} builder + */ + @Nonnull + public ReadOnlyOptionsBuilder setReadTime(@Nullable TimestampOrBuilder readTime) { + this.readTime = readTime; + return this; + } + + @Nonnull + @Override + public TransactionOptions build() { + final Timestamp timestamp; + if (readTime != null && readTime instanceof Timestamp.Builder) { + timestamp = ((Timestamp.Builder) readTime).build(); + } else { + timestamp = (Timestamp) readTime; + } + return new TransactionOptions(executor, TransactionOptionsType.READ_ONLY, 1, timestamp); + } + } + + /** + * A typesafe builder class representing those options that are applicable when configuring a + * transaction to be read-write. All methods function as "set" rather than returning a new copy + * with a value set on it. By default, a read-write transaction will be attempted a max of 5 + * times. + */ + public static final class ReadWriteOptionsBuilder extends Builder { + private int numberOfAttempts; + + private ReadWriteOptionsBuilder(@Nullable Executor executor, int numberOfAttempts) { + super(executor); + this.numberOfAttempts = numberOfAttempts; + } + + /** + * Specify the max number of attempts a transaction will be attempted before resulting in an + * error. + * + * @return The max number of attempts to try and commit the transaction. + */ + public int getNumberOfAttempts() { + return numberOfAttempts; + } + + /** + * Specify the max number of attempts a transaction will be attempted before resulting in an + * error. + * + * @param numberOfAttempts The max number of attempts to try and commit the transaction. + * @return {@code this} builder + * @throws IllegalArgumentException if numberOfAttempts is less than or equal to 0 + */ + @Nonnull + public ReadWriteOptionsBuilder setNumberOfAttempts(int numberOfAttempts) { + Preconditions.checkArgument(numberOfAttempts > 0, "You must allow at least one attempt"); + this.numberOfAttempts = numberOfAttempts; + return this; + } + + @Nonnull + @Override + public TransactionOptions build() { + return new TransactionOptions( + executor, TransactionOptionsType.READ_WRITE, numberOfAttempts, null); + } + } + + public enum TransactionOptionsType { + READ_ONLY, + READ_WRITE + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UpdateBuilder.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UpdateBuilder.java new file mode 100644 index 000000000000..cfa852ce4cfc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UpdateBuilder.java @@ -0,0 +1,706 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_DOC_COUNT; +import static com.google.cloud.firestore.telemetry.TraceUtil.ATTRIBUTE_KEY_IS_TRANSACTIONAL; +import static com.google.common.base.Predicates.not; +import static java.util.stream.Collectors.toCollection; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.firestore.UserDataConverter.EncodingOptions; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.telemetry.TelemetryConstants; +import com.google.cloud.firestore.telemetry.TraceUtil; +import com.google.cloud.firestore.telemetry.TraceUtil.Scope; +import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.Write; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Abstract class that collects and bundles all write operations for {@link Transaction} and {@link + * WriteBatch}. + */ +@InternalExtensionOnly +public abstract class UpdateBuilder { + static final class WriteOperation { + final Write write; + final DocumentReference documentReference; + + WriteOperation(DocumentReference documentReference, Write write) { + this.documentReference = documentReference; + this.write = write; + } + + @Override + public String toString() { + return String.format("WriteOperation{write=%s, doc=%s}", write, documentReference); + } + } + + final FirestoreImpl firestore; + + // All reads and writes on `writes` must be done in a block that is synchronized on `writes`; + // otherwise, you get undefined behavior. + private final List writes = new ArrayList<>(); + + protected volatile boolean committed; + + UpdateBuilder(FirestoreImpl firestore) { + this.firestore = firestore; + } + + /** + * Wraps the result of the write operation before it is returned. + * + *

This method is used to generate the return value for all public methods. It allows + * operations on Transaction and WriteBatch to return the object for chaining, while also allowing + * BulkWriter operations to return the future directly. + */ + abstract T wrapResult(int writeIndex); + + /** + * Turns a field map that contains field paths into a nested map. Turns {a.b : c} into {a : {b : + * c}}. + */ + private static Map expandObject(Map data) { + if (data instanceof SortedMap) { + return expandObject((SortedMap) data); + } else { + return expandObject(new TreeMap<>(data)); + } + } + + private static Map expandObject(SortedMap data) { + Map result = new HashMap<>(); + + FieldPath lastField = null; + + for (Entry entry : data.entrySet()) { + FieldPath field = entry.getKey(); + if (lastField != null && lastField.isPrefixOf(field)) { + throw new IllegalArgumentException( + String.format("Detected ambiguous definition for field '%s'.", lastField)); + } + + Iterator iterator = field.getSegments().iterator(); + if (iterator.hasNext()) { + String segment = iterator.next(); + Map currentMap = result; + while (iterator.hasNext()) { + currentMap = + (Map) currentMap.computeIfAbsent(segment, key -> new HashMap<>()); + segment = iterator.next(); + } + currentMap.put(segment, entry.getValue()); + } + + lastField = field; + } + + return result; + } + + /** + * Creates a new Document at the DocumentReference's location. It fails the write if the document + * exists. + * + * @param documentReference The DocumentReference to create. + * @param fields A map of the fields and values for the document. + * @return The instance for chaining. + */ + @Nonnull + public T create( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + return performCreate(documentReference, fields); + } + + private T performCreate( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + DocumentSnapshot documentSnapshot = + DocumentSnapshot.fromObject( + firestore, documentReference, fields, UserDataConverter.NO_DELETES); + DocumentTransform documentTransform = + DocumentTransform.fromFieldPathMap(convertToFieldPaths(fields)); + + Write.Builder write = documentSnapshot.toPb(); + write.setCurrentDocument(Precondition.exists(false).toPb()); + + if (!documentTransform.isEmpty()) { + write.addAllUpdateTransforms(documentTransform.toPb()); + } + + return addWrite(documentReference, write); + } + + /** + * Creates a new Document at the DocumentReference location. It fails the write if the document + * exists. + * + * @param documentReference The DocumentReference to create. + * @param pojo The POJO that will be used to populate the document contents. + * @return The instance for chaining. + */ + @Nonnull + public T create(@Nonnull DocumentReference documentReference, @Nonnull Object pojo) { + Object data = CustomClassMapper.convertToPlainJavaTypes(pojo); + if (!(data instanceof Map)) { + throw FirestoreException.forInvalidArgument( + "Can't set a document's data to an array or primitive"); + } + return performCreate(documentReference, (Map) data); + } + + /** + * Overwrites the document referred to by this DocumentReference. If the document doesn't exist + * yet, it will be created. If a document already exists, it will be overwritten. + * + * @param documentReference The DocumentReference to overwrite. + * @param fields A map of the field paths and values for the document. + * @return The instance for chaining. + */ + @Nonnull + public T set(@Nonnull DocumentReference documentReference, @Nonnull Map fields) { + return set(documentReference, fields, SetOptions.OVERWRITE); + } + + /** + * Overwrites the document referred to by this DocumentReference. If the document doesn't exist + * yet, it will be created. If you pass {@link SetOptions}, the provided data can be merged into + * an existing document. + * + * @param documentReference The DocumentReference to overwrite. + * @param fields A map of the field paths and values for the document. + * @param options An object to configure the set behavior. + * @return The instance for chaining. + */ + @Nonnull + public T set( + @Nonnull DocumentReference documentReference, + @Nonnull Map fields, + @Nonnull SetOptions options) { + return performSet(documentReference, fields, options); + } + + /** + * Overwrites the document referred to by this DocumentReference. If the document doesn't exist + * yet, it will be created. If a document already exists, it will be overwritten. + * + * @param documentReference The DocumentReference to overwrite. + * @param pojo The POJO that will be used to populate the document contents. + * @return The instance for chaining. + */ + @Nonnull + public T set(@Nonnull DocumentReference documentReference, @Nonnull Object pojo) { + return set(documentReference, pojo, SetOptions.OVERWRITE); + } + + /** + * Overwrites the document referred to by this DocumentReference. If the document doesn't exist + * yet, it will be created. If you pass {@link SetOptions}, the provided data can be merged into + * an existing document. + * + * @param documentReference The DocumentReference to overwrite. + * @param pojo The POJO that will be used to populate the document contents. + * @param options An object to configure the set behavior. + * @return The instance for chaining. + */ + @Nonnull + public T set( + @Nonnull DocumentReference documentReference, + @Nonnull Object pojo, + @Nonnull SetOptions options) { + Object data = CustomClassMapper.convertToPlainJavaTypes(pojo); + if (!(data instanceof Map)) { + throw new IllegalArgumentException("Can't set a document's data to an array or primitive"); + } + return performSet(documentReference, (Map) data, options); + } + + private T performSet( + @Nonnull DocumentReference documentReference, + @Nonnull Map fields, + @Nonnull SetOptions options) { + Map documentData; + + if (options.getFieldMask() != null) { + documentData = applyFieldMask(fields, options.getFieldMask()); + } else { + documentData = convertToFieldPaths(fields); + } + + DocumentSnapshot documentSnapshot = + DocumentSnapshot.fromObject( + firestore, documentReference, expandObject(documentData), options.getEncodingOptions()); + FieldMask documentMask = FieldMask.EMPTY_MASK; + DocumentTransform documentTransform = DocumentTransform.fromFieldPathMap(documentData); + + if (options.getFieldMask() != null) { + TreeSet fieldPaths = + options.getFieldMask().stream() + .filter(not(documentTransform.getFields()::contains)) + .collect(toCollection(TreeSet::new)); + documentMask = new FieldMask(fieldPaths); + } else if (options.isMerge()) { + documentMask = FieldMask.fromObject(fields); + } + + Write.Builder write = documentSnapshot.toPb(); + if (!documentTransform.isEmpty()) { + write.addAllUpdateTransforms(documentTransform.toPb()); + } + + if (options.isMerge() || options.getFieldMask() != null) { + write.setUpdateMask(documentMask.toPb()); + } + + return addWrite(documentReference, write); + } + + private T addWrite(DocumentReference documentReference, Write.Builder write) { + WriteOperation operation = new WriteOperation(documentReference, write.build()); + int writeIndex; + synchronized (writes) { + Preconditions.checkState( + !committed, + String.format("Cannot modify a %s that has already been committed.", className())); + writes.add(operation); + writeIndex = writes.size() - 1; + } + return wrapResult(writeIndex); + } + + protected String className() { + return this.getClass().getSimpleName(); + } + + /** Removes all values in 'fields' that are not specified in 'fieldMask'. */ + private static Map applyFieldMask( + Map fields, List fieldMask) { + Set remainingFields = new HashSet<>(fieldMask); + Map filteredData = + applyFieldMask(fields, remainingFields, FieldPath.empty()); + + if (!remainingFields.isEmpty()) { + throw new IllegalArgumentException( + String.format( + "Field masks contains invalid path. No data exist at field '%s'.", + remainingFields.iterator().next())); + } + + return filteredData; + } + + /** + * Strips all values in 'fields' that are not specified in 'fieldMask'. Modifies 'fieldMask' + * inline and removes all matched fields. + */ + private static Map applyFieldMask( + Map fields, Set fieldMask, FieldPath root) { + Map filteredMap = new HashMap<>(); + + for (Entry entry : fields.entrySet()) { + FieldPath currentField = root.append(FieldPath.of(entry.getKey())); + if (fieldMask.remove(currentField)) { + filteredMap.put(currentField, entry.getValue()); + } else if (entry.getValue() instanceof Map) { + filteredMap.putAll( + applyFieldMask((Map) entry.getValue(), fieldMask, currentField)); + } else if (entry.getValue() == FieldValue.DELETE_SENTINEL) { + throw new IllegalArgumentException( + String.format( + "Cannot specify FieldValue.delete() for non-merged field '%s'.", currentField)); + } + } + + return filteredMap; + } + + private static Map convertToFieldPaths(@Nonnull Map fields) { + Map fieldPaths = new HashMap<>(); + fields.forEach((k, v) -> fieldPaths.put(FieldPath.of(k), v)); + return fieldPaths; + } + + private static SortedMap convertToSplitOnDotsFieldPaths( + @Nonnull Map fields) { + SortedMap fieldPaths = new TreeMap<>(); + fields.forEach((k, v) -> fieldPaths.put(FieldPath.fromDotSeparatedString(k), v)); + return fieldPaths; + } + + /** + * Updates fields in the document referred to by this DocumentReference. If the document doesn't + * exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param fields A Map containing the fields and values with which to update the document. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, @Nonnull Map fields) { + return performUpdate( + documentReference, convertToSplitOnDotsFieldPaths(fields), Precondition.exists(true)); + } + + /** + * Updates fields in the document referred to by this DocumentReference. If the document doesn't + * exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param fields A Map containing the fields and values with which to update the document. + * @param precondition Precondition to enforce on this update. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, + @Nonnull Map fields, + Precondition precondition) { + Preconditions.checkArgument( + !Boolean.FALSE.equals(precondition.getExists()), + "Precondition 'exists' cannot have the value 'false' for update() calls."); + return performUpdate(documentReference, convertToSplitOnDotsFieldPaths(fields), precondition); + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param field The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, + @Nonnull String field, + @Nullable Object value, + Object... moreFieldsAndValues) { + return performUpdate( + documentReference, + Precondition.exists(true), + FieldPath.fromDotSeparatedString(field), + value, + moreFieldsAndValues); + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param fieldPath The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object... moreFieldsAndValues) { + return performUpdate( + documentReference, Precondition.exists(true), fieldPath, value, moreFieldsAndValues); + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param precondition Precondition to enforce on this update. + * @param field The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, + @Nonnull Precondition precondition, + @Nonnull String field, + @Nullable Object value, + Object... moreFieldsAndValues) { + Preconditions.checkArgument( + !Boolean.FALSE.equals(precondition.getExists()), + "Precondition 'exists' cannot have the value 'false' for update() calls."); + return performUpdate( + documentReference, + precondition, + FieldPath.fromDotSeparatedString(field), + value, + moreFieldsAndValues); + } + + /** + * Updates the fields in the document referred to by this DocumentReference. If the document + * doesn't exist yet, the update will fail. + * + * @param documentReference The DocumentReference to update. + * @param precondition Precondition to enforce on this update. + * @param fieldPath The first field to set. + * @param value The first value to set. + * @param moreFieldsAndValues String and Object pairs with more fields to be set. + * @return The instance for chaining. + */ + @Nonnull + public T update( + @Nonnull DocumentReference documentReference, + @Nonnull Precondition precondition, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object... moreFieldsAndValues) { + Preconditions.checkArgument( + !Boolean.FALSE.equals(precondition.getExists()), + "Precondition 'exists' cannot have the value 'false' for update() calls."); + return performUpdate(documentReference, precondition, fieldPath, value, moreFieldsAndValues); + } + + private T performUpdate( + @Nonnull DocumentReference documentReference, + @Nonnull Precondition precondition, + @Nonnull FieldPath fieldPath, + @Nullable Object value, + Object[] moreFieldsAndValues) { + Object data = CustomClassMapper.convertToPlainJavaTypes(value); + SortedMap fields = new TreeMap<>(); + fields.put(fieldPath, data); + + Preconditions.checkArgument( + moreFieldsAndValues.length % 2 == 0, "moreFieldsAndValues must be key-value pairs."); + for (int i = 0; i < moreFieldsAndValues.length; i += 2) { + Object objectPath = moreFieldsAndValues[i]; + Object objectValue = moreFieldsAndValues[i + 1]; + + FieldPath currentPath; + + if (objectPath instanceof String) { + currentPath = FieldPath.fromDotSeparatedString((String) objectPath); + } else if (objectPath instanceof FieldPath) { + currentPath = (FieldPath) objectPath; + } else { + throw new IllegalArgumentException( + "Field '" + objectPath + "' is not of type String or Field Path."); + } + + if (fields.containsKey(currentPath)) { + throw new IllegalArgumentException( + "Field value for field '" + objectPath + "' was specified multiple times."); + } + + fields.put(currentPath, objectValue); + } + + return performUpdate(documentReference, fields, precondition); + } + + private T performUpdate( + @Nonnull DocumentReference documentReference, + @Nonnull final SortedMap fields, + @Nonnull Precondition precondition) { + Preconditions.checkArgument(!fields.isEmpty(), "Data for update() cannot be empty."); + Map deconstructedMap = expandObject(fields); + DocumentSnapshot documentSnapshot = + DocumentSnapshot.fromObject( + firestore, + documentReference, + deconstructedMap, + new EncodingOptions() { + @Override + public boolean allowDelete(FieldPath fieldPath) { + return fields.containsKey(fieldPath); + } + + @Override + public boolean allowTransform() { + return true; + } + }); + DocumentTransform documentTransform = DocumentTransform.fromFieldPathMap(fields); + TreeSet fieldPaths = + fields.keySet().stream() + .filter(not(documentTransform.getFields()::contains)) + .collect(toCollection(TreeSet::new)); + FieldMask fieldMask = new FieldMask(fieldPaths); + + Write.Builder write = documentSnapshot.toPb(); + write.setCurrentDocument(precondition.toPb()); + write.setUpdateMask(fieldMask.toPb()); + + if (!documentTransform.isEmpty()) { + write.addAllUpdateTransforms(documentTransform.toPb()); + } + + return addWrite(documentReference, write); + } + + /** + * Deletes the document referred to by this DocumentReference. + * + * @param documentReference The DocumentReference to delete. + * @param precondition Precondition for the delete operation. + * @return The instance for chaining. + */ + @Nonnull + public T delete( + @Nonnull DocumentReference documentReference, @Nonnull Precondition precondition) { + return performDelete(documentReference, precondition); + } + + /** + * Deletes the document referred to by this DocumentReference. + * + * @param documentReference The DocumentReference to delete. + * @return The instance for chaining. + */ + @Nonnull + public T delete(@Nonnull DocumentReference documentReference) { + return performDelete(documentReference, Precondition.NONE); + } + + private T performDelete( + @Nonnull DocumentReference documentReference, @Nonnull Precondition precondition) { + Write.Builder write = Write.newBuilder().setDelete(documentReference.getName()); + + if (!precondition.isEmpty()) { + write.setCurrentDocument(precondition.toPb()); + } + + return addWrite(documentReference, write); + } + + /** Commit the current batch. */ + ApiFuture> commit(@Nullable ByteString transactionId) { + TraceUtil.Span span = + firestore + .getOptions() + .getTraceUtil() + .startSpan( + transactionId == null + ? TelemetryConstants.METHOD_NAME_BATCH_COMMIT + : TelemetryConstants.METHOD_NAME_TRANSACTION_COMMIT); + span.setAttribute(ATTRIBUTE_KEY_DOC_COUNT, writes.size()); + span.setAttribute(ATTRIBUTE_KEY_IS_TRANSACTIONAL, transactionId != null); + try (Scope ignored = span.makeCurrent()) { + // Sequence is thread safe. + // + // 1. Set committed = true + // 2. Build commit request + // + // Step 1 sets uses volatile property to ensure committed is visible to all + // threads immediately. + // + // Step 2 uses `forEach(..)` that is synchronized, therefore will be blocked + // until any writes are complete. + // + // Writes will verify `committed==false` within synchronized block of code + // before appending writes. Since committed is set to true before accessing + // writes, we are ensured that no more writes will be appended after commit + // accesses writes. + committed = true; + CommitRequest request = buildCommitRequest(transactionId); + + ApiFuture response = + firestore.sendRequest(request, firestore.getClient().commitCallable()); + + ApiFuture> returnValue = + ApiFutures.transform( + response, + commitResponse -> { + Timestamp commitTime = commitResponse.getCommitTime(); + return commitResponse.getWriteResultsList().stream() + .map(writeResult -> WriteResult.fromProto(writeResult, commitTime)) + .collect(Collectors.toList()); + }, + MoreExecutors.directExecutor()); + span.endAtFuture(returnValue); + return returnValue; + } catch (Exception error) { + span.end(error); + throw error; + } + } + + private CommitRequest buildCommitRequest(ByteString transactionId) { + CommitRequest.Builder builder = CommitRequest.newBuilder(); + builder.setDatabase(firestore.getDatabaseName()); + forEachWrite(builder::addWrites); + if (transactionId != null) { + builder.setTransaction(transactionId); + } + return builder.build(); + } + + /** Checks whether any updates have been queued. */ + boolean isEmpty() { + synchronized (writes) { + return writes.isEmpty(); + } + } + + void forEachWrite(Consumer consumer) { + synchronized (writes) { + for (WriteOperation writeOperation : writes) { + consumer.accept(writeOperation.write); + } + } + } + + /** Get the number of writes. */ + public int getMutationsSize() { + synchronized (writes) { + return writes.size(); + } + } + + @Override + public String toString() { + final String writesAsString; + synchronized (writes) { + writesAsString = writes.toString(); + } + + return String.format( + "%s{writes=%s, committed=%s}", getClass().getSimpleName(), writesAsString, committed); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java new file mode 100644 index 000000000000..23673c348d60 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/UserDataConverter.java @@ -0,0 +1,357 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.aggregateFunctionToValue; +import static com.google.cloud.firestore.pipeline.expressions.FunctionUtils.exprToValue; + +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.pipeline.expressions.AggregateFunction; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.primitives.Doubles; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import com.google.protobuf.NullValue; +import com.google.protobuf.Struct; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +/** Converts user input into the Firestore Value representation. */ +class UserDataConverter { + + static final Value NULL_VALUE = Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); + + private static final Logger LOGGER = Logger.getLogger(UserDataConverter.class.getName()); + + /** Controls the behavior for field deletes. */ + interface EncodingOptions { + /** Returns whether a field delete at `fieldPath` is allowed. */ + boolean allowDelete(FieldPath fieldPath); + + /** Returns whether a field transform (server timestamp, array ops) is allowed. */ + boolean allowTransform(); + } + + /** Rejects all field deletes and allows all field transforms */ + static final EncodingOptions NO_DELETES = + new EncodingOptions() { + @Override + public boolean allowDelete(FieldPath fieldPath) { + return false; + } + + @Override + public boolean allowTransform() { + return true; + } + }; + + /** Allows all field deletes and allows all field transforms. */ + static final EncodingOptions ALLOW_ALL_DELETES = + new EncodingOptions() { + @Override + public boolean allowDelete(FieldPath fieldPath) { + return true; + } + + @Override + public boolean allowTransform() { + return true; + } + }; + + /** Rejects all field deletes and any field transform. */ + static final EncodingOptions ARGUMENT = + new EncodingOptions() { + @Override + public boolean allowDelete(FieldPath fieldPath) { + return false; + } + + @Override + public boolean allowTransform() { + return false; + } + }; + + private UserDataConverter() {} + + /** + * Encodes a Java Object to a Firestore Value proto. + * + * @param path path THe field path of the object to encode. + * @param sanitizedObject An Object that has been sanitized by CustomClassMapper and only contains + * valid types. + * @param options Encoding options to use for this value. + * @return The Value proto. + */ + @Nullable + static Value encodeValue( + FieldPath path, @Nullable Object sanitizedObject, EncodingOptions options) { + if (sanitizedObject == FieldValue.DELETE_SENTINEL) { + Preconditions.checkArgument( + options.allowDelete(path), "FieldValue.delete() is not supported at field '%s'.", path); + return null; + } else if (sanitizedObject instanceof FieldValue) { + Preconditions.checkArgument( + options.allowTransform(), + "Cannot use " + + ((FieldValue) sanitizedObject).getMethodName() + + " as an argument at field '%s'.", + path); + return null; + + } else if (sanitizedObject == null) { + return NULL_VALUE; + } else if (sanitizedObject instanceof String) { + return Value.newBuilder().setStringValue((String) sanitizedObject).build(); + } else if (sanitizedObject instanceof Integer) { + return Value.newBuilder().setIntegerValue((Integer) sanitizedObject).build(); + } else if (sanitizedObject instanceof Long) { + return Value.newBuilder().setIntegerValue((Long) sanitizedObject).build(); + } else if (sanitizedObject instanceof Double) { + return Value.newBuilder().setDoubleValue((Double) sanitizedObject).build(); + } else if (sanitizedObject instanceof Float) { + return Value.newBuilder().setDoubleValue((Float) sanitizedObject).build(); + } else if (sanitizedObject instanceof Boolean) { + return Value.newBuilder().setBooleanValue((Boolean) sanitizedObject).build(); + } else if (sanitizedObject instanceof Date) { + Date date = (Date) sanitizedObject; + long epochSeconds = TimeUnit.MILLISECONDS.toSeconds(date.getTime()); + long msOffset = date.getTime() - TimeUnit.SECONDS.toMillis(epochSeconds); + com.google.protobuf.Timestamp.Builder timestampBuilder = + com.google.protobuf.Timestamp.newBuilder(); + timestampBuilder.setSeconds(epochSeconds); + timestampBuilder.setNanos((int) TimeUnit.MILLISECONDS.toNanos(msOffset)); + return Value.newBuilder().setTimestampValue(timestampBuilder.build()).build(); + } else if (sanitizedObject instanceof Timestamp) { + Timestamp timestamp = (Timestamp) sanitizedObject; + return Value.newBuilder().setTimestampValue(timestamp.toProto()).build(); + } else if (sanitizedObject instanceof List) { + ArrayValue.Builder res = ArrayValue.newBuilder(); + int i = 0; + for (Object child : (List) sanitizedObject) { + Value encodedValue = encodeValue(path.append(Integer.toString(i++)), child, options); + if (encodedValue != null) { + res.addValues(encodedValue); + } + } + return Value.newBuilder().setArrayValue(res.build()).build(); + } else if (sanitizedObject instanceof GeoPoint) { + GeoPoint geopoint = (GeoPoint) sanitizedObject; + return Value.newBuilder().setGeoPointValue(geopoint.toProto()).build(); + } else if (sanitizedObject instanceof Blob) { + Blob blob = (Blob) sanitizedObject; + return Value.newBuilder().setBytesValue(blob.toByteString()).build(); + } else if (sanitizedObject instanceof Expression) { + return exprToValue((Expression) sanitizedObject); + } else if (sanitizedObject instanceof AggregateFunction) { + return aggregateFunctionToValue((AggregateFunction) sanitizedObject); + } else if (sanitizedObject instanceof Value) { + return (Value) sanitizedObject; + } else if (sanitizedObject instanceof DocumentReference) { + DocumentReference docRef = (DocumentReference) sanitizedObject; + return Value.newBuilder().setReferenceValue(docRef.getName()).build(); + } else if (sanitizedObject instanceof Map) { + MapValue.Builder res = MapValue.newBuilder(); + Map map = (Map) sanitizedObject; + + for (Map.Entry entry : map.entrySet()) { + Value encodedValue = + encodeValue( + path.append(entry.getKey(), /* splitPath= */ false), entry.getValue(), options); + if (encodedValue != null) { + res.putFields(entry.getKey(), encodedValue); + } + } + + // If we encounter an empty object, we always need to send it to make sure + // the server creates a map entry. + if (map.isEmpty() || res.getFieldsCount() != 0) { + return Value.newBuilder().setMapValue(res.build()).build(); + } else { + // The input map may only have contained field transforms, in which case we don't need to + // send the map. + return null; + } + } else if (sanitizedObject instanceof VectorValue) { + VectorValue vectorValue = (VectorValue) sanitizedObject; + return Value.newBuilder().setMapValue(vectorValue.toProto()).build(); + } + + throw FirestoreException.forInvalidArgument( + "Cannot convert %s to Firestore Value", sanitizedObject); + } + + static MapValue encodeVector(double[] rawVector) { + MapValue.Builder res = MapValue.newBuilder(); + + res.putFields( + MapType.RESERVED_MAP_KEY, + encodeValue( + FieldPath.fromDotSeparatedString(MapType.RESERVED_MAP_KEY), + MapType.RESERVED_MAP_KEY_VECTOR_VALUE, + ARGUMENT)); + res.putFields( + MapType.VECTOR_MAP_VECTORS_KEY, + encodeValue( + FieldPath.fromDotSeparatedString(MapType.RESERVED_MAP_KEY_VECTOR_VALUE), + Doubles.asList(rawVector), + ARGUMENT)); + + return res.build(); + } + + static Object decodeValue(FirestoreRpcContext rpcContext, Value v) { + Value.ValueTypeCase typeCase = v.getValueTypeCase(); + switch (typeCase) { + case NULL_VALUE: + return null; + case BOOLEAN_VALUE: + return v.getBooleanValue(); + case INTEGER_VALUE: + return v.getIntegerValue(); + case DOUBLE_VALUE: + return v.getDoubleValue(); + case TIMESTAMP_VALUE: + return Timestamp.fromProto(v.getTimestampValue()); + case STRING_VALUE: + return v.getStringValue(); + case BYTES_VALUE: + return Blob.fromByteString(v.getBytesValue()); + case REFERENCE_VALUE: + String pathName = v.getReferenceValue(); + return new DocumentReference(rpcContext, ResourcePath.create(pathName)); + case GEO_POINT_VALUE: + return new GeoPoint( + v.getGeoPointValue().getLatitude(), v.getGeoPointValue().getLongitude()); + case ARRAY_VALUE: + List list = new ArrayList<>(); + List lv = v.getArrayValue().getValuesList(); + for (Value iv : lv) { + list.add(decodeValue(rpcContext, iv)); + } + return list; + case MAP_VALUE: + return decodeMap(rpcContext, v.getMapValue()); + default: + throw FirestoreException.forInvalidArgument( + String.format("Unknown Value Type: %s", typeCase)); + } + } + + static Object decodeMap(FirestoreRpcContext rpcContext, MapValue mapValue) { + MapRepresentation mapRepresentation = detectMapRepresentation(mapValue); + Map inputMap = mapValue.getFieldsMap(); + switch (mapRepresentation) { + case UNKNOWN: + LOGGER.warning( + "Parsing unknown map type as generic map. This map type may be supported in a newer SDK" + + " version."); + case NONE: + Map outputMap = new HashMap<>(); + for (Map.Entry entry : inputMap.entrySet()) { + outputMap.put(entry.getKey(), decodeValue(rpcContext, entry.getValue())); + } + return outputMap; + case VECTOR_VALUE: + double[] values = + inputMap.get(MapType.VECTOR_MAP_VECTORS_KEY).getArrayValue().getValuesList().stream() + .mapToDouble(val -> val.getDoubleValue()) + .toArray(); + return new VectorValue(values); + default: + throw FirestoreException.forInvalidArgument( + String.format("Unsupported MapRepresentation: %s", mapRepresentation)); + } + } + + /** Indicates the data type represented by a MapValue. */ + enum MapRepresentation { + /** The MapValue represents an unknown data type. */ + UNKNOWN, + /** The MapValue does not represent any special data type. */ + NONE, + /** The MapValue represents a VectorValue. */ + VECTOR_VALUE + } + + static MapRepresentation detectMapRepresentation(MapValue mapValue) { + Map fields = mapValue.getFieldsMap(); + if (!fields.containsKey(MapType.RESERVED_MAP_KEY)) { + return MapRepresentation.NONE; + } + + Value typeValue = fields.get(MapType.RESERVED_MAP_KEY); + if (typeValue.getValueTypeCase() != Value.ValueTypeCase.STRING_VALUE) { + LOGGER.warning( + "Unable to parse __type__ field of map. Unsupported value type: " + + typeValue.getValueTypeCase().toString()); + return MapRepresentation.UNKNOWN; + } + + String typeString = typeValue.getStringValue(); + + if (typeString.equals(MapType.RESERVED_MAP_KEY_VECTOR_VALUE)) { + return MapRepresentation.VECTOR_VALUE; + } + + LOGGER.warning("Unsupported __type__ value for map: " + typeString); + return MapRepresentation.UNKNOWN; + } + + static Object decodeGoogleProtobufValue(com.google.protobuf.Value v) { + switch (v.getKindCase()) { + case NULL_VALUE: + return null; + case BOOL_VALUE: + return v.getBoolValue(); + case NUMBER_VALUE: + return v.getNumberValue(); + case STRING_VALUE: + return v.getStringValue(); + case LIST_VALUE: + return Lists.transform( + v.getListValue().getValuesList(), UserDataConverter::decodeGoogleProtobufValue); + case STRUCT_VALUE: + return Maps.transformValues( + v.getStructValue().getFieldsMap(), UserDataConverter::decodeGoogleProtobufValue); + default: + throw FirestoreException.forInvalidArgument( + String.format("Unknown Value Type: %s", v.getKindCase().getNumber())); + } + } + + static Map decodeStruct(@Nullable Struct struct) { + if (struct == null || struct.getFieldsCount() == 0) { + return Collections.emptyMap(); + } + return Maps.transformValues( + struct.getFieldsMap(), UserDataConverter::decodeGoogleProtobufValue); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuery.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuery.java new file mode 100644 index 000000000000..205836a24388 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuery.java @@ -0,0 +1,201 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.cloud.Timestamp; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.StructuredQuery; +import com.google.protobuf.ByteString; +import java.util.List; +import java.util.Objects; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A query that finds the documents whose vector fields are closest to a certain query vector. + * Create an instance of `VectorQuery` with {@link Query#findNearest}. + */ +public final class VectorQuery extends StreamableQuery { + final Query query; + final FieldPath vectorField; + final VectorValue queryVector; + final int limit; + final DistanceMeasure distanceMeasure; + final VectorQueryOptions options; + + /** Creates a VectorQuery */ + VectorQuery( + Query query, + FieldPath vectorField, + VectorValue queryVector, + int limit, + DistanceMeasure distanceMeasure, + VectorQueryOptions options) { + super(query.rpcContext, query.options); + + this.query = query; + this.options = options; + this.vectorField = vectorField; + this.queryVector = queryVector; + this.limit = limit; + this.distanceMeasure = distanceMeasure; + } + + /** + * Executes the query and returns the results as {@link QuerySnapshot}. + * + * @return An ApiFuture that will be resolved with the results of the VectorQuery. + */ + @Override + @Nonnull + public ApiFuture get() { + return get(null, null); + } + + /** + * Plans and optionally executes this VectorQuery. Returns an ApiFuture that will be resolved with + * the planner information, statistics from the query execution (if any), and the query results + * (if any). + * + * @return An ApiFuture that will be resolved with the planner information, statistics from the + * query execution (if any), and the query results (if any). + */ + @Override + @Nonnull + public ApiFuture> explain(ExplainOptions options) { + return super.explain(options); + } + + /** + * Returns true if this VectorQuery is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this VectorQuery is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof VectorQuery)) { + return false; + } + VectorQuery otherQuery = (VectorQuery) obj; + return Objects.equals(query, otherQuery.query) + && Objects.equals(vectorField, otherQuery.vectorField) + && Objects.equals(queryVector, otherQuery.queryVector) + && Objects.equals(options, otherQuery.options) + && limit == otherQuery.limit + && distanceMeasure == otherQuery.distanceMeasure; + } + + @Override + public int hashCode() { + return Objects.hash(query, options, vectorField, queryVector, limit, distanceMeasure); + } + + @Override + protected RunQueryRequest.Builder toRunQueryRequestBuilder( + @Nullable final ByteString transactionId, + @Nullable final Timestamp readTime, + @Nullable ExplainOptions explainOptions) { + + // Builder for the base query + RunQueryRequest.Builder requestBuilder = + query.toRunQueryRequestBuilder(transactionId, readTime, explainOptions); + + // Builder for find nearest + StructuredQuery.FindNearest.Builder findNearestBuilder = + requestBuilder.getStructuredQueryBuilder().getFindNearestBuilder(); + findNearestBuilder.getQueryVectorBuilder().setMapValue(this.queryVector.toProto()); + findNearestBuilder.getLimitBuilder().setValue(this.limit); + findNearestBuilder.setDistanceMeasure(toProto(this.distanceMeasure)); + findNearestBuilder.getVectorFieldBuilder().setFieldPath(this.vectorField.toString()); + + if (this.options != null) { + if (this.options.getDistanceThreshold() != null) { + findNearestBuilder + .getDistanceThresholdBuilder() + .setValue(this.options.getDistanceThreshold().doubleValue()); + } + if (this.options.getDistanceResultField() != null) { + findNearestBuilder.setDistanceResultField(this.options.getDistanceResultField().toString()); + } + } + + return requestBuilder; + } + + private static StructuredQuery.FindNearest.DistanceMeasure toProto( + DistanceMeasure distanceMeasure) { + switch (distanceMeasure) { + case COSINE: + return StructuredQuery.FindNearest.DistanceMeasure.COSINE; + case EUCLIDEAN: + return StructuredQuery.FindNearest.DistanceMeasure.EUCLIDEAN; + case DOT_PRODUCT: + return StructuredQuery.FindNearest.DistanceMeasure.DOT_PRODUCT; + default: + return StructuredQuery.FindNearest.DistanceMeasure.UNRECOGNIZED; + } + } + + @Override + boolean isRetryableWithCursor() { + return false; + } + + @Override + VectorQuery startAfter(@Nonnull DocumentSnapshot snapshot) { + throw new RuntimeException("Not implemented"); + } + + @Override + VectorQuerySnapshot createSnaphot( + Timestamp readTime, final List documents) { + return VectorQuerySnapshot.withDocuments(this, readTime, documents); + } + + @SuppressWarnings("MethodDoesntCallSuperMethod") + @Override + public String toString() { + return String.format( + "VectorQuery{query=%s, vectorField=%s, queryVector=%s, limit=%d, distanceMeasure=%s," + + " options=%s, options=%s}", + query, vectorField, queryVector, limit, distanceMeasure, options, options); + } + + /** + * The distance measure to use when comparing vectors in a {@link VectorQuery}. + * + * @see com.google.cloud.firestore.Query#findNearest + */ + public enum DistanceMeasure { + /** + * COSINE distance compares vectors based on the angle between them, which allows you to measure + * similarity that isn't based on the vectors' magnitude. We recommend using DOT_PRODUCT with + * unit normalized vectors instead of COSINE distance, which is mathematically equivalent with + * better performance. + */ + COSINE, + /** Measures the EUCLIDEAN distance between the vectors. */ + EUCLIDEAN, + /** Similar to cosine but is affected by the magnitude of the vectors. */ + DOT_PRODUCT + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQueryOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQueryOptions.java new file mode 100644 index 000000000000..f06cc94699fa --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQueryOptions.java @@ -0,0 +1,168 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import java.util.Objects; +import javax.annotation.Nullable; + +/** + * Specifies the behavior of the {@link VectorQuery} generated by a call to {@link + * Query#findNearest}. + */ +public class VectorQueryOptions { + private final @Nullable FieldPath distanceResultField; + + private final @Nullable Double distanceThreshold; + + @Nullable + public FieldPath getDistanceResultField() { + return distanceResultField; + } + + @Nullable + public Double getDistanceThreshold() { + return distanceThreshold; + } + + VectorQueryOptions(VectorQueryOptions.Builder builder) { + this.distanceThreshold = builder.distanceThreshold; + this.distanceResultField = builder.distanceResultField; + } + + public static VectorQueryOptions.Builder newBuilder() { + return new VectorQueryOptions.Builder(); + } + + public static final class Builder { + /** + * Returns the name of the field that will be set on each returned DocumentSnapshot, which will + * contain the computed distance for the document. If `null`, then the computed distance will + * not be returned. Default value: `null`. + * + *

Set this value with {@link VectorQueryOptions.Builder#setDistanceResultField(FieldPath)} + * or {@link VectorQueryOptions.Builder#setDistanceResultField(String)}. + */ + private @Nullable FieldPath distanceResultField; + + /** + * Specifies a threshold for which no less similar documents will be returned. If `null`, then + * the computed distance will not be returned. Default value: `null`. + * + *

Set this value with {@link VectorQueryOptions.Builder#setDistanceThreshold(Double)}. + */ + private @Nullable Double distanceThreshold; + + private Builder() { + distanceThreshold = null; + distanceResultField = null; + } + + private Builder(VectorQueryOptions options) { + this.distanceThreshold = options.distanceThreshold; + this.distanceResultField = options.distanceResultField; + } + + /** + * Specifies the name of the field that will be set on each returned DocumentSnapshot, which + * will contain the computed distance for the document. If `null`, then the computed distance + * will not be returned. Default value: `null`. + * + * @param fieldPath A string value specifying the distance result field. + */ + public Builder setDistanceResultField(@Nullable String fieldPath) { + this.distanceResultField = FieldPath.fromDotSeparatedString(fieldPath); + return this; + } + + /** + * Specifies the name of the field that will be set on each returned DocumentSnapshot, which + * will contain the computed distance for the document. If `null`, then the computed distance + * will not be returned. Default value: `null`. + * + * @param fieldPath A {@link FieldPath} value specifying the distance result field. + */ + public Builder setDistanceResultField(@Nullable FieldPath fieldPath) { + this.distanceResultField = fieldPath; + return this; + } + + /** + * Specifies a threshold for which no less similar documents will be returned. The behavior of + * the specified `distanceMeasure` will affect the meaning of the distance threshold. + * + *

+ * + *

    + *
  • For `distanceMeasure: "EUCLIDEAN"`, the meaning of `distanceThreshold` is: {@code + * SELECT docs WHERE euclidean_distance <= distanceThreshold} + *
  • For `distanceMeasure: "COSINE"`, the meaning of `distanceThreshold` is: {@code SELECT + * docs WHERE cosine_distance <= distanceThreshold} + *
  • For `distanceMeasure: "DOT_PRODUCT"`, the meaning of `distanceThreshold` is: {@code + * SELECT docs WHERE dot_product_distance >= distanceThreshold} + *
+ * + *

If `null`, then the computed distance will not be returned. Default value: `null`. + * + * @param distanceThreshold A Double value specifying the distance threshold. + */ + public Builder setDistanceThreshold(@Nullable Double distanceThreshold) { + this.distanceThreshold = distanceThreshold; + return this; + } + + public VectorQueryOptions build() { + return new VectorQueryOptions(this); + } + } + + /** + * Returns true if this VectorQueryOptions is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this VectorQueryOptions is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || !(obj instanceof VectorQueryOptions)) { + return false; + } + VectorQueryOptions otherOptions = (VectorQueryOptions) obj; + return Objects.equals(distanceResultField, otherOptions.distanceResultField) + && Objects.equals(distanceThreshold, otherOptions.distanceThreshold); + } + + @Override + public String toString() { + return String.format( + "VectorQueryOptions{distanceResultField=%s, distanceThreshold=%s}", + distanceResultField, distanceThreshold); + } + + /** Default VectorQueryOptions instance. */ + private static VectorQueryOptions DEFAULT = newBuilder().build(); + + /** + * Returns a default {@code FirestoreOptions} instance. Note: package private until API review can + * be completed. + */ + static VectorQueryOptions getDefaultInstance() { + return DEFAULT; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuerySnapshot.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuerySnapshot.java new file mode 100644 index 000000000000..528512fada65 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorQuerySnapshot.java @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import java.util.List; + +/** + * A VectorQuerySnapshot contains the results of a VectorQuery. It can contain zero or more + * DocumentSnapshot objects. + */ +public class VectorQuerySnapshot extends GenericQuerySnapshot { + protected VectorQuerySnapshot( + VectorQuery query, + Timestamp readTime, + final List documents, + final List documentChanges) { + super(query, readTime, documents, documentChanges); + } + + /** + * Creates a new VectorQuerySnapshot representing the results of a VectorQuery with added + * documents. + */ + public static VectorQuerySnapshot withDocuments( + final VectorQuery query, Timestamp readTime, final List documents) { + return new VectorQuerySnapshot(query, readTime, documents, null); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorValue.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorValue.java new file mode 100644 index 000000000000..aac7dd11eaf2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/VectorValue.java @@ -0,0 +1,84 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.firestore.v1.MapValue; +import java.io.Serializable; +import java.util.Arrays; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Represents a vector in Firestore documents. Create an instance with {@link FieldValue#vector}. + */ +public final class VectorValue implements Serializable { + private final double[] values; + + VectorValue(@Nullable double[] values) { + if (values == null) this.values = new double[] {}; + else this.values = values.clone(); + } + + /** + * Returns a representation of the vector as an array of doubles. + * + * @return A representation of the vector as an array of doubles + */ + @Nonnull + public double[] toArray() { + return this.values.clone(); + } + + /** + * Returns true if this VectorValue is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this VectorValue is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + VectorValue otherArray = (VectorValue) obj; + return Arrays.equals(this.values, otherArray.values); + } + + @Override + public int hashCode() { + return Arrays.hashCode(values); + } + + MapValue toProto() { + return UserDataConverter.encodeVector(this.values); + } + + /** + * Returns the number of dimensions of the vector. Note: package private until API review is done. + */ + int size() { + return this.values.length; + } + + @Override + public String toString() { + return String.format("VectorValue{values=%s}", Arrays.toString(values)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java new file mode 100644 index 000000000000..8b8a1f0d9ea9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Watch.java @@ -0,0 +1,601 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.CurrentMillisClock; +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.retrying.ExponentialRetryAlgorithm; +import com.google.api.gax.retrying.TimedAttemptSettings; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.StreamController; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.DocumentChange.Type; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.Target; +import com.google.firestore.v1.Target.QueryTarget; +import com.google.firestore.v1.TargetChange; +import com.google.protobuf.ByteString; +import io.grpc.Status; +import io.grpc.Status.Code; +import io.grpc.StatusException; +import io.grpc.StatusRuntimeException; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +/** + * Watch provides listen functionality and exposes snapshot listeners. It can be used with any valid + * Firestore Listen target. + * + *

This class is thread-compatible when called through the methods defined in ApiStreamObserver. + * It synchronizes on its own instance so it is advisable not to use this class for external + * synchronization. + */ +final class Watch implements BidiStreamObserver { + private static final Logger LOGGER = Logger.getLogger(Watch.class.getName()); + + /** + * Target ID used by watch. Watch uses a fixed target id since we only support one target per + * stream. The actual target ID we use is arbitrary. + */ + private static final int WATCH_TARGET_ID = 0x1; + + private final FirestoreImpl firestore; + private final ScheduledExecutorService firestoreExecutor; + private final Query query; + private final Comparator comparator; + private final ExponentialRetryAlgorithm backoff; + private final Target target; + private TimedAttemptSettings nextAttempt; + private SilenceableBidiStream stream; + + /** The sorted tree of DocumentSnapshots as sent in the last snapshot. */ + private DocumentSet documentSet; + + /** The accumulates map of document changes (keyed by document name) for the current snapshot. */ + private Map changeMap; + + /** The server-assigned resume token. */ + private ByteString resumeToken; + + /** The user-provided listener. */ + private EventListener listener; + + /** The user-provided callback executor. */ + private Executor userCallbackExecutor; + + /** + * Whether the retrieved result set has been marked 'CURRENT' (has caught up with the backend + * state at target initialization). + */ + private boolean current; + + /** + * Tracks whether we've pushed an initial set of changes. This is needed since we should push + * those even when there are none. + */ + private boolean hasPushed; + + /** + * Indicates whether we are interested in data from the stream. Set to false in the + * 'unsubscribe()' callback. + */ + private final AtomicBoolean isActive; + + /** The list of document changes in a snapshot separated by change type. */ + static class ChangeSet { + List deletes = new ArrayList<>(); + List adds = new ArrayList<>(); + List updates = new ArrayList<>(); + } + + /** + * @param firestore The Firestore Database client. + * @param query The query that is used to order the document snapshots returned by this watch. + * @param target A Firestore 'Target' proto denoting the target to listen on. + */ + private Watch(FirestoreImpl firestore, Query query, Target target) { + this.firestore = firestore; + this.target = target; + this.query = query; + this.comparator = query.comparator(); + this.backoff = + new ExponentialRetryAlgorithm( + firestore.getOptions().getRetrySettings(), CurrentMillisClock.getDefaultClock()); + this.firestoreExecutor = firestore.getClient().getExecutor(); + this.isActive = new AtomicBoolean(); + this.nextAttempt = backoff.createFirstAttempt(); + } + + /** + * Creates a new Watch instance that listens on DocumentReferences. + * + * @param documentReference The document reference for this watch. + * @return A newly created Watch instance. + */ + static Watch forDocument(DocumentReference documentReference) { + Target.Builder target = Target.newBuilder(); + target.getDocumentsBuilder().addDocuments(documentReference.getName()); + target.setTargetId(WATCH_TARGET_ID); + + return new Watch( + (FirestoreImpl) documentReference.getFirestore(), + documentReference.getParent(), + target.build()); + } + + /** + * Creates a new Watch instance that listens on Queries. + * + * @param query The query used for this watch. + * @return A newly created Watch instance. + */ + static Watch forQuery(Query query) { + Target.Builder target = Target.newBuilder(); + target.setQuery( + QueryTarget.newBuilder() + .setStructuredQuery(query.buildQuery()) + .setParent(query.options.getParentPath().getName()) + .build()); + target.setTargetId(WATCH_TARGET_ID); + + return new Watch((FirestoreImpl) query.getFirestore(), query, target.build()); + } + + @Override + public void onStart(StreamController streamController) {} + + @Override + public void onReady(ClientStream clientStream) {} + + @Override + public synchronized void onResponse(ListenResponse listenResponse) { + switch (listenResponse.getResponseTypeCase()) { + case TARGET_CHANGE: + TargetChange change = listenResponse.getTargetChange(); + boolean noTargetIds = change.getTargetIdsCount() == 0; + + switch (change.getTargetChangeType()) { + case NO_CHANGE: + if (noTargetIds && change.hasReadTime() && current) { + // This means everything is up-to-date, so emit the current set of docs as a snapshot, + // if there were changes. + pushSnapshot(Timestamp.fromProto(change.getReadTime()), change.getResumeToken()); + } + break; + case ADD: + if (WATCH_TARGET_ID != change.getTargetIds(0)) { + closeStream(FirestoreException.forInvalidArgument("Target ID must be 0x01")); + } + break; + case REMOVE: + Status status = + change.hasCause() + ? Status.fromCodeValue(change.getCause().getCode()) + : Status.CANCELLED; + closeStream( + FirestoreException.forServerRejection( + status, "Backend ended Listen stream: " + change.getCause().getMessage())); + break; + case CURRENT: + current = true; + break; + case RESET: + resetDocs(); + break; + default: + closeStream( + FirestoreException.forInvalidArgument( + "Encountered invalid target change type: " + change.getTargetChangeType())); + } + + if (change.getResumeToken() != null + && affectsTarget(change.getTargetIdsList(), WATCH_TARGET_ID)) { + nextAttempt = backoff.createFirstAttempt(); + } + + break; + case DOCUMENT_CHANGE: + // No other targetIds can show up here, but we still need to see if the targetId was in the + // added list or removed list. + List targetIds = listenResponse.getDocumentChange().getTargetIdsList(); + List removedTargetIds = + listenResponse.getDocumentChange().getRemovedTargetIdsList(); + boolean changed = targetIds.contains(WATCH_TARGET_ID); + boolean removed = removedTargetIds.contains(WATCH_TARGET_ID); + + Document document = listenResponse.getDocumentChange().getDocument(); + ResourcePath name = ResourcePath.create(document.getName()); + + if (changed) { + changeMap.put(name, document); + } else if (removed) { + changeMap.put(name, null); + } + break; + case DOCUMENT_DELETE: + changeMap.put(ResourcePath.create(listenResponse.getDocumentDelete().getDocument()), null); + break; + case DOCUMENT_REMOVE: + changeMap.put(ResourcePath.create(listenResponse.getDocumentRemove().getDocument()), null); + break; + case FILTER: + // Keep copy of counts for producing log message. + // The method currentSize() is computationally expensive, and should only be run once. + int filterCount = listenResponse.getFilter().getCount(); + int currentSize = currentSize(); + if (filterCount != currentSize) { + LOGGER.info( + () -> + String.format( + "filter: count mismatch filter count %d != current size %d", + filterCount, currentSize)); + // We need to remove all the current results. + resetDocs(); + // The filter didn't match, so re-issue the query. + resetStream(); + } + break; + default: + closeStream( + FirestoreException.forInvalidArgument("Encountered invalid listen response type")); + break; + } + } + + @Override + public synchronized void onError(Throwable throwable) { + maybeReopenStream(throwable); + } + + @Override + public synchronized void onComplete() { + maybeReopenStream(new StatusException(Status.fromCode(Code.UNKNOWN))); + } + + /** API entry point that starts the Watch stream. */ + ListenerRegistration runWatch( + final Executor userCallbackExecutor, EventListener listener) { + boolean watchStarted = isActive.compareAndSet(false, true); + + Preconditions.checkState(watchStarted, "Can't restart an already active watch"); + + this.userCallbackExecutor = userCallbackExecutor; + this.listener = listener; + + this.stream = null; + this.documentSet = DocumentSet.emptySet(comparator); + this.changeMap = new HashMap<>(); + this.resumeToken = null; + this.current = false; + + initStream(); + + return () -> { + isActive.set(false); + + firestore + .getClient() + .getExecutor() + .execute( + () -> { + synchronized (Watch.this) { + stream.closeSend(); + stream = null; + } + }); + }; + } + + /** + * Returns the current count of all documents, including the changes from the current changeMap. + */ + private int currentSize() { + ChangeSet changeSet = extractChanges(Timestamp.now()); + return documentSet.size() + changeSet.adds.size() - changeSet.deletes.size(); + } + + /** Helper to clear the docs on RESET or filter mismatch. */ + private void resetDocs() { + changeMap.clear(); + resumeToken = null; + + for (DocumentSnapshot snapshot : documentSet) { + // Mark each document as deleted. If documents are not deleted, they will be sent again by + // the server. + changeMap.put(snapshot.getReference().getResourcePath(), null); + } + + current = false; + } + + /** Closes the stream and calls onError() if the stream is still active. */ + private void closeStream(final Throwable throwable) { + if (stream != null) { + stream.closeSendAndSilence(); + stream = null; + } + + if (isActive.getAndSet(false)) { + userCallbackExecutor.execute( + () -> { + if (throwable instanceof FirestoreException) { + listener.onEvent(null, (FirestoreException) throwable); + } else { + Status status = getStatus(throwable); + FirestoreException firestoreException = + FirestoreException.forApiException( + new ApiException( + throwable, + GrpcStatusCode.of(status != null ? status.getCode() : Code.UNKNOWN), + false)); + listener.onEvent(null, firestoreException); + } + }); + } + } + + /** + * Re-opens the stream unless the specified error is considered permanent. Clears the change map. + */ + private void maybeReopenStream(Throwable throwable) { + if (isActive.get() && !isPermanentError(throwable)) { + if (isResourceExhaustedError(throwable)) { + nextAttempt = backoff.createNextAttempt(nextAttempt); + } + + changeMap.clear(); + resetStream(); + } else { + closeStream(throwable); + } + } + + /** Helper to restart the outgoing stream to the backend. */ + private void resetStream() { + if (stream != null) { + stream.closeSendAndSilence(); + stream = null; + } + + initStream(); + } + + /** Initializes a new stream to the backend with backoff. */ + private void initStream() { + firestoreExecutor.schedule( + () -> { + try { + if (!isActive.get()) { + return; + } + + synchronized (Watch.this) { + if (!isActive.get()) { + return; + } + + Preconditions.checkState(stream == null); + + current = false; + nextAttempt = backoff.createNextAttempt(nextAttempt); + + stream = + new SilenceableBidiStream<>( + Watch.this, + observer -> + firestore.streamRequest( + observer, firestore.getClient().listenCallable())); + + ListenRequest.Builder request = ListenRequest.newBuilder(); + request.setDatabase(firestore.getDatabaseName()); + request.setAddTarget(target); + if (resumeToken != null) { + request.getAddTargetBuilder().setResumeToken(resumeToken); + } + + stream.send(request.build()); + } + } catch (Throwable throwable) { + onError(throwable); + } + }, + nextAttempt.getRandomizedRetryDelay().toMillis(), + TimeUnit.MILLISECONDS); + } + + /** + * Checks if the current target id is included in the list of target ids. Returns true if no + * targetIds are provided. + */ + private boolean affectsTarget(List targetIds, int currentId) { + return targetIds == null || targetIds.isEmpty() || targetIds.contains(currentId); + } + + /** Splits up document changes into removals, additions, and updates. */ + private ChangeSet extractChanges(Timestamp readTime) { + ChangeSet changeSet = new ChangeSet(); + + for (Entry change : changeMap.entrySet()) { + if (change.getValue() == null) { + if (documentSet.contains(change.getKey())) { + changeSet.deletes.add(documentSet.getDocument(change.getKey())); + } + continue; + } + + QueryDocumentSnapshot snapshot = + QueryDocumentSnapshot.fromDocument(firestore, readTime, change.getValue()); + + if (documentSet.contains(change.getKey())) { + changeSet.updates.add(snapshot); + } else { + changeSet.adds.add(snapshot); + } + } + + return changeSet; + } + + /** + * Assembles a new snapshot from the current set of changes and invokes the user's callback. + * Clears the current changes on completion. + */ + private void pushSnapshot(final Timestamp readTime, ByteString nextResumeToken) { + final List changes = computeSnapshot(readTime); + if (!hasPushed || !changes.isEmpty()) { + final QuerySnapshot querySnapshot = + QuerySnapshot.withChanges(query, readTime, documentSet, changes); + LOGGER.fine(querySnapshot::toString); + userCallbackExecutor.execute(() -> listener.onEvent(querySnapshot, null)); + hasPushed = true; + } + + changeMap.clear(); + resumeToken = nextResumeToken; + } + + /** + * Applies a document delete to the document tree. Returns the corresponding DocumentChange event. + */ + private DocumentChange deleteDoc(QueryDocumentSnapshot oldDocument) { + ResourcePath resourcePath = oldDocument.getReference().getResourcePath(); + int oldIndex = documentSet.indexOf(resourcePath); + documentSet = documentSet.remove(resourcePath); + return new DocumentChange(oldDocument, Type.REMOVED, oldIndex, -1); + } + + /** + * Applies a document add to the document tree. Returns the corresponding DocumentChange event. + */ + private DocumentChange addDoc(QueryDocumentSnapshot newDocument) { + ResourcePath resourcePath = newDocument.getReference().getResourcePath(); + documentSet = documentSet.add(newDocument); + int newIndex = documentSet.indexOf(resourcePath); + return new DocumentChange(newDocument, Type.ADDED, -1, newIndex); + } + + /** + * Applies a document modification to the document tree. Returns the DocumentChange event for + * successful modifications. + */ + @Nullable + private DocumentChange modifyDoc(QueryDocumentSnapshot newDocument) { + ResourcePath resourcePath = newDocument.getReference().getResourcePath(); + DocumentSnapshot oldDocument = documentSet.getDocument(resourcePath); + + if (!oldDocument.getUpdateTime().equals(newDocument.getUpdateTime())) { + int oldIndex = documentSet.indexOf(resourcePath); + documentSet = documentSet.remove(resourcePath); + documentSet = documentSet.add(newDocument); + int newIndex = documentSet.indexOf(resourcePath); + return new DocumentChange(newDocument, Type.MODIFIED, oldIndex, newIndex); + } + return null; + } + + /** + * Applies the mutations in changeMap to the document tree. Modified 'documentSet' in-place and + * returns the changed documents. + * + * @param readTime The time at which this snapshot was obtained. + */ + private List computeSnapshot(Timestamp readTime) { + List appliedChanges = new ArrayList<>(); + + ChangeSet changeSet = extractChanges(readTime); + + // Process the sorted changes in the order that is expected by our clients (removals, additions, + // and then modifications). We also need to sort the individual changes to assure that + // oldIndex/newIndex keep incrementing. + changeSet.deletes.sort(comparator); + for (QueryDocumentSnapshot delete : changeSet.deletes) { + appliedChanges.add(deleteDoc(delete)); + } + + changeSet.adds.sort(comparator); + for (QueryDocumentSnapshot add : changeSet.adds) { + appliedChanges.add(addDoc(add)); + } + + changeSet.updates.sort(comparator); + for (QueryDocumentSnapshot update : changeSet.updates) { + DocumentChange change = modifyDoc(update); + if (change != null) { + appliedChanges.add(change); + } + } + + return appliedChanges; + } + + /** Determines whether a GRPC Error is considered permanent and should not be retried. */ + private static boolean isPermanentError(Throwable throwable) { + Status status = getStatus(throwable); + + if (status == null) { + return true; + } + + switch (status.getCode()) { + case CANCELLED: + case UNKNOWN: + case DEADLINE_EXCEEDED: + case RESOURCE_EXHAUSTED: + case INTERNAL: + case UNAVAILABLE: + case UNAUTHENTICATED: + return false; + default: + return true; + } + } + + /** Extracts the GRPC status code if available. Returns `null` for non-GRPC exceptions. */ + @Nullable + private static Status getStatus(Throwable throwable) { + if (throwable instanceof StatusRuntimeException) { + return ((StatusRuntimeException) throwable).getStatus(); + } else if (throwable instanceof StatusException) { + return ((StatusException) throwable).getStatus(); + } else if (throwable instanceof ApiException + && ((ApiException) throwable).getStatusCode().getTransportCode() instanceof Code) { + return ((Code) ((ApiException) throwable).getStatusCode().getTransportCode()).toStatus(); + } + return null; + } + + /** Determines whether we need to initiate a longer backoff due to system overload. */ + private static boolean isResourceExhaustedError(Throwable throwable) { + Status status = getStatus(throwable); + return status != null && status.getCode().equals(Code.RESOURCE_EXHAUSTED); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteBatch.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteBatch.java new file mode 100644 index 000000000000..ef5435b57cac --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteBatch.java @@ -0,0 +1,47 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import java.util.List; +import javax.annotation.Nonnull; + +/** + * A Firestore WriteBatch that can be used to atomically commit multiple write operations at once. + * + * @see Firestore#batch() + */ +public class WriteBatch extends UpdateBuilder { + + WriteBatch(FirestoreImpl firestore) { + super(firestore); + } + + /** + * Applies the current WriteBatch and returns an array with WriteResults. + * + * @return ApiFuture with a List of WriteResults + */ + @Nonnull + public ApiFuture> commit() { + return super.commit(null); + } + + WriteBatch wrapResult(int writeIndex) { + return this; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteResult.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteResult.java new file mode 100644 index 000000000000..a8abc4901cf8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/WriteResult.java @@ -0,0 +1,71 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import java.util.Objects; +import javax.annotation.Nonnull; + +/** A WriteResult exposes the update time set by the server. */ +public final class WriteResult { + + private final Timestamp updateTime; + + WriteResult(Timestamp updateTime) { + this.updateTime = updateTime; + } + + /** + * The update time as exposed by the server. Can be used in {@link Precondition#updatedAt}. + * + * @return The update time of the corresponding write. + */ + @Nonnull + public Timestamp getUpdateTime() { + return this.updateTime; + } + + static WriteResult fromProto( + com.google.firestore.v1.WriteResult writeResult, com.google.protobuf.Timestamp commitTime) { + Timestamp timestamp = + Timestamp.fromProto(writeResult.hasUpdateTime() ? writeResult.getUpdateTime() : commitTime); + return new WriteResult(timestamp); + } + + /** + * Returns true if this WriteResult is equal to the provided object. + * + * @param obj The object to compare against. + * @return Whether this WriteResult is equal to the provided object. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + WriteResult that = (WriteResult) obj; + return Objects.equals(updateTime, that.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(updateTime); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/DocumentId.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/DocumentId.java new file mode 100644 index 000000000000..07913f6c1c76 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/DocumentId.java @@ -0,0 +1,53 @@ +/* + * Copyright 2019 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.WriteBatch; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation used to mark a POJO property to be automatically populated with the document's ID when + * the POJO is created from a Cloud Firestore document (for example, via {@link + * DocumentSnapshot#toObject}). + * + *

Any of the following will throw a runtime exception: + * + *

    + *
  • This annotation is applied to a property of a type other than String or {@link + * DocumentReference}. + *
  • This annotation is applied to a property that is not writable (for example, a Java Bean + * getter without a backing field). + *
  • This annotation is applied to a property with a name that conflicts with a read document + * field. For example, if a POJO has a field `firstName` annotated by @DocumentId, and there + * is a property from the document named `firstName` as well, an exception is thrown when you + * try to read the document into the POJO via {@link DocumentSnapshot#toObject} or {@link + * DocumentReference#get}. + *
  • + *
+ * + *

When using a POJO to write to a document (via {@link DocumentReference#set} or @{@link + * WriteBatch#set}), the property annotated by @DocumentId is ignored, which allows writing the POJO + * back to any document, even if it's not the origin of the POJO. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.FIELD, ElementType.METHOD}) +public @interface DocumentId {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/Exclude.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/Exclude.java new file mode 100644 index 000000000000..0ad1374b4706 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/Exclude.java @@ -0,0 +1,27 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Marks a field as excluded from the Database. */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD}) +public @interface Exclude {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/IgnoreExtraProperties.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/IgnoreExtraProperties.java new file mode 100644 index 000000000000..eb3a536130b1 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/IgnoreExtraProperties.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Properties that don't map to class fields are ignored when serializing to a class annotated with + * this annotation. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface IgnoreExtraProperties {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/PropertyName.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/PropertyName.java new file mode 100644 index 000000000000..d2394b1c27d0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/PropertyName.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** Marks a field to be renamed when serialized. */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD}) +public @interface PropertyName { + + String value(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ServerTimestamp.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ServerTimestamp.java new file mode 100644 index 000000000000..0d7564f0b5e8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ServerTimestamp.java @@ -0,0 +1,31 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation used to mark a timestamp field as being populated via Server Timestamps. If a POJO + * being written contains null for a @ServerTimestamp annotated field, it will be replaced with a + * server-generated timestamp. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.METHOD, ElementType.FIELD}) +public @interface ServerTimestamp {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ThrowOnExtraProperties.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ThrowOnExtraProperties.java new file mode 100644 index 000000000000..983b590f1cd0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/annotation/ThrowOnExtraProperties.java @@ -0,0 +1,30 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Properties that don't map to class fields when serializing to a class annotated with this + * annotation cause an exception to be thrown. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +public @interface ThrowOnExtraProperties {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ArraySortedMap.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ArraySortedMap.java new file mode 100644 index 000000000000..a27d7effa07a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ArraySortedMap.java @@ -0,0 +1,299 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * This is an array backed implementation of ImmutableSortedMap. It uses arrays and linear lookups + * to achieve good memory efficiency while maintaining good performance for small collections. To + * avoid degrading performance with increasing collection size it will automatically convert to a + * RBTreeSortedMap after an insert call above a certain threshold. + * + *

Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ + * src/main/java/com/google/firebase/database/collection + */ +@InternalApi +public class ArraySortedMap extends ImmutableSortedMap { + + @SuppressWarnings("unchecked") + public static ArraySortedMap buildFrom( + List keys, + Map values, + Builder.KeyTranslator translator, + Comparator comparator) { + keys.sort(comparator); + int size = keys.size(); + A[] keyArray = (A[]) new Object[size]; + C[] valueArray = (C[]) new Object[size]; + int pos = 0; + for (A k : keys) { + keyArray[pos] = k; + C value = values.get(translator.translate(k)); + valueArray[pos] = value; + pos++; + } + return new ArraySortedMap<>(comparator, keyArray, valueArray); + } + + public static ArraySortedMap fromMap(Map map, Comparator comparator) { + return buildFrom(new ArrayList<>(map.keySet()), map, Builder.identityTranslator(), comparator); + } + + private final K[] keys; + private final V[] values; + private final Comparator comparator; + + @SuppressWarnings("unchecked") + public ArraySortedMap(Comparator comparator) { + this.keys = (K[]) new Object[0]; + this.values = (V[]) new Object[0]; + this.comparator = comparator; + } + + @SuppressWarnings("unchecked") + private ArraySortedMap(Comparator comparator, K[] keys, V[] values) { + this.keys = keys; + this.values = values; + this.comparator = comparator; + } + + @Override + public boolean containsKey(K key) { + return findKey(key) != -1; + } + + @Override + public V get(K key) { + int pos = findKey(key); + return pos != -1 ? this.values[pos] : null; + } + + @Override + public ImmutableSortedMap remove(K key) { + int pos = findKey(key); + if (pos == -1) { + return this; + } else { + K[] keys = removeFromArray(this.keys, pos); + V[] values = removeFromArray(this.values, pos); + return new ArraySortedMap<>(this.comparator, keys, values); + } + } + + @Override + public ImmutableSortedMap insert(K key, V value) { + int pos = findKey(key); + if (pos != -1) { + if (this.keys[pos] == key && this.values[pos] == value) { + return this; + } else { + // The key and/or value might have changed, even though the comparison might still yield 0 + K[] newKeys = replaceInArray(this.keys, pos, key); + V[] newValues = replaceInArray(this.values, pos, value); + return new ArraySortedMap<>(this.comparator, newKeys, newValues); + } + } else { + if (this.keys.length > Builder.ARRAY_TO_RB_TREE_SIZE_THRESHOLD) { + @SuppressWarnings("unchecked") + Map map = new HashMap<>(this.keys.length + 1); + for (int i = 0; i < this.keys.length; i++) { + map.put(this.keys[i], this.values[i]); + } + map.put(key, value); + return RBTreeSortedMap.fromMap(map, this.comparator); + } else { + int newPos = findKeyOrInsertPosition(key); + K[] keys = addToArray(this.keys, newPos, key); + V[] values = addToArray(this.values, newPos, value); + return new ArraySortedMap<>(this.comparator, keys, values); + } + } + } + + @Override + public K getMinKey() { + return this.keys.length > 0 ? this.keys[0] : null; + } + + @Override + public K getMaxKey() { + return this.keys.length > 0 ? this.keys[this.keys.length - 1] : null; + } + + @Override + public int size() { + return this.keys.length; + } + + @Override + public boolean isEmpty() { + return this.keys.length == 0; + } + + @Override + public void inOrderTraversal(LLRBNode.NodeVisitor visitor) { + for (int i = 0; i < this.keys.length; i++) { + visitor.visitEntry(this.keys[i], this.values[i]); + } + } + + private Iterator> iterator(final int pos, final boolean reverse) { + return new Iterator>() { + int currentPos = pos; + + @Override + public boolean hasNext() { + return reverse ? currentPos >= 0 : currentPos < keys.length; + } + + @Override + public Map.Entry next() { + final K key = keys[currentPos]; + final V value = values[currentPos]; + currentPos = reverse ? currentPos - 1 : currentPos + 1; + return new AbstractMap.SimpleImmutableEntry<>(key, value); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Can't remove elements from ImmutableSortedMap"); + } + }; + } + + @Override + public Iterator> iterator() { + return iterator(0, false); + } + + @Override + public Iterator> iteratorFrom(K key) { + int pos = findKeyOrInsertPosition(key); + return iterator(pos, false); + } + + @Override + public Iterator> reverseIteratorFrom(K key) { + int pos = findKeyOrInsertPosition(key); + // if there's no exact match, findKeyOrInsertPosition will return the index *after* the closest + // match, but + // since this is a reverse iterator, we want to start just *before* the closest match. + if (pos < this.keys.length && this.comparator.compare(this.keys[pos], key) == 0) { + return iterator(pos, true); + } else { + return iterator(pos - 1, true); + } + } + + @Override + public Iterator> reverseIterator() { + return iterator(this.keys.length - 1, true); + } + + @Override + public K getPredecessorKey(K key) { + int pos = findKey(key); + if (pos == -1) { + throw new IllegalArgumentException("Can't find predecessor of nonexistent key"); + } else { + return (pos > 0) ? this.keys[pos - 1] : null; + } + } + + @Override + public K getSuccessorKey(K key) { + int pos = findKey(key); + if (pos == -1) { + throw new IllegalArgumentException("Can't find successor of nonexistent key"); + } else { + return (pos < this.keys.length - 1) ? this.keys[pos + 1] : null; + } + } + + @Override + public int indexOf(K key) { + return findKey(key); + } + + @Override + public Comparator getComparator() { + return comparator; + } + + @SuppressWarnings("unchecked") + private static T[] removeFromArray(T[] arr, int pos) { + int newSize = arr.length - 1; + T[] newArray = (T[]) new Object[newSize]; + System.arraycopy(arr, 0, newArray, 0, pos); + System.arraycopy(arr, pos + 1, newArray, pos, newSize - pos); + return newArray; + } + + @SuppressWarnings("unchecked") + private static T[] addToArray(T[] arr, int pos, T value) { + int newSize = arr.length + 1; + T[] newArray = (T[]) new Object[newSize]; + System.arraycopy(arr, 0, newArray, 0, pos); + newArray[pos] = value; + System.arraycopy(arr, pos, newArray, pos + 1, newSize - pos - 1); + return newArray; + } + + @SuppressWarnings("unchecked") + private static T[] replaceInArray(T[] arr, int pos, T value) { + int size = arr.length; + T[] newArray = (T[]) new Object[size]; + System.arraycopy(arr, 0, newArray, 0, size); + newArray[pos] = value; + return newArray; + } + + /** + * This does a linear scan which is simpler than a binary search. For a small collection size this + * still should be as fast as binary search. + */ + private int findKeyOrInsertPosition(K key) { + int newPos = 0; + while (newPos < this.keys.length && this.comparator.compare(this.keys[newPos], key) < 0) { + newPos++; + } + return newPos; + } + + /** + * This does a linear scan which is simpler than a binary search. For a small collection size this + * still should be as fast as binary search. + */ + private int findKey(K key) { + int i = 0; + for (K otherKey : this.keys) { + if (this.comparator.compare(key, otherKey) == 0) { + return i; + } + i++; + } + return -1; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMap.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMap.java new file mode 100644 index 000000000000..006dbd0ef20d --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMap.java @@ -0,0 +1,158 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/src +// /main/java/com/google/firebase/database/collection +@InternalApi +public abstract class ImmutableSortedMap implements Iterable> { + + public abstract boolean containsKey(K key); + + public abstract V get(K key); + + public abstract ImmutableSortedMap remove(K key); + + public abstract ImmutableSortedMap insert(K key, V value); + + public abstract K getMinKey(); + + public abstract K getMaxKey(); + + public abstract int size(); + + public abstract boolean isEmpty(); + + public abstract void inOrderTraversal(LLRBNode.NodeVisitor visitor); + + public abstract Iterator> iterator(); + + public abstract Iterator> iteratorFrom(K key); + + public abstract Iterator> reverseIteratorFrom(K key); + + public abstract Iterator> reverseIterator(); + + public abstract K getPredecessorKey(K key); + + public abstract K getSuccessorKey(K key); + + public abstract int indexOf(K key); + + public abstract Comparator getComparator(); + + @Override + @SuppressWarnings("unchecked") + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ImmutableSortedMap)) return false; + + ImmutableSortedMap that = (ImmutableSortedMap) o; + + if (!this.getComparator().equals(that.getComparator())) return false; + if (this.size() != that.size()) return false; + + Iterator> thisIterator = this.iterator(); + Iterator> thatIterator = that.iterator(); + while (thisIterator.hasNext()) { + if (!thisIterator.next().equals(thatIterator.next())) return false; + } + + return true; + } + + @Override + public int hashCode() { + int result = this.getComparator().hashCode(); + for (Map.Entry entry : this) { + result = 31 * result + entry.hashCode(); + } + + return result; + } + + public String toString() { + StringBuilder b = new StringBuilder(); + b.append(this.getClass().getSimpleName()); + b.append("{"); + boolean first = true; + for (Map.Entry entry : this) { + if (first) first = false; + else b.append(", "); + b.append("("); + b.append(entry.getKey()); + b.append("=>"); + b.append(entry.getValue()); + b.append(")"); + } + b.append("};"); + return b.toString(); + } + + public static class Builder { + /** + * The size threshold where we use a tree backed sorted map instead of an array backed sorted + * map. This is a more or less arbitrary chosen value, that was chosen to be large enough to fit + * most of object kind of Database data, but small enough to not notice degradation in + * performance for inserting and lookups. Feel free to empirically determine this constant, but + * don't expect much gain in real world performance. + */ + static final int ARRAY_TO_RB_TREE_SIZE_THRESHOLD = 25; + + public static ImmutableSortedMap emptyMap(Comparator comparator) { + return new ArraySortedMap<>(comparator); + } + + public interface KeyTranslator { + D translate(C key); + } + + private static final KeyTranslator IDENTITY_TRANSLATOR = key -> key; + + @SuppressWarnings("unchecked") + public static KeyTranslator identityTranslator() { + return IDENTITY_TRANSLATOR; + } + + public static ImmutableSortedMap fromMap( + Map values, Comparator comparator) { + if (values.size() < ARRAY_TO_RB_TREE_SIZE_THRESHOLD) { + return ArraySortedMap.fromMap(values, comparator); + } else { + return RBTreeSortedMap.fromMap(values, comparator); + } + } + + public static ImmutableSortedMap buildFrom( + List keys, + Map values, + ImmutableSortedMap.Builder.KeyTranslator translator, + Comparator comparator) { + if (keys.size() < ARRAY_TO_RB_TREE_SIZE_THRESHOLD) { + return ArraySortedMap.buildFrom(keys, values, translator, comparator); + } else { + return RBTreeSortedMap.buildFrom(keys, values, translator, comparator); + } + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMapIterator.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMapIterator.java new file mode 100644 index 000000000000..58444ae37a76 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedMapIterator.java @@ -0,0 +1,109 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.AbstractMap; +import java.util.Comparator; +import java.util.EmptyStackException; +import java.util.Iterator; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Stack; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public class ImmutableSortedMapIterator implements Iterator> { + + private final Stack> nodeStack; + + private final boolean isReverse; + + ImmutableSortedMapIterator( + LLRBNode root, K startKey, Comparator comparator, boolean isReverse) { + this.nodeStack = new Stack<>(); + this.isReverse = isReverse; + + LLRBNode node = root; + while (!node.isEmpty()) { + int cmp; + if (startKey != null) { + cmp = + isReverse + ? comparator.compare(startKey, node.getKey()) + : comparator.compare(node.getKey(), startKey); + } else { + cmp = 1; + } + if (cmp < 0) { + // This node is less than our start key. ignore it + if (isReverse) { + node = node.getLeft(); + } else { + node = node.getRight(); + } + } else if (cmp == 0) { + // This node is exactly equal to our start key. Push it on the stack, but stop iterating; + this.nodeStack.push((LLRBValueNode) node); + break; + } else { + this.nodeStack.push((LLRBValueNode) node); + if (isReverse) { + node = node.getRight(); + } else { + node = node.getLeft(); + } + } + } + } + + @Override + public boolean hasNext() { + return nodeStack.size() > 0; + } + + @Override + public Map.Entry next() { + try { + final LLRBValueNode node = nodeStack.pop(); + Map.Entry entry = new AbstractMap.SimpleEntry<>(node.getKey(), node.getValue()); + if (this.isReverse) { + LLRBNode next = node.getLeft(); + while (!next.isEmpty()) { + this.nodeStack.push((LLRBValueNode) next); + next = next.getRight(); + } + } else { + LLRBNode next = node.getRight(); + while (!next.isEmpty()) { + this.nodeStack.push((LLRBValueNode) next); + next = next.getLeft(); + } + } + return entry; + } catch (EmptyStackException e) { + // No more children + throw new NoSuchElementException(); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException("remove called on immutable collection"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedSet.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedSet.java new file mode 100644 index 000000000000..13b74472f05c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/ImmutableSortedSet.java @@ -0,0 +1,138 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public class ImmutableSortedSet implements Iterable { + + private final ImmutableSortedMap map; + + private static class WrappedEntryIterator implements Iterator { + final Iterator> iterator; + + public WrappedEntryIterator(Iterator> iterator) { + this.iterator = iterator; + } + + @Override + public boolean hasNext() { + return this.iterator.hasNext(); + } + + @Override + public T next() { + return this.iterator.next().getKey(); + } + + @Override + public void remove() { + this.iterator.remove(); + } + } + + public ImmutableSortedSet(List elems, Comparator comparator) { + this.map = + ImmutableSortedMap.Builder.buildFrom( + elems, + Collections.emptyMap(), + ImmutableSortedMap.Builder.identityTranslator(), + comparator); + } + + private ImmutableSortedSet(ImmutableSortedMap map) { + this.map = map; + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof ImmutableSortedSet)) { + return false; + } + ImmutableSortedSet otherSet = (ImmutableSortedSet) other; + return map.equals(otherSet.map); + } + + @Override + public int hashCode() { + return map.hashCode(); + } + + public boolean contains(T entry) { + return this.map.containsKey(entry); + } + + public ImmutableSortedSet remove(T entry) { + ImmutableSortedMap newMap = this.map.remove(entry); + return (newMap == this.map) ? this : new ImmutableSortedSet<>(newMap); + } + + public ImmutableSortedSet insert(T entry) { + return new ImmutableSortedSet<>(map.insert(entry, null)); + } + + public T getMinEntry() { + return this.map.getMinKey(); + } + + public T getMaxEntry() { + return this.map.getMaxKey(); + } + + public int size() { + return this.map.size(); + } + + public boolean isEmpty() { + return this.map.isEmpty(); + } + + public Iterator iterator() { + return new WrappedEntryIterator<>(this.map.iterator()); + } + + public Iterator iteratorFrom(T entry) { + return new WrappedEntryIterator<>(this.map.iteratorFrom(entry)); + } + + public Iterator reverseIteratorFrom(T entry) { + return new WrappedEntryIterator<>(this.map.reverseIteratorFrom(entry)); + } + + public Iterator reverseIterator() { + return new WrappedEntryIterator<>(this.map.reverseIterator()); + } + + public T getPredecessorEntry(T entry) { + return this.map.getPredecessorKey(entry); + } + + public int indexOf(T entry) { + return this.map.indexOf(entry); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBBlackValueNode.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBBlackValueNode.java new file mode 100644 index 000000000000..05d5a6296c82 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBBlackValueNode.java @@ -0,0 +1,76 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public class LLRBBlackValueNode extends LLRBValueNode { + + /** + * Only memoize size on black nodes, not on red nodes. This saves memory while guaranteeing that + * size will still have an amortized constant runtime. The first time size() may have to traverse + * the entire tree. However, the red black tree algorithm guarantees that every red node has two + * black children. So future invocations of the size() function will have to go at most 2 levels + * deep if the child is a red node. + * + *

Needs to be mutable because left node can be updated via setLeft. + */ + private int size = -1; + + LLRBBlackValueNode(K key, V value, LLRBNode left, LLRBNode right) { + super(key, value, left, right); + } + + @Override + protected Color getColor() { + return Color.BLACK; + } + + @Override + public boolean isRed() { + return false; + } + + @Override + public int size() { + if (size == -1) { + size = getLeft().size() + 1 + getRight().size(); + } + return size; + } + + @Override + void setLeft(LLRBNode left) { + if (size != -1) { + // Modifying left node after invoking size + throw new IllegalStateException("Can't set left after using size"); + } + super.setLeft(left); + } + + @Override + protected LLRBValueNode copy(K key, V value, LLRBNode left, LLRBNode right) { + K newKey = key == null ? this.getKey() : key; + V newValue = value == null ? this.getValue() : value; + LLRBNode newLeft = left == null ? this.getLeft() : left; + LLRBNode newRight = right == null ? this.getRight() : right; + return new LLRBBlackValueNode<>(newKey, newValue, newLeft, newRight); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBEmptyNode.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBEmptyNode.java new file mode 100644 index 000000000000..8658432614b3 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBEmptyNode.java @@ -0,0 +1,113 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.Comparator; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public class LLRBEmptyNode implements LLRBNode { + + private static final LLRBEmptyNode INSTANCE = new LLRBEmptyNode(); + + @SuppressWarnings("unchecked") + public static LLRBEmptyNode getInstance() { + return INSTANCE; + } + + private LLRBEmptyNode() {} + + @Override + public LLRBNode copy( + K key, V value, Color color, LLRBNode left, LLRBNode right) { + return this; + } + + @Override + public LLRBNode insert(K key, V value, Comparator comparator) { + return new LLRBRedValueNode<>(key, value); + } + + @Override + public LLRBNode remove(K key, Comparator comparator) { + return this; + } + + @Override + public boolean isEmpty() { + return true; + } + + @Override + public boolean isRed() { + return false; + } + + @Override + public K getKey() { + return null; + } + + @Override + public V getValue() { + return null; + } + + @Override + public LLRBNode getLeft() { + return this; + } + + @Override + public LLRBNode getRight() { + return this; + } + + @Override + public LLRBNode getMin() { + return this; + } + + @Override + public LLRBNode getMax() { + return this; + } + + @Override + public int size() { + return 0; + } + + @Override + public void inOrderTraversal(NodeVisitor visitor) { + // No-op + } + + @Override + public boolean shortCircuitingInOrderTraversal(ShortCircuitingNodeVisitor visitor) { + // No-op + return true; + } + + @Override + public boolean shortCircuitingReverseOrderTraversal(ShortCircuitingNodeVisitor visitor) { + // No-op + return true; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBNode.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBNode.java new file mode 100644 index 000000000000..b71a09267a8a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBNode.java @@ -0,0 +1,76 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.Comparator; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public interface LLRBNode { + + interface ShortCircuitingNodeVisitor { + boolean shouldContinue(K key, V value); + } + + abstract class NodeVisitor implements ShortCircuitingNodeVisitor { + + @Override + public boolean shouldContinue(K key, V value) { + visitEntry(key, value); + return true; + } + + public abstract void visitEntry(K key, V value); + } + + enum Color { + RED, + BLACK + } + + LLRBNode copy(K key, V value, Color color, LLRBNode left, LLRBNode right); + + LLRBNode insert(K key, V value, Comparator comparator); + + LLRBNode remove(K key, Comparator comparator); + + boolean isEmpty(); + + boolean isRed(); + + K getKey(); + + V getValue(); + + LLRBNode getLeft(); + + LLRBNode getRight(); + + LLRBNode getMin(); + + LLRBNode getMax(); + + int size(); + + void inOrderTraversal(NodeVisitor visitor); + + boolean shortCircuitingInOrderTraversal(ShortCircuitingNodeVisitor visitor); + + boolean shortCircuitingReverseOrderTraversal(ShortCircuitingNodeVisitor visitor); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBRedValueNode.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBRedValueNode.java new file mode 100644 index 000000000000..bf9ae961c799 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBRedValueNode.java @@ -0,0 +1,57 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public class LLRBRedValueNode extends LLRBValueNode { + + LLRBRedValueNode(K key, V value) { + super(key, value, LLRBEmptyNode.getInstance(), LLRBEmptyNode.getInstance()); + } + + LLRBRedValueNode(K key, V value, LLRBNode left, LLRBNode right) { + super(key, value, left, right); + } + + @Override + protected Color getColor() { + return LLRBNode.Color.RED; + } + + @Override + public boolean isRed() { + return true; + } + + @Override + public int size() { + return this.getLeft().size() + 1 + this.getRight().size(); + } + + @Override + protected LLRBValueNode copy(K key, V value, LLRBNode left, LLRBNode right) { + K newKey = key == null ? this.getKey() : key; + V newValue = value == null ? this.getValue() : value; + LLRBNode newLeft = left == null ? this.getLeft() : left; + LLRBNode newRight = right == null ? this.getRight() : right; + return new LLRBRedValueNode<>(newKey, newValue, newLeft, newRight); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBValueNode.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBValueNode.java new file mode 100644 index 000000000000..14c66f5141c2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/LLRBValueNode.java @@ -0,0 +1,257 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.Comparator; + +// Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ +// src/main/java/com/google/firebase/database/collection +@InternalApi +public abstract class LLRBValueNode implements LLRBNode { + + private static Color oppositeColor(LLRBNode node) { + return node.isRed() ? Color.BLACK : Color.RED; + } + + private final K key; + private final V value; + private LLRBNode left; + private final LLRBNode right; + + LLRBValueNode(K key, V value, LLRBNode left, LLRBNode right) { + this.key = key; + this.value = value; + this.left = left == null ? LLRBEmptyNode.getInstance() : left; + this.right = right == null ? LLRBEmptyNode.getInstance() : right; + } + + @Override + public LLRBNode getLeft() { + return left; + } + + @Override + public LLRBNode getRight() { + return right; + } + + @Override + public K getKey() { + return key; + } + + @Override + public V getValue() { + return value; + } + + protected abstract Color getColor(); + + protected abstract LLRBValueNode copy( + K key, V value, LLRBNode left, LLRBNode right); + + @Override + public LLRBValueNode copy( + K key, V value, Color color, LLRBNode left, LLRBNode right) { + K newKey = key == null ? this.key : key; + V newValue = value == null ? this.value : value; + LLRBNode newLeft = left == null ? this.left : left; + LLRBNode newRight = right == null ? this.right : right; + if (color == Color.RED) { + return new LLRBRedValueNode<>(newKey, newValue, newLeft, newRight); + } else { + return new LLRBBlackValueNode<>(newKey, newValue, newLeft, newRight); + } + } + + @Override + public LLRBNode insert(K key, V value, Comparator comparator) { + int cmp = comparator.compare(key, this.key); + LLRBValueNode n; + if (cmp < 0) { + // new key is less than current key + LLRBNode newLeft = this.left.insert(key, value, comparator); + n = copy(null, null, newLeft, null); + } else if (cmp == 0) { + // same key + n = copy(key, value, null, null); + } else { + // new key is greater than current key + LLRBNode newRight = this.right.insert(key, value, comparator); + n = copy(null, null, null, newRight); + } + return n.fixUp(); + } + + @Override + public LLRBNode remove(K key, Comparator comparator) { + LLRBValueNode n = this; + + if (comparator.compare(key, n.key) < 0) { + if (!n.left.isEmpty() && !n.left.isRed() && !((LLRBValueNode) n.left).left.isRed()) { + n = n.moveRedLeft(); + } + n = n.copy(null, null, n.left.remove(key, comparator), null); + } else { + if (n.left.isRed()) { + n = n.rotateRight(); + } + + if (!n.right.isEmpty() && !n.right.isRed() && !((LLRBValueNode) n.right).left.isRed()) { + n = n.moveRedRight(); + } + + if (comparator.compare(key, n.key) == 0) { + if (n.right.isEmpty()) { + return LLRBEmptyNode.getInstance(); + } else { + LLRBNode smallest = n.right.getMin(); + n = + n.copy( + smallest.getKey(), + smallest.getValue(), + null, + ((LLRBValueNode) n.right).removeMin()); + } + } + n = n.copy(null, null, null, n.right.remove(key, comparator)); + } + return n.fixUp(); + } + + @Override + public boolean isEmpty() { + return false; + } + + @Override + public LLRBNode getMin() { + if (left.isEmpty()) { + return this; + } else { + return left.getMin(); + } + } + + @Override + public LLRBNode getMax() { + if (right.isEmpty()) { + return this; + } else { + return right.getMax(); + } + } + + @Override + public void inOrderTraversal(NodeVisitor visitor) { + left.inOrderTraversal(visitor); + visitor.visitEntry(key, value); + right.inOrderTraversal(visitor); + } + + @Override + public boolean shortCircuitingInOrderTraversal(ShortCircuitingNodeVisitor visitor) { + if (left.shortCircuitingInOrderTraversal(visitor)) { + if (visitor.shouldContinue(key, value)) { + return right.shortCircuitingInOrderTraversal(visitor); + } + } + return false; + } + + @Override + public boolean shortCircuitingReverseOrderTraversal(ShortCircuitingNodeVisitor visitor) { + if (right.shortCircuitingReverseOrderTraversal(visitor)) { + if (visitor.shouldContinue(key, value)) { + return left.shortCircuitingReverseOrderTraversal(visitor); + } + } + return false; + } + + // For use by the builder, which is package local + void setLeft(LLRBNode left) { + this.left = left; + } + + private LLRBNode removeMin() { + if (left.isEmpty()) { + return LLRBEmptyNode.getInstance(); + } else { + LLRBValueNode n = this; + if (!n.getLeft().isRed() && !n.getLeft().getLeft().isRed()) { + n = n.moveRedLeft(); + } + + n = n.copy(null, null, ((LLRBValueNode) n.left).removeMin(), null); + return n.fixUp(); + } + } + + private LLRBValueNode moveRedLeft() { + LLRBValueNode n = colorFlip(); + if (n.getRight().getLeft().isRed()) { + n = n.copy(null, null, null, ((LLRBValueNode) n.getRight()).rotateRight()); + n = n.rotateLeft(); + n = n.colorFlip(); + } + return n; + } + + private LLRBValueNode moveRedRight() { + LLRBValueNode n = colorFlip(); + if (n.getLeft().getLeft().isRed()) { + n = n.rotateRight(); + n = n.colorFlip(); + } + return n; + } + + private LLRBValueNode fixUp() { + LLRBValueNode n = this; + if (n.right.isRed() && !n.left.isRed()) { + n = n.rotateLeft(); + } + if (n.left.isRed() && ((LLRBValueNode) (n.left)).left.isRed()) { + n = n.rotateRight(); + } + if (n.left.isRed() && n.right.isRed()) { + n = n.colorFlip(); + } + return n; + } + + private LLRBValueNode rotateLeft() { + LLRBValueNode newLeft = + this.copy(null, null, Color.RED, null, ((LLRBValueNode) (this.right)).left); + return (LLRBValueNode) this.right.copy(null, null, this.getColor(), newLeft, null); + } + + private LLRBValueNode rotateRight() { + LLRBValueNode newRight = + this.copy(null, null, Color.RED, ((LLRBValueNode) (this.left)).right, null); + return (LLRBValueNode) this.left.copy(null, null, this.getColor(), null, newRight); + } + + private LLRBValueNode colorFlip() { + LLRBNode newLeft = this.left.copy(null, null, oppositeColor(this.left), null, null); + LLRBNode newRight = this.right.copy(null, null, oppositeColor(this.right), null, null); + + return this.copy(null, null, oppositeColor(this), newLeft, newRight); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/RBTreeSortedMap.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/RBTreeSortedMap.java new file mode 100644 index 000000000000..befa7b72001c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/collection/RBTreeSortedMap.java @@ -0,0 +1,370 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.collection; + +import com.google.api.core.InternalApi; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * This is a red-black tree backed implementation of ImmutableSortedMap. This has better asymptotic + * complexity for large collections, but performs worse in practice than an ArraySortedMap for small + * collections. It also uses about twice as much memory. + * + *

Note: This package is copied from https://github.com/firebase/firebase-admin-java/tree/master/ + * src/main/java/com/google/firebase/database/collection + */ +@InternalApi +public class RBTreeSortedMap extends ImmutableSortedMap { + + private final LLRBNode root; + private final Comparator comparator; + + RBTreeSortedMap(Comparator comparator) { + this.root = LLRBEmptyNode.getInstance(); + this.comparator = comparator; + } + + private RBTreeSortedMap(LLRBNode root, Comparator comparator) { + this.root = root; + this.comparator = comparator; + } + + // For testing purposes + LLRBNode getRoot() { + return root; + } + + private LLRBNode getNode(K key) { + LLRBNode node = root; + while (!node.isEmpty()) { + int cmp = this.comparator.compare(key, node.getKey()); + if (cmp < 0) { + node = node.getLeft(); + } else if (cmp == 0) { + return node; + } else { + node = node.getRight(); + } + } + return null; + } + + @Override + public boolean containsKey(K key) { + return getNode(key) != null; + } + + @Override + public V get(K key) { + LLRBNode node = getNode(key); + return node != null ? node.getValue() : null; + } + + @Override + public ImmutableSortedMap remove(K key) { + if (!this.containsKey(key)) { + return this; + } else { + LLRBNode newRoot = + root.remove(key, this.comparator).copy(null, null, LLRBNode.Color.BLACK, null, null); + return new RBTreeSortedMap<>(newRoot, this.comparator); + } + } + + @Override + public ImmutableSortedMap insert(K key, V value) { + LLRBNode newRoot = + root.insert(key, value, this.comparator).copy(null, null, LLRBNode.Color.BLACK, null, null); + return new RBTreeSortedMap<>(newRoot, this.comparator); + } + + @Override + public K getMinKey() { + return root.getMin().getKey(); + } + + @Override + public K getMaxKey() { + return root.getMax().getKey(); + } + + @Override + public int size() { + return root.size(); + } + + @Override + public boolean isEmpty() { + return root.isEmpty(); + } + + @Override + public void inOrderTraversal(LLRBNode.NodeVisitor visitor) { + root.inOrderTraversal(visitor); + } + + @Override + public Iterator> iterator() { + return new ImmutableSortedMapIterator<>(root, null, this.comparator, false); + } + + @Override + public Iterator> iteratorFrom(K key) { + return new ImmutableSortedMapIterator<>(root, key, this.comparator, false); + } + + @Override + public Iterator> reverseIteratorFrom(K key) { + return new ImmutableSortedMapIterator<>(root, key, this.comparator, true); + } + + @Override + public Iterator> reverseIterator() { + return new ImmutableSortedMapIterator<>(root, null, this.comparator, true); + } + + @Override + public K getPredecessorKey(K key) { + LLRBNode node = root; + LLRBNode rightParent = null; + while (!node.isEmpty()) { + int cmp = this.comparator.compare(key, node.getKey()); + if (cmp == 0) { + if (!node.getLeft().isEmpty()) { + node = node.getLeft(); + while (!node.getRight().isEmpty()) { + node = node.getRight(); + } + return node.getKey(); + } else if (rightParent != null) { + return rightParent.getKey(); + } else { + return null; + } + } else if (cmp < 0) { + node = node.getLeft(); + } else { + rightParent = node; + node = node.getRight(); + } + } + throw new IllegalArgumentException("Couldn't find predecessor key of non-present key: " + key); + } + + @Override + public K getSuccessorKey(K key) { + LLRBNode node = root; + LLRBNode leftParent = null; + while (!node.isEmpty()) { + int cmp = this.comparator.compare(node.getKey(), key); + if (cmp == 0) { + if (!node.getRight().isEmpty()) { + node = node.getRight(); + while (!node.getLeft().isEmpty()) { + node = node.getLeft(); + } + return node.getKey(); + } else if (leftParent != null) { + return leftParent.getKey(); + } else { + return null; + } + } else if (cmp < 0) { + node = node.getRight(); + } else { + leftParent = node; + node = node.getLeft(); + } + } + throw new IllegalArgumentException("Couldn't find successor key of non-present key: " + key); + } + + public int indexOf(K key) { + // Number of nodes that were pruned when descending right + int prunedNodes = 0; + LLRBNode node = root; + while (!node.isEmpty()) { + int cmp = this.comparator.compare(key, node.getKey()); + if (cmp == 0) { + return prunedNodes + node.getLeft().size(); + } else if (cmp < 0) { + node = node.getLeft(); + } else { + // Count all nodes left of the node plus the node itself + prunedNodes += node.getLeft().size() + 1; + node = node.getRight(); + } + } + // Node not found + return -1; + } + + @Override + public Comparator getComparator() { + return comparator; + } + + public static RBTreeSortedMap buildFrom( + List keys, + Map values, + ImmutableSortedMap.Builder.KeyTranslator translator, + Comparator comparator) { + return Builder.buildFrom(keys, values, translator, comparator); + } + + public static RBTreeSortedMap fromMap(Map values, Comparator comparator) { + return Builder.buildFrom( + new ArrayList<>(values.keySet()), + values, + ImmutableSortedMap.Builder.identityTranslator(), + comparator); + } + + private static class Builder { + + static class BooleanChunk { + public boolean isOne; + public int chunkSize; + } + + static class Base1_2 implements Iterable { + + private final long value; + private final int length; + + public Base1_2(int size) { + int toCalc = size + 1; + length = (int) Math.floor(Math.log(toCalc) / Math.log(2)); + long mask = (long) (Math.pow(2, length)) - 1; + value = toCalc & mask; + } + + /** + * Iterates over booleans for whether or not a particular digit is a '1' in base {1, 2} + * + * @return A reverse iterator over the base {1, 2} number + */ + @Override + public Iterator iterator() { + return new Iterator() { + + private int current = length - 1; + + @Override + public boolean hasNext() { + return current >= 0; + } + + @Override + public BooleanChunk next() { + long result = value & ((byte) 1 << current); + BooleanChunk next = new BooleanChunk(); + next.isOne = result == 0; + next.chunkSize = (int) Math.pow(2, current); + current--; + return next; + } + + @Override + public void remove() { + // No-op + } + }; + } + } + + private final List keys; + private final Map values; + private final ImmutableSortedMap.Builder.KeyTranslator keyTranslator; + + private LLRBValueNode root; + private LLRBValueNode leaf; + + private Builder( + List keys, Map values, ImmutableSortedMap.Builder.KeyTranslator translator) { + this.keys = keys; + this.values = values; + this.keyTranslator = translator; + } + + private C getValue(A key) { + return values.get(keyTranslator.translate(key)); + } + + private LLRBNode buildBalancedTree(int start, int size) { + if (size == 0) { + return LLRBEmptyNode.getInstance(); + } else if (size == 1) { + A key = this.keys.get(start); + return new LLRBBlackValueNode<>(key, getValue(key), null, null); + } else { + int half = size / 2; + int middle = start + half; + LLRBNode left = buildBalancedTree(start, half); + LLRBNode right = buildBalancedTree(middle + 1, half); + A key = this.keys.get(middle); + return new LLRBBlackValueNode<>(key, getValue(key), left, right); + } + } + + private void buildPennant(LLRBNode.Color color, int chunkSize, int start) { + LLRBNode treeRoot = buildBalancedTree(start + 1, chunkSize - 1); + A key = this.keys.get(start); + LLRBValueNode node; + if (color == LLRBNode.Color.RED) { + node = new LLRBRedValueNode<>(key, getValue(key), null, treeRoot); + } else { + node = new LLRBBlackValueNode<>(key, getValue(key), null, treeRoot); + } + if (root == null) { + root = node; + leaf = node; + } else { + leaf.setLeft(node); + leaf = node; + } + } + + public static RBTreeSortedMap buildFrom( + List keys, + Map values, + ImmutableSortedMap.Builder.KeyTranslator translator, + Comparator comparator) { + Builder builder = new Builder<>(keys, values, translator); + keys.sort(comparator); + Iterator iter = (new Base1_2(keys.size())).iterator(); + int index = keys.size(); + while (iter.hasNext()) { + BooleanChunk next = iter.next(); + index -= next.chunkSize; + if (next.isOne) { + builder.buildPennant(LLRBNode.Color.BLACK, next.chunkSize, index); + } else { + builder.buildPennant(LLRBNode.Color.BLACK, next.chunkSize, index); + index -= next.chunkSize; + builder.buildPennant(LLRBNode.Color.RED, next.chunkSize, index); + } + } + return new RBTreeSortedMap<>( + builder.root == null ? LLRBEmptyNode.getInstance() : builder.root, comparator); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/BeanMapper.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/BeanMapper.java new file mode 100644 index 000000000000..fd5067b089e2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/BeanMapper.java @@ -0,0 +1,204 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.encoding; + +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.annotation.DocumentId; +import com.google.cloud.firestore.annotation.IgnoreExtraProperties; +import com.google.cloud.firestore.annotation.PropertyName; +import com.google.cloud.firestore.annotation.ServerTimestamp; +import com.google.cloud.firestore.annotation.ThrowOnExtraProperties; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.time.Instant; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.Map; + +/** Base bean mapper class, providing common functionality for class and record serialization. */ +abstract class BeanMapper { + private final Class clazz; + // Whether to throw exception if there are properties we don't know how to set to + // custom object fields/setters or record components during deserialization. + private final boolean throwOnUnknownProperties; + // Whether to log a message if there are properties we don't know how to set to + // custom object fields/setters or record components during deserialization. + private final boolean warnOnUnknownProperties; + // A set of property names that were annotated with @ServerTimestamp. + final HashSet serverTimestamps; + // A set of property names that were annotated with @DocumentId. These properties will be + // populated with document ID values during deserialization, and be skipped during + // serialization. + final HashSet documentIdPropertyNames; + + BeanMapper(Class clazz) { + this.clazz = clazz; + throwOnUnknownProperties = clazz.isAnnotationPresent(ThrowOnExtraProperties.class); + warnOnUnknownProperties = !clazz.isAnnotationPresent(IgnoreExtraProperties.class); + serverTimestamps = new HashSet<>(); + documentIdPropertyNames = new HashSet<>(); + } + + Class getClazz() { + return clazz; + } + + boolean isThrowOnUnknownProperties() { + return throwOnUnknownProperties; + } + + boolean isWarnOnUnknownProperties() { + return warnOnUnknownProperties; + } + + /** + * Serialize an object to a map. + * + * @param object the object to serialize + * @param path the path to a specific field/component in an object, for use in error messages + * @return the map + */ + abstract Map serialize(T object, DeserializeContext.ErrorPath path); + + /** + * Deserialize a map to an object. + * + * @param values the map to deserialize + * @param types generic type mappings + * @param context context information about the deserialization operation + * @return the deserialized object + */ + abstract T deserialize( + Map values, + Map>, Type> types, + DeserializeContext context); + + T deserialize(Map values, DeserializeContext context) { + return deserialize(values, Collections.emptyMap(), context); + } + + protected void verifyValidType(T object) { + if (!clazz.isAssignableFrom(object.getClass())) { + throw new IllegalArgumentException( + "Can't serialize object of class " + + object.getClass() + + " with BeanMapper for class " + + clazz); + } + } + + protected Type resolveType(Type type, Map>, Type> types) { + if (type instanceof TypeVariable) { + Type resolvedType = types.get(type); + if (resolvedType == null) { + throw new IllegalStateException("Could not resolve type " + type); + } + + return resolvedType; + } + + return type; + } + + protected void checkForDocIdConflict( + String docIdPropertyName, + Collection deserializedProperties, + DeserializeContext context) { + if (deserializedProperties.contains(docIdPropertyName)) { + String message = + "'" + + docIdPropertyName + + "' was found from document " + + context.documentRef.getPath() + + ", cannot apply @DocumentId on this property for class " + + clazz.getName(); + throw new RuntimeException(message); + } + } + + protected Object getSerializedValue( + String property, Object propertyValue, DeserializeContext.ErrorPath path) { + if (serverTimestamps.contains(property) && propertyValue == null) { + // Replace null ServerTimestamp-annotated fields with the sentinel. + return FieldValue.serverTimestamp(); + } else { + return CustomClassMapper.serialize(propertyValue, path.child(property)); + } + } + + protected void applyFieldAnnotations(Field field) { + Class fieldType = field.getType(); + if (field.isAnnotationPresent(ServerTimestamp.class)) { + validateServerTimestampType("Field", "is", fieldType); + serverTimestamps.add(propertyName(field)); + } + if (field.isAnnotationPresent(DocumentId.class)) { + validateDocumentIdType("Field", "is", fieldType); + documentIdPropertyNames.add(propertyName(field)); + } + } + + protected void validateDocumentIdType(String fieldDescription, String operation, Type type) { + if (type != String.class && type != DocumentReference.class) { + throw new IllegalArgumentException( + fieldDescription + + " is annotated with @DocumentId but " + + operation + + " " + + type + + " instead of String or DocumentReference."); + } + } + + protected void validateServerTimestampType(String fieldDescription, String operation, Type type) { + if (type != Date.class && type != Timestamp.class && type != Instant.class) { + throw new IllegalArgumentException( + fieldDescription + + " is annotated with @ServerTimestamp but " + + operation + + " " + + type + + " instead of Date, Timestamp, or Instant."); + } + } + + protected String propertyName(Field field) { + String annotatedName = annotatedName(field); + return annotatedName != null ? annotatedName : field.getName(); + } + + protected String annotatedName(AccessibleObject obj) { + if (obj.isAnnotationPresent(PropertyName.class)) { + PropertyName annotation = obj.getAnnotation(PropertyName.class); + return annotation.value(); + } + + return null; + } + + protected void hardAssert(boolean assertion, String message) { + if (!assertion) { + throw new RuntimeException("Hard assert failed: " + message); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/CustomClassMapper.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/CustomClassMapper.java new file mode 100644 index 000000000000..536fbd6187f2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/CustomClassMapper.java @@ -0,0 +1,629 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.encoding; + +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Blob; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.GeoPoint; +import com.google.cloud.firestore.VectorValue; +import com.google.cloud.firestore.annotation.DocumentId; +import com.google.cloud.firestore.annotation.PropertyName; +import com.google.firestore.v1.Value; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.lang.reflect.GenericArrayType; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.lang.reflect.WildcardType; +import java.math.BigDecimal; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** Helper class to convert to/from custom POJO classes and plain Java types. */ +@InternalApi +public class CustomClassMapper { + + /** Maximum depth before we give up and assume it's a recursive object graph. */ + private static final int MAX_DEPTH = 500; + + private static final ConcurrentMap, BeanMapper> mappers = new ConcurrentHashMap<>(); + + /** + * Converts a Java representation of JSON data to standard library Java data types: Map, Array, + * String, Double, Integer and Boolean. POJOs are converted to Java Maps. + * + * @param object The representation of the JSON data + * @return JSON representation containing only standard library Java types + */ + public static Object convertToPlainJavaTypes(Object object) { + return serialize(object); + } + + public static Map convertToPlainJavaTypes(Map update) { + Object converted = serialize(update); + hardAssert(converted instanceof Map); + @SuppressWarnings("unchecked") + Map convertedMap = (Map) converted; + return convertedMap; + } + + /** + * Converts a standard library Java representation of JSON data to an object of the provided + * class. + * + * @param object The representation of the JSON data + * @param clazz The class of the object to convert to + * @param docRef The value to set to {@link DocumentId} annotated fields in the custom class. + * @return The POJO object. + */ + public static T convertToCustomClass( + Object object, Class clazz, DocumentReference docRef) { + return deserializeToClass( + object, clazz, new DeserializeContext(DeserializeContext.ErrorPath.EMPTY, docRef)); + } + + public static Object serialize(T o) { + return serialize(o, DeserializeContext.ErrorPath.EMPTY); + } + + @SuppressWarnings("unchecked") + static Object serialize(T o, DeserializeContext.ErrorPath path) { + if (path.getLength() > MAX_DEPTH) { + throw path.serializeError( + "Exceeded maximum depth of " + + MAX_DEPTH + + ", which likely indicates there's an object cycle"); + } + if (o == null) { + return null; + } else if (o instanceof Number) { + if (o instanceof Long || o instanceof Integer || o instanceof Double || o instanceof Float) { + return o; + } else if (o instanceof BigDecimal) { + return String.valueOf(o); + } else { + throw path.serializeError( + String.format( + "Numbers of type %s are not supported, please use an int, long, float, double or" + + " BigDecimal", + o.getClass().getSimpleName())); + } + } else if (o instanceof String) { + return o; + } else if (o instanceof Boolean) { + return o; + } else if (o instanceof Character) { + throw path.serializeError("Characters are not supported, please use Strings"); + } else if (o instanceof Map) { + Map result = new HashMap<>(); + for (Map.Entry entry : ((Map) o).entrySet()) { + Object key = entry.getKey(); + if (key instanceof String) { + String keyString = (String) key; + result.put(keyString, serialize(entry.getValue(), path.child(keyString))); + } else { + throw path.serializeError("Maps with non-string keys are not supported"); + } + } + return result; + } else if (o instanceof Collection) { + if (o instanceof List) { + List list = (List) o; + List result = new ArrayList<>(list.size()); + for (int i = 0; i < list.size(); i++) { + result.add(serialize(list.get(i), path.child("[" + i + "]"))); + } + return result; + } else { + throw path.serializeError( + "Serializing Collections is not supported, please use Lists instead"); + } + } else if (o.getClass().isArray()) { + throw path.serializeError("Serializing Arrays is not supported, please use Lists instead"); + } else if (o instanceof Enum) { + String enumName = ((Enum) o).name(); + try { + Field enumField = o.getClass().getField(enumName); + return propertyName(enumField); + } catch (NoSuchFieldException ex) { + return enumName; + } + } else if (o instanceof Date + || o instanceof Timestamp + || o instanceof GeoPoint + || o instanceof Blob + || o instanceof DocumentReference + || o instanceof FieldValue + || o instanceof Value + || o instanceof VectorValue) { + return o; + } else if (o instanceof Instant) { + Instant instant = (Instant) o; + return Timestamp.ofTimeSecondsAndNanos(instant.getEpochSecond(), instant.getNano()); + } else { + Class clazz = (Class) o.getClass(); + BeanMapper mapper = loadOrCreateBeanMapperForClass(clazz); + return mapper.serialize(o, path); + } + } + + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) + static T deserializeToType(Object o, Type type, DeserializeContext context) { + if (o == null) { + return null; + } else if (type instanceof ParameterizedType) { + return deserializeToParameterizedType(o, (ParameterizedType) type, context); + } else if (type instanceof Class) { + return deserializeToClass(o, (Class) type, context); + } else if (type instanceof WildcardType) { + Type[] lowerBounds = ((WildcardType) type).getLowerBounds(); + if (lowerBounds.length > 0) { + throw context.errorPath.deserializeError( + "Generic lower-bounded wildcard types are not supported"); + } + + // Upper bounded wildcards are of the form . Multiple upper bounds are allowed + // but if any of the bounds are of class type, that bound must come first in this array. Note + // that this array always has at least one element, since the unbounded wildcard always + // has at least an upper bound of Object. + Type[] upperBounds = ((WildcardType) type).getUpperBounds(); + hardAssert(upperBounds.length > 0, "Unexpected type bounds on wildcard " + type); + return deserializeToType(o, upperBounds[0], context); + } else if (type instanceof TypeVariable) { + // As above, TypeVariables always have at least one upper bound of Object. + Type[] upperBounds = ((TypeVariable) type).getBounds(); + hardAssert(upperBounds.length > 0, "Unexpected type bounds on type variable " + type); + return deserializeToType(o, upperBounds[0], context); + + } else if (type instanceof GenericArrayType) { + throw context.errorPath.deserializeError( + "Generic Arrays are not supported, please use Lists instead"); + } else { + throw context.errorPath.deserializeError("Unknown type encountered: " + type); + } + } + + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) + private static T deserializeToParameterizedType( + Object o, ParameterizedType type, DeserializeContext context) { + // getRawType should always return a Class + Class rawType = (Class) type.getRawType(); + if (List.class.isAssignableFrom(rawType)) { + Type genericType = type.getActualTypeArguments()[0]; + if (o instanceof List) { + List list = (List) o; + List result; + try { + result = + (rawType == List.class) + ? new ArrayList<>(list.size()) + : (List) rawType.getDeclaredConstructor().newInstance(); + } catch (InstantiationException + | IllegalAccessException + | NoSuchMethodException + | InvocationTargetException e) { + throw context.errorPath.deserializeError( + String.format( + "Unable to deserialize to %s: %s", rawType.getSimpleName(), e.toString())); + } + for (int i = 0; i < list.size(); i++) { + result.add( + deserializeToType( + list.get(i), + genericType, + context.newInstanceWithErrorPath(context.errorPath.child("[" + i + "]")))); + } + return (T) result; + } else { + throw context.errorPath.deserializeError("Expected a List, but got a " + o.getClass()); + } + } else if (Map.class.isAssignableFrom(rawType)) { + Type keyType = type.getActualTypeArguments()[0]; + Type valueType = type.getActualTypeArguments()[1]; + if (!keyType.equals(String.class)) { + throw context.errorPath.deserializeError( + "Only Maps with string keys are supported, but found Map with key type " + keyType); + } + Map map = expectMap(o, context.errorPath); + HashMap result; + try { + result = + (rawType == Map.class) + ? new HashMap<>() + : (HashMap) rawType.getDeclaredConstructor().newInstance(); + } catch (InstantiationException + | IllegalAccessException + | NoSuchMethodException + | InvocationTargetException e) { + throw context.errorPath.deserializeError( + String.format( + "Unable to deserialize to %s: %s", rawType.getSimpleName(), e.toString())); + } + for (Map.Entry entry : map.entrySet()) { + result.put( + entry.getKey(), + deserializeToType( + entry.getValue(), + valueType, + context.newInstanceWithErrorPath(context.errorPath.child(entry.getKey())))); + } + return (T) result; + } else if (Collection.class.isAssignableFrom(rawType)) { + throw context.errorPath.deserializeError( + "Collections are not supported, please use Lists instead"); + } else { + Map map = expectMap(o, context.errorPath); + BeanMapper mapper = (BeanMapper) loadOrCreateBeanMapperForClass(rawType); + HashMap>, Type> typeMapping = new HashMap<>(); + TypeVariable>[] typeVariables = mapper.getClazz().getTypeParameters(); + Type[] types = type.getActualTypeArguments(); + if (types.length != typeVariables.length) { + throw new IllegalStateException("Mismatched lengths for type variables and actual types"); + } + for (int i = 0; i < typeVariables.length; i++) { + typeMapping.put(typeVariables[i], types[i]); + } + return mapper.deserialize(map, typeMapping, context); + } + } + + @SuppressWarnings("unchecked") + private static T deserializeToClass(Object o, Class clazz, DeserializeContext context) { + if (o == null) { + return null; + } else if (clazz.isPrimitive() + || Number.class.isAssignableFrom(clazz) + || Boolean.class.isAssignableFrom(clazz) + || Character.class.isAssignableFrom(clazz)) { + return deserializeToPrimitive(o, clazz, context.errorPath); + } else if (String.class.isAssignableFrom(clazz)) { + return (T) convertString(o, context.errorPath); + } else if (Date.class.isAssignableFrom(clazz)) { + return (T) convertDate(o, context.errorPath); + } else if (Timestamp.class.isAssignableFrom(clazz)) { + return (T) convertTimestamp(o, context.errorPath); + } else if (Instant.class.isAssignableFrom(clazz)) { + return (T) convertInstant(o, context.errorPath); + } else if (Blob.class.isAssignableFrom(clazz)) { + return (T) convertBlob(o, context.errorPath); + } else if (GeoPoint.class.isAssignableFrom(clazz)) { + return (T) convertGeoPoint(o, context.errorPath); + } else if (VectorValue.class.isAssignableFrom(clazz)) { + return (T) convertVectorValue(o, context.errorPath); + } else if (DocumentReference.class.isAssignableFrom(clazz)) { + return (T) convertDocumentReference(o, context.errorPath); + } else if (clazz.isArray()) { + throw context.errorPath.deserializeError( + "Converting to Arrays is not supported, please use Lists instead"); + } else if (clazz.getTypeParameters().length > 0) { + throw context.errorPath.deserializeError( + "Class " + + clazz.getName() + + " has generic type parameters, please use GenericTypeIndicator instead"); + } else if (clazz.equals(Object.class)) { + return (T) o; + } else if (clazz.isEnum()) { + return deserializeToEnum(o, clazz, context.errorPath); + } else { + return convertBean(o, clazz, context); + } + } + + private static T convertBean(Object o, Class clazz, DeserializeContext context) { + BeanMapper mapper = loadOrCreateBeanMapperForClass(clazz); + if (o instanceof Map) { + return mapper.deserialize(expectMap(o, context.errorPath), context); + } else { + throw context.errorPath.deserializeError( + "Can't convert object of type " + o.getClass().getName() + " to type " + clazz.getName()); + } + } + + private static BeanMapper loadOrCreateBeanMapperForClass(Class clazz) { + @SuppressWarnings("unchecked") + BeanMapper mapper = (BeanMapper) mappers.get(clazz); + if (mapper == null) { + if (isRecordType(clazz)) { + mapper = new RecordMapper<>(clazz); + } else { + mapper = new PojoBeanMapper<>(clazz); + } + // Inserting without checking is fine because mappers are "pure" and it's okay + // if we create and use multiple by different threads temporarily + mappers.put(clazz, mapper); + } + return mapper; + } + + @SuppressWarnings("unchecked") + private static Map expectMap( + Object object, DeserializeContext.ErrorPath errorPath) { + if (object instanceof Map) { + // TODO: runtime validation of keys? + return (Map) object; + } else { + throw errorPath.deserializeError( + "Expected a Map while deserializing, but got a " + object.getClass()); + } + } + + @SuppressWarnings("unchecked") + private static T deserializeToPrimitive( + Object o, Class clazz, DeserializeContext.ErrorPath errorPath) { + if (Integer.class.isAssignableFrom(clazz) || int.class.isAssignableFrom(clazz)) { + return (T) convertInteger(o, errorPath); + } else if (Boolean.class.isAssignableFrom(clazz) || boolean.class.isAssignableFrom(clazz)) { + return (T) convertBoolean(o, errorPath); + } else if (Double.class.isAssignableFrom(clazz) || double.class.isAssignableFrom(clazz)) { + return (T) convertDouble(o, errorPath); + } else if (Long.class.isAssignableFrom(clazz) || long.class.isAssignableFrom(clazz)) { + return (T) convertLong(o, errorPath); + } else if (BigDecimal.class.isAssignableFrom(clazz)) { + return (T) convertBigDecimal(o, errorPath); + } else if (Float.class.isAssignableFrom(clazz) || float.class.isAssignableFrom(clazz)) { + return (T) (Float) convertDouble(o, errorPath).floatValue(); + } else { + throw errorPath.deserializeError( + String.format("Deserializing values to %s is not supported", clazz.getSimpleName())); + } + } + + @SuppressWarnings("unchecked") + private static T deserializeToEnum( + Object object, Class clazz, DeserializeContext.ErrorPath errorPath) { + if (object instanceof String) { + String value = (String) object; + // We cast to Class without generics here since we can't prove the bound + // T extends Enum statically + + // try to use PropertyName if exist + Field[] enumFields = clazz.getFields(); + for (Field field : enumFields) { + if (field.isEnumConstant()) { + String propertyName = propertyName(field); + if (value.equals(propertyName)) { + value = field.getName(); + break; + } + } + } + + try { + return (T) Enum.valueOf((Class) clazz, value); + } catch (IllegalArgumentException e) { + throw errorPath.deserializeError( + "Could not find enum value of " + clazz.getName() + " for value \"" + value + "\""); + } + } else { + throw errorPath.deserializeError( + "Expected a String while deserializing to enum " + + clazz + + " but got a " + + object.getClass()); + } + } + + private static Integer convertInteger(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Integer) { + return (Integer) o; + } else if (o instanceof Long || o instanceof Double) { + double value = ((Number) o).doubleValue(); + if (value >= Integer.MIN_VALUE && value <= Integer.MAX_VALUE) { + return ((Number) o).intValue(); + } else { + throw errorPath.deserializeError( + "Numeric value out of 32-bit integer range: " + + value + + ". Did you mean to use a long or double instead of an int?"); + } + } else { + throw errorPath.deserializeError( + "Failed to convert a value of type " + o.getClass().getName() + " to int"); + } + } + + private static Long convertLong(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Integer) { + return ((Integer) o).longValue(); + } else if (o instanceof Long) { + return (Long) o; + } else if (o instanceof Double) { + Double value = (Double) o; + if (value >= Long.MIN_VALUE && value <= Long.MAX_VALUE) { + return value.longValue(); + } else { + throw errorPath.deserializeError( + "Numeric value out of 64-bit long range: " + + value + + ". Did you mean to use a double instead of a long?"); + } + } else { + throw errorPath.deserializeError( + "Failed to convert a value of type " + o.getClass().getName() + " to long"); + } + } + + private static Double convertDouble(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Integer) { + return ((Integer) o).doubleValue(); + } else if (o instanceof Long) { + Long value = (Long) o; + Double doubleValue = ((Long) o).doubleValue(); + if (doubleValue.longValue() == value) { + return doubleValue; + } else { + throw errorPath.deserializeError( + "Loss of precision while converting number to " + + "double: " + + o + + ". Did you mean to use a 64-bit long instead?"); + } + } else if (o instanceof Double) { + return (Double) o; + } else { + throw errorPath.deserializeError( + "Failed to convert a value of type " + o.getClass().getName() + " to double"); + } + } + + private static BigDecimal convertBigDecimal(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Integer) { + return BigDecimal.valueOf(((Integer) o).intValue()); + } else if (o instanceof Long) { + return BigDecimal.valueOf(((Long) o).longValue()); + } else if (o instanceof Double) { + return BigDecimal.valueOf(((Double) o).doubleValue()).abs(); + } else if (o instanceof BigDecimal) { + return (BigDecimal) o; + } else if (o instanceof String) { + return new BigDecimal((String) o); + } else { + throw errorPath.deserializeError( + "Failed to convert a value of type " + o.getClass().getName() + " to BigDecimal"); + } + } + + private static Boolean convertBoolean(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Boolean) { + return (Boolean) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to boolean"); + } + } + + private static String convertString(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof String) { + return (String) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to String"); + } + } + + private static Date convertDate(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Date) { + return (Date) o; + } else if (o instanceof Timestamp) { + return ((Timestamp) o).toDate(); + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to Date"); + } + } + + private static Timestamp convertTimestamp(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Timestamp) { + return (Timestamp) o; + } else if (o instanceof Date) { + return Timestamp.of((Date) o); + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to Timestamp"); + } + } + + private static Instant convertInstant(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Timestamp) { + Timestamp timestamp = (Timestamp) o; + return Instant.ofEpochSecond(timestamp.getSeconds(), timestamp.getNanos()); + } else if (o instanceof Date) { + return Instant.ofEpochMilli(((Date) o).getTime()); + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to Instant"); + } + } + + private static Blob convertBlob(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof Blob) { + return (Blob) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to Blob"); + } + } + + private static GeoPoint convertGeoPoint(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof GeoPoint) { + return (GeoPoint) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to GeoPoint"); + } + } + + private static VectorValue convertVectorValue(Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof VectorValue) { + return (VectorValue) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to VectorValue"); + } + } + + private static DocumentReference convertDocumentReference( + Object o, DeserializeContext.ErrorPath errorPath) { + if (o instanceof DocumentReference) { + return (DocumentReference) o; + } else { + throw errorPath.deserializeError( + "Failed to convert value of type " + o.getClass().getName() + " to DocumentReference"); + } + } + + private static boolean isRecordType(Class cls) { + Class parent = cls.getSuperclass(); + return parent != null && "java.lang.Record".equals(parent.getName()); + } + + private static String propertyName(Field field) { + String annotatedName = annotatedName(field); + return annotatedName != null ? annotatedName : field.getName(); + } + + private static String annotatedName(AccessibleObject obj) { + if (obj.isAnnotationPresent(PropertyName.class)) { + PropertyName annotation = obj.getAnnotation(PropertyName.class); + return annotation.value(); + } + + return null; + } + + private static void hardAssert(boolean assertion) { + hardAssert(assertion, "Internal inconsistency"); + } + + private static void hardAssert(boolean assertion, String message) { + if (!assertion) { + throw new RuntimeException("Hard assert failed: " + message); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/DeserializeContext.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/DeserializeContext.java new file mode 100644 index 000000000000..df85f5817a47 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/DeserializeContext.java @@ -0,0 +1,92 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.encoding; + +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.annotation.DocumentId; + +/** Holds information a deserialization operation needs to complete the job. */ +class DeserializeContext { + /** + * Immutable class representing the path to a specific field in an object. Used to provide better + * error messages. + */ + static class ErrorPath { + static final ErrorPath EMPTY = new ErrorPath(null, null, 0); + + private final int length; + private final ErrorPath parent; + private final String name; + + ErrorPath child(String name) { + return new ErrorPath(this, name, length + 1); + } + + @Override + public String toString() { + if (length == 0) { + return ""; + } else if (length == 1) { + return name; + } else { + // This is not very efficient, but it's only hit if there's an error. + return parent.toString() + "." + name; + } + } + + ErrorPath(ErrorPath parent, String name, int length) { + this.parent = parent; + this.name = name; + this.length = length; + } + + int getLength() { + return length; + } + + IllegalArgumentException serializeError(String reason) { + reason = "Could not serialize object. " + reason; + if (getLength() > 0) { + reason = reason + " (found in field '" + toString() + "')"; + } + return new IllegalArgumentException(reason); + } + + RuntimeException deserializeError(String reason) { + reason = "Could not deserialize object. " + reason; + if (getLength() > 0) { + reason = reason + " (found in field '" + toString() + "')"; + } + return new RuntimeException(reason); + } + } + + /** Current path to the field being deserialized, used for better error messages. */ + final ErrorPath errorPath; + + /** Value used to set to {@link DocumentId} annotated fields during deserialization, if any. */ + final DocumentReference documentRef; + + DeserializeContext newInstanceWithErrorPath(ErrorPath newPath) { + return new DeserializeContext(newPath, documentRef); + } + + DeserializeContext(ErrorPath path, DocumentReference docRef) { + errorPath = path; + documentRef = docRef; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/PojoBeanMapper.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/PojoBeanMapper.java new file mode 100644 index 000000000000..adf7ef229f30 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/PojoBeanMapper.java @@ -0,0 +1,494 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.encoding; + +import com.google.cloud.firestore.annotation.DocumentId; +import com.google.cloud.firestore.annotation.Exclude; +import com.google.cloud.firestore.annotation.ServerTimestamp; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Locale; +import java.util.Map; +import java.util.logging.Logger; + +// Helper class to convert from maps to custom objects (Beans), and vice versa. +class PojoBeanMapper extends BeanMapper { + private static final Logger LOGGER = Logger.getLogger(PojoBeanMapper.class.getName()); + + private final Constructor constructor; + + // Case insensitive mapping of properties to their case sensitive versions + private final Map properties; + + // Below are maps to find getter/setter/field from a given property name. + // A property name is the name annotated by @PropertyName, if exists; or their property name + // following the Java Bean convention: field name is kept as-is while getters/setters will have + // their prefixes removed. See method propertyName for details. + private final Map getters; + private final Map setters; + private final Map fields; + + PojoBeanMapper(Class clazz) { + super(clazz); + properties = new HashMap<>(); + + setters = new HashMap<>(); + getters = new HashMap<>(); + fields = new HashMap<>(); + + Constructor constructor; + try { + constructor = clazz.getDeclaredConstructor(); + constructor.setAccessible(true); + } catch (NoSuchMethodException e) { + // We will only fail at deserialization time if no constructor is present + constructor = null; + } + this.constructor = constructor; + // Add any public getters to properties (including isXyz()) + for (Method method : clazz.getMethods()) { + if (shouldIncludeGetter(method)) { + String propertyName = propertyName(method); + addProperty(propertyName); + method.setAccessible(true); + if (getters.containsKey(propertyName)) { + throw new RuntimeException( + "Found conflicting getters for name " + + method.getName() + + " on class " + + clazz.getName()); + } + getters.put(propertyName, method); + applyGetterAnnotations(method); + } + } + + // Add any public fields to properties + for (Field field : clazz.getFields()) { + if (shouldIncludeField(field)) { + String propertyName = propertyName(field); + addProperty(propertyName); + applyFieldAnnotations(field); + } + } + + // We can use private setters and fields for known (public) properties/getters. Since + // getMethods/getFields only returns public methods/fields we need to traverse the + // class hierarchy to find the appropriate setter or field. + Class currentClass = clazz; + do { + // Add any setters + for (Method method : currentClass.getDeclaredMethods()) { + if (shouldIncludeSetter(method)) { + String propertyName = propertyName(method); + String existingPropertyName = properties.get(propertyName.toLowerCase(Locale.US)); + if (existingPropertyName != null) { + if (!existingPropertyName.equals(propertyName)) { + throw new RuntimeException( + "Found setter on " + + currentClass.getName() + + " with invalid case-sensitive name: " + + method.getName()); + } else { + Method existingSetter = setters.get(propertyName); + if (existingSetter == null) { + method.setAccessible(true); + setters.put(propertyName, method); + applySetterAnnotations(method); + } else if (!isSetterOverride(method, existingSetter)) { + // We require that setters with conflicting property names are + // overrides from a base class + if (currentClass == clazz) { + // TODO: Should we support overloads? + throw new RuntimeException( + "Class " + + clazz.getName() + + " has multiple setter overloads with name " + + method.getName()); + } else { + throw new RuntimeException( + "Found conflicting setters " + + "with name: " + + method.getName() + + " (conflicts with " + + existingSetter.getName() + + " defined on " + + existingSetter.getDeclaringClass().getName() + + ")"); + } + } + } + } + } + } + + for (Field field : currentClass.getDeclaredFields()) { + String propertyName = propertyName(field); + + // Case sensitivity is checked at deserialization time + // Fields are only added if they don't exist on a subclass + if (properties.containsKey(propertyName.toLowerCase(Locale.US)) + && !fields.containsKey(propertyName)) { + field.setAccessible(true); + fields.put(propertyName, field); + applyFieldAnnotations(field); + } + } + + // Traverse class hierarchy until we reach java.lang.Object which contains a bunch + // of fields/getters we don't want to serialize + currentClass = currentClass.getSuperclass(); + } while (currentClass != null && !currentClass.equals(Object.class)); + + if (properties.isEmpty()) { + throw new RuntimeException("No properties to serialize found on class " + clazz.getName()); + } + + // Make sure we can write to @DocumentId annotated properties before proceeding. + for (String docIdProperty : documentIdPropertyNames) { + if (!setters.containsKey(docIdProperty) && !fields.containsKey(docIdProperty)) { + throw new RuntimeException( + "@DocumentId is annotated on property " + + docIdProperty + + " of class " + + clazz.getName() + + " but no field or public setter was found"); + } + } + } + + @Override + Map serialize(T object, DeserializeContext.ErrorPath path) { + verifyValidType(object); + Map result = new HashMap<>(); + for (String property : properties.values()) { + // Skip @DocumentId annotated properties; + if (documentIdPropertyNames.contains(property)) { + continue; + } + + Object propertyValue; + if (getters.containsKey(property)) { + Method getter = getters.get(property); + try { + propertyValue = getter.invoke(object); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } else { + // Must be a field + Field field = fields.get(property); + if (field == null) { + throw new IllegalStateException("Bean property without field or getter: " + property); + } + try { + propertyValue = field.get(object); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + Object serializedValue = getSerializedValue(property, propertyValue, path); + + result.put(property, serializedValue); + } + return result; + } + + @Override + T deserialize( + Map values, + Map>, Type> types, + DeserializeContext context) { + if (constructor == null) { + throw context.errorPath.deserializeError( + "Class " + + getClazz().getName() + + " does not define a no-argument constructor. If you are using ProGuard, make " + + "sure these constructors are not stripped"); + } + + T instance; + try { + instance = constructor.newInstance(); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + HashSet deserializedProperties = new HashSet<>(); + for (Map.Entry entry : values.entrySet()) { + String propertyName = entry.getKey(); + DeserializeContext.ErrorPath childPath = context.errorPath.child(propertyName); + if (setters.containsKey(propertyName)) { + Method setter = setters.get(propertyName); + Type[] params = setter.getGenericParameterTypes(); + if (params.length != 1) { + throw childPath.deserializeError("Setter does not have exactly one parameter"); + } + Type resolvedType = resolveType(params[0], types); + Object value = + CustomClassMapper.deserializeToType( + entry.getValue(), resolvedType, context.newInstanceWithErrorPath(childPath)); + try { + setter.invoke(instance, value); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + deserializedProperties.add(propertyName); + } else if (fields.containsKey(propertyName)) { + Field field = fields.get(propertyName); + Type resolvedType = resolveType(field.getGenericType(), types); + Object value = + CustomClassMapper.deserializeToType( + entry.getValue(), resolvedType, context.newInstanceWithErrorPath(childPath)); + try { + field.set(instance, value); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + deserializedProperties.add(propertyName); + } else { + String message = + "No setter/field for " + propertyName + " found on class " + getClazz().getName(); + if (properties.containsKey(propertyName.toLowerCase(Locale.US))) { + message += " (fields/setters are case sensitive!)"; + } + if (isThrowOnUnknownProperties()) { + throw new RuntimeException(message); + } else if (isWarnOnUnknownProperties()) { + LOGGER.warning(message); + } + } + } + populateDocumentIdProperties(types, context, instance, deserializedProperties); + + return instance; + } + + private void addProperty(String property) { + String oldValue = properties.put(property.toLowerCase(Locale.US), property); + if (oldValue != null && !property.equals(oldValue)) { + throw new RuntimeException( + "Found two getters or fields with conflicting case " + + "sensitivity for property: " + + property.toLowerCase(Locale.US)); + } + } + + // Populate @DocumentId annotated fields. If there is a conflict (@DocumentId annotation is + // applied to a property that is already deserialized from the firestore document) + // a runtime exception will be thrown. + private void populateDocumentIdProperties( + Map>, Type> types, + DeserializeContext context, + T instance, + HashSet deserializedProperties) { + for (String docIdPropertyName : documentIdPropertyNames) { + checkForDocIdConflict(docIdPropertyName, deserializedProperties, context); + DeserializeContext.ErrorPath childPath = context.errorPath.child(docIdPropertyName); + if (setters.containsKey(docIdPropertyName)) { + Method setter = setters.get(docIdPropertyName); + Type[] params = setter.getGenericParameterTypes(); + if (params.length != 1) { + throw childPath.deserializeError("Setter does not have exactly one parameter"); + } + Type resolvedType = resolveType(params[0], types); + try { + if (resolvedType == String.class) { + setter.invoke(instance, context.documentRef.getId()); + } else { + setter.invoke(instance, context.documentRef); + } + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } else { + Field docIdField = fields.get(docIdPropertyName); + try { + if (docIdField.getType() == String.class) { + docIdField.set(instance, context.documentRef.getId()); + } else { + docIdField.set(instance, context.documentRef); + } + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + } + + private void applyGetterAnnotations(Method method) { + Class returnType = method.getReturnType(); + if (method.isAnnotationPresent(ServerTimestamp.class)) { + validateServerTimestampType("Method", "returns", returnType); + serverTimestamps.add(propertyName(method)); + } + // Even though the value will be skipped, we still check for type matching for consistency. + if (method.isAnnotationPresent(DocumentId.class)) { + validateDocumentIdType("Method", "returns", returnType); + documentIdPropertyNames.add(propertyName(method)); + } + } + + private void applySetterAnnotations(Method method) { + if (method.isAnnotationPresent(ServerTimestamp.class)) { + throw new IllegalArgumentException( + "Method " + + method.getName() + + " is annotated with @ServerTimestamp but should not be. @ServerTimestamp can" + + " only be applied to fields and getters, not setters."); + } + if (method.isAnnotationPresent(DocumentId.class)) { + Class paramType = method.getParameterTypes()[0]; + validateDocumentIdType("Method", "accepts", paramType); + documentIdPropertyNames.add(propertyName(method)); + } + } + + private boolean shouldIncludeGetter(Method method) { + if (!method.getName().startsWith("get") && !method.getName().startsWith("is")) { + return false; + } + // Exclude methods from Object.class + if (method.getDeclaringClass().equals(Object.class)) { + return false; + } + // Non-public methods + if (!Modifier.isPublic(method.getModifiers())) { + return false; + } + // Static methods + if (Modifier.isStatic(method.getModifiers())) { + return false; + } + // No return type + if (method.getReturnType().equals(Void.TYPE)) { + return false; + } + // Non-zero parameters + if (method.getParameterTypes().length != 0) { + return false; + } + // Excluded methods + if (method.isAnnotationPresent(Exclude.class)) { + return false; + } + return true; + } + + private boolean shouldIncludeSetter(Method method) { + if (!method.getName().startsWith("set")) { + return false; + } + // Exclude methods from Object.class + if (method.getDeclaringClass().equals(Object.class)) { + return false; + } + // Static methods + if (Modifier.isStatic(method.getModifiers())) { + return false; + } + // Has a return type + if (!method.getReturnType().equals(Void.TYPE)) { + return false; + } + // Methods without exactly one parameters + if (method.getParameterTypes().length != 1) { + return false; + } + // Excluded methods + if (method.isAnnotationPresent(Exclude.class)) { + return false; + } + return true; + } + + private boolean shouldIncludeField(Field field) { + // Exclude methods from Object.class + if (field.getDeclaringClass().equals(Object.class)) { + return false; + } + // Non-public fields + if (!Modifier.isPublic(field.getModifiers())) { + return false; + } + // Static fields + if (Modifier.isStatic(field.getModifiers())) { + return false; + } + // Transient fields + if (Modifier.isTransient(field.getModifiers())) { + return false; + } + // Excluded fields + if (field.isAnnotationPresent(Exclude.class)) { + return false; + } + return true; + } + + private boolean isSetterOverride(Method base, Method override) { + // We expect an overridden setter here + hardAssert( + base.getDeclaringClass().isAssignableFrom(override.getDeclaringClass()), + "Expected override from a base class"); + hardAssert(base.getReturnType().equals(Void.TYPE), "Expected void return type"); + hardAssert(override.getReturnType().equals(Void.TYPE), "Expected void return type"); + + Type[] baseParameterTypes = base.getParameterTypes(); + Type[] overrideParameterTypes = override.getParameterTypes(); + hardAssert(baseParameterTypes.length == 1, "Expected exactly one parameter"); + hardAssert(overrideParameterTypes.length == 1, "Expected exactly one parameter"); + + return base.getName().equals(override.getName()) + && baseParameterTypes[0].equals(overrideParameterTypes[0]); + } + + private String propertyName(Method method) { + String annotatedName = annotatedName(method); + return annotatedName != null ? annotatedName : serializedName(method.getName()); + } + + private String serializedName(String methodName) { + String[] prefixes = new String[] {"get", "set", "is"}; + String methodPrefix = null; + for (String prefix : prefixes) { + if (methodName.startsWith(prefix)) { + methodPrefix = prefix; + } + } + if (methodPrefix == null) { + throw new IllegalArgumentException("Unknown Bean prefix for method: " + methodName); + } + String strippedName = methodName.substring(methodPrefix.length()); + + // Make sure the first word or upper-case prefix is converted to lower-case + char[] chars = strippedName.toCharArray(); + int pos = 0; + while (pos < chars.length && Character.isUpperCase(chars[pos])) { + chars[pos] = Character.toLowerCase(chars[pos]); + pos++; + } + return new String(chars); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/RecordMapper.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/RecordMapper.java new file mode 100644 index 000000000000..f15f65823d89 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/encoding/RecordMapper.java @@ -0,0 +1,230 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.encoding; + +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.lang.reflect.TypeVariable; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.logging.Logger; + +/** + * Serializes java records. Uses automatic record constructors and accessors only. Therefore, + * exclusion of fields is not supported. Supports DocumentId, PropertyName, and ServerTimestamp + * annotations on record components. Since records are not supported in JDK versions < 16, + * reflection is used for inspecting record metadata. + */ +class RecordMapper extends BeanMapper { + private static final Logger LOGGER = Logger.getLogger(RecordMapper.class.getName()); + private static final RecordInspector RECORD_INSPECTOR = new RecordInspector(); + + // Below are maps to find an accessor and constructor parameter index from a given property name. + // A property name is the name annotated by @PropertyName, if exists; or the component name. + // See method propertyName for details. + private final Map accessors = new HashMap<>(); + private final Constructor constructor; + private final Map constructorParamIndexes = new HashMap<>(); + + RecordMapper(Class clazz) { + super(clazz); + + constructor = RECORD_INSPECTOR.getCanonicalConstructor(clazz); + + AnnotatedElement[] recordComponents = RECORD_INSPECTOR.getRecordComponents(clazz); + if (recordComponents.length == 0) { + throw new RuntimeException("No properties to serialize found on class " + clazz.getName()); + } + + try { + for (int i = 0; i < recordComponents.length; i++) { + Field field = clazz.getDeclaredField(RECORD_INSPECTOR.getName(recordComponents[i])); + String propertyName = propertyName(field); + constructorParamIndexes.put(propertyName, i); + accessors.put(propertyName, RECORD_INSPECTOR.getAccessor(recordComponents[i])); + applyFieldAnnotations(field); + } + } catch (NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + + @Override + Map serialize(T object, DeserializeContext.ErrorPath path) { + verifyValidType(object); + Map result = new HashMap<>(); + for (Map.Entry entry : accessors.entrySet()) { + String property = entry.getKey(); + // Skip @DocumentId annotated properties; + if (documentIdPropertyNames.contains(property)) { + continue; + } + + Object propertyValue; + Method accessor = entry.getValue(); + try { + propertyValue = accessor.invoke(object); + } catch (IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + + Object serializedValue = getSerializedValue(property, propertyValue, path); + + result.put(property, serializedValue); + } + return result; + } + + @Override + T deserialize( + Map values, + Map>, Type> types, + DeserializeContext context) { + Object[] constructorParams = new Object[constructor.getParameterCount()]; + Set deserializedProperties = new HashSet<>(values.size()); + for (Map.Entry entry : values.entrySet()) { + String propertyName = entry.getKey(); + if (accessors.containsKey(propertyName)) { + Method accessor = accessors.get(propertyName); + Type resolvedType = resolveType(accessor.getGenericReturnType(), types); + DeserializeContext.ErrorPath childPath = context.errorPath.child(propertyName); + Object value = + CustomClassMapper.deserializeToType( + entry.getValue(), resolvedType, context.newInstanceWithErrorPath(childPath)); + constructorParams[constructorParamIndexes.get(propertyName).intValue()] = value; + deserializedProperties.add(propertyName); + } else { + String message = + "No accessor for " + propertyName + " found on class " + getClazz().getName(); + if (isThrowOnUnknownProperties()) { + throw new RuntimeException(message); + } + if (isWarnOnUnknownProperties()) { + LOGGER.warning(message); + } + } + } + + populateDocumentIdProperties(types, context, constructorParams, deserializedProperties); + + try { + return constructor.newInstance(constructorParams); + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + + // Populate @DocumentId annotated components. If there is a conflict (@DocumentId annotation is + // applied to a property that is already deserialized from the firestore document) + // a runtime exception will be thrown. + private void populateDocumentIdProperties( + Map>, Type> types, + DeserializeContext context, + Object[] params, + Set deserializedProperties) { + for (String docIdPropertyName : documentIdPropertyNames) { + checkForDocIdConflict(docIdPropertyName, deserializedProperties, context); + + if (accessors.containsKey(docIdPropertyName)) { + Object id; + Type resolvedType = + resolveType(accessors.get(docIdPropertyName).getGenericReturnType(), types); + if (resolvedType == String.class) { + id = context.documentRef.getId(); + } else { + id = context.documentRef; + } + params[constructorParamIndexes.get(docIdPropertyName).intValue()] = id; + } + } + } + + private static final class RecordInspector { + private final Method _getRecordComponents; + private final Method _getName; + private final Method _getType; + private final Method _getAccessor; + + @SuppressWarnings("JavaReflectionMemberAccess") + private RecordInspector() { + try { + _getRecordComponents = Class.class.getMethod("getRecordComponents"); + Class recordComponentClass = Class.forName("java.lang.reflect.RecordComponent"); + _getName = recordComponentClass.getMethod("getName"); + _getType = recordComponentClass.getMethod("getType"); + _getAccessor = recordComponentClass.getMethod("getAccessor"); + } catch (ClassNotFoundException | NoSuchMethodException e) { + throw new IllegalStateException( + "Failed to access class or methods needed to support record serialization", e); + } + } + + private Constructor getCanonicalConstructor(Class cls) { + try { + Class[] paramTypes = + Arrays.stream(getRecordComponents(cls)).map(this::getType).toArray(Class[]::new); + Constructor constructor = cls.getDeclaredConstructor(paramTypes); + constructor.setAccessible(true); + return constructor; + } catch (NoSuchMethodException e) { + throw new IllegalStateException(e); + } + } + + private AnnotatedElement[] getRecordComponents(Class recordType) { + try { + return (AnnotatedElement[]) _getRecordComponents.invoke(recordType); + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalArgumentException( + "Failed to load components of record " + recordType.getName(), e); + } + } + + private Class getType(AnnotatedElement recordComponent) { + try { + return (Class) _getType.invoke(recordComponent); + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalArgumentException("Failed to get record component type", e); + } + } + + private String getName(AnnotatedElement recordComponent) { + try { + return (String) _getName.invoke(recordComponent); + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalArgumentException("Failed to get record component name", e); + } + } + + private Method getAccessor(AnnotatedElement recordComponent) { + try { + Method accessor = (Method) _getAccessor.invoke(recordComponent); + accessor.setAccessible(true); + return accessor; + } catch (InvocationTargetException | IllegalAccessException e) { + throw new IllegalArgumentException("Failed to get record component accessor", e); + } + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AggregateFunction.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AggregateFunction.java new file mode 100644 index 000000000000..1cab6938965f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AggregateFunction.java @@ -0,0 +1,345 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; +import java.util.stream.Collectors; + +/** A class that represents an aggregate function. */ +@BetaApi +public class AggregateFunction { + private final String name; + private final ImmutableList params; + + private AggregateFunction(String name, Expression... params) { + this.name = name; + this.params = ImmutableList.copyOf(params); + } + + private AggregateFunction(String name, String fieldName) { + this(name, Expression.field(fieldName)); + } + + /** + * Creates a raw aggregation function. + * + *

This method provides a way to call aggregation functions that are supported by the Firestore + * backend but that are not available as specific factory methods in this class. + * + * @param name The name of the aggregation function. + * @param expr The expressions to pass as arguments to the function. + * @return A new {@link AggregateFunction} for the specified function. + */ + @BetaApi + public static AggregateFunction rawAggregate(String name, Expression... expr) { + return new AggregateFunction(name, expr); + } + + /** + * Creates an aggregation that counts the total number of stage inputs. + * + * @return A new {@link AggregateFunction} representing the countAll aggregation. + */ + @BetaApi + public static AggregateFunction countAll() { + return new AggregateFunction("count"); + } + + /** + * Creates an aggregation that counts the number of stage inputs where the input field exists. + * + * @param fieldName The name of the field to count. + * @return A new {@link AggregateFunction} representing the 'count' aggregation. + */ + @BetaApi + public static AggregateFunction count(String fieldName) { + return new AggregateFunction("count", fieldName); + } + + /** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * provided {@code expression}. + * + * @param expression The expression to count. + * @return A new {@link AggregateFunction} representing the 'count' aggregation. + */ + @BetaApi + public static AggregateFunction count(Expression expression) { + return new AggregateFunction("count", expression); + } + + /** + * Creates an aggregation that counts the number of distinct values of a field across multiple + * stage inputs. + * + * @param fieldName The name of the field to count the distinct values of. + * @return A new {@link AggregateFunction} representing the count distinct aggregation. + */ + @BetaApi + public static AggregateFunction countDistinct(String fieldName) { + return new AggregateFunction("count_distinct", fieldName); + } + + /** + * Creates an aggregation that counts the number of distinct values of an expression across + * multiple stage inputs. + * + * @param expression The expression to count the distinct values of. + * @return A new {@link AggregateFunction} representing the count distinct aggregation. + */ + @BetaApi + public static AggregateFunction countDistinct(Expression expression) { + return new AggregateFunction("count_distinct", expression); + } + + /** + * Creates an aggregation that counts the number of stage inputs where the provided boolean + * expression evaluates to true. + * + * @param condition The boolean expression to evaluate on each input. + * @return A new {@link AggregateFunction} representing the count aggregation. + */ + @BetaApi + public static AggregateFunction countIf(BooleanExpression condition) { + return new AggregateFunction("count_if", condition); + } + + /** + * Creates an aggregation that calculates the sum of a field's values across multiple stage + * inputs. + * + * @param fieldName The name of the field containing numeric values to sum up. + * @return A new {@link AggregateFunction} representing the sum aggregation. + */ + @BetaApi + public static AggregateFunction sum(String fieldName) { + return new AggregateFunction("sum", fieldName); + } + + /** + * Creates an aggregation that calculates the sum of values from an expression across multiple + * stage inputs. + * + * @param expression The expression to sum up. + * @return A new {@link AggregateFunction} representing the sum aggregation. + */ + @BetaApi + public static AggregateFunction sum(Expression expression) { + return new AggregateFunction("sum", expression); + } + + /** + * Creates an aggregation that calculates the average (mean) of a field's values across multiple + * stage inputs. + * + * @param fieldName The name of the field containing numeric values to average. + * @return A new {@link AggregateFunction} representing the average aggregation. + */ + @BetaApi + public static AggregateFunction average(String fieldName) { + return new AggregateFunction("average", fieldName); + } + + /** + * Creates an aggregation that calculates the average (mean) of values from an expression across + * multiple stage inputs. + * + * @param expression The expression representing the values to average. + * @return A new {@link AggregateFunction} representing the average aggregation. + */ + @BetaApi + public static AggregateFunction average(Expression expression) { + return new AggregateFunction("average", expression); + } + + /** + * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. + * + * @param fieldName The name of the field to find the minimum value of. + * @return A new {@link AggregateFunction} representing the minimum aggregation. + */ + @BetaApi + public static AggregateFunction minimum(String fieldName) { + return new AggregateFunction("minimum", fieldName); + } + + /** + * Creates an aggregation that finds the minimum value of an expression across multiple stage + * inputs. + * + * @param expression The expression to find the minimum value of. + * @return A new {@link AggregateFunction} representing the minimum aggregation. + */ + @BetaApi + public static AggregateFunction minimum(Expression expression) { + return new AggregateFunction("minimum", expression); + } + + /** + * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. + * + * @param fieldName The name of the field to find the maximum value of. + * @return A new {@link AggregateFunction} representing the maximum aggregation. + */ + @BetaApi + public static AggregateFunction maximum(String fieldName) { + return new AggregateFunction("maximum", fieldName); + } + + /** + * Creates an aggregation that finds the maximum value of an expression across multiple stage + * inputs. + * + * @param expression The expression to find the maximum value of. + * @return A new {@link AggregateFunction} representing the maximum aggregation. + */ + @BetaApi + public static AggregateFunction maximum(Expression expression) { + return new AggregateFunction("maximum", expression); + } + + /** + * Creates an aggregation that finds the first value of a field across multiple stage inputs. + * + * @param fieldName The name of the field to find the first value of. + * @return A new {@link AggregateFunction} representing the first aggregation. + */ + @BetaApi + public static AggregateFunction first(String fieldName) { + return new AggregateFunction("first", fieldName); + } + + /** + * Creates an aggregation that finds the first value of an expression across multiple stage + * inputs. + * + * @param expression The expression to find the first value of. + * @return A new {@link AggregateFunction} representing the first aggregation. + */ + @BetaApi + public static AggregateFunction first(Expression expression) { + return new AggregateFunction("first", expression); + } + + /** + * Creates an aggregation that finds the last value of a field across multiple stage inputs. + * + * @param fieldName The name of the field to find the last value of. + * @return A new {@link AggregateFunction} representing the last aggregation. + */ + @BetaApi + public static AggregateFunction last(String fieldName) { + return new AggregateFunction("last", fieldName); + } + + /** + * Creates an aggregation that finds the last value of an expression across multiple stage inputs. + * + * @param expression The expression to find the last value of. + * @return A new {@link AggregateFunction} representing the last aggregation. + */ + @BetaApi + public static AggregateFunction last(Expression expression) { + return new AggregateFunction("last", expression); + } + + /** + * Creates an aggregation that collects all values of a field across multiple stage inputs into an + * array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @param fieldName The name of the field to collect values from. + * @return A new {@link AggregateFunction} representing the array_agg aggregation. + */ + @BetaApi + public static AggregateFunction arrayAgg(String fieldName) { + return new AggregateFunction("array_agg", fieldName); + } + + /** + * Creates an aggregation that collects all values of an expression across multiple stage inputs + * into an array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @param expression The expression to collect values from. + * @return A new {@link AggregateFunction} representing the array_agg aggregation. + */ + @BetaApi + public static AggregateFunction arrayAgg(Expression expression) { + return new AggregateFunction("array_agg", expression); + } + + /** + * Creates an aggregation that collects all distinct values of a field across multiple stage + * inputs into an array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @param fieldName The name of the field to collect values from. + * @return A new {@link AggregateFunction} representing the array_agg_distinct aggregation. + */ + @BetaApi + public static AggregateFunction arrayAggDistinct(String fieldName) { + return new AggregateFunction("array_agg_distinct", fieldName); + } + + /** + * Creates an aggregation that collects all distinct values of an expression across multiple stage + * inputs into an array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @param expression The expression to collect values from. + * @return A new {@link AggregateFunction} representing the array_agg_distinct aggregation. + */ + @BetaApi + public static AggregateFunction arrayAggDistinct(Expression expression) { + return new AggregateFunction("array_agg_distinct", expression); + } + + /** + * Assigns an alias to this aggregate. + * + * @param alias The alias to assign to this aggregate. + * @return A new {@link AliasedAggregate} that wraps this aggregate and associates it with the + * provided alias. + */ + @BetaApi + public AliasedAggregate as(String alias) { + return new AliasedAggregate(alias, this); + } + + Value toProto() { + return Value.newBuilder() + .setFunctionValue( + com.google.firestore.v1.Function.newBuilder() + .setName(this.name) + .addAllArgs( + this.params.stream() + .map(FunctionUtils::exprToValue) + .collect(Collectors.toList()))) + .build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedAggregate.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedAggregate.java new file mode 100644 index 000000000000..b43b668b502f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedAggregate.java @@ -0,0 +1,40 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; + +@InternalApi +public class AliasedAggregate { + private final String alias; + private final AggregateFunction expr; + + AliasedAggregate(String alias, AggregateFunction expr) { + this.alias = alias; + this.expr = expr; + } + + @InternalApi + public String getAlias() { + return alias; + } + + @InternalApi + public AggregateFunction getExpr() { + return expr; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedExpression.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedExpression.java new file mode 100644 index 000000000000..16931e478561 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/AliasedExpression.java @@ -0,0 +1,62 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; + +@InternalApi +public final class AliasedExpression implements Selectable { + + private final String alias; + private final Expression expr; + + @InternalApi + AliasedExpression(Expression expr, String alias) { + this.expr = expr; + this.alias = alias; + } + + @InternalApi + public String getAlias() { + return alias; + } + + @InternalApi + public Expression getExpr() { + return expr; + } + + /** + * Creates a new {@link AliasedExpression} that wraps this expression and associates it with the + * given alias. + * + *

Aliases are useful for renaming fields in the output of a stage or for giving meaningful + * names to calculated values. + * + * @param alias The alias to assign to this expression. + * @return A new {@link Selectable} that wraps this expression and associates it with the provided + * alias. + */ + public Selectable as(String alias) { + return new AliasedExpression(this.expr, alias); + } + + Value toProto() { + return expr.toProto(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanConstant.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanConstant.java new file mode 100644 index 000000000000..9138dd0f85d6 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanConstant.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; + +@InternalApi +class BooleanConstant extends BooleanExpression { + private final Constant constant; + + BooleanConstant(Constant constant) { + this.constant = constant; + } + + @Override + Value toProto() { + return constant.toProto(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (o instanceof BooleanConstant) { + return constant.equals(((BooleanConstant) o).constant); + } + if (o instanceof Constant) { + return constant.equals(o); + } + return false; + } + + @Override + public int hashCode() { + return constant.hashCode(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanExpression.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanExpression.java new file mode 100644 index 000000000000..68eec573b8ac --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanExpression.java @@ -0,0 +1,97 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; +import com.google.common.collect.ImmutableList; + +@BetaApi +public abstract class BooleanExpression extends Expression { + BooleanExpression() {} + + /** + * Creates an aggregation that counts the number of stage inputs where the this boolean expression + * evaluates to true. + * + * @return A new {@link AggregateFunction} representing the count aggregation. + */ + @BetaApi + public AggregateFunction countIf() { + return AggregateFunction.countIf(this); + } + + /** + * Creates a conditional expression that evaluates to a {@code thenExpr} expression if this + * condition is true or an {@code elseExpr} expression if the condition is false. + * + * @param thenExpr The expression to evaluate if the condition is true. + * @param elseExpr The expression to evaluate if the condition is false. + * @return A new {@link Expression} representing the conditional operation. + */ + @BetaApi + public final Expression conditional(Expression thenExpr, Expression elseExpr) { + return conditional((BooleanExpression) this, thenExpr, elseExpr); + } + + /** + * Creates a conditional expression that evaluates to a {@code thenValue} if this condition is + * true or an {@code elseValue} if the condition is false. + * + * @param thenValue Value if the condition is true. + * @param elseValue Value if the condition is false. + * @return A new {@link Expression} representing the conditional operation. + */ + @BetaApi + public final Expression conditional(Object thenValue, Object elseValue) { + return conditional((BooleanExpression) this, thenValue, elseValue); + } + + /** + * Creates an expression that returns the {@code catchExpr} argument if there is an error, else + * return the result of this expression. + * + * @param catchExpr The catch expression that will be evaluated and returned if the this + * expression produces an error. + * @return A new {@link Expression} representing the ifError operation. + */ + @BetaApi + public final BooleanExpression ifError(BooleanExpression catchExpr) { + return ifError(this, catchExpr); + } + + /** + * Creates an expression that negates this boolean expression. + * + * @return A new {@link BooleanExpression} representing the not operation. + */ + @BetaApi + public final BooleanExpression not() { + return not(this); + } + + /** + * Creates a 'raw' boolean function expression. This is useful if the expression is available in + * the backend, but not yet in the current version of the SDK yet. + * + * @param name The name of the raw function. + * @param params The expressions to be passed as arguments to the function. + * @return A new [BooleanExpression] representing the raw function. + */ + public static BooleanExpression rawFunction(String name, Expression... params) { + return new BooleanFunctionExpression(name, ImmutableList.copyOf(params)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanField.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanField.java new file mode 100644 index 000000000000..6719c581cee0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanField.java @@ -0,0 +1,52 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; + +@InternalApi +class BooleanField extends BooleanExpression { + private final Field field; + + BooleanField(Field field) { + this.field = field; + } + + @Override + Value toProto() { + return field.toProto(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (o instanceof BooleanField) { + return field.equals(((BooleanField) o).field); + } + if (o instanceof Field) { + return field.equals(o); + } + return false; + } + + @Override + public int hashCode() { + return field.hashCode(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanFunctionExpression.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanFunctionExpression.java new file mode 100644 index 000000000000..e1a876c06101 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/BooleanFunctionExpression.java @@ -0,0 +1,61 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; +import java.util.List; + +@InternalApi +class BooleanFunctionExpression extends BooleanExpression { + private final Expression expr; + + BooleanFunctionExpression(Expression expr) { + this.expr = expr; + } + + BooleanFunctionExpression(String name, List params) { + this(new FunctionExpression(name, params)); + } + + BooleanFunctionExpression(String name, Expression... params) { + this(new FunctionExpression(name, java.util.Arrays.asList(params))); + } + + @Override + Value toProto() { + return expr.toProto(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null) return false; + if (o instanceof BooleanFunctionExpression) { + return expr.equals(((BooleanFunctionExpression) o).expr); + } + if (o instanceof FunctionExpression) { + return expr.equals(o); + } + return false; + } + + @Override + public int hashCode() { + return expr.hashCode(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Constant.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Constant.java new file mode 100644 index 000000000000..94a5a73ad11f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Constant.java @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.firestore.v1.Value; + +@BetaApi +final class Constant extends Expression { + + static final Constant NULL = new Constant(null); + + private final Object value; + + Constant(Object value) { + this.value = value; + } + + @Override + Value toProto() { + return encodeValue(value); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java new file mode 100644 index 000000000000..695051c20896 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Expression.java @@ -0,0 +1,5632 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Blob; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.GeoPoint; +import com.google.cloud.firestore.VectorValue; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * Represents an expression that can be evaluated to a value within the execution of a {@link + * com.google.cloud.firestore.Pipeline}. + * + *

Expressions are the building blocks for creating complex queries and transformations in + * Firestore pipelines. They can represent: + * + *

    + *
  • **Field references:** Access values from document fields. + *
  • **Literals:** Represent constant values (strings, numbers, booleans). + *
  • **Function calls:** Apply functions to one or more expressions. + *
+ * + *

The `Expression` class provides a fluent API for building expressions. You can chain together + * method calls to create complex expressions. + */ +@BetaApi +public abstract class Expression { + + /** Constructor is package-private to prevent extension. */ + Expression() {} + + private static Expression toExprOrConstant(Object o) { + return o instanceof Expression ? (Expression) o : new Constant(o); + } + + private static ImmutableList toArrayOfExprOrConstant(Object... others) { + return Arrays.stream(others) + .map(Expression::toExprOrConstant) + .collect(ImmutableList.toImmutableList()); + } + + @InternalApi + abstract Value toProto(); + + // Constants + /** + * Create a constant for a {@link String} value. + * + * @param value The {@link String} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(String value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link Number} value. + * + * @param value The {@link Number} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(Number value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link Date} value. + * + * @param value The {@link Date} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(Date value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link Timestamp} value. + * + * @param value The {@link Timestamp} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(Timestamp value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link Boolean} value. + * + * @param value The {@link Boolean} value. + * @return A new {@link BooleanExpression} constant instance. + */ + @BetaApi + public static BooleanExpression constant(Boolean value) { + return equal(new Constant(value), true); + } + + /** + * Create a constant for a {@link GeoPoint} value. + * + * @param value The {@link GeoPoint} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(GeoPoint value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link Blob} value. + * + * @param value The {@link Blob} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(Blob value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link DocumentReference} value. + * + * @param value The {@link DocumentReference} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(DocumentReference value) { + return new Constant(value); + } + + /** + * Create a constant for a bytes value. + * + * @param value The bytes value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(byte[] value) { + return new Constant(value); + } + + /** + * Create a constant for a {@link VectorValue} value. + * + * @param value The {@link VectorValue} value. + * @return A new {@link Expression} constant instance. + */ + @BetaApi + public static Expression constant(VectorValue value) { + return new Constant(value); + } + + /** + * Constant for a null value. + * + * @return An {@link Expression} constant instance. + */ + @BetaApi + public static Expression nullValue() { + return Constant.NULL; + } + + // Field Reference + /** + * Creates a {@link Field} instance representing the field at the given path. + * + *

The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + * @param path The path to the field. + * @return A new {@link Field} instance representing the specified path. + */ + @BetaApi + public static Field field(String path) { + return Field.ofUserPath(path); + } + + /** + * Creates a {@link Field} instance representing the field at the given path. + * + *

The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + * @param fieldPath The {@link FieldPath} to the field. + * @return A new {@link Field} instance representing the specified path. + */ + @BetaApi + public static Field field(FieldPath fieldPath) { + return Field.ofUserPath(fieldPath.toString()); + } + + /** + * Creates an expression that returns the current timestamp. + * + * @return A new {@link Expression} representing the current timestamp. + */ + @BetaApi + public static Expression currentTimestamp() { + return new FunctionExpression("current_timestamp", ImmutableList.of()); + } + + /** + * Creates an expression that returns a default value if an expression evaluates to an absent + * value. + * + * @param ifExpr The expression to check. + * @param elseExpr The default value. + * @return A new {@link Expression} representing the ifAbsent operation. + */ + @BetaApi + public static Expression ifAbsent(Expression ifExpr, Expression elseExpr) { + return new FunctionExpression("if_absent", ImmutableList.of(ifExpr, elseExpr)); + } + + /** + * Creates an expression that returns a default value if an expression evaluates to an absent + * value. + * + * @param ifExpr The expression to check. + * @param elseValue The default value. + * @return A new {@link Expression} representing the ifAbsent operation. + */ + @BetaApi + public static Expression ifAbsent(Expression ifExpr, Object elseValue) { + return ifAbsent(ifExpr, toExprOrConstant(elseValue)); + } + + /** + * Creates an expression that returns a default value if a field is absent. + * + * @param ifFieldName The field to check. + * @param elseExpr The default value. + * @return A new {@link Expression} representing the ifAbsent operation. + */ + @BetaApi + public static Expression ifAbsent(String ifFieldName, Expression elseExpr) { + return ifAbsent(field(ifFieldName), elseExpr); + } + + /** + * Creates an expression that returns a default value if a field is absent. + * + * @param ifFieldName The field to check. + * @param elseValue The default value. + * @return A new {@link Expression} representing the ifAbsent operation. + */ + @BetaApi + public static Expression ifAbsent(String ifFieldName, Object elseValue) { + return ifAbsent(field(ifFieldName), toExprOrConstant(elseValue)); + } + + /** + * Creates an expression that joins the elements of an array into a string. + * + * @param arrayExpression The expression representing the array. + * @param delimiter The delimiter to use. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public static Expression join(Expression arrayExpression, String delimiter) { + return new FunctionExpression("join", ImmutableList.of(arrayExpression, constant(delimiter))); + } + + /** + * Creates an expression that joins the elements of an array into a string. + * + * @param arrayExpression The expression representing the array. + * @param delimiterExpression The expression representing the delimiter. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public static Expression join(Expression arrayExpression, Expression delimiterExpression) { + return new FunctionExpression("join", ImmutableList.of(arrayExpression, delimiterExpression)); + } + + /** + * Creates an expression that joins the elements of an array into a string. + * + * @param arrayFieldName The field name of the array. + * @param delimiter The delimiter to use. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public static Expression join(String arrayFieldName, String delimiter) { + return join(field(arrayFieldName), constant(delimiter)); + } + + /** + * Creates an expression that joins the elements of an array into a string. + * + * @param arrayFieldName The field name of the array. + * @param delimiterExpression The expression representing the delimiter. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public static Expression join(String arrayFieldName, Expression delimiterExpression) { + return join(field(arrayFieldName), delimiterExpression); + } + + // Generic Function + /** + * Creates a generic function expression that is not yet implemented. + * + * @param name The name of the generic function. + * @param expr The expressions to be passed as arguments to the function. + * @return A new {@link Expression} representing the generic function. + */ + @BetaApi + public static Expression rawExpression(String name, Expression... expr) { + return new FunctionExpression(name, ImmutableList.copyOf(expr)); + } + + // Logical Operators + /** + * Creates an expression that performs a logical 'AND' operation. + * + * @param condition The first {@link BooleanExpression}. + * @param conditions Additional {@link BooleanExpression}s. + * @return A new {@link BooleanExpression} representing the logical 'AND' operation. + */ + @BetaApi + public static BooleanExpression and( + BooleanExpression condition, BooleanExpression... conditions) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(condition); + builder.add(conditions); + return new BooleanFunctionExpression("and", builder.build()); + } + + /** + * Creates an expression that performs a logical 'OR' operation. + * + * @param condition The first {@link BooleanExpression}. + * @param conditions Additional {@link BooleanExpression}s. + * @return A new {@link BooleanExpression} representing the logical 'OR' operation. + */ + @BetaApi + public static BooleanExpression or(BooleanExpression condition, BooleanExpression... conditions) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(condition); + builder.add(conditions); + return new BooleanFunctionExpression("or", builder.build()); + } + + /** + * Creates an expression that performs a logical 'XOR' operation. + * + * @param condition The first {@link BooleanExpression}. + * @param conditions Additional {@link BooleanExpression}s. + * @return A new {@link BooleanExpression} representing the logical 'XOR' operation. + */ + @BetaApi + public static BooleanExpression xor( + BooleanExpression condition, BooleanExpression... conditions) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(condition); + builder.add(conditions); + return new BooleanFunctionExpression("xor", builder.build()); + } + + /** + * Creates an expression that negates a boolean expression. + * + * @param condition The boolean expression to negate. + * @return A new {@link BooleanExpression} representing the not operation. + */ + @BetaApi + public static BooleanExpression not(BooleanExpression condition) { + return new BooleanFunctionExpression("not", condition); + } + + // Arithmetic Operators + /** + * Creates an expression that adds numeric expressions. + * + * @param first Numeric expression to add. + * @param second Numeric expression to add. + * @return A new {@link Expression} representing the addition operation. + */ + @BetaApi + public static Expression add(Expression first, Expression second) { + return new FunctionExpression("add", ImmutableList.of(first, second)); + } + + /** + * Creates an expression that adds numeric expressions with a constant. + * + * @param first Numeric expression to add. + * @param second Constant to add. + * @return A new {@link Expression} representing the addition operation. + */ + @BetaApi + public static Expression add(Expression first, Number second) { + return add(first, constant(second)); + } + + /** + * Creates an expression that adds a numeric field with a numeric expression. + * + * @param fieldName Numeric field to add. + * @param second Numeric expression to add to field value. + * @return A new {@link Expression} representing the addition operation. + */ + @BetaApi + public static Expression add(String fieldName, Expression second) { + return add(field(fieldName), second); + } + + /** + * Creates an expression that adds a numeric field with constant. + * + * @param fieldName Numeric field to add. + * @param second Constant to add. + * @return A new {@link Expression} representing the addition operation. + */ + @BetaApi + public static Expression add(String fieldName, Number second) { + return add(field(fieldName), constant(second)); + } + + /** + * Creates an expression that subtracts two expressions. + * + * @param minuend Numeric expression to subtract from. + * @param subtrahend Numeric expression to subtract. + * @return A new {@link Expression} representing the subtract operation. + */ + @BetaApi + public static Expression subtract(Expression minuend, Expression subtrahend) { + return new FunctionExpression("subtract", ImmutableList.of(minuend, subtrahend)); + } + + /** + * Creates an expression that subtracts a constant value from a numeric expression. + * + * @param minuend Numeric expression to subtract from. + * @param subtrahend Constant to subtract. + * @return A new {@link Expression} representing the subtract operation. + */ + @BetaApi + public static Expression subtract(Expression minuend, Number subtrahend) { + return subtract(minuend, constant(subtrahend)); + } + + /** + * Creates an expression that subtracts a numeric expressions from numeric field. + * + * @param fieldName Numeric field to subtract from. + * @param subtrahend Numeric expression to subtract. + * @return A new {@link Expression} representing the subtract operation. + */ + @BetaApi + public static Expression subtract(String fieldName, Expression subtrahend) { + return subtract(field(fieldName), subtrahend); + } + + /** + * Creates an expression that subtracts a constant from numeric field. + * + * @param fieldName Numeric field to subtract from. + * @param subtrahend Constant to subtract. + * @return A new {@link Expression} representing the subtract operation. + */ + @BetaApi + public static Expression subtract(String fieldName, Number subtrahend) { + return subtract(field(fieldName), constant(subtrahend)); + } + + /** + * Creates an expression that multiplies numeric expressions. + * + * @param first Numeric expression to multiply. + * @param second Numeric expression to multiply. + * @return A new {@link Expression} representing the multiplication operation. + */ + @BetaApi + public static Expression multiply(Expression first, Expression second) { + return new FunctionExpression("multiply", ImmutableList.of(first, second)); + } + + /** + * Creates an expression that multiplies numeric expressions with a constant. + * + * @param first Numeric expression to multiply. + * @param second Constant to multiply. + * @return A new {@link Expression} representing the multiplication operation. + */ + @BetaApi + public static Expression multiply(Expression first, Number second) { + return multiply(first, constant(second)); + } + + /** + * Creates an expression that multiplies a numeric field with a numeric expression. + * + * @param fieldName Numeric field to multiply. + * @param second Numeric expression to multiply. + * @return A new {@link Expression} representing the multiplication operation. + */ + @BetaApi + public static Expression multiply(String fieldName, Expression second) { + return multiply(field(fieldName), second); + } + + /** + * Creates an expression that multiplies a numeric field with a constant. + * + * @param fieldName Numeric field to multiply. + * @param second Constant to multiply. + * @return A new {@link Expression} representing the multiplication operation. + */ + @BetaApi + public static Expression multiply(String fieldName, Number second) { + return multiply(field(fieldName), constant(second)); + } + + /** + * Creates an expression that divides two numeric expressions. + * + * @param dividend The numeric expression to be divided. + * @param divisor The numeric expression to divide by. + * @return A new {@link Expression} representing the division operation. + */ + @BetaApi + public static Expression divide(Expression dividend, Expression divisor) { + return new FunctionExpression("divide", ImmutableList.of(dividend, divisor)); + } + + /** + * Creates an expression that divides a numeric expression by a constant. + * + * @param dividend The numeric expression to be divided. + * @param divisor The constant to divide by. + * @return A new {@link Expression} representing the division operation. + */ + @BetaApi + public static Expression divide(Expression dividend, Number divisor) { + return divide(dividend, constant(divisor)); + } + + /** + * Creates an expression that divides numeric field by a numeric expression. + * + * @param fieldName The numeric field name to be divided. + * @param divisor The numeric expression to divide by. + * @return A new {@link Expression} representing the divide operation. + */ + @BetaApi + public static Expression divide(String fieldName, Expression divisor) { + return divide(field(fieldName), divisor); + } + + /** + * Creates an expression that divides a numeric field by a constant. + * + * @param fieldName The numeric field name to be divided. + * @param divisor The constant to divide by. + * @return A new {@link Expression} representing the divide operation. + */ + @BetaApi + public static Expression divide(String fieldName, Number divisor) { + return divide(field(fieldName), constant(divisor)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing two numeric + * expressions. + * + * @param dividend The numeric expression to be divided. + * @param divisor The numeric expression to divide by. + * @return A new {@link Expression} representing the modulo operation. + */ + @BetaApi + public static Expression mod(Expression dividend, Expression divisor) { + return new FunctionExpression("mod", ImmutableList.of(dividend, divisor)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing a numeric expression + * by a constant. + * + * @param dividend The numeric expression to be divided. + * @param divisor The constant to divide by. + * @return A new {@link Expression} representing the modulo operation. + */ + @BetaApi + public static Expression mod(Expression dividend, Number divisor) { + return mod(dividend, constant(divisor)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a + * constant. + * + * @param fieldName The numeric field name to be divided. + * @param divisor The numeric expression to divide by. + * @return A new {@link Expression} representing the modulo operation. + */ + @BetaApi + public static Expression mod(String fieldName, Expression divisor) { + return mod(field(fieldName), divisor); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a + * constant. + * + * @param fieldName The numeric field name to be divided. + * @param divisor The constant to divide by. + * @return A new {@link Expression} representing the modulo operation. + */ + @BetaApi + public static Expression mod(String fieldName, Number divisor) { + return mod(field(fieldName), constant(divisor)); + } + + // Comparison Operators + /** + * Creates an expression that checks if two expressions are equal. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the equality comparison. + */ + @BetaApi + public static BooleanExpression equal(Expression left, Expression right) { + return new BooleanFunctionExpression("equal", left, right); + } + + /** + * Creates an expression that checks if an expression is equal to a constant value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the equality comparison. + */ + @BetaApi + public static BooleanExpression equal(Expression left, Object right) { + return new BooleanFunctionExpression("equal", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is equal to an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the equality comparison. + */ + @BetaApi + public static BooleanExpression equal(String fieldName, Expression right) { + return equal(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is equal to a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the equality comparison. + */ + @BetaApi + public static BooleanExpression equal(String fieldName, Object right) { + return equal(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if two expressions are not equal. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the inequality comparison. + */ + @BetaApi + public static BooleanExpression notEqual(Expression left, Expression right) { + return new BooleanFunctionExpression("not_equal", left, right); + } + + /** + * Creates an expression that checks if an expression is not equal to a constant value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the inequality comparison. + */ + @BetaApi + public static BooleanExpression notEqual(Expression left, Object right) { + return new BooleanFunctionExpression("not_equal", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is not equal to an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the inequality comparison. + */ + @BetaApi + public static BooleanExpression notEqual(String fieldName, Expression right) { + return notEqual(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is not equal to a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the inequality comparison. + */ + @BetaApi + public static BooleanExpression notEqual(String fieldName, Object right) { + return notEqual(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if the first expression is greater than the second + * expression. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the greater than comparison. + */ + @BetaApi + public static BooleanExpression greaterThan(Expression left, Expression right) { + return new BooleanFunctionExpression("greater_than", left, right); + } + + /** + * Creates an expression that checks if an expression is greater than a constant value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the greater than comparison. + */ + @BetaApi + public static BooleanExpression greaterThan(Expression left, Object right) { + return new BooleanFunctionExpression("greater_than", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is greater than an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the greater than comparison. + */ + @BetaApi + public static BooleanExpression greaterThan(String fieldName, Expression right) { + return greaterThan(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is greater than a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the greater than comparison. + */ + @BetaApi + public static BooleanExpression greaterThan(String fieldName, Object right) { + return greaterThan(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if the first expression is greater than or equal to the + * second expression. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the greater than or equal to comparison. + */ + @BetaApi + public static BooleanExpression greaterThanOrEqual(Expression left, Expression right) { + return new BooleanFunctionExpression("greater_than_or_equal", left, right); + } + + /** + * Creates an expression that checks if an expression is greater than or equal to a constant + * value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the greater than or equal to comparison. + */ + @BetaApi + public static BooleanExpression greaterThanOrEqual(Expression left, Object right) { + return new BooleanFunctionExpression("greater_than_or_equal", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is greater than or equal to an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the greater than or equal to comparison. + */ + @BetaApi + public static BooleanExpression greaterThanOrEqual(String fieldName, Expression right) { + return greaterThanOrEqual(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is greater than or equal to a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the greater than or equal to comparison. + */ + @BetaApi + public static BooleanExpression greaterThanOrEqual(String fieldName, Object right) { + return greaterThanOrEqual(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if the first expression is less than the second expression. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the less than comparison. + */ + @BetaApi + public static BooleanExpression lessThan(Expression left, Expression right) { + return new BooleanFunctionExpression("less_than", left, right); + } + + /** + * Creates an expression that checks if an expression is less than a constant value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the less than comparison. + */ + @BetaApi + public static BooleanExpression lessThan(Expression left, Object right) { + return new BooleanFunctionExpression("less_than", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is less than an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the less than comparison. + */ + @BetaApi + public static BooleanExpression lessThan(String fieldName, Expression right) { + return lessThan(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is less than a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the less than comparison. + */ + @BetaApi + public static BooleanExpression lessThan(String fieldName, Object right) { + return lessThan(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if the first expression is less than or equal to the second + * expression. + * + * @param left The first expression. + * @param right The second expression. + * @return A new {@link BooleanExpression} representing the less than or equal to comparison. + */ + @BetaApi + public static BooleanExpression lessThanOrEqual(Expression left, Expression right) { + return new BooleanFunctionExpression("less_than_or_equal", left, right); + } + + /** + * Creates an expression that checks if an expression is less than or equal to a constant value. + * + * @param left The expression. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the less than or equal to comparison. + */ + @BetaApi + public static BooleanExpression lessThanOrEqual(Expression left, Object right) { + return new BooleanFunctionExpression("less_than_or_equal", left, toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if a field is less than or equal to an expression. + * + * @param fieldName The field name. + * @param right The expression. + * @return A new {@link BooleanExpression} representing the less than or equal to comparison. + */ + @BetaApi + public static BooleanExpression lessThanOrEqual(String fieldName, Expression right) { + return lessThanOrEqual(field(fieldName), right); + } + + /** + * Creates an expression that checks if a field is less than or equal to a constant value. + * + * @param fieldName The field name. + * @param right The constant value. + * @return A new {@link BooleanExpression} representing the less than or equal to comparison. + */ + @BetaApi + public static BooleanExpression lessThanOrEqual(String fieldName, Object right) { + return lessThanOrEqual(field(fieldName), toExprOrConstant(right)); + } + + /** + * Creates an expression that checks if an {@code expression}, when evaluated, is equal to any of + * the provided {@code values}. + * + * @param expression The expression whose results to compare. + * @param values The values to check against. + * @return A new {@link BooleanExpression} representing the 'IN' comparison. + */ + @BetaApi + public static BooleanExpression equalAny(Expression expression, List values) { + return new BooleanFunctionExpression( + "equal_any", + expression, + new FunctionExpression("array", toArrayOfExprOrConstant(values.toArray()))); + } + + /** + * Creates an expression that checks if an {@code expression}, when evaluated, is equal to any of + * the elements of {@code arrayExpression}. + * + * @param expression The expression whose results to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for + * equality to the input. + * @return A new {@link BooleanExpression} representing the 'IN' comparison. + */ + @BetaApi + public static BooleanExpression equalAny(Expression expression, Expression arrayExpression) { + return new BooleanFunctionExpression("equal_any", expression, arrayExpression); + } + + /** + * Creates an expression that checks if a field's value is equal to any of the provided {@code + * values}. + * + * @param fieldName The field to compare. + * @param values The values to check against. + * @return A new {@link BooleanExpression} representing the 'IN' comparison. + */ + @BetaApi + public static BooleanExpression equalAny(String fieldName, List values) { + return equalAny( + field(fieldName), + new FunctionExpression("array", toArrayOfExprOrConstant(values.toArray()))); + } + + /** + * Creates an expression that checks if a field's value is equal to any of the elements of {@code + * arrayExpression}. + * + * @param fieldName The field to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for + * equality to the input. + * @return A new {@link BooleanExpression} representing the 'IN' comparison. + */ + @BetaApi + public static BooleanExpression equalAny(String fieldName, Expression arrayExpression) { + return equalAny(field(fieldName), arrayExpression); + } + + /** + * Creates an expression that checks if an {@code expression}, when evaluated, is not equal to all + * the provided {@code values}. + * + * @param expression The expression whose results to compare. + * @param values The values to check against. + * @return A new {@link BooleanExpression} representing the 'NOT IN' comparison. + */ + @BetaApi + public static BooleanExpression notEqualAny(Expression expression, List values) { + return new BooleanFunctionExpression( + "not_equal_any", + expression, + new FunctionExpression("array", toArrayOfExprOrConstant(values.toArray()))); + } + + /** + * Creates an expression that checks if an {@code expression}, when evaluated, is not equal to all + * the elements of {@code arrayExpression}. + * + * @param expression The expression whose results to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for + * equality to the input. + * @return A new {@link BooleanExpression} representing the 'NOT IN' comparison. + */ + @BetaApi + public static BooleanExpression notEqualAny(Expression expression, Expression arrayExpression) { + return new BooleanFunctionExpression("not_equal_any", expression, arrayExpression); + } + + /** + * Creates an expression that checks if a field's value is not equal to all of the provided {@code + * values}. + * + * @param fieldName The field to compare. + * @param values The values to check against. + * @return A new {@link BooleanExpression} representing the 'NOT IN' comparison. + */ + @BetaApi + public static BooleanExpression notEqualAny(String fieldName, List values) { + return notEqualAny( + field(fieldName), + new FunctionExpression("array", toArrayOfExprOrConstant(values.toArray()))); + } + + /** + * Creates an expression that checks if a field's value is not equal to all of the elements of + * {@code arrayExpression}. + * + * @param fieldName The field to compare. + * @param arrayExpression An expression that evaluates to an array, whose elements to check for + * equality to the input. + * @return A new {@link BooleanExpression} representing the 'NOT IN' comparison. + */ + @BetaApi + public static BooleanExpression notEqualAny(String fieldName, Expression arrayExpression) { + return notEqualAny(field(fieldName), arrayExpression); + } + + // String Functions + /** + * Creates an expression that calculates the character length of a string expression in UTF8. + * + * @param string The expression representing the string. + * @return A new {@link Expression} representing the charLength operation. + */ + @BetaApi + public static Expression charLength(Expression string) { + return new FunctionExpression("char_length", ImmutableList.of(string)); + } + + /** + * Creates an expression that calculates the character length of a string field in UTF8. + * + * @param fieldName The name of the field containing the string. + * @return A new {@link Expression} representing the charLength operation. + */ + @BetaApi + public static Expression charLength(String fieldName) { + return charLength(field(fieldName)); + } + + /** + * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length + * of a Blob. + * + * @param string The expression representing the string. + * @return A new {@link Expression} representing the length of the string in bytes. + */ + @BetaApi + public static Expression byteLength(Expression string) { + return new FunctionExpression("byte_length", ImmutableList.of(string)); + } + + /** + * Creates an expression that calculates the length of a string represented by a field in UTF-8 + * bytes, or just the length of a Blob. + * + * @param fieldName The name of the field containing the string. + * @return A new {@link Expression} representing the length of the string in bytes. + */ + @BetaApi + public static Expression byteLength(String fieldName) { + return byteLength(field(fieldName)); + } + + /** + * Creates an expression that calculates the length of string, array, map, vector, or Blob. + * + * @param string The expression representing the value to calculate the length of. + * @return A new {@link Expression} representing the length of the value. + */ + @BetaApi + public static Expression length(Expression string) { + return new FunctionExpression("length", ImmutableList.of(string)); + } + + /** + * Creates an expression that calculates the length of string, array, map, vector, or Blob. + * + * @param fieldName The name of the field containing the value. + * @return A new {@link Expression} representing the length of the value. + */ + @BetaApi + public static Expression length(String fieldName) { + return byteLength(field(fieldName)); + } + + /** + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * @param string The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@link BooleanExpression} representing the like operation. + */ + @BetaApi + public static BooleanExpression like(Expression string, Expression pattern) { + return new BooleanFunctionExpression("like", string, pattern); + } + + /** + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * @param string The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@link BooleanExpression} representing the like operation. + */ + @BetaApi + public static BooleanExpression like(Expression string, String pattern) { + return like(string, constant(pattern)); + } + + /** + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * @param fieldName The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@link BooleanExpression} representing the like comparison. + */ + @BetaApi + public static BooleanExpression like(String fieldName, Expression pattern) { + return like(field(fieldName), pattern); + } + + /** + * Creates an expression that performs a case-sensitive wildcard string comparison against a + * field. + * + * @param fieldName The name of the field containing the string. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@link BooleanExpression} representing the like comparison. + */ + @BetaApi + public static BooleanExpression like(String fieldName, String pattern) { + return like(field(fieldName), constant(pattern)); + } + + /** + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * @param string The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@link BooleanExpression} representing the contains regular expression + * comparison. + */ + @BetaApi + public static BooleanExpression regexContains(Expression string, Expression pattern) { + return new BooleanFunctionExpression("regex_contains", string, pattern); + } + + /** + * Creates an expression that checks if a string expression contains a specified regular + * expression as a substring. + * + * @param string The expression representing the string to perform the comparison on. + * @param pattern The regular expression to use for the search. + * @return A new {@link BooleanExpression} representing the contains regular expression + * comparison. + */ + @BetaApi + public static BooleanExpression regexContains(Expression string, String pattern) { + return regexContains(string, constant(pattern)); + } + + /** + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * @param fieldName The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@link BooleanExpression} representing the contains regular expression + * comparison. + */ + @BetaApi + public static BooleanExpression regexContains(String fieldName, Expression pattern) { + return regexContains(field(fieldName), pattern); + } + + /** + * Creates an expression that checks if a string field contains a specified regular expression as + * a substring. + * + * @param fieldName The name of the field containing the string. + * @param pattern The regular expression to use for the search. + * @return A new {@link BooleanExpression} representing the contains regular expression + * comparison. + */ + @BetaApi + public static BooleanExpression regexContains(String fieldName, String pattern) { + return regexContains(field(fieldName), constant(pattern)); + } + + /** + * Creates an expression that returns the first substring of a string expression that matches a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param string The expression representing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} representing the regular expression find function. + */ + @BetaApi + public static Expression regexFind(Expression string, Expression pattern) { + return new FunctionExpression("regex_find", ImmutableList.of(string, pattern)); + } + + /** + * Creates an expression that returns the first substring of a string expression that matches a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param string The expression representing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} representing the regular expression find function. + */ + @BetaApi + public static Expression regexFind(Expression string, String pattern) { + return regexFind(string, constant(pattern)); + } + + /** + * Creates an expression that returns the first substring of a string field that matches a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param fieldName The name of the field containing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} representing the regular expression find function. + */ + @BetaApi + public static Expression regexFind(String fieldName, Expression pattern) { + return regexFind(field(fieldName), pattern); + } + + /** + * Creates an expression that returns the first substring of a string field that matches a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param fieldName The name of the field containing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} representing the regular expression find function. + */ + @BetaApi + public static Expression regexFind(String fieldName, String pattern) { + return regexFind(field(fieldName), constant(pattern)); + } + + /** + * Creates an expression that evaluates to a list of all substrings in a string expression that + * match a specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param string The expression representing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} that evaluates to a list of matched substrings. + */ + @BetaApi + public static Expression regexFindAll(Expression string, Expression pattern) { + return new FunctionExpression("regex_find_all", ImmutableList.of(string, pattern)); + } + + /** + * Creates an expression that evaluates to a list of all substrings in a string expression that + * match a specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param string The expression representing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} that evaluates to a list of matched substrings. + */ + @BetaApi + public static Expression regexFindAll(Expression string, String pattern) { + return regexFindAll(string, constant(pattern)); + } + + /** + * Creates an expression that evaluates to a list of all substrings in a string field that match a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param fieldName The name of the field containing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} that evaluates to a list of matched substrings. + */ + @BetaApi + public static Expression regexFindAll(String fieldName, Expression pattern) { + return regexFindAll(field(fieldName), pattern); + } + + /** + * Creates an expression that evaluates to a list of all substrings in a string field that match a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param fieldName The name of the field containing the string to search. + * @param pattern The regular expression to search for. + * @return A new {@link Expression} that evaluates to a list of matched substrings. + */ + @BetaApi + public static Expression regexFindAll(String fieldName, String pattern) { + return regexFindAll(field(fieldName), constant(pattern)); + } + + /** + * Creates an expression that checks if a string field matches a specified regular expression. + * + * @param string The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@link BooleanExpression} representing the regular expression match comparison. + */ + @BetaApi + public static BooleanExpression regexMatch(Expression string, Expression pattern) { + return new BooleanFunctionExpression("regex_match", string, pattern); + } + + /** + * Creates an expression that checks if a string field matches a specified regular expression. + * + * @param string The expression representing the string to match against. + * @param pattern The regular expression to use for the match. + * @return A new {@link BooleanExpression} representing the regular expression match comparison. + */ + @BetaApi + public static BooleanExpression regexMatch(Expression string, String pattern) { + return regexMatch(string, constant(pattern)); + } + + /** + * Creates an expression that checks if a string field matches a specified regular expression. + * + * @param fieldName The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@link BooleanExpression} representing the regular expression match comparison. + */ + @BetaApi + public static BooleanExpression regexMatch(String fieldName, Expression pattern) { + return regexMatch(field(fieldName), pattern); + } + + /** + * Creates an expression that checks if a string field matches a specified regular expression. + * + * @param fieldName The name of the field containing the string. + * @param pattern The regular expression to use for the match. + * @return A new {@link BooleanExpression} representing the regular expression match comparison. + */ + @BetaApi + public static BooleanExpression regexMatch(String fieldName, String pattern) { + return regexMatch(field(fieldName), constant(pattern)); + } + + /** + * Creates an expression that checks if a string expression contains a specified substring. + * + * @param string The expression representing the string to perform the comparison on. + * @param substring The expression representing the substring to search for. + * @return A new {@link BooleanExpression} representing the contains comparison. + */ + @BetaApi + public static BooleanExpression stringContains(Expression string, Expression substring) { + return new BooleanFunctionExpression("string_contains", string, substring); + } + + /** + * Creates an expression that checks if a string expression contains a specified substring. + * + * @param string The expression representing the string to perform the comparison on. + * @param substring The substring to search for. + * @return A new {@link BooleanExpression} representing the contains comparison. + */ + @BetaApi + public static BooleanExpression stringContains(Expression string, String substring) { + return stringContains(string, constant(substring)); + } + + /** + * Creates an expression that checks if a string field contains a specified substring. + * + * @param fieldName The name of the field to perform the comparison on. + * @param substring The expression representing the substring to search for. + * @return A new {@link BooleanExpression} representing the contains comparison. + */ + @BetaApi + public static BooleanExpression stringContains(String fieldName, Expression substring) { + return stringContains(field(fieldName), substring); + } + + /** + * Creates an expression that checks if a string field contains a specified substring. + * + * @param fieldName The name of the field to perform the comparison on. + * @param substring The substring to search for. + * @return A new {@link BooleanExpression} representing the contains comparison. + */ + @BetaApi + public static BooleanExpression stringContains(String fieldName, String substring) { + return stringContains(field(fieldName), constant(substring)); + } + + /** + * Creates an expression that checks if a string expression starts with a given {@code prefix}. + * + * @param string The expression to check. + * @param prefix The prefix string expression to check for. + * @return A new {@link BooleanExpression} representing the 'starts with' comparison. + */ + @BetaApi + public static BooleanExpression startsWith(Expression string, Expression prefix) { + return new BooleanFunctionExpression("starts_with", string, prefix); + } + + /** + * Creates an expression that checks if a string expression starts with a given {@code prefix}. + * + * @param string The expression to check. + * @param prefix The prefix string to check for. + * @return A new {@link BooleanExpression} representing the 'starts with' comparison. + */ + @BetaApi + public static BooleanExpression startsWith(Expression string, String prefix) { + return startsWith(string, constant(prefix)); + } + + /** + * Creates an expression that checks if a string expression starts with a given {@code prefix}. + * + * @param fieldName The name of field that contains a string to check. + * @param prefix The prefix string expression to check for. + * @return A new {@link BooleanExpression} representing the 'starts with' comparison. + */ + @BetaApi + public static BooleanExpression startsWith(String fieldName, Expression prefix) { + return startsWith(field(fieldName), prefix); + } + + /** + * Creates an expression that checks if a string expression starts with a given {@code prefix}. + * + * @param fieldName The name of field that contains a string to check. + * @param prefix The prefix string to check for. + * @return A new {@link BooleanExpression} representing the 'starts with' comparison. + */ + @BetaApi + public static BooleanExpression startsWith(String fieldName, String prefix) { + return startsWith(field(fieldName), constant(prefix)); + } + + /** + * Creates an expression that checks if a string expression ends with a given {@code suffix}. + * + * @param string The expression to check. + * @param suffix The suffix string expression to check for. + * @return A new {@link BooleanExpression} representing the 'ends with' comparison. + */ + @BetaApi + public static BooleanExpression endsWith(Expression string, Expression suffix) { + return new BooleanFunctionExpression("ends_with", string, suffix); + } + + /** + * Creates an expression that checks if a string expression ends with a given {@code suffix}. + * + * @param string The expression to check. + * @param suffix The suffix string to check for. + * @return A new {@link BooleanExpression} representing the 'ends with' comparison. + */ + @BetaApi + public static BooleanExpression endsWith(Expression string, String suffix) { + return endsWith(string, constant(suffix)); + } + + /** + * Creates an expression that checks if a string expression ends with a given {@code suffix}. + * + * @param fieldName The name of field that contains a string to check. + * @param suffix The suffix string expression to check for. + * @return A new {@link BooleanExpression} representing the 'ends with' comparison. + */ + @BetaApi + public static BooleanExpression endsWith(String fieldName, Expression suffix) { + return endsWith(field(fieldName), suffix); + } + + /** + * Creates an expression that checks if a string expression ends with a given {@code suffix}. + * + * @param fieldName The name of field that contains a string to check. + * @param suffix The suffix string to check for. + * @return A new {@link BooleanExpression} representing the 'ends with' comparison. + */ + @BetaApi + public static BooleanExpression endsWith(String fieldName, String suffix) { + return endsWith(field(fieldName), constant(suffix)); + } + + /** + * Creates an expression that returns a substring of the given string. + * + * @param string The expression representing the string to get a substring from. + * @param index The starting index of the substring. + * @param length The length of the substring. + * @return A new {@link Expression} representing the substring. + */ + @BetaApi + public static Expression substring(Expression string, Expression index, Expression length) { + return new FunctionExpression("substring", ImmutableList.of(string, index, length)); + } + + /** + * Creates an expression that returns a substring of the given string. + * + * @param fieldName The name of the field containing the string to get a substring from. + * @param index The starting index of the substring. + * @param length The length of the substring. + * @return A new {@link Expression} representing the substring. + */ + @BetaApi + public static Expression substring(String fieldName, int index, int length) { + return substring(field(fieldName), constant(index), constant(length)); + } + + /** + * Creates an expression that converts a string expression to lowercase. + * + * @param string The expression representing the string to convert to lowercase. + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public static Expression toLower(Expression string) { + return new FunctionExpression("to_lower", ImmutableList.of(string)); + } + + /** + * Creates an expression that converts a string field to lowercase. + * + * @param fieldName The name of the field containing the string to convert to lowercase. + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public static Expression toLower(String fieldName) { + return toLower(field(fieldName)); + } + + /** + * Creates an expression that converts a string expression to uppercase. + * + * @param string The expression representing the string to convert to uppercase. + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public static Expression toUpper(Expression string) { + return new FunctionExpression("to_upper", ImmutableList.of(string)); + } + + /** + * Creates an expression that converts a string field to uppercase. + * + * @param fieldName The name of the field containing the string to convert to uppercase. + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public static Expression toUpper(String fieldName) { + return toUpper(field(fieldName)); + } + + /** + * Creates an expression that removes leading and trailing whitespace from a string expression. + * + * @param string The expression representing the string to trim. + * @return A new {@link Expression} representing the trimmed string. + */ + @BetaApi + public static Expression trim(Expression string) { + return new FunctionExpression("trim", ImmutableList.of(string)); + } + + /** + * Creates an expression that removes leading and trailing whitespace from a string field. + * + * @param fieldName The name of the field containing the string to trim. + * @return A new {@link Expression} representing the trimmed string. + */ + @BetaApi + public static Expression trim(String fieldName) { + return trim(field(fieldName)); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of a string + * or blob. + * + * @param value The expression representing the string or blob to trim. + * @param characters The characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public static Expression trimValue(Expression value, String characters) { + return new FunctionExpression("trim", ImmutableList.of(value, constant(characters))); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of a string + * or blob. + * + * @param fieldName The name of the field containing the string or blob to trim. + * @param characters The characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public static Expression trimValue(String fieldName, String characters) { + return trimValue(field(fieldName), characters); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of a string + * or blob. + * + * @param value The expression representing the string or blob to trim. + * @param characters The expression representing the characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public static Expression trimValue(Expression value, Expression characters) { + return new FunctionExpression("trim", ImmutableList.of(value, characters)); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of a string + * or blob. + * + * @param fieldName The name of the field containing the string or blob to trim. + * @param characters The expression representing the characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public static Expression trimValue(String fieldName, Expression characters) { + return trimValue(field(fieldName), characters); + } + + /** + * Creates an expression that splits a string or blob by a delimiter. + * + * @param value The expression representing the string or blob to split. + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public static Expression split(Expression value, Expression delimiter) { + return new FunctionExpression("split", ImmutableList.of(value, delimiter)); + } + + /** + * Creates an expression that splits a string or blob by a delimiter. + * + * @param value The expression representing the string or blob to split. + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public static Expression split(Expression value, String delimiter) { + return split(value, constant(delimiter)); + } + + /** + * Creates an expression that splits a string or blob by a delimiter. + * + * @param fieldName The name of the field containing the string or blob to split. + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public static Expression split(String fieldName, Expression delimiter) { + return split(field(fieldName), delimiter); + } + + /** + * Creates an expression that splits a string or blob by a delimiter. + * + * @param fieldName The name of the field containing the string or blob to split. + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public static Expression split(String fieldName, String delimiter) { + return split(field(fieldName), constant(delimiter)); + } + + /** + * Creates an expression that concatenates string expressions together. + * + * @param firstString The expression representing the initial string value. + * @param otherStrings Optional additional string expressions or string constants to concatenate. + * @return A new {@link Expression} representing the concatenated string. + */ + @BetaApi + public static Expression stringConcat(Expression firstString, Object... otherStrings) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(firstString); + builder.addAll(toArrayOfExprOrConstant(otherStrings)); + return new FunctionExpression("string_concat", builder.build()); + } + + /** + * Creates an expression that concatenates string expressions together. + * + * @param fieldName The field name containing the initial string value. + * @param otherStrings Optional additional string expressions or string constants to concatenate. + * @return A new {@link Expression} representing the concatenated string. + */ + @BetaApi + public static Expression stringConcat(String fieldName, Object... otherStrings) { + return stringConcat(field(fieldName), otherStrings); + } + + /** + * Creates an expression that concatenates expressions together. + * + * @param first The expression representing the initial value. + * @param others Optional additional expressions or constants to concatenate. + * @return A new {@link Expression} representing the concatenated value. + */ + @BetaApi + public static Expression concat(Expression first, Object... others) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(first); + builder.addAll(toArrayOfExprOrConstant(others)); + return new FunctionExpression("concat", builder.build()); + } + + /** + * Creates an expression that concatenates expressions together. + * + * @param fieldName The field name containing the initial value. + * @param others Optional additional expressions or constants to concatenate. + * @return A new {@link Expression} representing the concatenated value. + */ + @BetaApi + public static Expression concat(String fieldName, Object... others) { + return concat(field(fieldName), others); + } + + // Map Functions + /** + * Creates an expression that creates a Firestore map value from an input object. + * + * @param elements The input map to evaluate in the expression. + * @return A new {@link Expression} representing the map function. + */ + @BetaApi + public static Expression map(Map elements) { + ImmutableList params = + elements.entrySet().stream() + .flatMap( + e -> Arrays.asList(constant(e.getKey()), toExprOrConstant(e.getValue())).stream()) + .collect(ImmutableList.toImmutableList()); + return new FunctionExpression("map", params); + } + + /** + * Accesses a value from a map (object) field using the provided {@code keyExpression}. + * + * @param map The expression representing the map. + * @param key The key to access in the map. + * @return A new {@link Expression} representing the value associated with the given key in the + * map. + */ + @BetaApi + public static Expression mapGet(Expression map, Expression key) { + return new FunctionExpression("map_get", ImmutableList.of(map, key)); + } + + /** + * Accesses a value from a map (object) field using the provided {@code key}. + * + * @param map The expression representing the map. + * @param key The key to access in the map. + * @return A new {@link Expression} representing the value associated with the given key in the + * map. + */ + @BetaApi + public static Expression mapGet(Expression map, String key) { + return mapGet(map, constant(key)); + } + + /** + * Accesses a value from a map (object) field using the provided {@code key}. + * + * @param fieldName The field name of the map field. + * @param key The key to access in the map. + * @return A new {@link Expression} representing the value associated with the given key in the + * map. + */ + @BetaApi + public static Expression mapGet(String fieldName, String key) { + return mapGet(field(fieldName), constant(key)); + } + + /** + * Accesses a value from a map (object) field using the provided {@code keyExpression}. + * + * @param fieldName The field name of the map field. + * @param key The key to access in the map. + * @return A new {@link Expression} representing the value associated with the given key in the + * map. + */ + @BetaApi + public static Expression mapGet(String fieldName, Expression key) { + return mapGet(field(fieldName), key); + } + + @BetaApi + public static Expression mapMerge(Expression firstMap, Expression secondMap) { + return mapMerge(firstMap, secondMap, new Expression[0]); + } + + @BetaApi + public static Expression mapMerge(String firstMapFieldName, Expression secondMap) { + return mapMerge(field(firstMapFieldName), secondMap, new Expression[0]); + } + + /** + * Creates an expression that merges multiple maps into a single map. If multiple maps have the + * same key, the later value is used. + * + * @param firstMap First map expression that will be merged. + * @param secondMap Second map expression that will be merged. + * @param otherMaps Additional maps to merge. + * @return A new {@link Expression} representing the mapMerge operation. + */ + @BetaApi + public static Expression mapMerge( + Expression firstMap, Expression secondMap, Expression... otherMaps) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(firstMap); + builder.add(secondMap); + builder.add(otherMaps); + return new FunctionExpression("map_merge", builder.build()); + } + + /** + * Creates an expression that merges multiple maps into a single map. If multiple maps have the + * same key, the later value is used. + * + * @param firstMapFieldName Field name of the first map expression that will be merged. + * @param secondMap Second map expression that will be merged. + * @param otherMaps Additional maps to merge. + * @return A new {@link Expression} representing the mapMerge operation. + */ + @BetaApi + public static Expression mapMerge( + String firstMapFieldName, Expression secondMap, Expression... otherMaps) { + return mapMerge(field(firstMapFieldName), secondMap, otherMaps); + } + + /** + * Creates an expression that removes a key from a map. + * + * @param mapExpr The expression representing the map. + * @param key The key to remove from the map. + * @return A new {@link Expression} representing the map with the key removed. + */ + @BetaApi + public static Expression mapRemove(Expression mapExpr, Expression key) { + return new FunctionExpression("map_remove", ImmutableList.of(mapExpr, key)); + } + + /** + * Creates an expression that removes a key from a map. + * + * @param mapField The field name of the map. + * @param key The key to remove from the map. + * @return A new {@link Expression} representing the map with the key removed. + */ + @BetaApi + public static Expression mapRemove(String mapField, Expression key) { + return mapRemove(field(mapField), key); + } + + /** + * Creates an expression that removes a key from a map. + * + * @param mapExpr The expression representing the map. + * @param key The key to remove from the map. + * @return A new {@link Expression} representing the map with the key removed. + */ + @BetaApi + public static Expression mapRemove(Expression mapExpr, String key) { + return mapRemove(mapExpr, constant(key)); + } + + /** + * Creates an expression that removes a key from a map. + * + * @param mapField The field name of the map. + * @param key The key to remove from the map. + * @return A new {@link Expression} representing the map with the key removed. + */ + @BetaApi + public static Expression mapRemove(String mapField, String key) { + return mapRemove(field(mapField), key); + } + + /** + * Creates an expression that reverses a string, blob, or array. + * + * @param expr An expression evaluating to a string, blob, or array value, which will be reversed. + * @return A new {@link Expression} representing the reversed value. + */ + @BetaApi + public static Expression reverse(Expression expr) { + return new FunctionExpression("reverse", ImmutableList.of(expr)); + } + + /** + * Creates an expression that reverses the field value, which must be a string, blob, or array. + * + * @param fieldName A field evaluating to a string, blob, or array value. + * @return A new {@link Expression} representing the reversed value. + */ + @BetaApi + public static Expression reverse(String fieldName) { + return reverse(field(fieldName)); + } + + // Array Functions + /** + * Creates an expression that creates a Firestore array value from an input object. + * + * @param elements The input elements to evaluate in the expression. + * @return A new {@link Expression} representing the array function. + */ + @BetaApi + public static Expression array(Object... elements) { + return new FunctionExpression("array", toArrayOfExprOrConstant(elements)); + } + + /** + * Creates an expression that creates a Firestore array value from an input object. + * + * @param elements The input elements to evaluate in the expression. + * @return A new {@link Expression} representing the array function. + */ + @BetaApi + public static Expression array(List elements) { + return new FunctionExpression("array", toArrayOfExprOrConstant(elements.toArray())); + } + + /** + * Creates an expression that concatenates multiple arrays into a single array. + * + * @param firstArray The first array expression to concatenate. + * @param otherArrays Additional arrays to concatenate. + * @return A new {@link Expression} representing the concatenated array. + */ + @BetaApi + public static Expression arrayConcat(Expression firstArray, Object... otherArrays) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(firstArray); + builder.addAll(toArrayOfExprOrConstant(otherArrays)); + return new FunctionExpression("array_concat", builder.build()); + } + + /** + * Creates an expression that concatenates multiple arrays into a single array. + * + * @param firstArrayField The field name of the first array to concatenate. + * @param otherArrays Additional arrays to concatenate. + * @return A new {@link Expression} representing the concatenated array. + */ + @BetaApi + public static Expression arrayConcat(String firstArrayField, Object... otherArrays) { + return arrayConcat(field(firstArrayField), otherArrays); + } + + /** + * Creates an expression that reverses an array. + * + * @param array The expression representing the array to reverse. + * @return A new {@link Expression} representing the reversed array. + */ + @BetaApi + public static Expression arrayReverse(Expression array) { + return new FunctionExpression("array_reverse", ImmutableList.of(array)); + } + + /** + * Creates an expression that reverses an array. + * + * @param arrayFieldName The field name of the array to reverse. + * @return A new {@link Expression} representing the reversed array. + */ + @BetaApi + public static Expression arrayReverse(String arrayFieldName) { + return arrayReverse(field(arrayFieldName)); + } + + /** + * Creates an expression that checks if an array contains a specified element. + * + * @param array The expression representing the array. + * @param element The element to check for. + * @return A new {@link BooleanExpression} representing the array contains comparison. + */ + @BetaApi + public static BooleanExpression arrayContains(Expression array, Expression element) { + return new BooleanFunctionExpression("array_contains", array, element); + } + + /** + * Creates an expression that checks if an array contains a specified element. + * + * @param arrayFieldName The field name of the array. + * @param element The element to check for. + * @return A new {@link BooleanExpression} representing the array contains comparison. + */ + @BetaApi + public static BooleanExpression arrayContains(String arrayFieldName, Expression element) { + return arrayContains(field(arrayFieldName), element); + } + + /** + * Creates an expression that checks if an array contains a specified element. + * + * @param array The expression representing the array. + * @param element The element to check for. + * @return A new {@link BooleanExpression} representing the array contains comparison. + */ + @BetaApi + public static BooleanExpression arrayContains(Expression array, Object element) { + return arrayContains(array, toExprOrConstant(element)); + } + + /** + * Creates an expression that checks if an array contains a specified element. + * + * @param arrayFieldName The field name of the array. + * @param element The element to check for. + * @return A new {@link BooleanExpression} representing the array contains comparison. + */ + @BetaApi + public static BooleanExpression arrayContains(String arrayFieldName, Object element) { + return arrayContains(field(arrayFieldName), toExprOrConstant(element)); + } + + /** + * Creates an expression that checks if an array contains all of the provided values. + * + * @param array The expression representing the array. + * @param values The values to check for. + * @return A new {@link BooleanExpression} representing the array contains all comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAll(Expression array, List values) { + return arrayContainsAll(array, array(values)); + } + + /** + * Creates an expression that checks if an array contains all of the elements of another array. + * + * @param array The expression representing the array. + * @param arrayExpression The expression representing the array of values to check for. + * @return A new {@link BooleanExpression} representing the array contains all comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAll(Expression array, Expression arrayExpression) { + return new BooleanFunctionExpression("array_contains_all", array, arrayExpression); + } + + /** + * Creates an expression that checks if an array contains all of the provided values. + * + * @param arrayFieldName The field name of the array. + * @param values The values to check for. + * @return A new {@link BooleanExpression} representing the array contains all comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAll(String arrayFieldName, List values) { + return arrayContainsAll(field(arrayFieldName), array(values)); + } + + /** + * Creates an expression that checks if an array contains all of the elements of another array. + * + * @param arrayFieldName The field name of the array. + * @param arrayExpression The expression representing the array of values to check for. + * @return A new {@link BooleanExpression} representing the array contains all comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAll( + String arrayFieldName, Expression arrayExpression) { + return arrayContainsAll(field(arrayFieldName), arrayExpression); + } + + /** + * Creates an expression that checks if an array contains any of the provided values. + * + * @param array The expression representing the array. + * @param values The values to check for. + * @return A new {@link BooleanExpression} representing the array contains any comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAny(Expression array, List values) { + return new BooleanFunctionExpression("array_contains_any", array, array(values)); + } + + /** + * Creates an expression that checks if an array contains any of the elements of another array. + * + * @param array The expression representing the array. + * @param arrayExpression The expression representing the array of values to check for. + * @return A new {@link BooleanExpression} representing the array contains any comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAny(Expression array, Expression arrayExpression) { + return new BooleanFunctionExpression("array_contains_any", array, arrayExpression); + } + + /** + * Creates an expression that checks if an array contains any of the provided values. + * + * @param arrayFieldName The field name of the array. + * @param values The values to check for. + * @return A new {@link BooleanExpression} representing the array contains any comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAny(String arrayFieldName, List values) { + return arrayContainsAny(field(arrayFieldName), array(values)); + } + + /** + * Creates an expression that checks if an array contains any of the elements of another array. + * + * @param arrayFieldName The field name of the array. + * @param arrayExpression The expression representing the array of values to check for. + * @return A new {@link BooleanExpression} representing the array contains any comparison. + */ + @BetaApi + public static BooleanExpression arrayContainsAny( + String arrayFieldName, Expression arrayExpression) { + return arrayContainsAny(field(arrayFieldName), arrayExpression); + } + + /** + * Creates an expression that returns the length of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the length of the array. + */ + @BetaApi + public static Expression arrayLength(Expression array) { + return new FunctionExpression("array_length", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the length of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the length of the array. + */ + @BetaApi + public static Expression arrayLength(String arrayFieldName) { + return arrayLength(field(arrayFieldName)); + } + + /** + * Creates an expression that returns the first element of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the first element of the array. + */ + @BetaApi + public static Expression arrayFirst(Expression array) { + return new FunctionExpression("array_first", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the first element of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the first element of the array. + */ + @BetaApi + public static Expression arrayFirst(String arrayFieldName) { + return arrayFirst(field(arrayFieldName)); + } + + /** + * Creates an expression that returns the first n elements of an array. + * + * @param array The expression representing the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public static Expression arrayFirstN(Expression array, Expression n) { + return new FunctionExpression("array_first_n", ImmutableList.of(array, n)); + } + + /** + * Creates an expression that returns the first n elements of an array. + * + * @param array The expression representing the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public static Expression arrayFirstN(Expression array, int n) { + return arrayFirstN(array, constant(n)); + } + + /** + * Creates an expression that returns the first n elements of an array. + * + * @param arrayFieldName The field name of the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public static Expression arrayFirstN(String arrayFieldName, int n) { + return arrayFirstN(field(arrayFieldName), constant(n)); + } + + /** + * Creates an expression that returns the first n elements of an array. + * + * @param arrayFieldName The field name of the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public static Expression arrayFirstN(String arrayFieldName, Expression n) { + return arrayFirstN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the last element of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the last element of the array. + */ + @BetaApi + public static Expression arrayLast(Expression array) { + return new FunctionExpression("array_last", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the last element of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the last element of the array. + */ + @BetaApi + public static Expression arrayLast(String arrayFieldName) { + return arrayLast(field(arrayFieldName)); + } + + /** + * Creates an expression that returns the last n elements of an array. + * + * @param array The expression representing the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public static Expression arrayLastN(Expression array, Expression n) { + return new FunctionExpression("array_last_n", ImmutableList.of(array, n)); + } + + /** + * Creates an expression that returns the last n elements of an array. + * + * @param array The expression representing the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public static Expression arrayLastN(Expression array, int n) { + return arrayLastN(array, constant(n)); + } + + /** + * Creates an expression that returns the last n elements of an array. + * + * @param arrayFieldName The field name of the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public static Expression arrayLastN(String arrayFieldName, int n) { + return arrayLastN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the last n elements of an array. + * + * @param arrayFieldName The field name of the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public static Expression arrayLastN(String arrayFieldName, Expression n) { + return arrayLastN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the minimum value of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the minimum value of the array. + */ + @BetaApi + public static Expression arrayMinimum(Expression array) { + return new FunctionExpression("minimum", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the minimum value of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the minimum value of the array. + */ + @BetaApi + public static Expression arrayMinimum(String arrayFieldName) { + return arrayMinimum(field(arrayFieldName)); + } + + /** + * Creates an expression that returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param array The expression representing the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public static Expression arrayMinimumN(Expression array, Expression n) { + return new FunctionExpression("minimum_n", ImmutableList.of(array, n)); + } + + /** + * Creates an expression that returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param array The expression representing the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public static Expression arrayMinimumN(Expression array, int n) { + return arrayMinimumN(array, constant(n)); + } + + /** + * Creates an expression that returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param arrayFieldName The field name of the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public static Expression arrayMinimumN(String arrayFieldName, int n) { + return arrayMinimumN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param arrayFieldName The field name of the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public static Expression arrayMinimumN(String arrayFieldName, Expression n) { + return arrayMinimumN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the maximum value of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the maximum value of the array. + */ + @BetaApi + public static Expression arrayMaximum(Expression array) { + return new FunctionExpression("maximum", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the maximum value of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the maximum value of the array. + */ + @BetaApi + public static Expression arrayMaximum(String arrayFieldName) { + return arrayMaximum(field(arrayFieldName)); + } + + /** + * Creates an expression that returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param array The expression representing the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public static Expression arrayMaximumN(Expression array, Expression n) { + return new FunctionExpression("maximum_n", ImmutableList.of(array, n)); + } + + /** + * Creates an expression that returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param array The expression representing the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public static Expression arrayMaximumN(Expression array, int n) { + return arrayMaximumN(array, constant(n)); + } + + /** + * Creates an expression that returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param arrayFieldName The field name of the array. + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public static Expression arrayMaximumN(String arrayFieldName, int n) { + return arrayMaximumN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param arrayFieldName The field name of the array. + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public static Expression arrayMaximumN(String arrayFieldName, Expression n) { + return arrayMaximumN(field(arrayFieldName), n); + } + + /** + * Creates an expression that returns the index of the first occurrence of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public static Expression arrayIndexOf(Expression array, Expression value) { + return new FunctionExpression( + "array_index_of", + ImmutableList.of(array, toExprOrConstant(value), toExprOrConstant("first"))); + } + + /** + * Creates an expression that returns the index of the first occurrence of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public static Expression arrayIndexOf(Expression array, Object value) { + return arrayIndexOf(array, toExprOrConstant(value)); + } + + /** + * Creates an expression that returns the index of the first occurrence of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public static Expression arrayIndexOf(String arrayFieldName, Object value) { + return arrayIndexOf(field(arrayFieldName), value); + } + + /** + * Creates an expression that returns the index of the first occurrence of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public static Expression arrayIndexOf(String arrayFieldName, Expression value) { + return arrayIndexOf(field(arrayFieldName), value); + } + + /** + * Creates an expression that returns the index of the last occurrence of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public static Expression arrayLastIndexOf(Expression array, Expression value) { + return new FunctionExpression( + "array_index_of", + ImmutableList.of(array, toExprOrConstant(value), toExprOrConstant("last"))); + } + + /** + * Creates an expression that returns the index of the last occurrence of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public static Expression arrayLastIndexOf(Expression array, Object value) { + return arrayLastIndexOf(array, toExprOrConstant(value)); + } + + /** + * Creates an expression that returns the index of the last occurrence of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public static Expression arrayLastIndexOf(String arrayFieldName, Object value) { + return arrayLastIndexOf(field(arrayFieldName), value); + } + + /** + * Creates an expression that returns the index of the last occurrence of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public static Expression arrayLastIndexOf(String arrayFieldName, Expression value) { + return arrayLastIndexOf(field(arrayFieldName), value); + } + + /** + * Creates an expression that returns all indices of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public static Expression arrayIndexOfAll(Expression array, Expression value) { + return new FunctionExpression( + "array_index_of_all", ImmutableList.of(array, toExprOrConstant(value))); + } + + /** + * Creates an expression that returns all indices of a value in an array. + * + * @param array The expression representing the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public static Expression arrayIndexOfAll(Expression array, Object value) { + return arrayIndexOfAll(array, toExprOrConstant(value)); + } + + /** + * Creates an expression that returns all indices of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public static Expression arrayIndexOfAll(String arrayFieldName, Object value) { + return arrayIndexOfAll(field(arrayFieldName), toExprOrConstant(value)); + } + + /** + * Creates an expression that returns all indices of a value in an array. + * + * @param arrayFieldName The field name of the array. + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public static Expression arrayIndexOfAll(String arrayFieldName, Expression value) { + return arrayIndexOfAll(field(arrayFieldName), value); + } + + /** + * Creates an expression that returns an element from an array at a specified index. + * + * @param array The expression representing the array. + * @param offset The index of the element to return. + * @return A new {@link Expression} representing the element at the specified index. + */ + @BetaApi + public static Expression arrayGet(Expression array, Expression offset) { + return new FunctionExpression("array_get", ImmutableList.of(array, offset)); + } + + /** + * Creates an expression that returns an element from an array at a specified index. + * + * @param array The expression representing the array. + * @param offset The index of the element to return. + * @return A new {@link Expression} representing the element at the specified index. + */ + @BetaApi + public static Expression arrayGet(Expression array, int offset) { + return arrayGet(array, constant(offset)); + } + + /** + * Creates an expression that returns an element from an array at a specified index. + * + * @param arrayFieldName The field name of the array. + * @param offset The index of the element to return. + * @return A new {@link Expression} representing the element at the specified index. + */ + @BetaApi + public static Expression arrayGet(String arrayFieldName, Expression offset) { + return arrayGet(field(arrayFieldName), offset); + } + + /** + * Creates an expression that returns an element from an array at a specified index. + * + * @param arrayFieldName The field name of the array. + * @param offset The index of the element to return. + * @return A new {@link Expression} representing the element at the specified index. + */ + @BetaApi + public static Expression arrayGet(String arrayFieldName, int offset) { + return arrayGet(field(arrayFieldName), constant(offset)); + } + + /** + * Creates an expression that returns the sum of the elements of an array. + * + * @param array The expression representing the array. + * @return A new {@link Expression} representing the sum of the elements of the array. + */ + @BetaApi + public static Expression arraySum(Expression array) { + return new FunctionExpression("sum", ImmutableList.of(array)); + } + + /** + * Creates an expression that returns the sum of the elements of an array. + * + * @param arrayFieldName The field name of the array. + * @return A new {@link Expression} representing the sum of the elements of the array. + */ + @BetaApi + public static Expression arraySum(String arrayFieldName) { + return arraySum(field(arrayFieldName)); + } + + // Vector Functions + /** + * Creates an expression that calculates the cosine distance between two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the cosine distance. + */ + @BetaApi + public static Expression cosineDistance(Expression vector1, Expression vector2) { + return new FunctionExpression("cosine_distance", ImmutableList.of(vector1, vector2)); + } + + /** + * Creates an expression that calculates the cosine distance between two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the cosine distance. + */ + @BetaApi + public static Expression cosineDistance(Expression vector1, double[] vector2) { + return cosineDistance(vector1, constant(FieldValue.vector(vector2))); + } + + /** + * Creates an expression that calculates the cosine distance between two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the cosine distance. + */ + @BetaApi + public static Expression cosineDistance(String vectorFieldName, Expression vector) { + return cosineDistance(field(vectorFieldName), vector); + } + + /** + * Creates an expression that calculates the cosine distance between two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the cosine distance. + */ + @BetaApi + public static Expression cosineDistance(String vectorFieldName, double[] vector) { + return cosineDistance(field(vectorFieldName), constant(FieldValue.vector(vector))); + } + + /** + * Creates an expression that calculates the dot product of two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the dot product. + */ + @BetaApi + public static Expression dotProduct(Expression vector1, Expression vector2) { + return new FunctionExpression("dot_product", ImmutableList.of(vector1, vector2)); + } + + /** + * Creates an expression that calculates the dot product of two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the dot product. + */ + @BetaApi + public static Expression dotProduct(Expression vector1, double[] vector2) { + return dotProduct(vector1, constant(FieldValue.vector(vector2))); + } + + /** + * Creates an expression that calculates the dot product of two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the dot product. + */ + @BetaApi + public static Expression dotProduct(String vectorFieldName, Expression vector) { + return dotProduct(field(vectorFieldName), vector); + } + + /** + * Creates an expression that calculates the dot product of two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the dot product. + */ + @BetaApi + public static Expression dotProduct(String vectorFieldName, double[] vector) { + return dotProduct(field(vectorFieldName), constant(FieldValue.vector(vector))); + } + + /** + * Creates an expression that calculates the Euclidean distance between two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the Euclidean distance. + */ + @BetaApi + public static Expression euclideanDistance(Expression vector1, Expression vector2) { + return new FunctionExpression("euclidean_distance", ImmutableList.of(vector1, vector2)); + } + + /** + * Creates an expression that calculates the Euclidean distance between two vectors. + * + * @param vector1 The first vector. + * @param vector2 The second vector. + * @return A new {@link Expression} representing the Euclidean distance. + */ + @BetaApi + public static Expression euclideanDistance(Expression vector1, double[] vector2) { + return euclideanDistance(vector1, constant(FieldValue.vector(vector2))); + } + + /** + * Creates an expression that calculates the Euclidean distance between two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the Euclidean distance. + */ + @BetaApi + public static Expression euclideanDistance(String vectorFieldName, Expression vector) { + return euclideanDistance(field(vectorFieldName), vector); + } + + /** + * Creates an expression that calculates the Euclidean distance between two vectors. + * + * @param vectorFieldName The field name of the first vector. + * @param vector The second vector. + * @return A new {@link Expression} representing the Euclidean distance. + */ + @BetaApi + public static Expression euclideanDistance(String vectorFieldName, double[] vector) { + return euclideanDistance(field(vectorFieldName), constant(FieldValue.vector(vector))); + } + + /** + * Creates an expression that calculates the length of a vector. + * + * @param vectorExpression The expression representing the vector. + * @return A new {@link Expression} representing the length of the vector. + */ + @BetaApi + public static Expression vectorLength(Expression vectorExpression) { + return new FunctionExpression("vector_length", ImmutableList.of(vectorExpression)); + } + + /** + * Creates an expression that calculates the length of a vector. + * + * @param fieldName The field name of the vector. + * @return A new {@link Expression} representing the length of the vector. + */ + @BetaApi + public static Expression vectorLength(String fieldName) { + return vectorLength(field(fieldName)); + } + + // Timestamp Functions + /** + * Creates an expression that converts a Unix timestamp in microseconds to a Firestore timestamp. + * + * @param expr The expression representing the Unix timestamp in microseconds. + * @return A new {@link Expression} representing the Firestore timestamp. + */ + @BetaApi + public static Expression unixMicrosToTimestamp(Expression expr) { + return new FunctionExpression("unix_micros_to_timestamp", ImmutableList.of(expr)); + } + + /** + * Creates an expression that interprets a field's value as the number of microseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @param fieldName The name of the field containing the number of microseconds since epoch. + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public static Expression unixMicrosToTimestamp(String fieldName) { + return unixMicrosToTimestamp(field(fieldName)); + } + + /** + * Creates an expression that converts a timestamp expression to the number of microseconds since + * the Unix epoch (1970-01-01 00:00:00 UTC). + * + * @param expr The expression representing the timestamp. + * @return A new {@link Expression} representing the number of microseconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixMicros(Expression expr) { + return new FunctionExpression("timestamp_to_unix_micros", ImmutableList.of(expr)); + } + + /** + * Creates an expression that converts a timestamp field to the number of microseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC). + * + * @param fieldName The name of the field that contains the timestamp. + * @return A new {@link Expression} representing the number of microseconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixMicros(String fieldName) { + return timestampToUnixMicros(field(fieldName)); + } + + /** + * Creates an expression that interprets an expression as the number of milliseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @param expr The expression representing the number of milliseconds since epoch. + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public static Expression unixMillisToTimestamp(Expression expr) { + return new FunctionExpression("unix_millis_to_timestamp", ImmutableList.of(expr)); + } + + /** + * Creates an expression that interprets a field's value as the number of milliseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @param fieldName The name of the field containing the number of milliseconds since epoch. + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public static Expression unixMillisToTimestamp(String fieldName) { + return unixMillisToTimestamp(field(fieldName)); + } + + /** + * Creates an expression that converts a timestamp expression to the number of milliseconds since + * the Unix epoch (1970-01-01 00:00:00 UTC). + * + * @param expr The expression representing the timestamp. + * @return A new {@link Expression} representing the number of milliseconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixMillis(Expression expr) { + return new FunctionExpression("timestamp_to_unix_millis", ImmutableList.of(expr)); + } + + /** + * Creates an expression that converts a timestamp field to the number of milliseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC). + * + * @param fieldName The name of the field that contains the timestamp. + * @return A new {@link Expression} representing the number of milliseconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixMillis(String fieldName) { + return timestampToUnixMillis(field(fieldName)); + } + + /** + * Creates an expression that interprets an expression as the number of seconds since the Unix + * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @param expr The expression representing the number of seconds since epoch. + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public static Expression unixSecondsToTimestamp(Expression expr) { + return new FunctionExpression("unix_seconds_to_timestamp", ImmutableList.of(expr)); + } + + /** + * Creates an expression that interprets a field's value as the number of seconds since the Unix + * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @param fieldName The name of the field containing the number of seconds since epoch. + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public static Expression unixSecondsToTimestamp(String fieldName) { + return unixSecondsToTimestamp(field(fieldName)); + } + + /** + * Creates an expression that converts a timestamp expression to the number of seconds since the + * Unix epoch (1970-01-01 00:00:00 UTC). + * + * @param expr The expression representing the timestamp. + * @return A new {@link Expression} representing the number of seconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixSeconds(Expression expr) { + return new FunctionExpression("timestamp_to_unix_seconds", ImmutableList.of(expr)); + } + + /** + * Creates an expression that converts a timestamp field to the number of seconds since the Unix + * epoch (1970-01-01 00:00:00 UTC). + * + * @param fieldName The name of the field that contains the timestamp. + * @return A new {@link Expression} representing the number of seconds since epoch. + */ + @BetaApi + public static Expression timestampToUnixSeconds(String fieldName) { + return timestampToUnixSeconds(field(fieldName)); + } + + /** + * Creates an expression that adds a specified amount of time to a timestamp. + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression representing the unit of time to add. Valid units include + * "microsecond", "millisecond", "second", "minute", "hour" and "day". + * @param amount The expression representing the amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampAdd(Expression timestamp, Expression unit, Expression amount) { + return new FunctionExpression("timestamp_add", ImmutableList.of(timestamp, unit, amount)); + } + + /** + * Creates an expression that adds a specified amount of time to a timestamp. + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampAdd(Expression timestamp, String unit, long amount) { + return timestampAdd(timestamp, constant(unit), constant(amount)); + } + + /** + * Creates an expression that adds a specified amount of time to a timestamp. + * + * @param fieldName The name of the field that contains the timestamp. + * @param unit The expression representing the unit of time to add. Valid units include + * "microsecond", "millisecond", "second", "minute", "hour" and "day". + * @param amount The expression representing the amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampAdd(String fieldName, Expression unit, Expression amount) { + return timestampAdd(field(fieldName), unit, amount); + } + + /** + * Creates an expression that adds a specified amount of time to a timestamp. + * + * @param fieldName The name of the field that contains the timestamp. + * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampAdd(String fieldName, String unit, long amount) { + return timestampAdd(field(fieldName), constant(unit), constant(amount)); + } + + /** + * Creates an expression that subtracts a specified amount of time to a timestamp. + * + * @param timestamp The expression representing the timestamp. + * @param unit The expression representing the unit of time to subtract. Valid units include + * "microsecond", "millisecond", "second", "minute", "hour" and "day". + * @param amount The expression representing the amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampSubtract( + Expression timestamp, Expression unit, Expression amount) { + return new FunctionExpression("timestamp_subtract", ImmutableList.of(timestamp, unit, amount)); + } + + /** + * Creates an expression that subtracts a specified amount of time to a timestamp. + * + * @param timestamp The expression representing the timestamp. + * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampSubtract(Expression timestamp, String unit, long amount) { + return timestampSubtract(timestamp, constant(unit), constant(amount)); + } + + /** + * Creates an expression that subtracts a specified amount of time to a timestamp. + * + * @param fieldName The name of the field that contains the timestamp. + * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampSubtract(String fieldName, Expression unit, Expression amount) { + return timestampSubtract(field(fieldName), unit, amount); + } + + /** + * Creates an expression that subtracts a specified amount of time to a timestamp. + * + * @param fieldName The name of the field that contains the timestamp. + * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public static Expression timestampSubtract(String fieldName, String unit, long amount) { + return timestampSubtract(field(fieldName), constant(unit), constant(amount)); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity. + * + * @param timestamp The timestamp expression. + * @param granularity The granularity to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate(Expression timestamp, String granularity) { + return new FunctionExpression( + "timestamp_trunc", ImmutableList.of(timestamp, constant(granularity))); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity. + * + * @param timestamp The timestamp expression. + * @param granularity The granularity expression to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate(Expression timestamp, Expression granularity) { + return new FunctionExpression("timestamp_trunc", ImmutableList.of(timestamp, granularity)); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity. + * + * @param fieldName The name of the field containing the timestamp. + * @param granularity The granularity to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate(String fieldName, String granularity) { + return timestampTruncate(field(fieldName), constant(granularity)); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity. + * + * @param fieldName The name of the field containing the timestamp. + * @param granularity The granularity expression to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate(String fieldName, Expression granularity) { + return timestampTruncate(field(fieldName), granularity); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity in a given + * timezone. + * + * @param timestamp The timestamp expression. + * @param granularity The granularity to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @param timezone The timezone to use for truncation. Valid values are from the TZ database + * (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate( + Expression timestamp, String granularity, String timezone) { + return new FunctionExpression( + "timestamp_trunc", ImmutableList.of(timestamp, constant(granularity), constant(timezone))); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity in a given + * timezone. + * + * @param timestamp The timestamp expression. + * @param granularity The granularity expression to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @param timezone The timezone to use for truncation. Valid values are from the TZ database + * (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate( + Expression timestamp, Expression granularity, String timezone) { + return new FunctionExpression( + "timestamp_trunc", ImmutableList.of(timestamp, granularity, constant(timezone))); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity in a given + * timezone. + * + * @param fieldName The name of the field containing the timestamp. + * @param granularity The granularity to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @param timezone The timezone to use for truncation. Valid values are from the TZ database + * (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate( + String fieldName, String granularity, String timezone) { + return timestampTruncate(field(fieldName), constant(granularity), timezone); + } + + /** + * Creates an expression that truncates a timestamp to a specified granularity in a given + * timezone. + * + * @param fieldName The name of the field containing the timestamp. + * @param granularity The granularity expression to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @param timezone The timezone to use for truncation. Valid values are from the TZ database + * (e.g., "America/Los_Angeles") or in the format "Etc/GMT-1". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public static Expression timestampTruncate( + String fieldName, Expression granularity, String timezone) { + return timestampTruncate(field(fieldName), granularity, timezone); + } + + // Conditional Functions + /** + * Creates a conditional expression that evaluates to a {@code thenExpr} expression if a condition + * is true or an {@code elseExpr} expression if the condition is false. + * + * @param condition The condition to evaluate. + * @param thenExpr The expression to evaluate if the condition is true. + * @param elseExpr The expression to evaluate if the condition is false. + * @return A new {@link Expression} representing the conditional operation. + */ + @BetaApi + public static Expression conditional( + BooleanExpression condition, Expression thenExpr, Expression elseExpr) { + return new FunctionExpression("conditional", ImmutableList.of(condition, thenExpr, elseExpr)); + } + + /** + * Creates a conditional expression that evaluates to a {@code thenValue} if a condition is true + * or an {@code elseValue} if the condition is false. + * + * @param condition The condition to evaluate. + * @param thenValue Value if the condition is true. + * @param elseValue Value if the condition is false. + * @return A new {@link Expression} representing the conditional operation. + */ + @BetaApi + public static Expression conditional( + BooleanExpression condition, Object thenValue, Object elseValue) { + return conditional(condition, toExprOrConstant(thenValue), toExprOrConstant(elseValue)); + } + + // Error Handling Functions + /** + * Creates an expression that returns the {@code catchExpr} argument if there is an error, else + * return the result of the {@code tryExpr} argument evaluation. + * + * @param tryExpr The try expression. + * @param catchExpr The catch expression that will be evaluated and returned if the {@code + * tryExpr} produces an error. + * @return A new {@link Expression} representing the ifError operation. + */ + @BetaApi + public static Expression ifError(Expression tryExpr, Expression catchExpr) { + return new FunctionExpression("if_error", ImmutableList.of(tryExpr, catchExpr)); + } + + /** + * Creates an expression that returns the {@code catchExpr} argument if there is an error, else + * return the result of the {@code tryExpr} argument evaluation. + * + *

This overload will return {@link BooleanExpression} when both parameters are also {@link + * BooleanExpression}. + * + * @param tryExpr The try boolean expression. + * @param catchExpr The catch boolean expression that will be evaluated and returned if the {@code + * tryExpr} produces an error. + * @return A new {@link BooleanExpression} representing the ifError operation. + */ + @BetaApi + public static BooleanExpression ifError(BooleanExpression tryExpr, BooleanExpression catchExpr) { + return new BooleanFunctionExpression("if_error", tryExpr, catchExpr); + } + + /** + * Creates an expression that returns the {@code catchValue} argument if there is an error, else + * return the result of the {@code tryExpr} argument evaluation. + * + * @param tryExpr The try expression. + * @param catchValue The value that will be returned if the {@code tryExpr} produces an error. + * @return A new {@link Expression} representing the ifError operation. + */ + @BetaApi + public static Expression ifError(Expression tryExpr, Object catchValue) { + return ifError(tryExpr, toExprOrConstant(catchValue)); + } + + /** + * Creates an expression that checks if a given expression produces an error. + * + * @param expr The expression to check. + * @return A new {@link BooleanExpression} representing the `isError` check. + */ + @BetaApi + public static BooleanExpression isError(Expression expr) { + return new BooleanFunctionExpression("is_error", expr); + } + + // Other Utility Functions + /** + * Creates an expression that returns the document ID from a path. + * + * @param documentPath An expression the evaluates to document path. + * @return A new {@link Expression} representing the documentId operation. + */ + @BetaApi + public static Expression documentId(Expression documentPath) { + return new FunctionExpression("document_id", ImmutableList.of(documentPath)); + } + + /** + * Creates an expression that returns the document ID from a path. + * + * @param documentPath The string representation of the document path. + * @return A new {@link Expression} representing the documentId operation. + */ + @BetaApi + public static Expression documentId(String documentPath) { + return documentId(constant(documentPath)); + } + + /** + * Creates an expression that returns the document ID from a {@link DocumentReference}. + * + * @param docRef The {@link DocumentReference}. + * @return A new {@link Expression} representing the documentId operation. + */ + @BetaApi + public static Expression documentId(DocumentReference docRef) { + return documentId(constant(docRef)); + } + + /** + * Creates an expression that returns the collection ID from a path. + * + * @param path An expression the evaluates to document path. + * @return A new {@link Expression} representing the collectionId operation. + */ + @BetaApi + public static Expression collectionId(Expression path) { + return new FunctionExpression("collection_id", ImmutableList.of(path)); + } + + /** + * Creates an expression that returns the collection ID from a path. + * + * @param pathFieldName The field name of the path. + * @return A new {@link Expression} representing the collectionId operation. + */ + @BetaApi + public static Expression collectionId(String pathFieldName) { + return collectionId(field(pathFieldName)); + } + + // Type Checking Functions + /** + * Creates an expression that checks if a field exists. + * + * @param value An expression evaluates to the name of the field to check. + * @return A new {@link Expression} representing the exists check. + */ + @BetaApi + public static BooleanExpression exists(Expression value) { + return new BooleanFunctionExpression("exists", value); + } + + /** + * Creates an expression that checks if a field exists. + * + * @param fieldName The field name to check. + * @return A new {@link Expression} representing the exists check. + */ + @BetaApi + public static BooleanExpression exists(String fieldName) { + return exists(field(fieldName)); + } + + /** + * Creates an expression that returns true if a value is absent. Otherwise, returns false even if + * the value is null. + * + * @param value The expression to check. + * @return A new {@link BooleanExpression} representing the isAbsent operation. + */ + @BetaApi + public static BooleanExpression isAbsent(Expression value) { + return new BooleanFunctionExpression("is_absent", value); + } + + /** + * Creates an expression that returns true if a field is absent. Otherwise, returns false even if + * the field value is null. + * + * @param fieldName The field to check. + * @return A new {@link BooleanExpression} representing the isAbsent operation. + */ + @BetaApi + public static BooleanExpression isAbsent(String fieldName) { + return isAbsent(field(fieldName)); + } + + /** + * Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). + * + * @param value The expression to check. + * @return A new {@link BooleanExpression} representing the isNan operation. + */ + @BetaApi + static BooleanExpression isNaN(Expression value) { + return new BooleanFunctionExpression("is_nan", value); + } + + /** + * Creates an expression that checks if a field's value evaluates to 'NaN' (Not a Number). + * + * @param fieldName The field to check. + * @return A new {@link BooleanExpression} representing the isNan operation. + */ + @BetaApi + static BooleanExpression isNaN(String fieldName) { + return isNaN(field(fieldName)); + } + + /** + * Creates an expression that checks if the result of an expression is null. + * + * @param value The expression to check. + * @return A new {@link BooleanExpression} representing the isNull operation. + */ + @BetaApi + static BooleanExpression isNull(Expression value) { + return new BooleanFunctionExpression("is_null", value); + } + + /** + * Creates an expression that checks if the value of a field is null. + * + * @param fieldName The field to check. + * @return A new {@link BooleanExpression} representing the isNull operation. + */ + @BetaApi + static BooleanExpression isNull(String fieldName) { + return isNull(field(fieldName)); + } + + /** + * Creates an expression that checks if the result of an expression is not null. + * + * @param value The expression to check. + * @return A new {@link BooleanExpression} representing the isNotNull operation. + */ + @BetaApi + static BooleanExpression isNotNull(Expression value) { + return new BooleanFunctionExpression("is_not_null", value); + } + + /** + * Creates an expression that checks if the value of a field is not null. + * + * @param fieldName The field to check. + * @return A new {@link BooleanExpression} representing the isNotNull operation. + */ + @BetaApi + static BooleanExpression isNotNull(String fieldName) { + return isNotNull(field(fieldName)); + } + + /** + * Creates an expression that returns a string indicating the type of the value this expression + * evaluates to. + * + * @param expr The expression to get the type of. + * @return A new {@link Expression} representing the type operation. + */ + @BetaApi + public static Expression type(Expression expr) { + return new FunctionExpression("type", ImmutableList.of(expr)); + } + + /** + * Creates an expression that returns a string indicating the type of the value this field + * evaluates to. + * + * @param fieldName The name of the field to get the type of. + * @return A new {@link Expression} representing the type operation. + */ + @BetaApi + public static Expression type(String fieldName) { + return type(field(fieldName)); + } + + // Numeric Operations + /** + * Creates an expression that rounds {@code numericExpr} to nearest integer. + * + *

Rounds away from zero in halfway cases. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the round operation. + */ + @BetaApi + public static Expression round(Expression numericExpr) { + return new FunctionExpression("round", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that rounds {@code numericField} to nearest integer. + * + *

Rounds away from zero in halfway cases. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the round operation. + */ + @BetaApi + public static Expression round(String numericField) { + return round(field(numericField)); + } + + /** + * Creates an expression that rounds off {@code numericExpr} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param numericExpr An expression that returns number when evaluated. + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public static Expression roundToPrecision(Expression numericExpr, int decimalPlace) { + return new FunctionExpression("round", ImmutableList.of(numericExpr, constant(decimalPlace))); + } + + /** + * Creates an expression that rounds off {@code numericField} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param numericField Name of field that returns number when evaluated. + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public static Expression roundToPrecision(String numericField, int decimalPlace) { + return roundToPrecision(field(numericField), decimalPlace); + } + + /** + * Creates an expression that rounds off {@code numericExpr} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param numericExpr An expression that returns number when evaluated. + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public static Expression roundToPrecision(Expression numericExpr, Expression decimalPlace) { + return new FunctionExpression("round", ImmutableList.of(numericExpr, decimalPlace)); + } + + /** + * Creates an expression that rounds off {@code numericField} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param numericField Name of field that returns number when evaluated. + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public static Expression roundToPrecision(String numericField, Expression decimalPlace) { + return roundToPrecision(field(numericField), decimalPlace); + } + + /** + * Creates an expression that returns a random double between 0.0 and 1.0 but not including 1.0. + * + * @return A new {@link Expression} representing a random double result from the rand operation. + */ + @BetaApi + public static Expression rand() { + return new FunctionExpression("rand", ImmutableList.of()); + } + + /** + * Creates an expression that truncates {@code numericExpr} to an integer. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression trunc(Expression numericExpr) { + return new FunctionExpression("trunc", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that truncates {@code numericField} to an integer. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression trunc(String numericField) { + return trunc(field(numericField)); + } + + /** + * Creates an expression that truncates {@code numericExpr} to {@code decimalPlace} decimal places + * if {@code decimalPlace} is positive, truncates digits to the left of the decimal point if + * {@code decimalPlace} is negative. + * + * @param numericExpr An expression that returns number when evaluated. + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression truncToPrecision(Expression numericExpr, int decimalPlace) { + return new FunctionExpression("trunc", ImmutableList.of(numericExpr, constant(decimalPlace))); + } + + /** + * Creates an expression that truncates {@code numericField} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, truncates digits to the left of the decimal point + * if {@code decimalPlace} is negative. + * + * @param numericField Name of field that returns number when evaluated. + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression truncToPrecision(String numericField, int decimalPlace) { + return truncToPrecision(field(numericField), decimalPlace); + } + + /** + * Creates an expression that truncates {@code numericExpr} to {@code decimalPlace} decimal places + * if {@code decimalPlace} is positive, truncates digits to the left of the decimal point if + * {@code decimalPlace} is negative. + * + * @param numericExpr An expression that returns number when evaluated. + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression truncToPrecision(Expression numericExpr, Expression decimalPlace) { + return new FunctionExpression("trunc", ImmutableList.of(numericExpr, decimalPlace)); + } + + /** + * Creates an expression that truncates {@code numericField} to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, truncates digits to the left of the decimal point + * if {@code decimalPlace} is negative. + * + * @param numericField Name of field that returns number when evaluated. + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public static Expression truncToPrecision(String numericField, Expression decimalPlace) { + return truncToPrecision(field(numericField), decimalPlace); + } + + /** + * Creates an expression that returns the smallest integer that isn't less than {@code + * numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the ceil operation. + */ + @BetaApi + public static Expression ceil(Expression numericExpr) { + return new FunctionExpression("ceil", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the smallest integer that isn't less than {@code + * numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the ceil operation. + */ + @BetaApi + public static Expression ceil(String numericField) { + return ceil(field(numericField)); + } + + /** + * Creates an expression that returns the largest integer that isn't less than {@code + * numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the floor operation. + */ + @BetaApi + public static Expression floor(Expression numericExpr) { + return new FunctionExpression("floor", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the largest integer that isn't less than {@code + * numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing an integer result from the floor operation. + */ + @BetaApi + public static Expression floor(String numericField) { + return floor(field(numericField)); + } + + /** + * Creates an expression that returns the {@code numericExpr} raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param numericExpr An expression that returns number when evaluated. + * @param exponent The numeric power to raise the {@code numericExpr}. + * @return A new {@link Expression} representing a numeric result from raising {@code numericExpr} + * to the power of {@code exponent}. + */ + @BetaApi + public static Expression pow(Expression numericExpr, Number exponent) { + return new FunctionExpression("pow", ImmutableList.of(numericExpr, constant(exponent))); + } + + /** + * Creates an expression that returns the {@code numericField} raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param numericField Name of field that returns number when evaluated. + * @param exponent The numeric power to raise the {@code numericField}. + * @return A new {@link Expression} representing a numeric result from raising {@code + * numericField} to the power of {@code exponent}. + */ + @BetaApi + public static Expression pow(String numericField, Number exponent) { + return pow(field(numericField), exponent); + } + + /** + * Creates an expression that returns the {@code numericExpr} raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param numericExpr An expression that returns number when evaluated. + * @param exponent The numeric power to raise the {@code numericExpr}. + * @return A new {@link Expression} representing a numeric result from raising {@code numericExpr} + * to the power of {@code exponent}. + */ + @BetaApi + public static Expression pow(Expression numericExpr, Expression exponent) { + return new FunctionExpression("pow", ImmutableList.of(numericExpr, exponent)); + } + + /** + * Creates an expression that returns the {@code numericField} raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param numericField Name of field that returns number when evaluated. + * @param exponent The numeric power to raise the {@code numericField}. + * @return A new {@link Expression} representing a numeric result from raising {@code + * numericField} to the power of {@code exponent}. + */ + @BetaApi + public static Expression pow(String numericField, Expression exponent) { + return pow(field(numericField), exponent); + } + + /** + * Creates an expression that returns the absolute value of {@code numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the absolute value + * operation. + */ + @BetaApi + public static Expression abs(Expression numericExpr) { + return new FunctionExpression("abs", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the absolute value of {@code numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the absolute value + * operation. + */ + @BetaApi + public static Expression abs(String numericField) { + return abs(field(numericField)); + } + + /** + * Creates an expression that returns Euler's number e raised to the power of {@code numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the exponentiation. + */ + @BetaApi + public static Expression exp(Expression numericExpr) { + return new FunctionExpression("exp", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns Euler's number e raised to the power of {@code + * numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the exponentiation. + */ + @BetaApi + public static Expression exp(String numericField) { + return exp(field(numericField)); + } + + /** + * Creates an expression that returns the natural logarithm (base e) of {@code numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the natural logarithm. + */ + @BetaApi + public static Expression ln(Expression numericExpr) { + return new FunctionExpression("ln", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the natural logarithm (base e) of {@code numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the natural logarithm. + */ + @BetaApi + public static Expression ln(String numericField) { + return ln(field(numericField)); + } + + /** + * Creates an expression that returns the logarithm of {@code numericExpr} with a given {@code + * base}. + * + * @param numericExpr An expression that returns number when evaluated. + * @param base The base of the logarithm. + * @return A new {@link Expression} representing a numeric result from the logarithm of {@code + * numericExpr} with a given {@code base}. + */ + @BetaApi + public static Expression log(Expression numericExpr, Number base) { + return new FunctionExpression("log", ImmutableList.of(numericExpr, constant(base))); + } + + /** + * Creates an expression that returns the logarithm of {@code numericField} with a given {@code + * base}. + * + * @param numericField Name of field that returns number when evaluated. + * @param base The base of the logarithm. + * @return A new {@link Expression} representing a numeric result from the logarithm of {@code + * numericField} with a given {@code base}. + */ + @BetaApi + public static Expression log(String numericField, Number base) { + return log(field(numericField), base); + } + + /** + * Creates an expression that returns the logarithm of {@code numericExpr} with a given {@code + * base}. + * + * @param numericExpr An expression that returns number when evaluated. + * @param base The base of the logarithm. + * @return A new {@link Expression} representing a numeric result from the logarithm of {@code + * numericExpr} with a given {@code base}. + */ + @BetaApi + public static Expression log(Expression numericExpr, Expression base) { + return new FunctionExpression("log", ImmutableList.of(numericExpr, base)); + } + + /** + * Creates an expression that returns the logarithm of {@code numericField} with a given {@code + * base}. + * + * @param numericField Name of field that returns number when evaluated. + * @param base The base of the logarithm. + * @return A new {@link Expression} representing a numeric result from the logarithm of {@code + * numericField} with a given {@code base}. + */ + @BetaApi + public static Expression log(String numericField, Expression base) { + return log(field(numericField), base); + } + + /** + * Creates an expression that returns the base 10 logarithm of {@code numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the base 10 logarithm. + */ + @BetaApi + public static Expression log10(Expression numericExpr) { + return new FunctionExpression("log10", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the base 10 logarithm of {@code numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the base 10 logarithm. + */ + @BetaApi + public static Expression log10(String numericField) { + return log10(field(numericField)); + } + + /** + * Creates an expression that returns the square root of {@code numericExpr}. + * + * @param numericExpr An expression that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the square root operation. + */ + @BetaApi + public static Expression sqrt(Expression numericExpr) { + return new FunctionExpression("sqrt", ImmutableList.of(numericExpr)); + } + + /** + * Creates an expression that returns the square root of {@code numericField}. + * + * @param numericField Name of field that returns number when evaluated. + * @return A new {@link Expression} representing the numeric result of the square root operation. + */ + @BetaApi + public static Expression sqrt(String numericField) { + return sqrt(field(numericField)); + } + + // Logical/Comparison Operations + /** + * Creates an expression that checks if the results of {@code expr} is NOT 'NaN' (Not a Number). + * + * @param expr The expression to check. + * @return A new {@link BooleanExpression} representing the isNotNan operation. + */ + @BetaApi + public static BooleanExpression isNotNaN(Expression expr) { + return new BooleanFunctionExpression("is_not_nan", expr); + } + + /** + * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a + * Number). + * + * @param fieldName The field to check. + * @return A new {@link BooleanExpression} representing the isNotNan operation. + */ + @BetaApi + public static BooleanExpression isNotNaN(String fieldName) { + return isNotNaN(field(fieldName)); + } + + /** + * Creates an expression that returns the largest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param expr The first operand expression. + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical maximum operation. + */ + @BetaApi + public static Expression logicalMaximum(Expression expr, Object... others) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(expr); + builder.addAll(toArrayOfExprOrConstant(others)); + return new FunctionExpression("maximum", builder.build()); + } + + /** + * Creates an expression that returns the largest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param fieldName The first operand field name. + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical maximum operation. + */ + @BetaApi + public static Expression logicalMaximum(String fieldName, Object... others) { + return logicalMaximum(field(fieldName), others); + } + + /** + * Creates an expression that returns the smallest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param expr The first operand expression. + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical minimum operation. + */ + @BetaApi + public static Expression logicalMinimum(Expression expr, Object... others) { + ImmutableList.Builder builder = ImmutableList.builder(); + builder.add(expr); + builder.addAll(toArrayOfExprOrConstant(others)); + return new FunctionExpression("minimum", builder.build()); + } + + /** + * Creates an expression that returns the smallest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param fieldName The first operand field name. + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical minimum operation. + */ + @BetaApi + public static Expression logicalMinimum(String fieldName, Object... others) { + return logicalMinimum(field(fieldName), others); + } + + /** + * Creates an expression that concatenates this expression with other values. + * + * @param others Optional additional expressions or constants to concatenate. + * @return A new {@link Expression} representing the concatenated value. + */ + @BetaApi + public Expression concat(Object... others) { + return Expression.concat(this, others); + } + + /** + * Creates an expression that returns a default value if this expression evaluates to an absent + * value. + * + * @param elseValue The default value. + * @return A new {@link Expression} representing the ifAbsent operation. + */ + @BetaApi + public Expression ifAbsent(Object elseValue) { + return Expression.ifAbsent(this, elseValue); + } + + /** + * Creates an expression that joins the elements of this array expression into a string. + * + * @param delimiter The delimiter to use. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public Expression join(String delimiter) { + return Expression.join(this, delimiter); + } + + /** + * Creates an expression that joins the elements of this array expression into a string. + * + * @param delimiter The delimiter to use. + * @return A new {@link Expression} representing the join operation. + */ + @BetaApi + public Expression join(Expression delimiter) { + return Expression.join(this, delimiter); + } + + /** + * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a + * Number). + * + * @return A new {@link BooleanExpression} representing the isNotNan operation. + */ + @BetaApi + public final BooleanExpression isNotNaN() { + return isNotNaN(this); + } + + /** + * Creates an expression that returns the largest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical maximum operation. + */ + @BetaApi + public final Expression logicalMaximum(Object... others) { + return logicalMaximum(this, others); + } + + /** + * Creates an expression that returns the smallest value between multiple input expressions or + * literal values. Based on Firestore's value type ordering. + * + * @param others Optional additional expressions or literals. + * @return A new {@link Expression} representing the logical minimum operation. + */ + @BetaApi + public final Expression logicalMinimum(Object... others) { + return logicalMinimum(this, others); + } + + /** + * Creates an expression that rounds this numeric expression to nearest integer. + * + *

Rounds away from zero in halfway cases. + * + * @return A new {@link Expression} representing an integer result from the round operation. + */ + @BetaApi + public final Expression round() { + return round(this); + } + + /** + * Creates an expression that rounds off this numeric expression to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public final Expression roundToPrecision(int decimalPlace) { + return roundToPrecision(this, decimalPlace); + } + + /** + * Creates an expression that rounds off this numeric expression to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, rounds off digits to the left of the decimal point + * if {@code decimalPlace} is negative. Rounds away from zero in halfway cases. + * + * @param decimalPlace The number of decimal places to round. + * @return A new {@link Expression} representing the round operation. + */ + @BetaApi + public final Expression roundToPrecision(Expression decimalPlace) { + return roundToPrecision(this, decimalPlace); + } + + /** + * Creates an expression that truncates this numeric expression to an integer. + * + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public final Expression trunc() { + return trunc(this); + } + + /** + * Creates an expression that truncates this numeric expression to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, truncates digits to the left of the decimal point + * if {@code decimalPlace} is negative. + * + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public final Expression truncToPrecision(int decimalPlace) { + return truncToPrecision(this, decimalPlace); + } + + /** + * Creates an expression that truncates this numeric expression to {@code decimalPlace} decimal + * places if {@code decimalPlace} is positive, truncates digits to the left of the decimal point + * if {@code decimalPlace} is negative. + * + * @param decimalPlace The number of decimal places to truncate. + * @return A new {@link Expression} representing the trunc operation. + */ + @BetaApi + public final Expression truncToPrecision(Expression decimalPlace) { + return truncToPrecision(this, decimalPlace); + } + + /** + * Creates an expression that returns the smallest integer that isn't less than this numeric + * expression. + * + * @return A new {@link Expression} representing an integer result from the ceil operation. + */ + @BetaApi + public final Expression ceil() { + return ceil(this); + } + + /** + * Creates an expression that returns the largest integer that isn't less than this numeric + * expression. + * + * @return A new {@link Expression} representing an integer result from the floor operation. + */ + @BetaApi + public final Expression floor() { + return floor(this); + } + + /** + * Creates an expression that returns this numeric expression raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param exponent The numeric power to raise this numeric expression. + * @return A new {@link Expression} representing a numeric result from raising this numeric + * expression to the power of {@code exponent}. + */ + @BetaApi + public final Expression pow(Number exponent) { + return pow(this, exponent); + } + + /** + * Creates an expression that returns this numeric expression raised to the power of the {@code + * exponent}. Returns infinity on overflow and zero on underflow. + * + * @param exponent The numeric power to raise this numeric expression. + * @return A new {@link Expression} representing a numeric result from raising this numeric + * expression to the power of {@code exponent}. + */ + @BetaApi + public final Expression pow(Expression exponent) { + return pow(this, exponent); + } + + /** + * Creates an expression that returns the absolute value of this numeric expression. + * + * @return A new {@link Expression} representing the numeric result of the absolute value + * operation. + */ + @BetaApi + public final Expression abs() { + return abs(this); + } + + /** + * Creates an expression that returns Euler's number e raised to the power of this numeric + * expression. + * + * @return A new {@link Expression} representing the numeric result of the exponentiation. + */ + @BetaApi + public final Expression exp() { + return exp(this); + } + + /** + * Creates an expression that returns the natural logarithm (base e) of this numeric expression. + * + * @return A new {@link Expression} representing the numeric result of the natural logarithm. + */ + @BetaApi + public final Expression ln() { + return ln(this); + } + + /** + * Creates an expression that returns the base 10 logarithm of this numeric expression. + * + * @return A new {@link Expression} representing the numeric result of the base 10 logarithm. + */ + @BetaApi + public Expression log10() { + return Expression.log10(this); + } + + /** + * Creates an expression that returns the sum of the elements of this array expression. + * + * @return A new {@link Expression} representing the sum of the elements of the array. + */ + @BetaApi + public Expression arraySum() { + return Expression.arraySum(this); + } + + /** + * Creates an expression that returns the square root of this numeric expression. + * + * @return A new {@link Expression} representing the numeric result of the square root operation. + */ + @BetaApi + public final Expression sqrt() { + return sqrt(this); + } + + // Fluent API + /** + * Creates an expression that adds this numeric expression to another numeric expression. + * + * @param other Numeric expression to add. + * @return A new {@link Expression} representing the addition operation. + */ + @BetaApi + public final Expression add(Object other) { + return add(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that subtracts a numeric expressions from this numeric expression. + * + * @param other Constant to subtract. + * @return A new {@link Expression} representing the subtract operation. + */ + @BetaApi + public final Expression subtract(Object other) { + return subtract(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that multiplies this numeric expression with another numeric expression. + * + * @param other Numeric expression to multiply. + * @return A new {@link Expression} representing the multiplication operation. + */ + @BetaApi + public final Expression multiply(Object other) { + return multiply(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that divides this numeric expression by another numeric expression. + * + * @param other Numeric expression to divide this numeric expression by. + * @return A new {@link Expression} representing the division operation. + */ + @BetaApi + public final Expression divide(Object other) { + return divide(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that calculates the modulo (remainder) of dividing this numeric + * expressions by another numeric expression. + * + * @param other The numeric expression to divide this expression by. + * @return A new {@link Expression} representing the modulo operation. + */ + @BetaApi + public final Expression mod(Object other) { + return mod(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is equal to a {@code value}. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the equality comparison. + */ + @BetaApi + public final BooleanExpression equal(Object other) { + return equal(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is not equal to a {@code value}. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the inequality comparison. + */ + @BetaApi + public final BooleanExpression notEqual(Object other) { + return notEqual(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is greater than a {@code value}. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the greater than comparison. + */ + @BetaApi + public final BooleanExpression greaterThan(Object other) { + return greaterThan(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is greater than or equal to a {@code + * value}. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the greater than or equal to comparison. + */ + @BetaApi + public final BooleanExpression greaterThanOrEqual(Object other) { + return greaterThanOrEqual(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is less than a value. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the less than comparison. + */ + @BetaApi + public final BooleanExpression lessThan(Object other) { + return lessThan(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression is less than or equal to a {@code value}. + * + * @param other The value to compare to. + * @return A new {@link BooleanExpression} representing the less than or equal to comparison. + */ + @BetaApi + public final BooleanExpression lessThanOrEqual(Object other) { + return lessThanOrEqual(this, toExprOrConstant(other)); + } + + /** + * Creates an expression that checks if this expression, when evaluated, is equal to any of the + * provided {@code values}. + * + * @param other The values to check against. + * @return A new {@link BooleanExpression} representing the 'IN' comparison. + */ + @BetaApi + public final BooleanExpression equalAny(List other) { + return equalAny(this, other); + } + + /** + * Creates an expression that checks if this expression, when evaluated, is not equal to all the + * provided {@code values}. + * + * @param other The values to check against. + * @return A new {@link BooleanExpression} representing the 'NOT IN' comparison. + */ + @BetaApi + public final BooleanExpression notEqualAny(List other) { + return notEqualAny(this, other); + } + + /** + * Creates an expression that calculates the character length of this string expression in UTF8. + * + * @return A new {@link Expression} representing the charLength operation. + */ + @BetaApi + public final Expression charLength() { + return charLength(this); + } + + /** + * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length + * of a Blob. + * + * @return A new {@link Expression} representing the length of the string in bytes. + */ + @BetaApi + public final Expression byteLength() { + return byteLength(this); + } + + /** + * Creates an expression that calculates the length of the expression if it is a string, array, + * map, or Blob. + * + * @return A new {@link Expression} representing the length of the expression. + */ + @BetaApi + public final Expression length() { + return length(this); + } + + /** + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new {@link BooleanExpression} representing the like operation. + */ + @BetaApi + public final BooleanExpression like(Object pattern) { + return like(this, toExprOrConstant(pattern)); + } + + /** + * Creates an expression that checks if this string expression contains a specified regular + * expression as a substring. + * + * @param pattern The regular expression to use for the search. + * @return A new {@link BooleanExpression} representing the contains regular expression + * comparison. + */ + @BetaApi + public final BooleanExpression regexContains(Object pattern) { + return regexContains(this, toExprOrConstant(pattern)); + } + + /** + * Creates an expression that returns the first substring of a string expression that matches a + * specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param pattern The regular expression to search for. + * @return A new {@link Expression} representing the regular expression find function. + */ + @BetaApi + public final Expression regexFind(Object pattern) { + return regexFind(this, toExprOrConstant(pattern)); + } + + /** + * Creates an expression that evaluates to a list of all substrings in a string expression that + * match a specified regular expression. + * + *

This expression uses the [RE2](https://github.com/google/re2/wiki/Syntax) regular expression + * syntax. + * + * @param pattern The regular expression to search for. + * @return A new {@link Expression} that evaluates to a list of matched substrings. + */ + @BetaApi + public final Expression regexFindAll(Object pattern) { + return regexFindAll(this, toExprOrConstant(pattern)); + } + + /** + * Creates an expression that checks if this string expression matches a specified regular + * expression. + * + * @param pattern The regular expression to use for the match. + * @return A new {@link BooleanExpression} representing the regular expression match comparison. + */ + @BetaApi + public final BooleanExpression regexMatch(Object pattern) { + return regexMatch(this, toExprOrConstant(pattern)); + } + + /** + * Creates an expression that checks if this string expression contains a specified substring. + * + * @param substring The expression representing the substring to search for. + * @return A new {@link BooleanExpression} representing the contains comparison. + */ + @BetaApi + public final BooleanExpression stringContains(Object substring) { + return stringContains(this, toExprOrConstant(substring)); + } + + /** + * Creates an expression that checks if this string expression starts with a given {@code prefix}. + * + * @param prefix The prefix string expression to check for. + * @return A new {@link Expression} representing the the 'starts with' comparison. + */ + @BetaApi + public final BooleanExpression startsWith(Object prefix) { + return startsWith(this, toExprOrConstant(prefix)); + } + + /** + * Creates an expression that checks if this string expression ends with a given {@code suffix}. + * + * @param suffix The suffix string expression to check for. + * @return A new {@link Expression} representing the 'ends with' comparison. + */ + @BetaApi + public final BooleanExpression endsWith(Object suffix) { + return endsWith(this, toExprOrConstant(suffix)); + } + + /** + * Creates an expression that returns a substring of the given string. + * + * @param index The starting index of the substring. + * @param length The length of the substring. + * @return A new {@link Expression} representing the substring. + */ + @BetaApi + public final Expression substring(Object index, Object length) { + return substring(this, toExprOrConstant(index), toExprOrConstant(length)); + } + + /** + * Creates an expression that converts this string expression to lowercase. + * + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public final Expression toLower() { + return toLower(this); + } + + /** + * Creates an expression that converts this string expression to uppercase. + * + * @return A new {@link Expression} representing the lowercase string. + */ + @BetaApi + public final Expression toUpper() { + return toUpper(this); + } + + /** + * Creates an expression that removes leading and trailing whitespace from this string expression. + * + * @return A new {@link Expression} representing the trimmed string. + */ + @BetaApi + public final Expression trim() { + return trim(this); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of this + * string or blob expression. + * + * @param characters The characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public Expression trimValue(String characters) { + return trimValue(this, characters); + } + + /** + * Creates an expression that removes specified characters from the beginning and end of this + * string or blob expression. + * + * @param characters The expression representing the characters to remove. + * @return A new {@link Expression} representing the trimmed string or blob. + */ + @BetaApi + public Expression trimValue(Expression characters) { + return trimValue(this, characters); + } + + /** + * Creates an expression that splits this string or blob expression by a delimiter. + * + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public Expression split(Expression delimiter) { + return split(this, delimiter); + } + + /** + * Creates an expression that splits this string or blob expression by a delimiter. + * + * @param delimiter The delimiter to split by. + * @return A new {@link Expression} representing the split string or blob as an array. + */ + @BetaApi + public Expression split(String delimiter) { + return split(this, delimiter); + } + + /** + * Creates an expression that concatenates string expressions and string constants together. + * + * @param others The string expressions or string constants to concatenate. + * @return A new {@link Expression} representing the concatenated string. + */ + @BetaApi + public final Expression stringConcat(String... others) { + return stringConcat(this, others); + } + + /** + * Creates an expression that concatenates string expressions together. + * + * @param others The string expressions or string constants to concatenate. + * @return A new {@link Expression} representing the concatenated string. + */ + @BetaApi + public final Expression stringConcat(Expression... others) { + return stringConcat(this, others); + } + + /** + * Accesses a map (object) value using the provided {@code key}. + * + * @param key The key to access in the map. + * @return A new {@link Expression} representing the value associated with the given key in the + * map. + */ + @BetaApi + public final Expression mapGet(Object key) { + return mapGet(this, toExprOrConstant(key)); + } + + /** + * Creates an expression that returns true if yhe result of this expression is absent. Otherwise, + * returns false even if the value is null. + * + * @return A new {@link BooleanExpression} representing the isAbsent operation. + */ + @BetaApi + public final BooleanExpression isAbsent() { + return isAbsent(this); + } + + /** + * Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). + * + * @return A new {@link BooleanExpression} representing the isNan operation. + */ + @BetaApi + public final BooleanExpression isNaN() { + return isNaN(this); + } + + /** + * Creates an expression that checks if tbe result of this expression is null. + * + * @return A new {@link BooleanExpression} representing the isNull operation. + */ + @BetaApi + public final BooleanExpression isNull() { + return isNull(this); + } + + /** + * Creates an expression that checks if tbe result of this expression is not null. + * + * @return A new {@link BooleanExpression} representing the isNotNull operation. + */ + @BetaApi + public final BooleanExpression isNotNull() { + return isNotNull(this); + } + + /** + * Creates an aggregation that calculates the sum of this numeric expression across multiple stage + * inputs. + * + * @return A new {@link AggregateFunction} representing the sum aggregation. + */ + @BetaApi + public final AggregateFunction sum() { + return AggregateFunction.sum(this); + } + + /** + * Creates an aggregation that calculates the average (mean) of this numeric expression across + * multiple stage inputs. + * + * @return A new {@link AggregateFunction} representing the average aggregation. + */ + @BetaApi + public final AggregateFunction average() { + return AggregateFunction.average(this); + } + + /** + * Creates an aggregation that finds the minimum value of this expression across multiple stage + * inputs. + * + * @return A new {@link AggregateFunction} representing the minimum aggregation. + */ + @BetaApi + public final AggregateFunction minimum() { + return AggregateFunction.minimum(this); + } + + /** + * Creates an aggregation that finds the maximum value of this expression across multiple stage + * inputs. + * + * @return A new {@link AggregateFunction} representing the maximum aggregation. + */ + @BetaApi + public final AggregateFunction maximum() { + return AggregateFunction.maximum(this); + } + + /** + * Creates an aggregation that counts the number of stage inputs with valid evaluations of the + * this expression. + * + * @return A new {@link AggregateFunction} representing the count aggregation. + */ + @BetaApi + public final AggregateFunction count() { + return AggregateFunction.count(this); + } + + /** + * Creates an aggregation that counts the number of distinct values of this expression. + * + * @return A new {@link AggregateFunction} representing the count distinct aggregation. + */ + @BetaApi + public final AggregateFunction countDistinct() { + return AggregateFunction.countDistinct(this); + } + + /** + * Creates an aggregation that finds the first value of this expression across multiple stage + * inputs. + * + * @return A new {@link AggregateFunction} representing the first aggregation. + */ + @BetaApi + public final AggregateFunction first() { + return AggregateFunction.first(this); + } + + /** + * Creates an aggregation that finds the last value of this expression across multiple stage + * inputs. + * + * @return A new {@link AggregateFunction} representing the last aggregation. + */ + @BetaApi + public final AggregateFunction last() { + return AggregateFunction.last(this); + } + + /** + * Creates an aggregation that collects all values of this expression across multiple stage inputs + * into an array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @return A new {@link AggregateFunction} representing the array_agg aggregation. + */ + @BetaApi + public final AggregateFunction arrayAgg() { + return AggregateFunction.arrayAgg(this); + } + + /** + * Creates an aggregation that collects all distinct values of this expression across multiple + * stage inputs into an array. + * + *

If the expression resolves to an absent value, it is converted to `null`. The order of + * elements in the output array is not stable and shouldn't be relied upon. + * + * @return A new {@link AggregateFunction} representing the array_agg_distinct aggregation. + */ + @BetaApi + public final AggregateFunction arrayAggDistinct() { + return AggregateFunction.arrayAggDistinct(this); + } + + /** + * Create an {@link Ordering} that sorts documents in ascending order based on value of this + * expression + * + * @return A new {@link Ordering} object with ascending sort by this expression. + */ + @BetaApi + public final Ordering ascending() { + return Ordering.ascending(this); + } + + /** + * Create an {@link Ordering} that sorts documents in descending order based on value of this + * expression + * + * @return A new {@link Ordering} object with descending sort by this expression. + */ + @BetaApi + public final Ordering descending() { + return Ordering.descending(this); + } + + /** + * Assigns an alias to this expression. + * + *

Aliases are useful for renaming fields in the output of a stage or for giving meaningful + * names to calculated values. + * + * @param alias The alias to assign to this expression. + * @return A new {@link AliasedExpression} that wraps this expression and associates it with the + * provided alias. + */ + @BetaApi + public AliasedExpression as(String alias) { + return new AliasedExpression(this, alias); + } + + // Fluent API for new functions + /** + * Creates an expression that merges multiple maps into a single map. If multiple maps have the + * same key, the later value is used. + * + * @param secondMap Map expression that will be merged. + * @param otherMaps Additional maps to merge. + * @return A new {@link Expression} representing the mapMerge operation. + */ + @BetaApi + public final Expression mapMerge(Expression secondMap, Expression... otherMaps) { + return mapMerge(this, secondMap, otherMaps); + } + + /** + * Creates an expression that removes a key from this map expression. + * + * @param key The name of the key to remove from this map expression. + * @return A new {@link Expression} that evaluates to a modified map. + */ + @BetaApi + public final Expression mapRemove(Expression key) { + return mapRemove(this, key); + } + + /** + * Creates an expression that removes a key from this map expression. + * + * @param key The name of the key to remove from this map expression. + * @return A new {@link Expression} that evaluates to a modified map. + */ + @BetaApi + public final Expression mapRemove(String key) { + return mapRemove(this, key); + } + + /** + * Creates an expression that reverses this expression, which must be a string, blob, or array. + * + * @return A new {@link Expression} representing the reversed value. + */ + @BetaApi + public final Expression reverse() { + return reverse(this); + } + + /** + * Creates an expression that concatenates a field's array value with other arrays. + * + * @param otherArrays Optional additional array expressions or array literals to concatenate. + * @return A new {@link Expression} representing the arrayConcat operation. + */ + @BetaApi + public final Expression arrayConcat(Expression... otherArrays) { + return arrayConcat(this, otherArrays); + } + + /** + * Returns the first element of an array. + * + * @return A new {@link Expression} representing the first element of the array. + */ + @BetaApi + public final Expression arrayFirst() { + return arrayFirst(this); + } + + /** + * Returns the first n elements of an array. + * + * @param n The number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public final Expression arrayFirstN(int n) { + return arrayFirstN(this, n); + } + + /** + * Returns the first n elements of an array. + * + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the first n elements of the array. + */ + @BetaApi + public final Expression arrayFirstN(Expression n) { + return arrayFirstN(this, n); + } + + /** + * Returns the last element of an array. + * + * @return A new {@link Expression} representing the last element of the array. + */ + @BetaApi + public final Expression arrayLast() { + return arrayLast(this); + } + + /** + * Returns the last n elements of an array. + * + * @param n The number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public final Expression arrayLastN(int n) { + return arrayLastN(this, n); + } + + /** + * Returns the last n elements of an array. + * + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the last n elements of the array. + */ + @BetaApi + public final Expression arrayLastN(Expression n) { + return arrayLastN(this, n); + } + + /** + * Returns the minimum value of an array. + * + * @return A new {@link Expression} representing the minimum value of the array. + */ + @BetaApi + public final Expression arrayMinimum() { + return arrayMinimum(this); + } + + /** + * Returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public final Expression arrayMinimumN(int n) { + return arrayMinimumN(this, n); + } + + /** + * Returns the n minimum values of an array. + * + *

Note: Returns the n smallest non-null elements in the array, in ascending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n minimum values of the array. + */ + @BetaApi + public final Expression arrayMinimumN(Expression n) { + return arrayMinimumN(this, n); + } + + /** + * Returns the maximum value of an array. + * + * @return A new {@link Expression} representing the maximum value of the array. + */ + @BetaApi + public final Expression arrayMaximum() { + return arrayMaximum(this); + } + + /** + * Returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param n The number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public final Expression arrayMaximumN(int n) { + return arrayMaximumN(this, n); + } + + /** + * Returns the n maximum values of an array. + * + *

Note: Returns the n largest non-null elements in the array, in descending order. This does + * not use a stable sort, meaning the order of equivalent elements is undefined. + * + * @param n The Expression evaluates to the number of elements to return. + * @return A new {@link Expression} representing the n maximum values of the array. + */ + @BetaApi + public final Expression arrayMaximumN(Expression n) { + return arrayMaximumN(this, n); + } + + /** + * Returns the index of the first occurrence of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public final Expression arrayIndexOf(Object value) { + return arrayIndexOf(this, value); + } + + /** + * Returns the index of the first occurrence of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the index. + */ + @BetaApi + public final Expression arrayIndexOf(Expression value) { + return arrayIndexOf(this, value); + } + + /** + * Returns the index of the last occurrence of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public final Expression arrayLastIndexOf(Object value) { + return arrayLastIndexOf(this, value); + } + + /** + * Returns the index of the last occurrence of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the last index. + */ + @BetaApi + public final Expression arrayLastIndexOf(Expression value) { + return arrayLastIndexOf(this, value); + } + + /** + * Returns all indices of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public final Expression arrayIndexOfAll(Object value) { + return arrayIndexOfAll(this, value); + } + + /** + * Returns all indices of a value in an array. + * + * @param value The value to search for. + * @return A new {@link Expression} representing the indices. + */ + @BetaApi + public final Expression arrayIndexOfAll(Expression value) { + return arrayIndexOfAll(this, value); + } + + /** + * Reverses the order of elements in the array. + * + * @return A new {@link Expression} representing the arrayReverse operation. + */ + @BetaApi + public final Expression arrayReverse() { + return arrayReverse(this); + } + + /** + * Creates an expression that checks if array contains a specific {@code element}. + * + * @param element The element to search for in the array. + * @return A new {@link BooleanExpression} representing the arrayContains operation. + */ + @BetaApi + public final BooleanExpression arrayContains(Object element) { + return arrayContains(this, element); + } + + /** + * Creates an expression that checks if array contains all the specified {@code values}. + * + * @param values The elements to check for in the array. + * @return A new {@link BooleanExpression} representing the arrayContainsAll operation. + */ + @BetaApi + public final BooleanExpression arrayContainsAll(List values) { + return arrayContainsAll(this, values); + } + + /** + * Creates an expression that checks if array contains all elements of {@code arrayExpression}. + * + * @param arrayExpression The elements to check for in the array. + * @return A new {@link BooleanExpression} representing the arrayContainsAll operation. + */ + @BetaApi + public final BooleanExpression arrayContainsAll(Expression arrayExpression) { + return arrayContainsAll(this, arrayExpression); + } + + /** + * Creates an expression that checks if array contains any of the specified {@code values}. + * + * @param values The elements to check for in the array. + * @return A new {@link BooleanExpression} representing the arrayContainsAny operation. + */ + @BetaApi + public final BooleanExpression arrayContainsAny(List values) { + return arrayContainsAny(this, values); + } + + /** + * Creates an expression that checks if array contains any elements of {@code arrayExpression}. + * + * @param arrayExpression The elements to check for in the array. + * @return A new {@link BooleanExpression} representing the arrayContainsAny operation. + */ + @BetaApi + public final BooleanExpression arrayContainsAny(Expression arrayExpression) { + return arrayContainsAny(this, arrayExpression); + } + + /** + * Creates an expression that calculates the length of an array expression. + * + * @return A new {@link Expression} representing the length of the array. + */ + @BetaApi + public final Expression arrayLength() { + return arrayLength(this); + } + + /** + * Creates an expression that indexes into an array from the beginning or end and return the + * element. If the offset exceeds the array length, an error is returned. A negative offset, + * starts from the end. + * + * @param offset An Expression evaluating to the index of the element to return. + * @return A new {@link Expression} representing the arrayGet operation. + */ + @BetaApi + public final Expression arrayGet(Expression offset) { + return arrayGet(this, offset); + } + + /** + * Creates an expression that indexes into an array from the beginning or end and return the + * element. If the offset exceeds the array length, an error is returned. A negative offset, + * starts from the end. + * + * @param offset An Expression evaluating to the index of the element to return. + * @return A new {@link Expression} representing the arrayOffset operation. + */ + @BetaApi + public final Expression arrayGet(int offset) { + return arrayGet(this, offset); + } + + /** + * Calculates the Cosine distance between this and another vector expressions. + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new {@link Expression} representing the cosine distance between the two vectors. + */ + @BetaApi + public final Expression cosineDistance(Expression vector) { + return cosineDistance(this, vector); + } + + /** + * Calculates the Cosine distance between this vector expression and a vector literal. + * + * @param vector The other vector (as an array of doubles) to compare against. + * @return A new {@link Expression} representing the cosine distance between the two vectors. + */ + @BetaApi + public final Expression cosineDistance(double[] vector) { + return cosineDistance(this, vector); + } + + /** + * Calculates the dot product distance between this and another vector expression. + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new {@link Expression} representing the dot product distance between the two vectors. + */ + @BetaApi + public final Expression dotProduct(Expression vector) { + return dotProduct(this, vector); + } + + /** + * Calculates the dot product distance between this vector expression and a vector literal. + * + * @param vector The other vector (as an array of doubles) to compare against. + * @return A new {@link Expression} representing the dot product distance between the two vectors. + */ + @BetaApi + public final Expression dotProduct(double[] vector) { + return dotProduct(this, vector); + } + + /** + * Calculates the Euclidean distance between this and another vector expression. + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new {@link Expression} representing the Euclidean distance between the two vectors. + */ + @BetaApi + public final Expression euclideanDistance(Expression vector) { + return euclideanDistance(this, vector); + } + + /** + * Calculates the Euclidean distance between this vector expression and a vector literal. + * + * @param vector The other vector (as an array of doubles) to compare against. + * @return A new {@link Expression} representing the Euclidean distance between the two vectors. + */ + @BetaApi + public final Expression euclideanDistance(double[] vector) { + return euclideanDistance(this, vector); + } + + /** + * Creates an expression that calculates the length (dimension) of a Firestore Vector. + * + * @return A new {@link Expression} representing the length (dimension) of the vector. + */ + @BetaApi + public final Expression vectorLength() { + return vectorLength(this); + } + + /** + * Creates an expression that interprets this expression as the number of microseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public final Expression unixMicrosToTimestamp() { + return unixMicrosToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of microseconds + * since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * @return A new {@link Expression} representing the number of microseconds since epoch. + */ + @BetaApi + public final Expression timestampToUnixMicros() { + return timestampToUnixMicros(this); + } + + /** + * Creates an expression that interprets this expression as the number of milliseconds since the + * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public final Expression unixMillisToTimestamp() { + return unixMillisToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of milliseconds + * since the Unix epoch (1970-01-01 00:00:00 UTC). + * + * @return A new {@link Expression} representing the number of milliseconds since epoch. + */ + @BetaApi + public final Expression timestampToUnixMillis() { + return timestampToUnixMillis(this); + } + + /** + * Creates an expression that interprets this expression as the number of seconds since the Unix + * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. + * + * @return A new {@link Expression} representing the timestamp. + */ + @BetaApi + public final Expression unixSecondsToTimestamp() { + return unixSecondsToTimestamp(this); + } + + /** + * Creates an expression that converts this timestamp expression to the number of seconds since + * the Unix epoch (1970-01-01 00:00:00 UTC). + * + * @return A new {@link Expression} representing the number of seconds since epoch. + */ + @BetaApi + public final Expression timestampToUnixSeconds() { + return timestampToUnixSeconds(this); + } + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * @param unit The expression representing the unit of time to add. Valid units include + * "microsecond", "millisecond", "second", "minute", "hour" and "day". + * @param amount The expression representing the amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public final Expression timestampAdd(Expression unit, Expression amount) { + return timestampAdd(this, unit, amount); + } + + /** + * Creates an expression that adds a specified amount of time to this timestamp expression. + * + * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to add. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public final Expression timestampAdd(String unit, long amount) { + return timestampAdd(this, unit, amount); + } + + /** + * Creates an expression that subtracts a specified amount of time to this timestamp expression. + * + * @param unit The expression representing the unit of time to subtract. Valid units include + * "microsecond", "millisecond", "second", "minute", "hour" and "day". + * @param amount The expression representing the amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public final Expression timestampSubtract(Expression unit, Expression amount) { + return timestampSubtract(this, unit, amount); + } + + /** + * Creates an expression that subtracts a specified amount of time to this timestamp expression. + * + * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", + * "second", "minute", "hour" and "day". + * @param amount The amount of time to subtract. + * @return A new {@link Expression} representing the resulting timestamp. + */ + @BetaApi + public final Expression timestampSubtract(String unit, long amount) { + return timestampSubtract(this, unit, amount); + } + + /** + * Creates an expression that truncates this timestamp expression to a specified granularity. + * + * @param granularity The granularity to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public final Expression timestampTruncate(String granularity) { + return timestampTruncate(this, granularity); + } + + /** + * Creates an expression that truncates this timestamp expression to a specified granularity. + * + * @param granularity The granularity expression to truncate to. Valid values are "microsecond", + * "millisecond", "second", "minute", "hour", "day", "week", "week(monday)", "week(tuesday)", + * "week(wednesday)", "week(thursday)", "week(friday)", "week(saturday)", "week(sunday)", + * "isoweek", "month", "quarter", "year", and "isoyear". + * @return A new {@link Expression} representing the truncated timestamp. + */ + @BetaApi + public final Expression timestampTruncate(Expression granularity) { + return timestampTruncate(this, granularity); + } + + /** + * Creates an expression that checks if this expression evaluates to a name of the field that + * exists. + * + * @return A new {@link Expression} representing the exists check. + */ + @BetaApi + public final BooleanExpression exists() { + return exists(this); + } + + /** + * Creates an expression that returns the {@code catchExpr} argument if there is an error, else + * return the result of this expression. + * + * @param catchExpr The catch expression that will be evaluated and returned if the this + * expression produces an error. + * @return A new {@link Expression} representing the ifError operation. + */ + @BetaApi + public final Expression ifError(Expression catchExpr) { + return ifError(this, catchExpr); + } + + /** + * Creates an expression that returns the {@code catchValue} argument if there is an error, else + * return the result of this expression. + * + * @param catchValue The value that will be returned if this expression produces an error. + * @return A new {@link Expression} representing the ifError operation. + */ + @BetaApi + public final Expression ifError(Object catchValue) { + return ifError(this, catchValue); + } + + /** + * Creates an expression that checks if this expression produces an error. + * + * @return A new {@link BooleanExpression} representing the `isError` check. + */ + @BetaApi + public final BooleanExpression isError() { + return isError(this); + } + + /** + * Creates an expression that returns the document ID from this path expression. + * + * @return A new {@link Expression} representing the documentId operation. + */ + @BetaApi + public final Expression documentId() { + return documentId(this); + } + + /** + * Creates an expression that returns the collection ID from this path expression. + * + * @return A new {@link Expression} representing the collectionId operation. + */ + @BetaApi + public final Expression collectionId() { + return collectionId(this); + } + + /** + * Creates an expression that returns a string indicating the type of the value this expression + * evaluates to. + * + * @return A new {@link Expression} representing the type operation. + */ + @BetaApi + public final Expression type() { + return type(this); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Field.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Field.java new file mode 100644 index 000000000000..0b5729040f37 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Field.java @@ -0,0 +1,114 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.Pipeline; +import com.google.common.base.Objects; +import com.google.firestore.v1.Value; +import javax.annotation.Nullable; + +/** + * Represents a reference to a field in a Firestore document. + * + *

Field references are used to access document field values in expressions and to specify fields + * for sorting, filtering, and projecting data in Firestore pipelines. + * + *

You can create a `Field` instance using the static {@link #field(String)} method: + * + *

{@code
+ * // Create a Field instance for the 'name' field
+ * Field nameField = Field.of("name");
+ *
+ * // Create a Field instance for a nested field 'address.city'
+ * Field cityField = Field.of("address.city");
+ * }
+ */ +@BetaApi +public final class Field extends Expression implements Selectable { + public static final String DOCUMENT_ID = "__name__"; + private final FieldPath path; + @Nullable private Pipeline pipeline; // Nullable + + private Field(FieldPath path) { + this.path = path; + } + + /** + * Creates a {@code Field} instance representing the field at the given path. + * + *

The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field + * (e.g., "address.city"). + * + *

Example: + * + *

{@code
+   * // Create a Field instance for the 'title' field
+   * Field titleField = Field.of("title");
+   *
+   * // Create a Field instance for a nested field 'author.firstName'
+   * Field authorFirstNameField = Field.of("author.firstName");
+   * }
+ * + * @param path The path to the field. + * @return A new {@code Field} instance representing the specified field. + */ + @InternalApi + public static Field ofUserPath(String path) { + if (path.equals(DOCUMENT_ID)) { + return new Field(FieldPath.documentId()); + } + return new Field(FieldPath.fromDotSeparatedString(path)); + } + + @InternalApi + public static Field ofServerPath(String path) { + if (path.equals(DOCUMENT_ID)) { + return new Field(FieldPath.documentId()); + } + return new Field(FieldPath.fromServerFormat(path)); + } + + @InternalApi + public Value toProto() { + return Value.newBuilder().setFieldReferenceValue(path.toString()).build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Field field = (Field) o; + return Objects.equal(path, field.path) && Objects.equal(pipeline, field.pipeline); + } + + @Override + public int hashCode() { + return Objects.hashCode(path, pipeline); + } + + @InternalApi + public FieldPath getPath() { + return path; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionExpression.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionExpression.java new file mode 100644 index 000000000000..eacbf953e34e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionExpression.java @@ -0,0 +1,63 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.common.base.Objects; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +@BetaApi +public class FunctionExpression extends Expression { + private final String name; + private final List params; + + FunctionExpression(String name, List params) { + this.name = name; + this.params = Collections.unmodifiableList(params); + } + + @InternalApi + @Override + Value toProto() { + return Value.newBuilder() + .setFunctionValue( + com.google.firestore.v1.Function.newBuilder() + .setName(this.name) + .addAllArgs( + this.params.stream() + .map(FunctionUtils::exprToValue) + .collect(Collectors.toList()))) + .build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + FunctionExpression that = (FunctionExpression) o; + return Objects.equal(name, that.name) && Objects.equal(params, that.params); + } + + @Override + public int hashCode() { + return Objects.hashCode(name, params); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionUtils.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionUtils.java new file mode 100644 index 000000000000..85c997902503 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/FunctionUtils.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; + +@InternalApi +public final class FunctionUtils { + @InternalApi + public static Value exprToValue(Expression expr) { + return (expr == null ? Constant.NULL : expr).toProto(); + } + + @InternalApi + public static Value aggregateFunctionToValue(AggregateFunction expr) { + return expr.toProto(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Ordering.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Ordering.java new file mode 100644 index 000000000000..e6f27dfd5a93 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Ordering.java @@ -0,0 +1,79 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import java.util.Locale; + +@BetaApi +public final class Ordering { + + private final Expression expr; + private final Ordering.Direction dir; + + private Ordering(Expression expr, Ordering.Direction dir) { + this.expr = expr; + this.dir = dir; + } + + @BetaApi + public enum Direction { + ASCENDING, + DESCENDING; + + @Override + public String toString() { + return name().toLowerCase(Locale.getDefault()); + } + } + + @InternalApi + public Value toProto() { + return Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields("direction", encodeValue(dir.toString())) + .putFields("expression", expr.toProto()) + .build()) + .build(); + } + + @BetaApi + public static Ordering ascending(Expression expr) { + return new Ordering(expr, Direction.ASCENDING); + } + + @BetaApi + public static Ordering descending(Expression expr) { + return new Ordering(expr, Direction.DESCENDING); + } + + @InternalApi + public Expression getExpr() { + return expr; + } + + @InternalApi + public Ordering.Direction getDir() { + return dir; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Selectable.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Selectable.java new file mode 100644 index 000000000000..cf7bc71c055e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/expressions/Selectable.java @@ -0,0 +1,22 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.expressions; + +import com.google.api.core.BetaApi; + +@BetaApi +public interface Selectable {} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AbstractOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AbstractOptions.java new file mode 100644 index 000000000000..ca1491cd67c0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AbstractOptions.java @@ -0,0 +1,99 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.cloud.firestore.PipelineUtils; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.expressions.FunctionUtils; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.firestore.v1.Value; +import java.util.Arrays; +import java.util.List; + +/** + * Parent class to Pipeline and Stage options. + * + *

Provides a base set of `wither` methods for adding undefined options. + * + *

Standardizes structure of options for uniform encoding and handling. + * + *

Intentionally package-private to prevent extension outside of library. + * + * @param Subclass type. + */ +abstract class AbstractOptions { + + protected final InternalOptions options; + + AbstractOptions(InternalOptions options) { + this.options = options; + } + + abstract T self(InternalOptions options); + + public final T with(String key, String value) { + return with(key, encodeValue(value)); + } + + public final T with(String key, boolean value) { + return with(key, encodeValue(value)); + } + + public final T with(String key, long value) { + return with(key, encodeValue(value)); + } + + public final T with(String key, double value) { + return with(key, encodeValue(value)); + } + + public final T with(String key, Field value) { + return with(key, value.toProto()); + } + + protected final T with(String key, Value value) { + return self(options.with(key, value)); + } + + protected final T with(String key, String[] values) { + return self(options.with(key, Arrays.stream(values).map(PipelineUtils::encodeValue)::iterator)); + } + + protected final T with(String key, List expressions) { + return self(options.with(key, Lists.transform(expressions, FunctionUtils::exprToValue))); + } + + protected final T with(String key, AbstractOptions subSection) { + return self(options.with(key, subSection.options)); + } + + protected final T adding(AbstractOptions subSection) { + return self(options.adding(subSection)); + } + + public final T withSection(String key, RawOptions subSection) { + return with(key, subSection); + } + + final ImmutableMap toMap() { + return options.options; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AddFields.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AddFields.java new file mode 100644 index 000000000000..6488aaee7def --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AddFields.java @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.Map; + +@InternalApi +public final class AddFields extends Stage { + + private final Map fields; + + @InternalApi + public AddFields(Map fields) { + super("add_fields", InternalOptions.EMPTY); + this.fields = fields; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(fields)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Aggregate.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Aggregate.java new file mode 100644 index 000000000000..a4e64c870be5 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Aggregate.java @@ -0,0 +1,90 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.PipelineUtils; +import com.google.cloud.firestore.pipeline.expressions.AggregateFunction; +import com.google.cloud.firestore.pipeline.expressions.AliasedAggregate; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Selectable; +import com.google.firestore.v1.Value; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Nonnull; + +@BetaApi +public final class Aggregate extends Stage { + + private final Map groups; + private final Map accumulators; + + @BetaApi + public Aggregate withGroups(String... fields) { + return new Aggregate( + PipelineUtils.fieldNamesToMap(fields), this.accumulators, new AggregateOptions()); + } + + @BetaApi + public Aggregate withGroups(Selectable... selectables) { + return new Aggregate( + PipelineUtils.selectablesToMap(selectables), this.accumulators, new AggregateOptions()); + } + + @BetaApi + public static Aggregate withAccumulators(AliasedAggregate... accumulators) { + Map accumulatorMap = new HashMap<>(); + for (AliasedAggregate accumulator : accumulators) { + if (accumulatorMap.containsKey(accumulator.getAlias())) { + throw new IllegalArgumentException( + "Duplicate alias or field name: " + accumulator.getAlias()); + } + accumulatorMap.put(accumulator.getAlias(), accumulator.getExpr()); + } + return new Aggregate(Collections.emptyMap(), accumulatorMap, new AggregateOptions()); + } + + @InternalApi + public Aggregate withOptions(@Nonnull AggregateOptions options) { + return new Aggregate(groups, accumulators, options); + } + + private Aggregate( + Map groups, + Map accumulators, + AggregateOptions options) { + super("aggregate", options.options); + if (accumulators.isEmpty()) { + throw new IllegalArgumentException( + "Must specify at least one accumulator for aggregate() stage. There is a distinct() stage" + + " if only distinct group values are needed."); + } + + this.groups = groups; + this.accumulators = accumulators; + } + + @Override + Iterable toStageArgs() { + return Arrays.asList(encodeValue(accumulators), encodeValue(groups)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateHints.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateHints.java new file mode 100644 index 000000000000..c7f553a984c7 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateHints.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class AggregateHints extends AbstractOptions { + + public AggregateHints() { + this(InternalOptions.EMPTY); + } + + AggregateHints(InternalOptions options) { + super(options); + } + + @Override + AggregateHints self(InternalOptions options) { + return new AggregateHints(options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateOptions.java new file mode 100644 index 000000000000..7cb7d7309ee2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/AggregateOptions.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class AggregateOptions extends AbstractOptions { + + public AggregateOptions() { + this(InternalOptions.EMPTY); + } + + AggregateOptions(InternalOptions options) { + super(options); + } + + @Override + AggregateOptions self(InternalOptions options) { + return new AggregateOptions(options); + } + + public AggregateOptions withHints(AggregateHints hints) { + return adding(hints); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Collection.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Collection.java new file mode 100644 index 000000000000..0d049b0ee0c2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Collection.java @@ -0,0 +1,46 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; +import java.util.Collections; +import javax.annotation.Nonnull; + +@InternalApi +public final class Collection extends Stage { + + @Nonnull private final String path; + + public Collection(@Nonnull String path, CollectionOptions options) { + super("collection", options.options); + if (!path.startsWith("/")) { + this.path = "/" + path; + } else { + this.path = path; + } + } + + public Collection withOptions(CollectionOptions options) { + return new Collection(path, options); + } + + @Override + Iterable toStageArgs() { + return Collections.singleton(Value.newBuilder().setReferenceValue(path).build()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroup.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroup.java new file mode 100644 index 000000000000..f3535230a731 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroup.java @@ -0,0 +1,45 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; + +@InternalApi +public final class CollectionGroup extends Stage { + + private final String collectionId; + + @InternalApi + public CollectionGroup(String collectionId, CollectionGroupOptions options) { + super("collection_group", options.options); + this.collectionId = collectionId; + } + + public CollectionGroup withOptions(CollectionGroupOptions options) { + return new CollectionGroup(collectionId, options); + } + + @Override + Iterable toStageArgs() { + return ImmutableList.of( + Value.newBuilder().setReferenceValue("").build(), encodeValue(collectionId)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroupOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroupOptions.java new file mode 100644 index 000000000000..e42bef68bbba --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionGroupOptions.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class CollectionGroupOptions extends AbstractOptions { + + public CollectionGroupOptions() { + this(InternalOptions.EMPTY); + } + + CollectionGroupOptions(InternalOptions options) { + super(options); + } + + @Override + CollectionGroupOptions self(InternalOptions options) { + return new CollectionGroupOptions(options); + } + + public CollectionGroupOptions withHints(CollectionHints hints) { + return with("hints", hints); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionHints.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionHints.java new file mode 100644 index 000000000000..0b9eafba2566 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionHints.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class CollectionHints extends AbstractOptions { + + public CollectionHints() { + this(InternalOptions.EMPTY); + } + + CollectionHints(InternalOptions options) { + super(options); + } + + @Override + CollectionHints self(InternalOptions options) { + return new CollectionHints(options); + } + + public CollectionHints withForceIndex(String value) { + return with("force_index", value); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionOptions.java new file mode 100644 index 000000000000..73dea074e7d5 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/CollectionOptions.java @@ -0,0 +1,37 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class CollectionOptions extends AbstractOptions { + + public CollectionOptions() { + super(InternalOptions.EMPTY); + } + + CollectionOptions(InternalOptions options) { + super(options); + } + + @Override + CollectionOptions self(InternalOptions options) { + return new CollectionOptions(options); + } + + public CollectionOptions withHints(CollectionHints hints) { + return adding(hints); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Database.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Database.java new file mode 100644 index 000000000000..121cde8f5ad5 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Database.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; +import java.util.Collections; + +@InternalApi +public final class Database extends Stage { + + @InternalApi + public Database() { + super("database", InternalOptions.EMPTY); + } + + @Override + Iterable toStageArgs() { + return Collections.emptyList(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Distinct.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Distinct.java new file mode 100644 index 000000000000..58f54c019d33 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Distinct.java @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.Map; + +@BetaApi +public final class Distinct extends Stage { + + private final Map groups; + + @InternalApi + public Distinct(Map groups) { + super("distinct", InternalOptions.EMPTY); + this.groups = groups; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(groups)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Documents.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Documents.java new file mode 100644 index 000000000000..93dd2322ea7b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Documents.java @@ -0,0 +1,48 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.DocumentReference; +import com.google.common.collect.Iterables; +import com.google.firestore.v1.Value; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@InternalApi +public final class Documents extends Stage { + + private List documents; + + @InternalApi + Documents(List documents) { + super("documents", InternalOptions.EMPTY); + this.documents = documents; + } + + @InternalApi + public static Documents of(DocumentReference... documents) { + return new Documents( + Arrays.stream(documents).map(doc -> "/" + doc.getPath()).collect(Collectors.toList())); + } + + @Override + Iterable toStageArgs() { + return Iterables.transform(documents, doc -> Value.newBuilder().setReferenceValue(doc).build()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ExplainOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ExplainOptions.java new file mode 100644 index 000000000000..edafba57219a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ExplainOptions.java @@ -0,0 +1,55 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.cloud.firestore.PipelineUtils; +import com.google.firestore.v1.Value; + +public final class ExplainOptions extends AbstractOptions { + + public static class ExecutionMode { + public static final ExecutionMode EXPLAIN = new ExecutionMode("explain"); + public static final ExecutionMode ANALYZE = new ExecutionMode("analyze"); + + private final Value value; + + private ExecutionMode(String format) { + this.value = PipelineUtils.encodeValue(format); + } + + public Value toProto() { + return value; + } + } + + public ExplainOptions() { + super(InternalOptions.EMPTY); + } + + ExplainOptions(InternalOptions options) { + super(options); + } + + @Override + ExplainOptions self(InternalOptions options) { + return new ExplainOptions(options); + } + + public ExplainOptions withExecutionMode(ExecutionMode mode) { + return with("mode", mode.toProto()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearest.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearest.java new file mode 100644 index 000000000000..6cefeffb45c8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.VectorValue; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; + +@BetaApi +public final class FindNearest extends Stage { + + public static final class DistanceMeasure { + + final String protoString; + + private DistanceMeasure(String protoString) { + this.protoString = protoString; + } + + public static final DistanceMeasure EUCLIDEAN = new DistanceMeasure("euclidean"); + public static final DistanceMeasure COSINE = new DistanceMeasure("cosine"); + public static final DistanceMeasure DOT_PRODUCT = new DistanceMeasure("dot_product"); + + public static DistanceMeasure generic(String name) { + return new DistanceMeasure(name); + } + + Value toProto() { + return encodeValue(protoString); + } + } + + private final Expression property; + private final VectorValue vector; + private final DistanceMeasure distanceMeasure; + + @InternalApi + public FindNearest( + Expression property, + VectorValue vector, + DistanceMeasure distanceMeasure, + FindNearestOptions options) { + super("find_nearest", options.options); + this.property = property; + this.vector = vector; + this.distanceMeasure = distanceMeasure; + } + + @Override + Iterable toStageArgs() { + return ImmutableList.of(encodeValue(property), encodeValue(vector), distanceMeasure.toProto()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearestOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearestOptions.java new file mode 100644 index 000000000000..e876517c5ecc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/FindNearestOptions.java @@ -0,0 +1,51 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.pipeline.expressions.Expression.field; + +import com.google.api.core.BetaApi; +import com.google.cloud.firestore.pipeline.expressions.Field; + +@BetaApi +public final class FindNearestOptions extends AbstractOptions { + + public FindNearestOptions() { + this(InternalOptions.EMPTY); + } + + private FindNearestOptions(InternalOptions options) { + super(options); + } + + @Override + FindNearestOptions self(InternalOptions options) { + return new FindNearestOptions(options); + } + + public FindNearestOptions withLimit(long limit) { + return with("limit", limit); + } + + public FindNearestOptions withDistanceField(Field distanceField) { + return with("distance_field", distanceField); + } + + public FindNearestOptions withDistanceField(String distanceField) { + return withDistanceField(field(distanceField)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/InternalOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/InternalOptions.java new file mode 100644 index 000000000000..300e352e840c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/InternalOptions.java @@ -0,0 +1,78 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; + +/** + * Wither style Key/Value options object. + * + *

Basic `wither` functionality built upon `ImmutableMap`. Exposes methods to + * construct, augment, and encode Kay/Value pairs. The wrapped collection `ImmutableMap` is an implementation detail, not to be exposed, since more efficient implementations are + * possible. + */ +final class InternalOptions { + + public static final InternalOptions EMPTY = new InternalOptions(ImmutableMap.of()); + + final ImmutableMap options; + + InternalOptions(ImmutableMap options) { + this.options = options; + } + + public static InternalOptions of(String key, Value value) { + return new InternalOptions(ImmutableMap.of(key, value)); + } + + InternalOptions with(String key, Value value) { + ImmutableMap.Builder builder = + ImmutableMap.builderWithExpectedSize(options.size() + 1); + builder.putAll(options); + builder.put(key, value); + return new InternalOptions(builder.buildKeepingLast()); + } + + InternalOptions with(String key, Iterable values) { + ArrayValue arrayValue = ArrayValue.newBuilder().addAllValues(values).build(); + return with(key, Value.newBuilder().setArrayValue(arrayValue).build()); + } + + InternalOptions with(String key, InternalOptions value) { + return with(key, value.toValue()); + } + + InternalOptions adding(AbstractOptions value) { + ImmutableMap.Builder builder = + ImmutableMap.builderWithExpectedSize(options.size() + value.toMap().size()); + builder.putAll(options); + for (ImmutableMap.Entry entry : value.toMap().entrySet()) { + builder.put(entry.getKey(), entry.getValue()); + } + + return new InternalOptions(builder.buildKeepingLast()); + } + + private Value toValue() { + MapValue mapValue = MapValue.newBuilder().putAllFields(options).build(); + return Value.newBuilder().setMapValue(mapValue).build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Limit.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Limit.java new file mode 100644 index 000000000000..8723b980c51f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Limit.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; +import java.util.Collections; + +@InternalApi +public final class Limit extends Stage { + + private final int limit; + + @InternalApi + public Limit(int limit) { + super("limit", InternalOptions.EMPTY); + this.limit = limit; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(limit)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Offset.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Offset.java new file mode 100644 index 000000000000..63a96812a0b4 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Offset.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.firestore.v1.Value; +import java.util.Collections; + +@InternalApi +public final class Offset extends Stage { + + private final int offset; + + @InternalApi + public Offset(int offset) { + super("offset", InternalOptions.EMPTY); + this.offset = offset; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(offset)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/PipelineExecuteOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/PipelineExecuteOptions.java new file mode 100644 index 000000000000..754215e675f2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/PipelineExecuteOptions.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class PipelineExecuteOptions extends AbstractOptions { + + public PipelineExecuteOptions() { + super(InternalOptions.EMPTY); + } + + PipelineExecuteOptions(InternalOptions options) { + super(options); + } + + @Override + PipelineExecuteOptions self(InternalOptions options) { + return new PipelineExecuteOptions(options); + } + + public PipelineExecuteOptions withExplainOptions(ExplainOptions options) { + return with("explain_options", options); + } + + public PipelineExecuteOptions withIndexMode(String indexMode) { + return with("index_mode", indexMode); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawOptions.java new file mode 100644 index 000000000000..1e8a1f0c2b5b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawOptions.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.cloud.firestore.pipeline.expressions.Field; + +public final class RawOptions extends AbstractOptions { + + public RawOptions() { + this(InternalOptions.EMPTY); + } + + public static RawOptions of(String key, String value) { + return new RawOptions(InternalOptions.of(key, encodeValue(value))); + } + + public static RawOptions of(String key, boolean value) { + return new RawOptions(InternalOptions.of(key, encodeValue(value))); + } + + public static RawOptions of(String key, long value) { + return new RawOptions(InternalOptions.of(key, encodeValue(value))); + } + + public static RawOptions of(String key, double value) { + return new RawOptions(InternalOptions.of(key, encodeValue(value))); + } + + public static RawOptions of(String key, Field value) { + return new RawOptions(InternalOptions.of(key, value.toProto())); + } + + RawOptions(InternalOptions options) { + super(options); + } + + @Override + protected RawOptions self(InternalOptions options) { + return new RawOptions(options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawStage.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawStage.java new file mode 100644 index 000000000000..d25ec04956ed --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RawStage.java @@ -0,0 +1,78 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.PipelineUtils; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.firestore.v1.Value; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Nonnull; + +/** + * Adds a stage to the pipeline by specifying the stage name as an argument. This does not offer any + * type safety on the stage params and requires the caller to know the order (and optionally names) + * of parameters accepted by the stage. + * + *

This class provides a way to call stages that are supported by the Firestore backend but that + * are not implemented in the SDK version being used. + */ +public final class RawStage extends Stage { + + private final List arguments; + + private RawStage( + @Nonnull String name, @Nonnull List arguments, @Nonnull RawOptions options) { + super(name, options.options); + this.arguments = arguments; + } + + /** + * Specify name of stage + * + * @param name The unique name of the stage to add. + * @return A new {@code RawStage} for the specified stage name. + */ + @Nonnull + public static RawStage ofName(@Nonnull String name) { + return new RawStage(name, ImmutableList.of(), new RawOptions()); + } + + /** + * Specify arguments to stage. + * + * @param arguments A list of ordered parameters to configure the stage's behavior. + * @return {@code RawStage} with specified parameters. + */ + @Nonnull + public RawStage withArguments(@Nonnull Object... arguments) { + return new RawStage(name, Arrays.asList(arguments), new RawOptions(options)); + } + + @Nonnull + public RawStage withOptions(@Nonnull RawOptions options) { + return new RawStage(name, arguments, options); + } + + @Override + @InternalApi + Iterable toStageArgs() { + return Iterables.transform(arguments, PipelineUtils::encodeValue); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RemoveFields.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RemoveFields.java new file mode 100644 index 000000000000..613f1bf0e659 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/RemoveFields.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.PipelineUtils; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.firestore.v1.Value; + +@InternalApi +public final class RemoveFields extends Stage { + + private final ImmutableList fields; + + @InternalApi + public RemoveFields(ImmutableList fields) { + super("remove_fields", InternalOptions.EMPTY); + this.fields = fields; + } + + @Override + Iterable toStageArgs() { + return Iterables.transform(fields, PipelineUtils::encodeValue); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ReplaceWith.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ReplaceWith.java new file mode 100644 index 000000000000..1fe58d1acf52 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/ReplaceWith.java @@ -0,0 +1,57 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; +import javax.annotation.Nonnull; + +public class ReplaceWith extends Stage { + + private final Expression expr; + private final Mode mode; + + public enum Mode { + FULL_REPLACE(Value.newBuilder().setStringValue("full_replace").build()), + MERGE_PREFER_NEXT(Value.newBuilder().setStringValue("merge_prefer_nest").build()), + MERGE_PREFER_PARENT(Value.newBuilder().setStringValue("merge_prefer_parent").build()); + + public final Value value; + + Mode(Value value) { + this.value = value; + } + } + + public ReplaceWith(@Nonnull Expression field) { + this(field, Mode.FULL_REPLACE); + } + + public ReplaceWith(@Nonnull Expression expr, @Nonnull Mode mode) { + super("replace_with", InternalOptions.EMPTY); + this.expr = expr; + this.mode = mode; + } + + @Override + Iterable toStageArgs() { + return ImmutableList.of(encodeValue(expr), mode.value); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sample.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sample.java new file mode 100644 index 000000000000..d4a5bd22bf8f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sample.java @@ -0,0 +1,69 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; +import javax.annotation.Nonnull; + +public final class Sample extends Stage { + + private final Number size; + private final Mode mode; + + public enum Mode { + DOCUMENTS(encodeValue("documents")), + PERCENT(encodeValue("percent")); + + public final Value value; + + Mode(Value value) { + this.value = value; + } + } + + @BetaApi + public static Sample withPercentage(double percentage) { + return new Sample(percentage, Mode.PERCENT, new SampleOptions()); + } + + @BetaApi + public static Sample withDocLimit(int documents) { + return new Sample(documents, Mode.DOCUMENTS, new SampleOptions()); + } + + @BetaApi + public Sample withOptions(@Nonnull SampleOptions options) { + return new Sample(size, mode, options); + } + + @InternalApi + private Sample(Number size, Mode mode, SampleOptions options) { + super("sample", options.options); + this.size = size; + this.mode = mode; + } + + @Override + Iterable toStageArgs() { + return ImmutableList.of(encodeValue(size), mode.value); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/SampleOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/SampleOptions.java new file mode 100644 index 000000000000..2e88b2802f4c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/SampleOptions.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +public final class SampleOptions extends AbstractOptions { + + public SampleOptions() { + this(InternalOptions.EMPTY); + } + + SampleOptions(InternalOptions options) { + super(options); + } + + @Override + SampleOptions self(InternalOptions options) { + return new SampleOptions(options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Select.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Select.java new file mode 100644 index 000000000000..1017d90d37de --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Select.java @@ -0,0 +1,42 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.Map; + +@InternalApi +public final class Select extends Stage { + + private final Map projections; + + @InternalApi + public Select(Map projections) { + super("select", InternalOptions.EMPTY); + this.projections = projections; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(projections)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sort.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sort.java new file mode 100644 index 000000000000..c8926611872c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Sort.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.expressions.Ordering; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterables; +import com.google.firestore.v1.Value; +import java.util.List; + +public final class Sort extends Stage { + + private static final String name = "sort"; + private final List orders; + + @InternalApi + public Sort(ImmutableList orders) { + super("sort", InternalOptions.EMPTY); + this.orders = orders; + } + + @Override + Iterable toStageArgs() { + return Iterables.transform(orders, Ordering::toProto); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Stage.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Stage.java new file mode 100644 index 000000000000..8f82195f7204 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Stage.java @@ -0,0 +1,43 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.firestore.v1.Pipeline; +import com.google.firestore.v1.Value; + +/** Parent to all stages. */ +public abstract class Stage { + + protected final String name; + final InternalOptions options; + + /** Constructor is package-private to prevent extension. */ + Stage(String name, InternalOptions options) { + this.name = name; + this.options = options; + } + + final Pipeline.Stage toStageProto() { + return Pipeline.Stage.newBuilder() + .setName(name) + .addAllArgs(toStageArgs()) + .putAllOptions(options.options) + .build(); + } + + abstract Iterable toStageArgs(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/StageUtils.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/StageUtils.java new file mode 100644 index 000000000000..5381daa508d2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/StageUtils.java @@ -0,0 +1,35 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.api.core.InternalApi; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.Value; + +@InternalApi +public final class StageUtils { + @InternalApi + public static com.google.firestore.v1.Pipeline.Stage toStageProto(Stage stage) { + return stage.toStageProto(); + } + + @SuppressWarnings("ReferencesHidden") + @InternalApi + public static ImmutableMap toMap(AbstractOptions options) { + return options.options.options; + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Union.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Union.java new file mode 100644 index 000000000000..d54a650f499c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Union.java @@ -0,0 +1,36 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.cloud.firestore.Pipeline; +import com.google.firestore.v1.Value; +import java.util.Collections; + +public final class Union extends Stage { + + private final Pipeline other; + + public Union(Pipeline other) { + super("union", InternalOptions.EMPTY); + this.other = other; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(other.toProtoValue()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Unnest.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Unnest.java new file mode 100644 index 000000000000..da1bd29d6b86 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Unnest.java @@ -0,0 +1,73 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; +import static com.google.cloud.firestore.pipeline.expressions.Expression.field; + +import com.google.cloud.firestore.pipeline.expressions.AliasedExpression; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.expressions.Selectable; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Value; +import javax.annotation.Nonnull; + +public final class Unnest extends Stage { + + private final Expression expr; + private final Field alias; + + public Unnest(@Nonnull Field field, @Nonnull String alias) { + super("unnest", InternalOptions.EMPTY); + this.expr = field; + this.alias = field(alias); + } + + public Unnest(@Nonnull Field field, @Nonnull String alias, @Nonnull UnnestOptions options) { + super("unnest", options.options); + this.expr = field; + this.alias = field(alias); + } + + public Unnest(@Nonnull Selectable field) { + super("unnest", InternalOptions.EMPTY); + if (field instanceof AliasedExpression) { + this.expr = ((AliasedExpression) field).getExpr(); + this.alias = field(((AliasedExpression) field).getAlias()); + } else { + this.expr = (Field) field; + this.alias = (Field) field; + } + } + + public Unnest(@Nonnull Selectable field, @Nonnull UnnestOptions options) { + super("unnest", options.options); + if (field instanceof AliasedExpression) { + this.expr = ((AliasedExpression) field).getExpr(); + this.alias = field(((AliasedExpression) field).getAlias()); + } else { + this.expr = (Field) field; + this.alias = (Field) field; + } + } + + @Override + Iterable toStageArgs() { + return ImmutableList.of(encodeValue(expr), encodeValue(alias)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/UnnestOptions.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/UnnestOptions.java new file mode 100644 index 000000000000..1b8e267f02f9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/UnnestOptions.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import com.google.firestore.v1.Value; +import javax.annotation.Nonnull; + +public final class UnnestOptions extends AbstractOptions { + + public UnnestOptions() { + this(InternalOptions.EMPTY); + } + + public UnnestOptions withIndexField(@Nonnull String indexField) { + return with("index_field", Value.newBuilder().setFieldReferenceValue(indexField).build()); + } + + @Override + UnnestOptions self(InternalOptions options) { + return new UnnestOptions(options); + } + + private UnnestOptions(InternalOptions options) { + super(options); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Where.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Where.java new file mode 100644 index 000000000000..d6626f7cc1de --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/pipeline/stages/Where.java @@ -0,0 +1,41 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.pipeline.stages; + +import static com.google.cloud.firestore.PipelineUtils.encodeValue; + +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.pipeline.expressions.BooleanExpression; +import com.google.firestore.v1.Value; +import java.util.Collections; + +@InternalApi +public final class Where extends Stage { + + private final BooleanExpression condition; + + @InternalApi + public Where(BooleanExpression condition) { + super("where", InternalOptions.EMPTY); + this.condition = condition; + } + + @Override + Iterable toStageArgs() { + return Collections.singletonList(encodeValue(condition)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java new file mode 100644 index 000000000000..5c8dd457264f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/FirestoreRpc.java @@ -0,0 +1,97 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.spi.v1; + +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.ServiceRpc; +import com.google.cloud.firestore.v1.FirestoreClient; +import com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; +import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.protobuf.Empty; +import java.util.concurrent.ScheduledExecutorService; + +/** Contains the RPC stubs used by the manual Cloud Firestore client. */ +public interface FirestoreRpc extends AutoCloseable, ServiceRpc { + + /** Commits a transaction, while optionally updating documents. */ + UnaryCallable commitCallable(); + + UnaryCallable batchWriteCallable(); + + /** Gets multiple documents. */ + ServerStreamingCallable + batchGetDocumentsCallable(); + + /** Returns the executor used by the GAPIC client. */ + ScheduledExecutorService getExecutor(); + + /** Runs a query. */ + ServerStreamingCallable runQueryCallable(); + + /** Executes a pipeline. */ + ServerStreamingCallable + executePipelineCallable(); + + /** Runs an aggregation query. */ + ServerStreamingCallable + runAggregationQueryCallable(); + + /** Starts a new transaction. */ + UnaryCallable beginTransactionCallable(); + + /** Rolls back a transaction. */ + UnaryCallable rollbackCallable(); + + /** Returns a list of collections IDs. */ + UnaryCallable + listCollectionIdsPagedCallable(); + + UnaryCallable + partitionQueryPagedCallable(); + + /** Returns a list of documents. */ + UnaryCallable listDocumentsPagedCallable(); + + /** Returns a bi-directional watch stream. */ + BidiStreamingCallable listenCallable(); + + void shutdownNow(); + + void shutdown(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java new file mode 100644 index 000000000000..7224a3014bd2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpc.java @@ -0,0 +1,301 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.spi.v1; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.grpc.GrpcCallContext; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.api.gax.rpc.NoHeaderProvider; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.TransportChannel; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.cloud.NoCredentials; +import com.google.cloud.ServiceOptions; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.v1.FirestoreClient; +import com.google.cloud.firestore.v1.FirestoreClient.ListCollectionIdsPagedResponse; +import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import com.google.cloud.firestore.v1.FirestoreSettings; +import com.google.cloud.firestore.v1.stub.FirestoreStub; +import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; +import com.google.cloud.firestore.v1.stub.GrpcFirestoreStub; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.DatabaseRootName; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.protobuf.Empty; +import io.grpc.CallOptions; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.util.Collections; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * GRPC client implementation of the Firestore RPC methods. Exposes FirestoreOptions on top of the + * GRPC-based Firestore GAPIC client. + */ +public class GrpcFirestoreRpc implements FirestoreRpc { + + private final FirestoreStub firestoreStub; + private final ScheduledExecutorService executor; + private final ExecutorFactory executorFactory; + private final ClientContext clientContext; + + private boolean closed; + + public GrpcFirestoreRpc(final FirestoreOptions options) throws IOException { + GrpcTransportOptions transportOptions = (GrpcTransportOptions) options.getTransportOptions(); + executorFactory = transportOptions.getExecutorFactory(); + executor = executorFactory.get(); + try { + if (options.getHost().contains("localhost") + || NoCredentials.getInstance().equals(options.getCredentials())) { + ManagedChannel managedChannel = + ManagedChannelBuilder.forTarget(options.getHost()) + .usePlaintext() + .executor(executor) + .build(); + TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel); + clientContext = + ClientContext.newBuilder() + .setCredentials(null) + .setExecutor(executor) + .setTransportChannel(transportChannel) + .setDefaultCallContext(GrpcCallContext.of(managedChannel, CallOptions.DEFAULT)) + .setBackgroundResources(Collections.singletonList(transportChannel)) + .build(); + } else { + FirestoreSettingsBuilder settingsBuilder = + new FirestoreSettingsBuilder(FirestoreSettings.newBuilder().build()); + + DatabaseRootName databaseName = + DatabaseRootName.of(options.getProjectId(), options.getDatabaseId()); + + settingsBuilder.setCredentialsProvider(options.getCredentialsProvider()); + settingsBuilder.setTransportChannelProvider(options.getTransportChannelProvider()); + + HeaderProvider internalHeaderProvider = + FirestoreSettings.defaultApiClientHeaderProviderBuilder() + .setClientLibToken( + ServiceOptions.getGoogApiClientLibName(), + GaxProperties.getLibraryVersion(options.getClass())) + .setResourceToken(databaseName.toString()) + .build(); + + settingsBuilder.setInternalHeaderProvider(internalHeaderProvider); + settingsBuilder.setHeaderProvider(options.getMergedHeaderProvider(new NoHeaderProvider())); + + clientContext = ClientContext.create(settingsBuilder.build()); + } + + FirestoreStubSettings.Builder firestoreBuilder = + FirestoreStubSettings.newBuilder(clientContext); + RetrySettings retrySettings = options.getRetrySettings(); + + // Override retry settings only if customer provides settings different from default. + if (retrySettings.equals(ServiceOptions.getDefaultRetrySettings())) { + // We are manually setting `setMaxAttempts(5)` to follow + // the `firestore_grpc_service_config.json` configuration. + // This code should be removed when following issue is fixed: + // https://github.com/googleapis/sdk-platform-java/issues/2306 + firestoreBuilder.applyToAllUnaryMethods( + builder -> { + builder.retrySettings().setMaxAttempts(5); + return null; + }); + // Manually apply the retry settings to streaming methods + firestoreBuilder.runQuerySettings().retrySettings().setMaxAttempts(5); + firestoreBuilder.runAggregationQuerySettings().retrySettings().setMaxAttempts(5); + firestoreBuilder.batchGetDocumentsSettings().retrySettings().setMaxAttempts(5); + firestoreBuilder.executePipelineSettings().retrySettings().setMaxAttempts(5); + } else { + firestoreBuilder.applyToAllUnaryMethods( + builder -> { + builder.setRetrySettings(retrySettings); + return null; + }); + // Manually apply the retry settings to streaming methods + firestoreBuilder.runQuerySettings().setRetrySettings(retrySettings); + firestoreBuilder.runAggregationQuerySettings().setRetrySettings(retrySettings); + firestoreBuilder.batchGetDocumentsSettings().setRetrySettings(retrySettings); + firestoreBuilder.executePipelineSettings().setRetrySettings(retrySettings); + } + + ApiTracerFactory apiTracerFactory = options.getApiTracerFactory(); + if (apiTracerFactory != null) { + firestoreBuilder.setTracerFactory(apiTracerFactory); + } + + firestoreStub = GrpcFirestoreStub.create(firestoreBuilder.build()); + } catch (Exception e) { + throw new IOException(e); + } + } + + @Override + public void close() throws Exception { + if (!closed) { + firestoreStub.close(); + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.close(); + } + executorFactory.release(executor); + closed = true; + } + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.awaitTermination(1, TimeUnit.SECONDS); + } + } + + @Override + public void shutdown() { + if (closed) { + return; + } + firestoreStub.shutdown(); + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.shutdown(); + } + executorFactory.release(executor); + closed = true; + } + + @Override + public void shutdownNow() { + if (closed) { + return; + } + firestoreStub.shutdownNow(); + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.shutdownNow(); + } + executorFactory.release(executor); + closed = true; + } + + @Override + public ScheduledExecutorService getExecutor() { + return executor; + } + + @Override + public UnaryCallable commitCallable() { + return firestoreStub.commitCallable(); + } + + @Override + public UnaryCallable batchWriteCallable() { + return firestoreStub.batchWriteCallable(); + } + + @Override + public ServerStreamingCallable + batchGetDocumentsCallable() { + return firestoreStub.batchGetDocumentsCallable(); + } + + @Override + public ServerStreamingCallable runQueryCallable() { + return firestoreStub.runQueryCallable(); + } + + @Override + public ServerStreamingCallable + executePipelineCallable() { + return firestoreStub.executePipelineCallable(); + } + + @Override + public ServerStreamingCallable + runAggregationQueryCallable() { + return firestoreStub.runAggregationQueryCallable(); + } + + @Override + public UnaryCallable + beginTransactionCallable() { + return firestoreStub.beginTransactionCallable(); + } + + @Override + public UnaryCallable rollbackCallable() { + return firestoreStub.rollbackCallable(); + } + + @Override + public UnaryCallable + listCollectionIdsPagedCallable() { + return firestoreStub.listCollectionIdsPagedCallable(); + } + + @Override + public UnaryCallable + partitionQueryPagedCallable() { + return firestoreStub.partitionQueryPagedCallable(); + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return firestoreStub.listDocumentsPagedCallable(); + } + + @Override + public BidiStreamingCallable listenCallable() { + return firestoreStub.listenCallable(); + } + + // This class is needed solely to get access to protected method setInternalHeaderProvider() + private static class FirestoreSettingsBuilder extends FirestoreSettings.Builder { + private FirestoreSettingsBuilder(FirestoreSettings settings) { + super(settings); + } + + @Override + protected FirestoreSettings.Builder setInternalHeaderProvider( + HeaderProvider internalHeaderProvider) { + return super.setInternalHeaderProvider(internalHeaderProvider); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/BuiltinMetricsProvider.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/BuiltinMetricsProvider.java new file mode 100644 index 000000000000..621efb914c6a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/BuiltinMetricsProvider.java @@ -0,0 +1,181 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import static com.google.cloud.firestore.telemetry.TelemetryConstants.FIRESTORE_METER_NAME; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_ATTRIBUTE_KEY_CLIENT_UID; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_ATTRIBUTE_KEY_LIBRARY_NAME; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_ATTRIBUTE_KEY_LIBRARY_VERSION; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_NAME_END_TO_END_LATENCY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_NAME_FIRST_RESPONSE_LATENCY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_NAME_TRANSACTION_ATTEMPT_COUNT; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_NAME_TRANSACTION_LATENCY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_PREFIX; + +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.api.gax.tracing.MetricsTracerFactory; +import com.google.api.gax.tracing.OpenTelemetryMetricsRecorder; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.api.metrics.DoubleHistogram; +import io.opentelemetry.api.metrics.LongCounter; +import io.opentelemetry.api.metrics.Meter; +import io.opentelemetry.api.metrics.MeterProvider; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * A provider for built-in metrics. This class is responsible for storing OpenTelemetry metrics + * configuration and recording built-in metrics for the Firestore SDK. + */ +class BuiltinMetricsProvider { + private static final Logger logger = Logger.getLogger(BuiltinMetricsProvider.class.getName()); + + private OpenTelemetry openTelemetry; + private DoubleHistogram endToEndLatency; + private DoubleHistogram firstResponseLatency; + private DoubleHistogram transactionLatency; + private LongCounter transactionAttemptCount; + + private ApiTracerFactory apiTracerFactory; + private final Map staticAttributes; + + private static final String MILLISECOND_UNIT = "ms"; + private static final String INTEGER_UNIT = "1"; + private static final String FIRESTORE_LIBRARY_NAME = "com.google.cloud.firestore"; + + public BuiltinMetricsProvider(OpenTelemetry openTelemetry) { + this.openTelemetry = openTelemetry; + this.staticAttributes = createStaticAttributes(); + + if (openTelemetry.getMeterProvider() != MeterProvider.noop()) { + configureRPCLayerMetrics(); + configureSDKLayerMetrics(); + } + } + + private Map createStaticAttributes() { + Map staticAttributes = new HashMap<>(); + staticAttributes.put(METRIC_ATTRIBUTE_KEY_CLIENT_UID.getKey(), ClientIdentifier.getClientUid()); + staticAttributes.put(METRIC_ATTRIBUTE_KEY_LIBRARY_NAME.getKey(), FIRESTORE_LIBRARY_NAME); + String pkgVersion = this.getClass().getPackage().getImplementationVersion(); + if (pkgVersion != null) { + staticAttributes.put(METRIC_ATTRIBUTE_KEY_LIBRARY_VERSION.getKey(), pkgVersion); + } + return staticAttributes; + } + + /** Creates an ApiTracerFactory to be passed into GAX library and collect RPC layer metrics. */ + private void configureRPCLayerMetrics() { + OpenTelemetryMetricsRecorder recorder = + new OpenTelemetryMetricsRecorder(openTelemetry, METRIC_PREFIX); + this.apiTracerFactory = new MetricsTracerFactory(recorder, staticAttributes); + } + + /** Registers metrics to be collected at the Firestore SDK layer */ + private void configureSDKLayerMetrics() { + Meter meter = openTelemetry.getMeter(FIRESTORE_METER_NAME); + + this.endToEndLatency = + meter + .histogramBuilder(METRIC_PREFIX + "/" + METRIC_NAME_END_TO_END_LATENCY) + .setDescription("Firestore operations' end-to-end latency") + .setUnit(MILLISECOND_UNIT) + .build(); + + this.firstResponseLatency = + meter + .histogramBuilder(METRIC_PREFIX + "/" + METRIC_NAME_FIRST_RESPONSE_LATENCY) + .setDescription("Firestore streaming operations' first response latency") + .setUnit(MILLISECOND_UNIT) + .build(); + + this.transactionLatency = + meter + .histogramBuilder(METRIC_PREFIX + "/" + METRIC_NAME_TRANSACTION_LATENCY) + .setDescription("Firestore transactions' end-to-end latency") + .setUnit(MILLISECOND_UNIT) + .build(); + + this.transactionAttemptCount = + meter + .counterBuilder(METRIC_PREFIX + "/" + METRIC_NAME_TRANSACTION_ATTEMPT_COUNT) + .setDescription("Number of Firestore transaction attempts including retries") + .setUnit(INTEGER_UNIT) + .build(); + } + + public ApiTracerFactory getApiTracerFactory() { + return this.apiTracerFactory; + } + + public void latencyRecorder( + MetricType metricType, double latency, Map attributes) { + DoubleHistogram histogram = getHistogram(metricType); + if (histogram != null) { + attributes.putAll(staticAttributes); + try { + histogram.record(latency, toOtelAttributes(attributes)); + } catch (Exception e) { + logger.log(Level.WARNING, "Failed to record latency metric: " + e.getMessage(), e); + } + } + } + + public void counterRecorder(MetricType metricType, long count, Map attributes) { + LongCounter counter = getCounter(metricType); + if (counter != null) { + attributes.putAll(staticAttributes); + try { + counter.add(count, toOtelAttributes(attributes)); + } catch (Exception e) { + logger.log(Level.WARNING, "Failed to record counter metric:" + e.getMessage(), e); + } + } + } + + public DoubleHistogram getHistogram(MetricType metricType) { + switch (metricType) { + case END_TO_END_LATENCY: + return endToEndLatency; + case FIRST_RESPONSE_LATENCY: + return firstResponseLatency; + case TRANSACTION_LATENCY: + return transactionLatency; + default: + throw new IllegalArgumentException("Unknown latency MetricType: " + metricType); + } + } + + public LongCounter getCounter(MetricType metricType) { + if (metricType == MetricType.TRANSACTION_ATTEMPT_COUNT) { + return transactionAttemptCount; + } else { + throw new IllegalArgumentException("Unknown counter MetricType: " + metricType); + } + } + + private Attributes toOtelAttributes(Map attributes) { + AttributesBuilder attributesBuilder = Attributes.builder(); + attributes.forEach(attributesBuilder::put); + return attributesBuilder.build(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/ClientIdentifier.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/ClientIdentifier.java new file mode 100644 index 000000000000..dc4a3eae055a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/ClientIdentifier.java @@ -0,0 +1,77 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import java.lang.management.ManagementFactory; +import java.lang.reflect.Method; +import java.net.InetAddress; +import java.util.UUID; + +/** A utility class for retrieving a unique client identifier (CLIENT_UID) */ +final class ClientIdentifier { + + private ClientIdentifier() {} + + private static String CLIENT_UID; + + /** Gets the unique identifier for the client. */ + public static String getClientUid() { + if (CLIENT_UID == null) { + CLIENT_UID = generateClientUid(); + } + return CLIENT_UID; + } + + /** + * Generates a unique identifier for the client that is composed of a random UUID, the process ID, + * and the hostname of the machine. + */ + private static String generateClientUid() { + String identifier = UUID.randomUUID().toString(); + String pid = getProcessId(); + String hostname = getHostName(); + return String.format("%s@%s@%s", identifier, pid, hostname); + } + + private static String getHostName() { + try { + return InetAddress.getLocalHost().getHostName(); + } catch (Exception e) { + return "localhost"; + } + } + + private static String getProcessId() { + try { + // Check if Java 9+ and ProcessHandle class is available + Class processHandleClass = Class.forName("java.lang.ProcessHandle"); + Method currentMethod = processHandleClass.getMethod("current"); + Object processHandleInstance = currentMethod.invoke(null); + Method pidMethod = processHandleClass.getMethod("pid"); + long pid = (long) pidMethod.invoke(processHandleInstance); + return Long.toString(pid); + } catch (Exception e) { + // Fallback to Java 8 method + final String jvmName = ManagementFactory.getRuntimeMXBean().getName(); + if (jvmName != null && jvmName.contains("@")) { + return jvmName.split("@")[0]; + } else { + return "unknown"; + } + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java new file mode 100644 index 000000000000..695b7c287e54 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracer.java @@ -0,0 +1,130 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + +import com.google.api.gax.tracing.ApiTracer; +import com.google.api.gax.tracing.BaseApiTracer; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** Combines multiple {@link ApiTracer}s into a single {@link ApiTracer}. */ +class CompositeApiTracer extends BaseApiTracer { + private final List children; + + public CompositeApiTracer(List children) { + this.children = ImmutableList.copyOf(children); + } + + @Override + public Scope inScope() { + List childScopes = + children.stream() + .map(ApiTracer::inScope) + .collect(Collectors.toCollection(() -> new ArrayList<>(children.size()))); + + return () -> childScopes.forEach(Scope::close); + } + + @Override + public void operationSucceeded() { + children.forEach(ApiTracer::operationSucceeded); + } + + @Override + public void operationCancelled() { + children.forEach(ApiTracer::operationCancelled); + } + + @Override + public void operationFailed(Throwable error) { + children.forEach(child -> child.operationFailed(error)); + } + + @Override + public void connectionSelected(String id) { + children.forEach(child -> child.connectionSelected(id)); + } + + @Override + public void attemptStarted(int attemptNumber) { + children.forEach(child -> child.attemptStarted(null, attemptNumber)); + } + + @Override + public void attemptStarted(Object request, int attemptNumber) { + children.forEach(child -> child.attemptStarted(request, attemptNumber)); + } + + @Override + public void attemptSucceeded() { + children.forEach(ApiTracer::attemptSucceeded); + } + + @Override + public void attemptCancelled() { + children.forEach(ApiTracer::attemptCancelled); + } + + @Override + public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { + attemptFailedDuration(error, toJavaTimeDuration(delay)); + } + + @Override + public void attemptFailedDuration(Throwable error, java.time.Duration delay) { + children.forEach(child -> child.attemptFailedDuration(error, delay)); + } + + @Override + public void attemptFailedRetriesExhausted(Throwable error) { + children.forEach(child -> child.attemptFailedRetriesExhausted(error)); + } + + @Override + public void attemptPermanentFailure(Throwable error) { + children.forEach(child -> child.attemptPermanentFailure(error)); + } + + @Override + public void lroStartFailed(Throwable error) { + children.forEach(child -> child.lroStartFailed(error)); + } + + @Override + public void lroStartSucceeded() { + children.forEach(ApiTracer::lroStartSucceeded); + } + + @Override + public void responseReceived() { + children.forEach(ApiTracer::responseReceived); + } + + @Override + public void requestSent() { + children.forEach(ApiTracer::requestSent); + } + + @Override + public void batchRequestSent(long elementCount, long requestSize) { + children.forEach(child -> child.batchRequestSent(elementCount, requestSize)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracerFactory.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracerFactory.java new file mode 100644 index 000000000000..ddd0f226d17b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/CompositeApiTracerFactory.java @@ -0,0 +1,47 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.InternalApi; +import com.google.api.gax.tracing.ApiTracer; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.api.gax.tracing.BaseApiTracerFactory; +import com.google.api.gax.tracing.SpanName; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.List; + +/** Combines multiple {@link ApiTracerFactory} into a single {@link ApiTracerFactory}. */ +@InternalApi +public class CompositeApiTracerFactory extends BaseApiTracerFactory { + + private final List apiTracerFactories; + + public CompositeApiTracerFactory(List apiTracerFactories) { + this.apiTracerFactories = ImmutableList.copyOf(apiTracerFactories); + } + + @Override + public ApiTracer newTracer(ApiTracer parent, SpanName spanName, OperationType operationType) { + List children = new ArrayList<>(apiTracerFactories.size()); + + for (ApiTracerFactory factory : apiTracerFactories) { + children.add(factory.newTracer(parent, spanName, operationType)); + } + return new CompositeApiTracer(children); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledMetricsUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledMetricsUtil.java new file mode 100644 index 000000000000..0642033c00b6 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledMetricsUtil.java @@ -0,0 +1,55 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.ApiFuture; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import java.util.List; + +/** + * A fully disabled (No-op) MetricsUtil class that does not perform any metrics collection actions + * and has near-zero overhead. + */ +class DisabledMetricsUtil implements MetricsUtil { + + class MetricsContext implements MetricsUtil.MetricsContext { + + @Override + public void recordLatencyAtFuture(MetricType metric, ApiFuture futureValue) {} + + @Override + public void recordLatency(MetricType metric) {} + + @Override + public void recordLatency(MetricType metric, Throwable t) {} + + @Override + public void recordCounterAtFuture(MetricType metric, ApiFuture futureValue) {} + + @Override + public void incrementCounter() {} + } + + @Override + public MetricsContext createMetricsContext(String methodName) { + return new MetricsContext(); + } + + @Override + public void addMetricsTracerFactory(List apiTracerFactories) {} +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledTraceUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledTraceUtil.java new file mode 100644 index 000000000000..16428b8cfdbe --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/DisabledTraceUtil.java @@ -0,0 +1,114 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import io.grpc.ManagedChannelBuilder; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A no-op implementation of {@link MetricsUtil} that does not collect or export any metrics and has + * near-zero overhead. + */ +@InternalApi +public class DisabledTraceUtil implements TraceUtil { + + static class Span implements TraceUtil.Span { + @Override + public void end() {} + + @Override + public void end(Throwable error) {} + + @Override + public void endAtFuture(ApiFuture futureValue) {} + + @Override + public TraceUtil.Span addEvent(String name) { + return this; + } + + @Override + public TraceUtil.Span addEvent(String name, Map attributes) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, int value) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, String value) { + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, boolean value) { + return this; + } + + @Override + public Scope makeCurrent() { + return new Scope(); + } + } + + static class Context implements TraceUtil.Context { + @Override + public Scope makeCurrent() { + return new Scope(); + } + } + + static class Scope implements TraceUtil.Scope { + @Override + public void close() {} + } + + @Nullable + @Override + public ApiFunction getChannelConfigurator() { + return null; + } + + @Override + public Span startSpan(String spanName) { + return new Span(); + } + + @Override + public TraceUtil.Span startSpan(String spanName, TraceUtil.Context parent) { + return new Span(); + } + + @Nonnull + @Override + public TraceUtil.Span currentSpan() { + return new Span(); + } + + @Nonnull + @Override + public TraceUtil.Context currentContext() { + return new DisabledTraceUtil.Context(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledMetricsUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledMetricsUtil.java new file mode 100644 index 000000000000..e8ebfc355b0a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledMetricsUtil.java @@ -0,0 +1,263 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import static com.google.cloud.firestore.telemetry.TelemetryConstants.COMMON_ATTRIBUTES; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.FIRESTORE_METER_NAME; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.FIRESTORE_METRICS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.GAX_METER_NAME; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.GAX_METRICS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_ATTRIBUTE_KEY_METHOD; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_ATTRIBUTE_KEY_STATUS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METRIC_PREFIX; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.cloud.firestore.FirestoreException; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import com.google.cloud.opentelemetry.metric.GoogleCloudMetricExporter; +import com.google.cloud.opentelemetry.metric.MetricConfiguration; +import com.google.common.base.Stopwatch; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.util.concurrent.MoreExecutors; +import io.grpc.Status; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.metrics.InstrumentSelector; +import io.opentelemetry.sdk.metrics.SdkMeterProvider; +import io.opentelemetry.sdk.metrics.SdkMeterProviderBuilder; +import io.opentelemetry.sdk.metrics.View; +import io.opentelemetry.sdk.metrics.export.MetricExporter; +import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import javax.annotation.Nullable; + +/** + * An implementation of {@link MetricsUtil} that uses OpenTelemetry to collect and export metrics. + * `FirestoreOpenTelemetryOptions` in `FirestoreOptions` can be used to configure its behavior. + */ +class EnabledMetricsUtil implements MetricsUtil { + private BuiltinMetricsProvider defaultMetricsProvider; + private BuiltinMetricsProvider customMetricsProvider; + + private static final Logger logger = Logger.getLogger(EnabledMetricsUtil.class.getName()); + + EnabledMetricsUtil(FirestoreOptions firestoreOptions) { + try { + configureDefaultMetricsProvider(firestoreOptions); + configureCustomMetricsProvider(firestoreOptions); + } catch (IOException e) { + logger.warning( + "Unable to create MetricsUtil object for client side metrics, will skip exporting client" + + " side metrics" + + e); + } + } + + private void configureDefaultMetricsProvider(FirestoreOptions firestoreOptions) + throws IOException { + OpenTelemetry defaultOpenTelemetry; + boolean exportBuiltinMetricsToGoogleCloudMonitoring = + firestoreOptions.getOpenTelemetryOptions().exportBuiltinMetricsToGoogleCloudMonitoring(); + if (exportBuiltinMetricsToGoogleCloudMonitoring) { + defaultOpenTelemetry = getDefaultOpenTelemetryInstance(firestoreOptions.getProjectId()); + } else { + defaultOpenTelemetry = OpenTelemetry.noop(); + } + this.defaultMetricsProvider = new BuiltinMetricsProvider(defaultOpenTelemetry); + } + + private void configureCustomMetricsProvider(FirestoreOptions firestoreOptions) + throws IOException { + OpenTelemetry customOpenTelemetry = + firestoreOptions.getOpenTelemetryOptions().getOpenTelemetry(); + if (customOpenTelemetry == null) { + customOpenTelemetry = GlobalOpenTelemetry.get(); + } + this.customMetricsProvider = new BuiltinMetricsProvider(customOpenTelemetry); + } + + @Override + public MetricsContext createMetricsContext(String methodName) { + return new MetricsContext(methodName); + } + + @Override + public void addMetricsTracerFactory(List apiTracerFactories) { + addTracerFactory(apiTracerFactories, defaultMetricsProvider); + addTracerFactory(apiTracerFactories, customMetricsProvider); + } + + /** + * Creates a default {@link OpenTelemetry} instance to collect and export built-in client side + * metrics to Google Cloud Monitoring. + */ + private OpenTelemetry getDefaultOpenTelemetryInstance(String projectId) throws IOException { + SdkMeterProviderBuilder sdkMeterProviderBuilder = SdkMeterProvider.builder(); + + // Filter out attributes that are not defined + for (Map.Entry entry : getAllViews().entrySet()) { + sdkMeterProviderBuilder.registerView(entry.getKey(), entry.getValue()); + } + + MetricExporter metricExporter = + GoogleCloudMetricExporter.createWithConfiguration( + MetricConfiguration.builder() + .setProjectId(projectId) + // Ignore library info as it is collected by the metric attributes as well + .setInstrumentationLibraryLabelsEnabled(false) + .build()); + sdkMeterProviderBuilder.registerMetricReader(PeriodicMetricReader.create(metricExporter)); + + return OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProviderBuilder.build()).build(); + } + + private static Map getAllViews() { + ImmutableMap.Builder views = ImmutableMap.builder(); + GAX_METRICS.forEach(metric -> defineView(views, metric, GAX_METER_NAME)); + FIRESTORE_METRICS.forEach(metric -> defineView(views, metric, FIRESTORE_METER_NAME)); + return views.build(); + } + + private static void defineView( + ImmutableMap.Builder viewMap, String id, String meter) { + InstrumentSelector selector = + InstrumentSelector.builder().setMeterName(meter).setName(METRIC_PREFIX + "/" + id).build(); + Set attributesFilter = + ImmutableSet.builder() + .addAll( + COMMON_ATTRIBUTES.stream().map(AttributeKey::getKey).collect(Collectors.toSet())) + .build(); + View view = View.builder().setAttributeFilter(attributesFilter).build(); + + viewMap.put(selector, view); + } + + private void addTracerFactory( + List apiTracerFactories, BuiltinMetricsProvider metricsProvider) { + ApiTracerFactory tracerFactory = metricsProvider.getApiTracerFactory(); + if (tracerFactory != null) { + apiTracerFactories.add(tracerFactory); + } + } + + class MetricsContext implements MetricsUtil.MetricsContext { + private final Stopwatch stopwatch; + private int counter; + protected final String methodName; + + public MetricsContext(String methodName) { + this.stopwatch = Stopwatch.createStarted(); + this.methodName = methodName; + this.counter = 0; + } + + public void recordLatencyAtFuture(MetricType metric, ApiFuture futureValue) { + ApiFutures.addCallback( + futureValue, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable t) { + recordLatency(metric, t); + } + + @Override + public void onSuccess(T result) { + recordLatency(metric); + } + }, + MoreExecutors.directExecutor()); + } + + public void recordLatency(MetricType metric) { + recordLatency(metric, StatusCode.Code.OK.toString()); + } + + public void recordLatency(MetricType metric, Throwable t) { + recordLatency(metric, extractErrorStatus(t)); + } + + private void recordLatency(MetricType metric, String status) { + double elapsedTime = stopwatch.elapsed(TimeUnit.MILLISECONDS); + Map attributes = createAttributes(status, methodName); + defaultMetricsProvider.latencyRecorder(metric, elapsedTime, attributes); + customMetricsProvider.latencyRecorder(metric, elapsedTime, attributes); + } + + public void incrementCounter() { + counter++; + } + + public void recordCounterAtFuture(MetricType metric, ApiFuture futureValue) { + ApiFutures.addCallback( + futureValue, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable t) { + recordCounter(metric, extractErrorStatus(t)); + } + + @Override + public void onSuccess(T result) { + recordCounter(metric, StatusCode.Code.OK.toString()); + } + }, + MoreExecutors.directExecutor()); + } + + private void recordCounter(MetricType metric, String status) { + Map attributes = createAttributes(status, methodName); + defaultMetricsProvider.counterRecorder( + MetricType.TRANSACTION_ATTEMPT_COUNT, (long) counter, attributes); + customMetricsProvider.counterRecorder( + MetricType.TRANSACTION_ATTEMPT_COUNT, (long) counter, attributes); + } + } + + private Map createAttributes(String status, String methodName) { + Map attributes = new HashMap<>(); + attributes.put(METRIC_ATTRIBUTE_KEY_METHOD.getKey(), methodName); + attributes.put(METRIC_ATTRIBUTE_KEY_STATUS.getKey(), status); + return attributes; + } + + private String extractErrorStatus(@Nullable Throwable throwable) { + if (!(throwable instanceof FirestoreException)) { + return StatusCode.Code.UNKNOWN.toString(); + } + + Status status = ((FirestoreException) throwable).getStatus(); + if (status == null) { + return StatusCode.Code.UNKNOWN.toString(); + } + return status.getCode().name(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java new file mode 100644 index 000000000000..863012b4e5cc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/EnabledTraceUtil.java @@ -0,0 +1,411 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutureCallback; +import com.google.api.core.ApiFutures; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.common.base.Throwables; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.OpenTelemetry; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.common.AttributesBuilder; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.SpanKind; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.api.trace.TracerProvider; +import io.opentelemetry.instrumentation.grpc.v1_6.GrpcTelemetry; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A utility class that uses OpenTelemetry for trace collection. `FirestoreOpenTelemetryOptions` in + * `FirestoreOptions` can be used to configure its behavior. + */ +@InternalApi +public class EnabledTraceUtil implements TraceUtil { + private final Tracer tracer; + private final OpenTelemetry openTelemetry; + private final FirestoreOptions firestoreOptions; + + EnabledTraceUtil(FirestoreOptions firestoreOptions) { + OpenTelemetry openTelemetry = firestoreOptions.getOpenTelemetryOptions().getOpenTelemetry(); + + // If an OpenTelemetry instance is not provided, fall back to using GlobalOpenTelemetry. + if (openTelemetry == null) { + openTelemetry = GlobalOpenTelemetry.get(); + } + + this.firestoreOptions = firestoreOptions; + this.openTelemetry = openTelemetry; + Package pkg = this.getClass().getPackage(); + if (pkg != null) { + // TODO(tracing): OpenTelemetry is currently missing the API for adding scope attributes in + // Java. We should add `gcp.client.service` as scope attributes once + // https://github.com/open-telemetry/opentelemetry-java/issues/4695 is resolved. + this.tracer = openTelemetry.getTracer(LIBRARY_NAME, pkg.getImplementationVersion()); + } else { + this.tracer = openTelemetry.getTracer(LIBRARY_NAME); + } + } + + public OpenTelemetry getOpenTelemetry() { + return openTelemetry; + } + + // The gRPC channel configurator that intercepts gRPC calls for tracing purposes. + public class OpenTelemetryGrpcChannelConfigurator + implements ApiFunction { + @Override + public ManagedChannelBuilder apply(ManagedChannelBuilder managedChannelBuilder) { + GrpcTelemetry grpcTelemetry = GrpcTelemetry.create(getOpenTelemetry()); + return managedChannelBuilder.intercept(grpcTelemetry.newClientInterceptor()); + } + } + + @Override + @Nullable + public ApiFunction getChannelConfigurator() { + // Note: using `==` rather than `.equals` since OpenTelemetry has only 1 static instance of + // `TracerProvider.noop`. + if (openTelemetry.getTracerProvider() == TracerProvider.noop()) { + return null; + } + return new OpenTelemetryGrpcChannelConfigurator(); + } + + // Returns a JSON String representation of the given duration. The JSON representation for a + // Duration is a String that + // ends in `s` to indicate seconds and is preceded by the number of seconds, with nanoseconds + // expressed as fractional + // seconds. + String durationString(java.time.Duration duration) { + int nanos = duration.getNano(); + long seconds = duration.getSeconds(); + int numLeadingZeros = 9; + + double nanosFraction = nanos; + while (nanosFraction >= 1) { + nanosFraction = nanosFraction / 10; + numLeadingZeros--; + } + + // If seconds=1 and nanos=0, we don't show 1.000000000s. We want to show 1.0s. + if (numLeadingZeros == 9) { + numLeadingZeros = 0; + } + + // Get rid of trailing zeros. + while (nanos > 0 && nanos % 10 == 0) { + nanos = nanos / 10; + } + + StringBuilder stringBuilder = new StringBuilder().append(seconds).append("."); + for (int i = 0; i < numLeadingZeros; ++i) { + stringBuilder.append("0"); + } + stringBuilder.append(nanos).append("s"); + + return stringBuilder.toString(); + } + + static class Span implements TraceUtil.Span { + private final io.opentelemetry.api.trace.Span span; + private final String spanName; + + public Span(io.opentelemetry.api.trace.Span span, String spanName) { + this.span = span; + this.spanName = spanName; + } + + /** Ends this span. */ + @Override + public void end() { + span.end(); + } + + /** Ends this span in an error. */ + @Override + public void end(Throwable error) { + span.setStatus(StatusCode.ERROR, error.getMessage()); + span.recordException( + error, + Attributes.builder() + .put("exception.message", error.getMessage()) + .put("exception.type", error.getClass().getName()) + .put("exception.stacktrace", Throwables.getStackTraceAsString(error)) + .build()); + span.end(); + } + + /** + * If an operation ends in the future, its relevant span should end _after_ the future has been + * completed. This method "appends" the span completion code at the completion of the given + * future. In order for telemetry info to be recorded, the future returned by this method should + * be completed. + */ + @Override + public void endAtFuture(ApiFuture futureValue) { + io.opentelemetry.context.Context asyncContext = io.opentelemetry.context.Context.current(); + ApiFutures.addCallback( + futureValue, + new ApiFutureCallback() { + @Override + public void onFailure(Throwable t) { + try (io.opentelemetry.context.Scope scope = asyncContext.makeCurrent()) { + span.addEvent(spanName + " failed."); + end(t); + } + } + + @Override + public void onSuccess(T result) { + try (io.opentelemetry.context.Scope scope = asyncContext.makeCurrent()) { + span.addEvent(spanName + " succeeded."); + end(); + } + } + }); + } + + /** Adds the given event to this span. */ + @Override + public TraceUtil.Span addEvent(String name) { + span.addEvent(name); + return this; + } + + @Override + public TraceUtil.Span addEvent(String name, Map attributes) { + AttributesBuilder attributesBuilder = Attributes.builder(); + attributes.forEach( + (key, value) -> { + if (value instanceof Integer) { + attributesBuilder.put(key, (int) value); + } else if (value instanceof Long) { + attributesBuilder.put(key, (long) value); + } else if (value instanceof Double) { + attributesBuilder.put(key, (double) value); + } else if (value instanceof Float) { + attributesBuilder.put(key, (float) value); + } else if (value instanceof Boolean) { + attributesBuilder.put(key, (boolean) value); + } else if (value instanceof String) { + attributesBuilder.put(key, (String) value); + } else { + // OpenTelemetry APIs do not support any other type. + throw new IllegalArgumentException( + "Unknown attribute type:" + value.getClass().getSimpleName()); + } + }); + span.addEvent(name, attributesBuilder.build()); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, int value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, String value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public TraceUtil.Span setAttribute(String key, boolean value) { + span.setAttribute(ATTRIBUTE_SERVICE_PREFIX + key, value); + return this; + } + + @Override + public Scope makeCurrent() { + return new Scope(span.makeCurrent()); + } + } + + static class Scope implements TraceUtil.Scope { + private final io.opentelemetry.context.Scope scope; + + Scope(io.opentelemetry.context.Scope scope) { + this.scope = scope; + } + + @Override + public void close() { + scope.close(); + } + } + + static class Context implements TraceUtil.Context { + private final io.opentelemetry.context.Context context; + + Context(io.opentelemetry.context.Context context) { + this.context = context; + } + + @Override + public Scope makeCurrent() { + return new Scope(context.makeCurrent()); + } + } + + /** Applies the current Firestore instance settings as attributes to the current Span */ + private SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder) { + // TODO(tracing): OpenTelemetry is currently missing the API for adding scope attributes in + // Java. We are instead adding `gcp.client.service` as span attributes here. + // We should remove this span attribute once + // https://github.com/open-telemetry/opentelemetry-java/issues/4695 is resolved. + spanBuilder = spanBuilder.setAttribute("gcp.client.service", "Firestore"); + + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_GCP_RESOURCE_NAME, + String.format( + ATTRIBUTE_GCP_RESOURCE_NAME_FORMAT, + firestoreOptions.getProjectId(), + firestoreOptions.getDatabaseId())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.project_id", + firestoreOptions.getProjectId()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.database_id", + firestoreOptions.getDatabaseId()) + .put(ATTRIBUTE_SERVICE_PREFIX + "settings.host", firestoreOptions.getHost()) + .build()); + + if (firestoreOptions.getTransportChannelProvider() != null) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.channel.transport_name", + firestoreOptions.getTransportChannelProvider().getTransportName()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.channel.needs_credentials", + String.valueOf( + firestoreOptions.getTransportChannelProvider().needsCredentials())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.channel.needs_endpoint", + String.valueOf( + firestoreOptions.getTransportChannelProvider().needsEndpoint())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.channel.needs_headers", + String.valueOf(firestoreOptions.getTransportChannelProvider().needsHeaders())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.channel.should_auto_close", + String.valueOf( + firestoreOptions.getTransportChannelProvider().shouldAutoClose())) + .build()); + } + + if (firestoreOptions.getCredentials() != null) { + spanBuilder = + spanBuilder.setAttribute( + ATTRIBUTE_SERVICE_PREFIX + "settings.credentials.authentication_type", + firestoreOptions.getCredentials().getAuthenticationType()); + } + + if (firestoreOptions.getRetrySettings() != null) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.initial_retry_delay", + durationString( + firestoreOptions.getRetrySettings().getInitialRetryDelayDuration())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.max_retry_delay", + durationString( + firestoreOptions.getRetrySettings().getMaxRetryDelayDuration())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.retry_delay_multiplier", + String.valueOf(firestoreOptions.getRetrySettings().getRetryDelayMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.max_attempts", + String.valueOf(firestoreOptions.getRetrySettings().getMaxAttempts())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.initial_rpc_timeout", + durationString( + firestoreOptions.getRetrySettings().getInitialRpcTimeoutDuration())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.max_rpc_timeout", + durationString( + firestoreOptions.getRetrySettings().getMaxRpcTimeoutDuration())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.rpc_timeout_multiplier", + String.valueOf(firestoreOptions.getRetrySettings().getRpcTimeoutMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retry_settings.total_timeout", + durationString(firestoreOptions.getRetrySettings().getTotalTimeoutDuration())) + .build()); + } + + // Add the memory utilization of the client at the time this trace was collected. + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + double memoryUtilization = ((double) (totalMemory - freeMemory)) / totalMemory; + spanBuilder.setAttribute( + ATTRIBUTE_SERVICE_PREFIX + "memory_utilization", + String.format("%.2f", memoryUtilization * 100) + "%"); + + return spanBuilder; + } + + @Override + public Span startSpan(String spanName) { + SpanBuilder spanBuilder = tracer.spanBuilder(spanName).setSpanKind(SpanKind.PRODUCER); + io.opentelemetry.api.trace.Span span = + addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(); + return new Span(span, spanName); + } + + @Override + public TraceUtil.Span startSpan(String spanName, TraceUtil.Context parent) { + assert (parent instanceof EnabledTraceUtil.Context); + SpanBuilder spanBuilder = + tracer + .spanBuilder(spanName) + .setSpanKind(SpanKind.PRODUCER) + .setParent(((EnabledTraceUtil.Context) parent).context); + io.opentelemetry.api.trace.Span span = + addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(); + return new Span(span, spanName); + } + + @Nonnull + @Override + public TraceUtil.Span currentSpan() { + return new Span(io.opentelemetry.api.trace.Span.current(), ""); + } + + @Nonnull + @Override + public TraceUtil.Context currentContext() { + return new Context(io.opentelemetry.context.Context.current()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/MetricsUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/MetricsUtil.java new file mode 100644 index 000000000000..02ac3a26be97 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/MetricsUtil.java @@ -0,0 +1,119 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.api.gax.tracing.ApiTracerFactory; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.telemetry.TelemetryConstants.MetricType; +import java.util.List; +import java.util.logging.Logger; +import javax.annotation.Nonnull; + +/** + * A utility interface for metrics collection. Classes that implement this interface may make their + * own design choices for how they approach metrics collection. For instance, they may be no-op, or + * they may use a particular metrics framework such as OpenTelemetry. + */ +@InternalApi +public interface MetricsUtil { + final Logger logger = Logger.getLogger(MetricsUtil.class.getName()); + + static final String ENABLE_METRICS_ENV_VAR = "FIRESTORE_ENABLE_METRICS"; + + /** + * Creates an instance of {@code MetricsUtil}. If the environment variable + * `FIRESTORE_ENABLE_METRICS` is set to false or off, an instance of {@link DisabledMetricsUtil} + * will be returned. Otherwise, an instance of {@link EnabledMetricsUtil} will be returned. + * + * @param firestoreOptions The Firestore options that configures client side metrics. + * @return An instance of {@code MetricsUtil}. + */ + static MetricsUtil getInstance(@Nonnull FirestoreOptions firestoreOptions) { + if (shouldCreateEnabledInstance()) { + return new EnabledMetricsUtil(firestoreOptions); + } else { + return new DisabledMetricsUtil(); + } + } + + static boolean shouldCreateEnabledInstance() { + // Client side metrics feature is default on unless it is manually turned off by + // environment variables + // TODO(metrics): The feature is disabled before it is ready for general release. + boolean shouldCreateEnabledInstance = false; + + String enableMetricsEnvVar = System.getenv(ENABLE_METRICS_ENV_VAR); + if (enableMetricsEnvVar != null) { + switch (enableMetricsEnvVar.toLowerCase()) { + case "true": + case "on": + // The feature is default on. + break; + case "false": + case "off": + shouldCreateEnabledInstance = false; + break; + default: + logger.warning("Invalid value for FIRESTORE_ENABLE_METRICS: " + enableMetricsEnvVar); + } + } + + return shouldCreateEnabledInstance; + } + + /** + * Creates a new {@code MetricsContext} for the given method and starts timing. + * + * @param methodName The name of the method. + * @return A new {@code MetricsContext}. + */ + abstract MetricsContext createMetricsContext(String methodName); + + /** + * Adds a metrics tracer factory to the given list of API tracer factories. + * + * @param apiTracerFactories The list of API tracer factories. + */ + abstract void addMetricsTracerFactory(List apiTracerFactories); + + /** A context for recording metrics in the Firestore SDK. */ + interface MetricsContext { + /** + * If the operation ends in the future, its relevant metrics should be recorded _after_ the + * future has been completed. This method "appends" the metrics recording code at the completion + * of the given future. + */ + void recordLatencyAtFuture(MetricType metric, ApiFuture futureValue); + + /** Records specific type of latency for the current operation. */ + void recordLatency(MetricType metric); + + /** Records specific type of latency for the current operation, which ended with a throwable. */ + void recordLatency(MetricType metric, Throwable t); + + /** + * Records the counter value for a metric type _after_ the future has been completed. This + * method "appends" the metrics recording code at the completion of the given future. + */ + void recordCounterAtFuture(MetricType metric, ApiFuture futureValue); + + /** Increments the counter tracked inside the MetricsContext. */ + void incrementCounter(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TelemetryConstants.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TelemetryConstants.java new file mode 100644 index 000000000000..f97dbfc719f2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TelemetryConstants.java @@ -0,0 +1,127 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.InternalApi; +import com.google.api.gax.tracing.OpenTelemetryMetricsRecorder; +import com.google.common.collect.ImmutableSet; +import io.opentelemetry.api.common.AttributeKey; +import java.util.Set; + +/** Constants used for telemetry in the Firestore SDK. */ +@InternalApi +public interface TelemetryConstants { + // Method names for Firestore operations + String METHOD_NAME_DOC_REF_CREATE = "DocumentReference.Create"; + String METHOD_NAME_DOC_REF_SET = "DocumentReference.Set"; + String METHOD_NAME_DOC_REF_UPDATE = "DocumentReference.Update"; + String METHOD_NAME_DOC_REF_DELETE = "DocumentReference.Delete"; + String METHOD_NAME_DOC_REF_GET = "DocumentReference.Get"; + String METHOD_NAME_DOC_REF_LIST_COLLECTIONS = "DocumentReference.ListCollections"; + String METHOD_NAME_COL_REF_ADD = "CollectionReference.Add"; + String METHOD_NAME_COL_REF_LIST_DOCUMENTS = "CollectionReference.ListDocuments"; + String METHOD_NAME_QUERY_GET = "Query.Get"; + String METHOD_NAME_AGGREGATION_QUERY_GET = "AggregationQuery.Get"; + String METHOD_NAME_RUN_QUERY = "RunQuery"; + String METHOD_NAME_RUN_QUERY_EXPLAIN = "RunQuery.Explain"; + String METHOD_NAME_RUN_QUERY_GET = "RunQuery.Get"; + String METHOD_NAME_RUN_QUERY_TRANSACTIONAL = "RunQuery.Transactional"; + String METHOD_NAME_RUN_AGGREGATION_QUERY = "RunAggregationQuery"; + String METHOD_NAME_RUN_AGGREGATION_QUERY_EXPLAIN = "RunAggregationQuery.Explain"; + String METHOD_NAME_RUN_AGGREGATION_QUERY_GET = "RunAggregationQuery.Get"; + String METHOD_NAME_RUN_AGGREGATION_QUERY_TRANSACTIONAL = "RunAggregationQuery.Transactional"; + String METHOD_NAME_BATCH_GET_DOCUMENTS = "BatchGetDocuments"; + String METHOD_NAME_BATCH_GET_DOCUMENTS_GET_ALL = "BatchGetDocuments.GetAll"; + String METHOD_NAME_BATCH_GET_DOCUMENTS_TRANSACTIONAL = "BatchGetDocuments.Transactional"; + String METHOD_NAME_TRANSACTION_RUN = "Transaction.Run"; + String METHOD_NAME_TRANSACTION_BEGIN = "Transaction.Begin"; + String METHOD_NAME_TRANSACTION_GET_QUERY = "Transaction.Get.Query"; + String METHOD_NAME_TRANSACTION_GET_AGGREGATION_QUERY = "Transaction.Get.AggregationQuery"; + String METHOD_NAME_TRANSACTION_GET_DOCUMENT = "Transaction.Get.Document"; + String METHOD_NAME_TRANSACTION_GET_DOCUMENTS = "Transaction.Get.Documents"; + String METHOD_NAME_TRANSACTION_ROLLBACK = "Transaction.Rollback"; + String METHOD_NAME_BATCH_COMMIT = "Batch.Commit"; + String METHOD_NAME_TRANSACTION_COMMIT = "Transaction.Commit"; + String METHOD_NAME_PARTITION_QUERY = "PartitionQuery"; + String METHOD_NAME_BULK_WRITER_COMMIT = "BulkWriter.Commit"; + String METHOD_NAME_RUN_TRANSACTION = "RunTransaction"; + String METHOD_NAME_PIPELINE_EXECUTE = "Pipeline.Execute"; + String METHOD_NAME_EXECUTE_PIPELINE = "ExecutePipeline"; + String METHOD_NAME_EXECUTE_PIPELINE_EXECUTE = "ExecutePipeline.Execute"; + + // OpenTelemetry built-in metrics constants + String FIRESTORE_RESOURCE_TYPE = "firestore_client_raw"; + // TODO(metrics): change to firestore.googleapis.com + String METRIC_PREFIX = "custom.googleapis.com/internal/client"; + String FIRESTORE_METER_NAME = "java_firestore"; + String GAX_METER_NAME = OpenTelemetryMetricsRecorder.GAX_METER_NAME; + + // Monitored resource keys for labels + String RESOURCE_KEY_RESOURCE_CONTAINER = "resource_container"; + String RESOURCE_KEY_LOCATION = "location"; + String RESOURCE_KEY_DATABASE_ID = "database_id"; + Set FIRESTORE_RESOURCE_LABELS = + ImmutableSet.of( + RESOURCE_KEY_RESOURCE_CONTAINER, RESOURCE_KEY_LOCATION, RESOURCE_KEY_DATABASE_ID); + + // Metric attribute keys for labels + AttributeKey METRIC_ATTRIBUTE_KEY_METHOD = AttributeKey.stringKey("method"); + AttributeKey METRIC_ATTRIBUTE_KEY_STATUS = AttributeKey.stringKey("status"); + AttributeKey METRIC_ATTRIBUTE_KEY_LIBRARY_NAME = AttributeKey.stringKey("library_name"); + AttributeKey METRIC_ATTRIBUTE_KEY_LIBRARY_VERSION = + AttributeKey.stringKey("library_version"); + AttributeKey METRIC_ATTRIBUTE_KEY_CLIENT_UID = AttributeKey.stringKey("client_uid"); + Set COMMON_ATTRIBUTES = + ImmutableSet.of( + METRIC_ATTRIBUTE_KEY_CLIENT_UID, + METRIC_ATTRIBUTE_KEY_LIBRARY_NAME, + METRIC_ATTRIBUTE_KEY_LIBRARY_VERSION, + METRIC_ATTRIBUTE_KEY_STATUS, + METRIC_ATTRIBUTE_KEY_METHOD); + + // Metric names + String METRIC_NAME_OPERATION_LATENCY = "operation_latency"; + String METRIC_NAME_OPERATION_COUNT = "operation_count"; + String METRIC_NAME_ATTEMPT_LATENCY = "attempt_latency"; + String METRIC_NAME_ATTEMPT_COUNT = "attempt_count"; + String METRIC_NAME_FIRST_RESPONSE_LATENCY = "first_response_latency"; + String METRIC_NAME_END_TO_END_LATENCY = "end_to_end_latency"; + String METRIC_NAME_TRANSACTION_LATENCY = "transaction_latency"; + String METRIC_NAME_TRANSACTION_ATTEMPT_COUNT = "transaction_attempt_count"; + + // Metrics collected on GAX and Firestore SDK layer + Set GAX_METRICS = + ImmutableSet.of( + METRIC_NAME_OPERATION_LATENCY, + METRIC_NAME_ATTEMPT_LATENCY, + METRIC_NAME_OPERATION_COUNT, + METRIC_NAME_ATTEMPT_COUNT); + + Set FIRESTORE_METRICS = + ImmutableSet.of( + METRIC_NAME_FIRST_RESPONSE_LATENCY, + METRIC_NAME_END_TO_END_LATENCY, + METRIC_NAME_TRANSACTION_LATENCY, + METRIC_NAME_TRANSACTION_ATTEMPT_COUNT); + + public enum MetricType { + END_TO_END_LATENCY, + FIRST_RESPONSE_LATENCY, + TRANSACTION_LATENCY, + TRANSACTION_ATTEMPT_COUNT + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TraceUtil.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TraceUtil.java new file mode 100644 index 000000000000..2b84cfe5ab0d --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/telemetry/TraceUtil.java @@ -0,0 +1,147 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.cloud.firestore.FirestoreOptions; +import io.grpc.ManagedChannelBuilder; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * A utility interface for trace collection. Classes that implement this interface may make their + * own design choices for how they approach trace collection. For instance, they may be no-op, or + * they may use a particular tracing framework such as OpenTelemetry. + */ +public interface TraceUtil { + String ATTRIBUTE_SERVICE_PREFIX = "gcp.firestore."; + String ATTRIBUTE_KEY_ATTEMPT = "attempt"; + String ATTRIBUTE_KEY_DOC_COUNT = "doc_count"; + String ATTRIBUTE_KEY_IS_TRANSACTIONAL = "transactional"; + String ATTRIBUTE_KEY_NUM_RESPONSES = "response_count"; + String ATTRIBUTE_KEY_IS_RETRY_WITH_CURSOR = "retry_query_with_cursor"; + String ATTRIBUTE_KEY_TRANSACTION_TYPE = "transaction_type"; + String ATTRIBUTE_KEY_ATTEMPTS_ALLOWED = "attempts_allowed"; + String ATTRIBUTE_KEY_ATTEMPTS_REMAINING = "attempts_remaining"; + String ATTRIBUTE_GCP_RESOURCE_NAME = "gcp.resource.name"; + String ATTRIBUTE_GCP_RESOURCE_NAME_FORMAT = "//firestore.googleapis.com/projects/%s/databases/%s"; + + String ENABLE_TRACING_ENV_VAR = "FIRESTORE_ENABLE_TRACING"; + String LIBRARY_NAME = "com.google.cloud.firestore"; + + /** + * Creates and returns an instance of the TraceUtil class. + * + * @param firestoreOptions The FirestoreOptions object that is requesting an instance of + * TraceUtil. + * @return An instance of the TraceUtil class. + */ + @InternalApi + static TraceUtil getInstance(@Nonnull FirestoreOptions firestoreOptions) { + boolean createEnabledInstance = true; + + // The environment variable can override options to enable/disable telemetry collection. + String enableTracingEnvVar = System.getenv(ENABLE_TRACING_ENV_VAR); + if (enableTracingEnvVar != null) { + if (enableTracingEnvVar.equalsIgnoreCase("true") + || enableTracingEnvVar.equalsIgnoreCase("on")) { + createEnabledInstance = true; + } + if (enableTracingEnvVar.equalsIgnoreCase("false") + || enableTracingEnvVar.equalsIgnoreCase("off")) { + createEnabledInstance = false; + } + } + + if (createEnabledInstance) { + return new EnabledTraceUtil(firestoreOptions); + } else { + return new DisabledTraceUtil(); + } + } + + /** Returns a channel configurator for gRPC, or {@code null} if tracing is disabled. */ + @Nullable + ApiFunction getChannelConfigurator(); + + /** Represents a trace span. */ + interface Span { + /** Adds the given event to this span. */ + Span addEvent(String name); + + /** Adds the given event with the given attributes to this span. */ + Span addEvent(String name, Map attributes); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, int value); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, String value); + + /** Adds the given attribute to this span. */ + Span setAttribute(String key, boolean value); + + /** Marks this span as the current span. */ + Scope makeCurrent(); + + /** Ends this span. */ + void end(); + + /** Ends this span in an error. */ + void end(Throwable error); + + /** + * If an operation ends in the future, its relevant span should end _after_ the future has been + * completed. This method "appends" the span completion code at the completion of the given + * future. In order for telemetry info to be recorded, the future returned by this method should + * be completed. + */ + void endAtFuture(ApiFuture futureValue); + } + + /** Represents a trace context. */ + interface Context { + /** Makes this context the current context. */ + Scope makeCurrent(); + } + + /** Represents a trace scope. */ + interface Scope extends AutoCloseable { + /** Closes the current scope. */ + void close(); + } + + /** Starts a new span with the given name, sets it as the current span, and returns it. */ + Span startSpan(String spanName); + + /** + * Starts a new span with the given name and the given context as its parent, sets it as the + * current span, and returns it. + */ + Span startSpan(String spanName, Context parent); + + /** Returns the current span. */ + @Nonnull + Span currentSpan(); + + /** Returns the current Context. */ + @Nonnull + Context currentContext(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java new file mode 100644 index 000000000000..5d5b40fac124 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreClient.java @@ -0,0 +1,1917 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.paging.AbstractFixedSizeCollection; +import com.google.api.gax.paging.AbstractPage; +import com.google.api.gax.paging.AbstractPagedListResponse; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.v1.stub.FirestoreStub; +import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.Write; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: The Cloud Firestore service. + * + *

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

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

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+ *   GetDocumentRequest request =
+ *       GetDocumentRequest.newBuilder()
+ *           .setName("name3373707")
+ *           .setMask(DocumentMask.newBuilder().build())
+ *           .build();
+ *   Document response = firestoreClient.getDocument(request);
+ * }
+ * }
+ * + *

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

GetDocument

Gets a single document.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • getDocument(GetDocumentRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • getDocumentCallable() + *

+ *

ListDocuments

Lists documents.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listDocuments(ListDocumentsRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listDocumentsPagedCallable() + *

  • listDocumentsCallable() + *

+ *

UpdateDocument

Updates or inserts a document.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • updateDocument(UpdateDocumentRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • updateDocument(Document document, DocumentMask updateMask) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • updateDocumentCallable() + *

+ *

DeleteDocument

Deletes a document.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • deleteDocument(DeleteDocumentRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • deleteDocument(String name) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • deleteDocumentCallable() + *

+ *

BatchGetDocuments

Gets multiple documents. + *

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

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • batchGetDocumentsCallable() + *

+ *

BeginTransaction

Starts a new transaction.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • beginTransaction(BeginTransactionRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • beginTransaction(String database) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • beginTransactionCallable() + *

+ *

Commit

Commits a transaction, while optionally updating documents.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • commit(CommitRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • commit(String database, List<Write> writes) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • commitCallable() + *

+ *

Rollback

Rolls back a transaction.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • rollback(RollbackRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • rollback(String database, ByteString transaction) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • rollbackCallable() + *

+ *

RunQuery

Runs a query.

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • runQueryCallable() + *

+ *

ExecutePipeline

Executes a pipeline query.

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • executePipelineCallable() + *

+ *

RunAggregationQuery

Runs an aggregation query. + *

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

High-Level Example: + *

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

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • runAggregationQueryCallable() + *

+ *

PartitionQuery

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

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • partitionQuery(PartitionQueryRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • partitionQueryPagedCallable() + *

  • partitionQueryCallable() + *

+ *

Write

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

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • writeCallable() + *

+ *

Listen

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

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listenCallable() + *

+ *

ListCollectionIds

Lists all the collection IDs underneath a document.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • listCollectionIds(ListCollectionIdsRequest request) + *

+ *

"Flattened" method variants have converted the fields of the request object into function parameters to enable multiple ways to call the same method.

+ *
    + *
  • listCollectionIds(String parent) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • listCollectionIdsPagedCallable() + *

  • listCollectionIdsCallable() + *

+ *

BatchWrite

Applies a batch of write operations. + *

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

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

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • batchWrite(BatchWriteRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • batchWriteCallable() + *

+ *

CreateDocument

Creates a new document.

+ *

Request object method variants only take one parameter, a request object, which must be constructed before the call.

+ *
    + *
  • createDocument(CreateDocumentRequest request) + *

+ *

Callable method variants take no parameters and return an immutable API callable object, which can be used to initiate calls to the service.

+ *
    + *
  • createDocumentCallable() + *

+ *
+ * + *

See the individual methods for example code. + * + *

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

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

To customize credentials: + * + *

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

To customize the endpoint: + * + *

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

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

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

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class FirestoreClient implements BackgroundResource { + private final FirestoreSettings settings; + private final FirestoreStub stub; + + /** Constructs an instance of FirestoreClient with default settings. */ + public static final FirestoreClient create() throws IOException { + return create(FirestoreSettings.newBuilder().build()); + } + + /** + * Constructs an instance of FirestoreClient, using the given settings. The channels are created + * based on the settings passed in, or defaults for any settings that are not set. + */ + public static final FirestoreClient create(FirestoreSettings settings) throws IOException { + return new FirestoreClient(settings); + } + + /** + * Constructs an instance of FirestoreClient, using the given stub for making calls. This is for + * advanced usage - prefer using create(FirestoreSettings). + */ + public static final FirestoreClient create(FirestoreStub stub) { + return new FirestoreClient(stub); + } + + /** + * Constructs an instance of FirestoreClient, using the given settings. This is protected so that + * it is easy to make a subclass, but otherwise, the static factory methods should be preferred. + */ + protected FirestoreClient(FirestoreSettings settings) throws IOException { + this.settings = settings; + this.stub = ((FirestoreStubSettings) settings.getStubSettings()).createStub(); + } + + protected FirestoreClient(FirestoreStub stub) { + this.settings = null; + this.stub = stub; + } + + public final FirestoreSettings getSettings() { + return settings; + } + + public FirestoreStub getStub() { + return stub; + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a single document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   GetDocumentRequest request =
+   *       GetDocumentRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .build();
+   *   Document response = firestoreClient.getDocument(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Document getDocument(GetDocumentRequest request) { + return getDocumentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets a single document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   GetDocumentRequest request =
+   *       GetDocumentRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreClient.getDocumentCallable().futureCall(request);
+   *   // Do something.
+   *   Document response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getDocumentCallable() { + return stub.getDocumentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists documents. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListDocumentsRequest request =
+   *       ListDocumentsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setCollectionId("collectionId1636075609")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .setShowMissing(true)
+   *           .build();
+   *   for (Document element : firestoreClient.listDocuments(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListDocumentsPagedResponse listDocuments(ListDocumentsRequest request) { + return listDocumentsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists documents. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListDocumentsRequest request =
+   *       ListDocumentsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setCollectionId("collectionId1636075609")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .setShowMissing(true)
+   *           .build();
+   *   ApiFuture future = firestoreClient.listDocumentsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Document element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listDocumentsPagedCallable() { + return stub.listDocumentsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists documents. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListDocumentsRequest request =
+   *       ListDocumentsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setCollectionId("collectionId1636075609")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .setOrderBy("orderBy-1207110587")
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .setShowMissing(true)
+   *           .build();
+   *   while (true) {
+   *     ListDocumentsResponse response = firestoreClient.listDocumentsCallable().call(request);
+   *     for (Document element : response.getDocumentsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable listDocumentsCallable() { + return stub.listDocumentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates or inserts a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   Document document = Document.newBuilder().build();
+   *   DocumentMask updateMask = DocumentMask.newBuilder().build();
+   *   Document response = firestoreClient.updateDocument(document, updateMask);
+   * }
+   * }
+ * + * @param document Required. The updated document. Creates the document if it does not already + * exist. + * @param updateMask The fields to update. None of the field paths in the mask may contain a + * reserved name. + *

If the document exists on the server and has fields not referenced in the mask, they are + * left unchanged. Fields referenced in the mask, but not present in the input document, are + * deleted from the document on the server. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Document updateDocument(Document document, DocumentMask updateMask) { + UpdateDocumentRequest request = + UpdateDocumentRequest.newBuilder().setDocument(document).setUpdateMask(updateMask).build(); + return updateDocument(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates or inserts a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   UpdateDocumentRequest request =
+   *       UpdateDocumentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setUpdateMask(DocumentMask.newBuilder().build())
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .setCurrentDocument(Precondition.newBuilder().build())
+   *           .build();
+   *   Document response = firestoreClient.updateDocument(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Document updateDocument(UpdateDocumentRequest request) { + return updateDocumentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates or inserts a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   UpdateDocumentRequest request =
+   *       UpdateDocumentRequest.newBuilder()
+   *           .setDocument(Document.newBuilder().build())
+   *           .setUpdateMask(DocumentMask.newBuilder().build())
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .setCurrentDocument(Precondition.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreClient.updateDocumentCallable().futureCall(request);
+   *   // Do something.
+   *   Document response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable updateDocumentCallable() { + return stub.updateDocumentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   String name = "name3373707";
+   *   firestoreClient.deleteDocument(name);
+   * }
+   * }
+ * + * @param name Required. The resource name of the Document to delete. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteDocument(String name) { + DeleteDocumentRequest request = DeleteDocumentRequest.newBuilder().setName(name).build(); + deleteDocument(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   DeleteDocumentRequest request =
+   *       DeleteDocumentRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setCurrentDocument(Precondition.newBuilder().build())
+   *           .build();
+   *   firestoreClient.deleteDocument(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteDocument(DeleteDocumentRequest request) { + deleteDocumentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   DeleteDocumentRequest request =
+   *       DeleteDocumentRequest.newBuilder()
+   *           .setName("name3373707")
+   *           .setCurrentDocument(Precondition.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreClient.deleteDocumentCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteDocumentCallable() { + return stub.deleteDocumentCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets multiple documents. + * + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BatchGetDocumentsRequest request =
+   *       BatchGetDocumentsRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .addAllDocuments(new ArrayList())
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .build();
+   *   ServerStream stream =
+   *       firestoreClient.batchGetDocumentsCallable().call(request);
+   *   for (BatchGetDocumentsResponse response : stream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final ServerStreamingCallable + batchGetDocumentsCallable() { + return stub.batchGetDocumentsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts a new transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   String database = "database1789464955";
+   *   BeginTransactionResponse response = firestoreClient.beginTransaction(database);
+   * }
+   * }
+ * + * @param database Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BeginTransactionResponse beginTransaction(String database) { + BeginTransactionRequest request = + BeginTransactionRequest.newBuilder().setDatabase(database).build(); + return beginTransaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts a new transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BeginTransactionRequest request =
+   *       BeginTransactionRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .setOptions(TransactionOptions.newBuilder().build())
+   *           .build();
+   *   BeginTransactionResponse response = firestoreClient.beginTransaction(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BeginTransactionResponse beginTransaction(BeginTransactionRequest request) { + return beginTransactionCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Starts a new transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BeginTransactionRequest request =
+   *       BeginTransactionRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .setOptions(TransactionOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreClient.beginTransactionCallable().futureCall(request);
+   *   // Do something.
+   *   BeginTransactionResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + beginTransactionCallable() { + return stub.beginTransactionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Commits a transaction, while optionally updating documents. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   String database = "database1789464955";
+   *   List writes = new ArrayList<>();
+   *   CommitResponse response = firestoreClient.commit(database, writes);
+   * }
+   * }
+ * + * @param database Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param writes The writes to apply. + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   CommitRequest request =
+   *       CommitRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .addAllWrites(new ArrayList())
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   CommitResponse response = firestoreClient.commit(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CommitResponse commit(CommitRequest request) { + return commitCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Commits a transaction, while optionally updating documents. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   CommitRequest request =
+   *       CommitRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .addAllWrites(new ArrayList())
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   ApiFuture future = firestoreClient.commitCallable().futureCall(request);
+   *   // Do something.
+   *   CommitResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable commitCallable() { + return stub.commitCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Rolls back a transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   String database = "database1789464955";
+   *   ByteString transaction = ByteString.EMPTY;
+   *   firestoreClient.rollback(database, transaction);
+   * }
+   * }
+ * + * @param database Required. The database name. In the format: + * `projects/{project_id}/databases/{database_id}`. + * @param transaction Required. The transaction to roll back. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void rollback(String database, ByteString transaction) { + RollbackRequest request = + RollbackRequest.newBuilder().setDatabase(database).setTransaction(transaction).build(); + rollback(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Rolls back a transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   RollbackRequest request =
+   *       RollbackRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   firestoreClient.rollback(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void rollback(RollbackRequest request) { + rollbackCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Rolls back a transaction. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   RollbackRequest request =
+   *       RollbackRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   ApiFuture future = firestoreClient.rollbackCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable rollbackCallable() { + return stub.rollbackCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Runs a query. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   RunQueryRequest request =
+   *       RunQueryRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   ServerStream stream = firestoreClient.runQueryCallable().call(request);
+   *   for (RunQueryResponse response : stream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final ServerStreamingCallable runQueryCallable() { + return stub.runQueryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Executes a pipeline query. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ExecutePipelineRequest request =
+   *       ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build();
+   *   ServerStream stream =
+   *       firestoreClient.executePipelineCallable().call(request);
+   *   for (ExecutePipelineResponse response : stream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final ServerStreamingCallable + executePipelineCallable() { + return stub.executePipelineCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Runs an aggregation query. + * + *

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

High-Level Example: + * + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   RunAggregationQueryRequest request =
+   *       RunAggregationQueryRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   ServerStream stream =
+   *       firestoreClient.runAggregationQueryCallable().call(request);
+   *   for (RunAggregationQueryResponse response : stream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final ServerStreamingCallable + runAggregationQueryCallable() { + return stub.runAggregationQueryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Partitions a query by returning partition cursors that can be used to run the query in + * parallel. The returned partition cursors are split points that can be used by RunQuery as + * starting/end points for the query results. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   PartitionQueryRequest request =
+   *       PartitionQueryRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPartitionCount(-1738969222)
+   *           .setPageToken("pageToken873572522")
+   *           .setPageSize(883849137)
+   *           .build();
+   *   for (Cursor element : firestoreClient.partitionQuery(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final PartitionQueryPagedResponse partitionQuery(PartitionQueryRequest request) { + return partitionQueryPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Partitions a query by returning partition cursors that can be used to run the query in + * parallel. The returned partition cursors are split points that can be used by RunQuery as + * starting/end points for the query results. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   PartitionQueryRequest request =
+   *       PartitionQueryRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPartitionCount(-1738969222)
+   *           .setPageToken("pageToken873572522")
+   *           .setPageSize(883849137)
+   *           .build();
+   *   ApiFuture future = firestoreClient.partitionQueryPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (Cursor element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + partitionQueryPagedCallable() { + return stub.partitionQueryPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Partitions a query by returning partition cursors that can be used to run the query in + * parallel. The returned partition cursors are split points that can be used by RunQuery as + * starting/end points for the query results. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   PartitionQueryRequest request =
+   *       PartitionQueryRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPartitionCount(-1738969222)
+   *           .setPageToken("pageToken873572522")
+   *           .setPageSize(883849137)
+   *           .build();
+   *   while (true) {
+   *     PartitionQueryResponse response = firestoreClient.partitionQueryCallable().call(request);
+   *     for (Cursor element : response.getPartitionsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + partitionQueryCallable() { + return stub.partitionQueryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Streams batches of document updates and deletes, in order. This method is only available via + * gRPC or WebChannel (not REST). + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BidiStream bidiStream = firestoreClient.writeCallable().call();
+   *   WriteRequest request =
+   *       WriteRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .setStreamId("streamId1790933179")
+   *           .addAllWrites(new ArrayList())
+   *           .setStreamToken(ByteString.EMPTY)
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   bidiStream.send(request);
+   *   for (WriteResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final BidiStreamingCallable writeCallable() { + return stub.writeCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Listens to changes. This method is only available via gRPC or WebChannel (not REST). + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BidiStream bidiStream =
+   *       firestoreClient.listenCallable().call();
+   *   ListenRequest request =
+   *       ListenRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   bidiStream.send(request);
+   *   for (ListenResponse response : bidiStream) {
+   *     // Do something when a response is received.
+   *   }
+   * }
+   * }
+ */ + public final BidiStreamingCallable listenCallable() { + return stub.listenCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the collection IDs underneath a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   String parent = "parent-995424086";
+   *   for (String element : firestoreClient.listCollectionIds(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. The parent document. In the format: + * `projects/{project_id}/databases/{database_id}/documents/{document_path}`. For example: + * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListCollectionIdsPagedResponse listCollectionIds(String parent) { + ListCollectionIdsRequest request = + ListCollectionIdsRequest.newBuilder().setParent(parent).build(); + return listCollectionIds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the collection IDs underneath a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListCollectionIdsRequest request =
+   *       ListCollectionIdsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (String element : firestoreClient.listCollectionIds(request).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListCollectionIdsPagedResponse listCollectionIds(ListCollectionIdsRequest request) { + return listCollectionIdsPagedCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the collection IDs underneath a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListCollectionIdsRequest request =
+   *       ListCollectionIdsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreClient.listCollectionIdsPagedCallable().futureCall(request);
+   *   // Do something.
+   *   for (String element : future.get().iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listCollectionIdsPagedCallable() { + return stub.listCollectionIdsPagedCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the collection IDs underneath a document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   ListCollectionIdsRequest request =
+   *       ListCollectionIdsRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListCollectionIdsResponse response =
+   *         firestoreClient.listCollectionIdsCallable().call(request);
+   *     for (String element : response.getCollectionIdsList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listCollectionIdsCallable() { + return stub.listCollectionIdsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Applies a batch of write operations. + * + *

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

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BatchWriteRequest request =
+   *       BatchWriteRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .addAllWrites(new ArrayList())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   BatchWriteResponse response = firestoreClient.batchWrite(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BatchWriteResponse batchWrite(BatchWriteRequest request) { + return batchWriteCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Applies a batch of write operations. + * + *

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

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   BatchWriteRequest request =
+   *       BatchWriteRequest.newBuilder()
+   *           .setDatabase("database1789464955")
+   *           .addAllWrites(new ArrayList())
+   *           .putAllLabels(new HashMap())
+   *           .build();
+   *   ApiFuture future =
+   *       firestoreClient.batchWriteCallable().futureCall(request);
+   *   // Do something.
+   *   BatchWriteResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable batchWriteCallable() { + return stub.batchWriteCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   CreateDocumentRequest request =
+   *       CreateDocumentRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setCollectionId("collectionId1636075609")
+   *           .setDocumentId("documentId-814940266")
+   *           .setDocument(Document.newBuilder().build())
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .build();
+   *   Document response = firestoreClient.createDocument(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final Document createDocument(CreateDocumentRequest request) { + return createDocumentCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new document. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+   *   CreateDocumentRequest request =
+   *       CreateDocumentRequest.newBuilder()
+   *           .setParent("parent-995424086")
+   *           .setCollectionId("collectionId1636075609")
+   *           .setDocumentId("documentId-814940266")
+   *           .setDocument(Document.newBuilder().build())
+   *           .setMask(DocumentMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = firestoreClient.createDocumentCallable().futureCall(request);
+   *   // Do something.
+   *   Document response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createDocumentCallable() { + return stub.createDocumentCallable(); + } + + @Override + public final void close() { + stub.close(); + } + + @Override + public void shutdown() { + stub.shutdown(); + } + + @Override + public boolean isShutdown() { + return stub.isShutdown(); + } + + @Override + public boolean isTerminated() { + return stub.isTerminated(); + } + + @Override + public void shutdownNow() { + stub.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return stub.awaitTermination(duration, unit); + } + + public static class ListDocumentsPagedResponse + extends AbstractPagedListResponse< + ListDocumentsRequest, + ListDocumentsResponse, + Document, + ListDocumentsPage, + ListDocumentsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListDocumentsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListDocumentsPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListDocumentsPagedResponse(ListDocumentsPage page) { + super(page, ListDocumentsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListDocumentsPage + extends AbstractPage< + ListDocumentsRequest, ListDocumentsResponse, Document, ListDocumentsPage> { + + private ListDocumentsPage( + PageContext context, + ListDocumentsResponse response) { + super(context, response); + } + + private static ListDocumentsPage createEmptyPage() { + return new ListDocumentsPage(null, null); + } + + @Override + protected ListDocumentsPage createPage( + PageContext context, + ListDocumentsResponse response) { + return new ListDocumentsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListDocumentsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListDocumentsRequest, + ListDocumentsResponse, + Document, + ListDocumentsPage, + ListDocumentsFixedSizeCollection> { + + private ListDocumentsFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListDocumentsFixedSizeCollection createEmptyCollection() { + return new ListDocumentsFixedSizeCollection(null, 0); + } + + @Override + protected ListDocumentsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListDocumentsFixedSizeCollection(pages, collectionSize); + } + } + + public static class PartitionQueryPagedResponse + extends AbstractPagedListResponse< + PartitionQueryRequest, + PartitionQueryResponse, + Cursor, + PartitionQueryPage, + PartitionQueryFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + PartitionQueryPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new PartitionQueryPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private PartitionQueryPagedResponse(PartitionQueryPage page) { + super(page, PartitionQueryFixedSizeCollection.createEmptyCollection()); + } + } + + public static class PartitionQueryPage + extends AbstractPage< + PartitionQueryRequest, PartitionQueryResponse, Cursor, PartitionQueryPage> { + + private PartitionQueryPage( + PageContext context, + PartitionQueryResponse response) { + super(context, response); + } + + private static PartitionQueryPage createEmptyPage() { + return new PartitionQueryPage(null, null); + } + + @Override + protected PartitionQueryPage createPage( + PageContext context, + PartitionQueryResponse response) { + return new PartitionQueryPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class PartitionQueryFixedSizeCollection + extends AbstractFixedSizeCollection< + PartitionQueryRequest, + PartitionQueryResponse, + Cursor, + PartitionQueryPage, + PartitionQueryFixedSizeCollection> { + + private PartitionQueryFixedSizeCollection(List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static PartitionQueryFixedSizeCollection createEmptyCollection() { + return new PartitionQueryFixedSizeCollection(null, 0); + } + + @Override + protected PartitionQueryFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new PartitionQueryFixedSizeCollection(pages, collectionSize); + } + } + + public static class ListCollectionIdsPagedResponse + extends AbstractPagedListResponse< + ListCollectionIdsRequest, + ListCollectionIdsResponse, + String, + ListCollectionIdsPage, + ListCollectionIdsFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListCollectionIdsPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListCollectionIdsPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListCollectionIdsPagedResponse(ListCollectionIdsPage page) { + super(page, ListCollectionIdsFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListCollectionIdsPage + extends AbstractPage< + ListCollectionIdsRequest, ListCollectionIdsResponse, String, ListCollectionIdsPage> { + + private ListCollectionIdsPage( + PageContext context, + ListCollectionIdsResponse response) { + super(context, response); + } + + private static ListCollectionIdsPage createEmptyPage() { + return new ListCollectionIdsPage(null, null); + } + + @Override + protected ListCollectionIdsPage createPage( + PageContext context, + ListCollectionIdsResponse response) { + return new ListCollectionIdsPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListCollectionIdsFixedSizeCollection + extends AbstractFixedSizeCollection< + ListCollectionIdsRequest, + ListCollectionIdsResponse, + String, + ListCollectionIdsPage, + ListCollectionIdsFixedSizeCollection> { + + private ListCollectionIdsFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListCollectionIdsFixedSizeCollection createEmptyCollection() { + return new ListCollectionIdsFixedSizeCollection(null, 0); + } + + @Override + protected ListCollectionIdsFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListCollectionIdsFixedSizeCollection(pages, collectionSize); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java new file mode 100644 index 000000000000..cfffc9f8857f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/FirestoreSettings.java @@ -0,0 +1,432 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import 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.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientSettings; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link FirestoreClient}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (firestore.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

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 + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getDocument: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreSettings.Builder firestoreSettingsBuilder = FirestoreSettings.newBuilder();
+ * firestoreSettingsBuilder
+ *     .getDocumentSettings()
+ *     .setRetrySettings(
+ *         firestoreSettingsBuilder
+ *             .getDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
+ *             .build());
+ * FirestoreSettings firestoreSettings = firestoreSettingsBuilder.build();
+ * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting + * retries. + */ +@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(); + } + + /** Returns the object with the settings used for calls to listDocuments. */ + public PagedCallSettings + listDocumentsSettings() { + return ((FirestoreStubSettings) getStubSettings()).listDocumentsSettings(); + } + + /** Returns the object with the settings used for calls to updateDocument. */ + public UnaryCallSettings updateDocumentSettings() { + return ((FirestoreStubSettings) getStubSettings()).updateDocumentSettings(); + } + + /** Returns the object with the settings used for calls to deleteDocument. */ + public UnaryCallSettings deleteDocumentSettings() { + return ((FirestoreStubSettings) getStubSettings()).deleteDocumentSettings(); + } + + /** Returns the object with the settings used for calls to batchGetDocuments. */ + public ServerStreamingCallSettings + batchGetDocumentsSettings() { + return ((FirestoreStubSettings) getStubSettings()).batchGetDocumentsSettings(); + } + + /** Returns the object with the settings used for calls to beginTransaction. */ + public UnaryCallSettings + beginTransactionSettings() { + return ((FirestoreStubSettings) getStubSettings()).beginTransactionSettings(); + } + + /** Returns the object with the settings used for calls to commit. */ + public UnaryCallSettings commitSettings() { + return ((FirestoreStubSettings) getStubSettings()).commitSettings(); + } + + /** Returns the object with the settings used for calls to rollback. */ + public UnaryCallSettings rollbackSettings() { + return ((FirestoreStubSettings) getStubSettings()).rollbackSettings(); + } + + /** Returns the object with the settings used for calls to runQuery. */ + public ServerStreamingCallSettings runQuerySettings() { + return ((FirestoreStubSettings) getStubSettings()).runQuerySettings(); + } + + /** Returns the object with the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings + executePipelineSettings() { + return ((FirestoreStubSettings) getStubSettings()).executePipelineSettings(); + } + + /** Returns the object with the settings used for calls to runAggregationQuery. */ + public ServerStreamingCallSettings + runAggregationQuerySettings() { + return ((FirestoreStubSettings) getStubSettings()).runAggregationQuerySettings(); + } + + /** 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(); + } + + /** Returns the object with the settings used for calls to listen. */ + public StreamingCallSettings listenSettings() { + return ((FirestoreStubSettings) getStubSettings()).listenSettings(); + } + + /** Returns the object with the settings used for calls to listCollectionIds. */ + public PagedCallSettings< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings() { + return ((FirestoreStubSettings) getStubSettings()).listCollectionIdsSettings(); + } + + /** 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 { + return new FirestoreSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return FirestoreStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return FirestoreStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return FirestoreStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return FirestoreStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return FirestoreStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return FirestoreStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return FirestoreStubSettings.defaultTransportChannelProvider(); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirestoreStubSettings.defaultApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected FirestoreSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for FirestoreSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(FirestoreStubSettings.newBuilder(clientContext)); + } + + protected Builder(FirestoreSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(FirestoreStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(FirestoreStubSettings.newBuilder()); + } + + private static Builder createHttpJsonDefault() { + return new Builder(FirestoreStubSettings.newHttpJsonBuilder()); + } + + public FirestoreStubSettings.Builder getStubSettingsBuilder() { + return ((FirestoreStubSettings.Builder) getStubSettings()); + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods( + getStubSettingsBuilder().unaryMethodSettingsBuilders(), settingsUpdater); + return this; + } + + /** Returns the builder for the settings used for calls to getDocument. */ + public UnaryCallSettings.Builder getDocumentSettings() { + return getStubSettingsBuilder().getDocumentSettings(); + } + + /** Returns the builder for the settings used for calls to listDocuments. */ + public PagedCallSettings.Builder< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> + listDocumentsSettings() { + return getStubSettingsBuilder().listDocumentsSettings(); + } + + /** Returns the builder for the settings used for calls to updateDocument. */ + public UnaryCallSettings.Builder updateDocumentSettings() { + return getStubSettingsBuilder().updateDocumentSettings(); + } + + /** Returns the builder for the settings used for calls to deleteDocument. */ + public UnaryCallSettings.Builder deleteDocumentSettings() { + return getStubSettingsBuilder().deleteDocumentSettings(); + } + + /** Returns the builder for the settings used for calls to batchGetDocuments. */ + public ServerStreamingCallSettings.Builder + batchGetDocumentsSettings() { + return getStubSettingsBuilder().batchGetDocumentsSettings(); + } + + /** Returns the builder for the settings used for calls to beginTransaction. */ + public UnaryCallSettings.Builder + beginTransactionSettings() { + return getStubSettingsBuilder().beginTransactionSettings(); + } + + /** Returns the builder for the settings used for calls to commit. */ + public UnaryCallSettings.Builder commitSettings() { + return getStubSettingsBuilder().commitSettings(); + } + + /** Returns the builder for the settings used for calls to rollback. */ + public UnaryCallSettings.Builder rollbackSettings() { + return getStubSettingsBuilder().rollbackSettings(); + } + + /** Returns the builder for the settings used for calls to runQuery. */ + public ServerStreamingCallSettings.Builder + runQuerySettings() { + return getStubSettingsBuilder().runQuerySettings(); + } + + /** Returns the builder for the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings.Builder + executePipelineSettings() { + return getStubSettingsBuilder().executePipelineSettings(); + } + + /** Returns the builder for the settings used for calls to runAggregationQuery. */ + public ServerStreamingCallSettings.Builder< + RunAggregationQueryRequest, RunAggregationQueryResponse> + runAggregationQuerySettings() { + return getStubSettingsBuilder().runAggregationQuerySettings(); + } + + /** 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(); + } + + /** Returns the builder for the settings used for calls to listen. */ + public StreamingCallSettings.Builder listenSettings() { + return getStubSettingsBuilder().listenSettings(); + } + + /** Returns the builder for the settings used for calls to listCollectionIds. */ + public PagedCallSettings.Builder< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings() { + return getStubSettingsBuilder().listCollectionIdsSettings(); + } + + /** 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 + public FirestoreSettings build() throws IOException { + return new FirestoreSettings(this); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json new file mode 100644 index 000000000000..44b5ecb1dc80 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/gapic_metadata.json @@ -0,0 +1,69 @@ +{ + "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"] + }, + "ExecutePipeline": { + "methods": ["executePipelineCallable"] + }, + "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"] + }, + "RunAggregationQuery": { + "methods": ["runAggregationQueryCallable"] + }, + "RunQuery": { + "methods": ["runQueryCallable"] + }, + "UpdateDocument": { + "methods": ["updateDocument", "updateDocument", "updateDocumentCallable"] + }, + "Write": { + "methods": ["writeCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java new file mode 100644 index 000000000000..0e9bb43fac0a --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/package-info.java @@ -0,0 +1,53 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A client to Cloud Firestore API + * + *

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

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

Service Description: The Cloud Firestore service. + * + *

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

Sample for FirestoreClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * try (FirestoreClient firestoreClient = FirestoreClient.create()) {
+ *   GetDocumentRequest request =
+ *       GetDocumentRequest.newBuilder()
+ *           .setName("name3373707")
+ *           .setMask(DocumentMask.newBuilder().build())
+ *           .build();
+ *   Document response = firestoreClient.getDocument(request);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.firestore.v1; + +import javax.annotation.Generated; diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java new file mode 100644 index 000000000000..cda06e152dda --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStub.java @@ -0,0 +1,159 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.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.gax.core.BackgroundResource; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.Empty; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the Firestore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class FirestoreStub implements BackgroundResource { + + public UnaryCallable getDocumentCallable() { + throw new UnsupportedOperationException("Not implemented: getDocumentCallable()"); + } + + public UnaryCallable + listDocumentsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listDocumentsPagedCallable()"); + } + + public UnaryCallable listDocumentsCallable() { + throw new UnsupportedOperationException("Not implemented: listDocumentsCallable()"); + } + + public UnaryCallable updateDocumentCallable() { + throw new UnsupportedOperationException("Not implemented: updateDocumentCallable()"); + } + + public UnaryCallable deleteDocumentCallable() { + throw new UnsupportedOperationException("Not implemented: deleteDocumentCallable()"); + } + + public ServerStreamingCallable + batchGetDocumentsCallable() { + throw new UnsupportedOperationException("Not implemented: batchGetDocumentsCallable()"); + } + + public UnaryCallable + beginTransactionCallable() { + throw new UnsupportedOperationException("Not implemented: beginTransactionCallable()"); + } + + public UnaryCallable commitCallable() { + throw new UnsupportedOperationException("Not implemented: commitCallable()"); + } + + public UnaryCallable rollbackCallable() { + throw new UnsupportedOperationException("Not implemented: rollbackCallable()"); + } + + public ServerStreamingCallable runQueryCallable() { + throw new UnsupportedOperationException("Not implemented: runQueryCallable()"); + } + + public ServerStreamingCallable + executePipelineCallable() { + throw new UnsupportedOperationException("Not implemented: executePipelineCallable()"); + } + + public ServerStreamingCallable + runAggregationQueryCallable() { + throw new UnsupportedOperationException("Not implemented: runAggregationQueryCallable()"); + } + + 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()"); + } + + public BidiStreamingCallable listenCallable() { + throw new UnsupportedOperationException("Not implemented: listenCallable()"); + } + + public UnaryCallable + listCollectionIdsPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listCollectionIdsPagedCallable()"); + } + + public UnaryCallable + listCollectionIdsCallable() { + throw new UnsupportedOperationException("Not implemented: listCollectionIdsCallable()"); + } + + public UnaryCallable batchWriteCallable() { + throw new UnsupportedOperationException("Not implemented: batchWriteCallable()"); + } + + public UnaryCallable createDocumentCallable() { + throw new UnsupportedOperationException("Not implemented: createDocumentCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java new file mode 100644 index 000000000000..ff61fac4c6f5 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/FirestoreStubSettings.java @@ -0,0 +1,1008 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.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.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.BetaApi; +import com.google.api.core.ObsoleteApi; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.core.GoogleCredentialsProvider; +import com.google.api.gax.core.InstantiatingExecutorProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.GrpcTransportChannel; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiCallContext; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.PageContext; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.PagedListDescriptor; +import com.google.api.gax.rpc.PagedListResponseFactory; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.StreamingCallSettings; +import com.google.api.gax.rpc.StubSettings; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.time.Duration; +import java.util.List; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Settings class to configure an instance of {@link FirestoreStub}. + * + *

The default instance has everything set to sensible defaults: + * + *

    + *
  • The default service address (firestore.googleapis.com) and default port (443) are used. + *
  • Credentials are acquired automatically through Application Default Credentials. + *
  • Retries are configured for idempotent methods but not for non-idempotent methods. + *
+ * + *

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 + * [RetrySettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.retrying.RetrySettings) + * of getDocument: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * FirestoreStubSettings.Builder firestoreSettingsBuilder = FirestoreStubSettings.newBuilder();
+ * firestoreSettingsBuilder
+ *     .getDocumentSettings()
+ *     .setRetrySettings(
+ *         firestoreSettingsBuilder
+ *             .getDocumentSettings()
+ *             .getRetrySettings()
+ *             .toBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofSeconds(1))
+ *             .setInitialRpcTimeoutDuration(Duration.ofSeconds(5))
+ *             .setMaxAttempts(5)
+ *             .setMaxRetryDelayDuration(Duration.ofSeconds(30))
+ *             .setMaxRpcTimeoutDuration(Duration.ofSeconds(60))
+ *             .setRetryDelayMultiplier(1.3)
+ *             .setRpcTimeoutMultiplier(1.5)
+ *             .setTotalTimeoutDuration(Duration.ofSeconds(300))
+ *             .build());
+ * FirestoreStubSettings firestoreSettings = firestoreSettingsBuilder.build();
+ * }
+ * + * Please refer to the [Client Side Retry + * Guide](https://docs.cloud.google.com/java/docs/client-retries) for additional support in setting + * retries. + */ +@Generated("by gapic-generator-java") +public class FirestoreStubSettings extends StubSettings { + /** The default scopes of the service. */ + private static final ImmutableList DEFAULT_SERVICE_SCOPES = + ImmutableList.builder() + .add("https://www.googleapis.com/auth/cloud-platform") + .add("https://www.googleapis.com/auth/datastore") + .build(); + + private final UnaryCallSettings getDocumentSettings; + private final PagedCallSettings< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> + listDocumentsSettings; + private final UnaryCallSettings updateDocumentSettings; + private final UnaryCallSettings deleteDocumentSettings; + private final ServerStreamingCallSettings + batchGetDocumentsSettings; + private final UnaryCallSettings + beginTransactionSettings; + private final UnaryCallSettings commitSettings; + private final UnaryCallSettings rollbackSettings; + private final ServerStreamingCallSettings runQuerySettings; + private final ServerStreamingCallSettings + executePipelineSettings; + private final ServerStreamingCallSettings + runAggregationQuerySettings; + private final PagedCallSettings< + PartitionQueryRequest, PartitionQueryResponse, PartitionQueryPagedResponse> + partitionQuerySettings; + private final StreamingCallSettings writeSettings; + private final StreamingCallSettings listenSettings; + private final PagedCallSettings< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings; + 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(); + } + }; + + 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(); + } + }; + + 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(); + } + }; + + 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> + 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() { + return getDocumentSettings; + } + + /** Returns the object with the settings used for calls to listDocuments. */ + public PagedCallSettings + listDocumentsSettings() { + return listDocumentsSettings; + } + + /** Returns the object with the settings used for calls to updateDocument. */ + public UnaryCallSettings updateDocumentSettings() { + return updateDocumentSettings; + } + + /** Returns the object with the settings used for calls to deleteDocument. */ + public UnaryCallSettings deleteDocumentSettings() { + return deleteDocumentSettings; + } + + /** Returns the object with the settings used for calls to batchGetDocuments. */ + public ServerStreamingCallSettings + batchGetDocumentsSettings() { + return batchGetDocumentsSettings; + } + + /** Returns the object with the settings used for calls to beginTransaction. */ + public UnaryCallSettings + beginTransactionSettings() { + return beginTransactionSettings; + } + + /** Returns the object with the settings used for calls to commit. */ + public UnaryCallSettings commitSettings() { + return commitSettings; + } + + /** Returns the object with the settings used for calls to rollback. */ + public UnaryCallSettings rollbackSettings() { + return rollbackSettings; + } + + /** Returns the object with the settings used for calls to runQuery. */ + public ServerStreamingCallSettings runQuerySettings() { + return runQuerySettings; + } + + /** Returns the object with the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings + executePipelineSettings() { + return executePipelineSettings; + } + + /** Returns the object with the settings used for calls to runAggregationQuery. */ + public ServerStreamingCallSettings + runAggregationQuerySettings() { + return runAggregationQuerySettings; + } + + /** 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; + } + + /** Returns the object with the settings used for calls to listen. */ + public StreamingCallSettings listenSettings() { + return listenSettings; + } + + /** Returns the object with the settings used for calls to listCollectionIds. */ + public PagedCallSettings< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings() { + return listCollectionIdsSettings; + } + + /** 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; + } + + public FirestoreStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcFirestoreStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonFirestoreStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns the default service name. */ + @Override + public String getServiceName() { + return "firestore"; + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return InstantiatingExecutorProvider.newBuilder(); + } + + /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") + public static String getDefaultEndpoint() { + return "firestore.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "firestore.mtls.googleapis.com:443"; + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DEFAULT_SERVICE_SCOPES; + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return GoogleCredentialsProvider.newBuilder() + .setScopesToApply(DEFAULT_SERVICE_SCOPES) + .setUseJwtAccessWithScope(true); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return InstantiatingGrpcChannelProvider.newBuilder() + .setMaxInboundMessageSize(Integer.MAX_VALUE); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return defaultGrpcTransportProviderBuilder().build(); + } + + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(FirestoreStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(FirestoreStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return FirestoreStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ + public static Builder newBuilder() { + return Builder.createDefault(); + } + + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + + /** Returns a new builder for this class. */ + public static Builder newBuilder(ClientContext clientContext) { + return new Builder(clientContext); + } + + /** Returns a builder containing all the values of this settings class. */ + public Builder toBuilder() { + return new Builder(this); + } + + protected FirestoreStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + getDocumentSettings = settingsBuilder.getDocumentSettings().build(); + listDocumentsSettings = settingsBuilder.listDocumentsSettings().build(); + updateDocumentSettings = settingsBuilder.updateDocumentSettings().build(); + deleteDocumentSettings = settingsBuilder.deleteDocumentSettings().build(); + batchGetDocumentsSettings = settingsBuilder.batchGetDocumentsSettings().build(); + beginTransactionSettings = settingsBuilder.beginTransactionSettings().build(); + commitSettings = settingsBuilder.commitSettings().build(); + rollbackSettings = settingsBuilder.rollbackSettings().build(); + runQuerySettings = settingsBuilder.runQuerySettings().build(); + executePipelineSettings = settingsBuilder.executePipelineSettings().build(); + runAggregationQuerySettings = settingsBuilder.runAggregationQuerySettings().build(); + partitionQuerySettings = settingsBuilder.partitionQuerySettings().build(); + writeSettings = settingsBuilder.writeSettings().build(); + listenSettings = settingsBuilder.listenSettings().build(); + listCollectionIdsSettings = settingsBuilder.listCollectionIdsSettings().build(); + batchWriteSettings = settingsBuilder.batchWriteSettings().build(); + createDocumentSettings = settingsBuilder.createDocumentSettings().build(); + } + + /** 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 ServerStreamingCallSettings.Builder< + ExecutePipelineRequest, ExecutePipelineResponse> + executePipelineSettings; + private final ServerStreamingCallSettings.Builder< + RunAggregationQueryRequest, RunAggregationQueryResponse> + runAggregationQuerySettings; + 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( + "retry_policy_4_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.RESOURCE_EXHAUSTED, + StatusCode.Code.UNAVAILABLE, + StatusCode.Code.INTERNAL, + StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.RESOURCE_EXHAUSTED, StatusCode.Code.UNAVAILABLE))); + definitions.put( + "retry_policy_1_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + 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(); + } + + private static final ImmutableMap RETRY_PARAM_DEFINITIONS; + + static { + ImmutableMap.Builder definitions = ImmutableMap.builder(); + RetrySettings settings = null; + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_4_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_0_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(300000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(300000L)) + .setTotalTimeoutDuration(Duration.ofMillis(300000L)) + .build(); + definitions.put("retry_policy_1_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRpcTimeoutDuration(Duration.ofMillis(86400000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(86400000L)) + .setTotalTimeoutDuration(Duration.ofMillis(86400000L)) + .build(); + definitions.put("no_retry_3_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(86400000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(86400000L)) + .setTotalTimeoutDuration(Duration.ofMillis(86400000L)) + .build(); + definitions.put("retry_policy_2_params", settings); + settings = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ofMillis(100L)) + .setRetryDelayMultiplier(1.3) + .setMaxRetryDelayDuration(Duration.ofMillis(60000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("retry_policy_5_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + getDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listDocumentsSettings = PagedCallSettings.newBuilder(LIST_DOCUMENTS_PAGE_STR_FACT); + updateDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + batchGetDocumentsSettings = ServerStreamingCallSettings.newBuilder(); + beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + runQuerySettings = ServerStreamingCallSettings.newBuilder(); + executePipelineSettings = ServerStreamingCallSettings.newBuilder(); + runAggregationQuerySettings = ServerStreamingCallSettings.newBuilder(); + partitionQuerySettings = PagedCallSettings.newBuilder(PARTITION_QUERY_PAGE_STR_FACT); + writeSettings = StreamingCallSettings.newBuilder(); + listenSettings = StreamingCallSettings.newBuilder(); + listCollectionIdsSettings = PagedCallSettings.newBuilder(LIST_COLLECTION_IDS_PAGE_STR_FACT); + batchWriteSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + getDocumentSettings, + listDocumentsSettings, + updateDocumentSettings, + deleteDocumentSettings, + beginTransactionSettings, + commitSettings, + rollbackSettings, + partitionQuerySettings, + listCollectionIdsSettings, + 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(); + executePipelineSettings = settings.executePipelineSettings.toBuilder(); + runAggregationQuerySettings = settings.runAggregationQuerySettings.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.setTransportChannelProvider(defaultTransportChannelProvider()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + + private static Builder initDefaults(Builder builder) { + builder + .getDocumentSettings() + .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("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + + builder + .updateDocumentSettings() + .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("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + + builder + .batchGetDocumentsSettings() + .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("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + + builder + .commitSettings() + .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("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + + builder + .runQuerySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .executePipelineSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .runAggregationQuerySettings() + .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("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listCollectionIdsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_4_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_4_params")); + + builder + .batchWriteSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_5_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_5_params")); + + builder + .createDocumentSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + return builder; + } + + /** + * Applies the given settings updater function to all of the unary API methods in this service. + * + *

Note: This method does not support applying settings to streaming methods. + */ + public Builder applyToAllUnaryMethods( + ApiFunction, Void> settingsUpdater) { + super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater); + return this; + } + + public ImmutableList> unaryMethodSettingsBuilders() { + return unaryMethodSettingsBuilders; + } + + /** Returns the builder for the settings used for calls to getDocument. */ + public UnaryCallSettings.Builder getDocumentSettings() { + return getDocumentSettings; + } + + /** Returns the builder for the settings used for calls to listDocuments. */ + public PagedCallSettings.Builder< + ListDocumentsRequest, ListDocumentsResponse, ListDocumentsPagedResponse> + listDocumentsSettings() { + return listDocumentsSettings; + } + + /** Returns the builder for the settings used for calls to updateDocument. */ + public UnaryCallSettings.Builder updateDocumentSettings() { + return updateDocumentSettings; + } + + /** Returns the builder for the settings used for calls to deleteDocument. */ + public UnaryCallSettings.Builder deleteDocumentSettings() { + return deleteDocumentSettings; + } + + /** Returns the builder for the settings used for calls to batchGetDocuments. */ + public ServerStreamingCallSettings.Builder + batchGetDocumentsSettings() { + return batchGetDocumentsSettings; + } + + /** Returns the builder for the settings used for calls to beginTransaction. */ + public UnaryCallSettings.Builder + beginTransactionSettings() { + return beginTransactionSettings; + } + + /** Returns the builder for the settings used for calls to commit. */ + public UnaryCallSettings.Builder commitSettings() { + return commitSettings; + } + + /** Returns the builder for the settings used for calls to rollback. */ + public UnaryCallSettings.Builder rollbackSettings() { + return rollbackSettings; + } + + /** Returns the builder for the settings used for calls to runQuery. */ + public ServerStreamingCallSettings.Builder + runQuerySettings() { + return runQuerySettings; + } + + /** Returns the builder for the settings used for calls to executePipeline. */ + public ServerStreamingCallSettings.Builder + executePipelineSettings() { + return executePipelineSettings; + } + + /** Returns the builder for the settings used for calls to runAggregationQuery. */ + public ServerStreamingCallSettings.Builder< + RunAggregationQueryRequest, RunAggregationQueryResponse> + runAggregationQuerySettings() { + return runAggregationQuerySettings; + } + + /** 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; + } + + /** Returns the builder for the settings used for calls to listen. */ + public StreamingCallSettings.Builder listenSettings() { + return listenSettings; + } + + /** Returns the builder for the settings used for calls to listCollectionIds. */ + public PagedCallSettings.Builder< + ListCollectionIdsRequest, ListCollectionIdsResponse, ListCollectionIdsPagedResponse> + listCollectionIdsSettings() { + return listCollectionIdsSettings; + } + + /** 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 + public FirestoreStubSettings build() throws IOException { + return new FirestoreStubSettings(this); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java new file mode 100644 index 000000000000..e38803cbab68 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreCallableFactory.java @@ -0,0 +1,113 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcCallableFactory; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.ClientStreamingCallable; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +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. +/** + * gRPC callable factory implementation for the Firestore service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcFirestoreCallableFactory implements GrpcStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + GrpcCallSettings grpcCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createUnaryCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + GrpcCallSettings grpcCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createPagedCallable(grpcCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + GrpcCallSettings grpcCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBatchingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + GrpcCallSettings grpcCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + return GrpcCallableFactory.createOperationCallable( + grpcCallSettings, callSettings, clientContext, operationsStub); + } + + @Override + public + BidiStreamingCallable createBidiStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createBidiStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + GrpcCallSettings grpcCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createServerStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } + + @Override + public + ClientStreamingCallable createClientStreamingCallable( + GrpcCallSettings grpcCallSettings, + StreamingCallSettings callSettings, + ClientContext clientContext) { + return GrpcCallableFactory.createClientStreamingCallable( + grpcCallSettings, callSettings, clientContext); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java new file mode 100644 index 000000000000..3824d24dbdfb --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/GrpcFirestoreStub.java @@ -0,0 +1,738 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.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.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.grpc.GrpcCallSettings; +import com.google.api.gax.grpc.GrpcStubCallableFactory; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsBuilder; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.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; +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * gRPC stub implementation for the Firestore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcFirestoreStub extends FirestoreStub { + private static final MethodDescriptor getDocumentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/GetDocument") + .setRequestMarshaller(ProtoUtils.marshaller(GetDocumentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listDocumentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/ListDocuments") + .setRequestMarshaller( + ProtoUtils.marshaller(ListDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListDocumentsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + updateDocumentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/UpdateDocument") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateDocumentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Document.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + deleteDocumentMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/DeleteDocument") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteDocumentRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + batchGetDocumentsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/BatchGetDocuments") + .setRequestMarshaller( + ProtoUtils.marshaller(BatchGetDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(BatchGetDocumentsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + beginTransactionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/BeginTransaction") + .setRequestMarshaller( + ProtoUtils.marshaller(BeginTransactionRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(BeginTransactionResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor commitMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/Commit") + .setRequestMarshaller(ProtoUtils.marshaller(CommitRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(CommitResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor rollbackMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/Rollback") + .setRequestMarshaller(ProtoUtils.marshaller(RollbackRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + runQueryMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/RunQuery") + .setRequestMarshaller(ProtoUtils.marshaller(RunQueryRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(RunQueryResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + executePipelineMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/ExecutePipeline") + .setRequestMarshaller( + ProtoUtils.marshaller(ExecutePipelineRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ExecutePipelineResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + runAggregationQueryMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/RunAggregationQuery") + .setRequestMarshaller( + ProtoUtils.marshaller(RunAggregationQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(RunAggregationQueryResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .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())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor writeMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/Write") + .setRequestMarshaller(ProtoUtils.marshaller(WriteRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(WriteResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor listenMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName("google.firestore.v1.Firestore/Listen") + .setRequestMarshaller(ProtoUtils.marshaller(ListenRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ListenResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listCollectionIdsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.firestore.v1.Firestore/ListCollectionIds") + .setRequestMarshaller( + ProtoUtils.marshaller(ListCollectionIdsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListCollectionIdsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .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())) + .setSampledToLocalTracing(true) + .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())) + .setSampledToLocalTracing(true) + .build(); + + private final UnaryCallable getDocumentCallable; + private final UnaryCallable listDocumentsCallable; + private final UnaryCallable + listDocumentsPagedCallable; + private final UnaryCallable updateDocumentCallable; + private final UnaryCallable deleteDocumentCallable; + private final ServerStreamingCallable + batchGetDocumentsCallable; + private final UnaryCallable + beginTransactionCallable; + private final UnaryCallable commitCallable; + private final UnaryCallable rollbackCallable; + private final ServerStreamingCallable runQueryCallable; + private final ServerStreamingCallable + executePipelineCallable; + private final ServerStreamingCallable + runAggregationQueryCallable; + 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 batchWriteCallable; + private final UnaryCallable createDocumentCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + private static final PathTemplate EXECUTE_PIPELINE_0_PATH_TEMPLATE = + PathTemplate.create("projects/{project_id=*}/**"); + private static final PathTemplate EXECUTE_PIPELINE_1_PATH_TEMPLATE = + PathTemplate.create("projects/*/databases/{database_id=*}/**"); + + public static final GrpcFirestoreStub create(FirestoreStubSettings settings) throws IOException { + return new GrpcFirestoreStub(settings, ClientContext.create(settings)); + } + + public static final GrpcFirestoreStub create(ClientContext clientContext) throws IOException { + return new GrpcFirestoreStub(FirestoreStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcFirestoreStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcFirestoreStub( + FirestoreStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcFirestoreStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcFirestoreStub(FirestoreStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcFirestoreCallableFactory()); + } + + /** + * Constructs an instance of GrpcFirestoreStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected GrpcFirestoreStub( + FirestoreStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings getDocumentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getDocumentMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings listDocumentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listDocumentsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("collection_id", String.valueOf(request.getCollectionId())); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings updateDocumentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateDocumentMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("document.name", String.valueOf(request.getDocument().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteDocumentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteDocumentMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings + batchGetDocumentsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchGetDocumentsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings + beginTransactionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(beginTransactionMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings commitTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(commitMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings rollbackTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(rollbackMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings runQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(runQueryMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + executePipelineTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(executePipelineMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getDatabase(), "project_id", EXECUTE_PIPELINE_0_PATH_TEMPLATE); + builder.add( + request.getDatabase(), "database_id", EXECUTE_PIPELINE_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings + runAggregationQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(runAggregationQueryMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings + partitionQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(partitionQueryMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings writeTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(writeMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings listenTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listenMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings + listCollectionIdsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listCollectionIdsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings batchWriteTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(batchWriteMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + GrpcCallSettings createDocumentTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("collection_id", String.valueOf(request.getCollectionId())); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + + this.getDocumentCallable = + callableFactory.createUnaryCallable( + getDocumentTransportSettings, settings.getDocumentSettings(), clientContext); + this.listDocumentsCallable = + callableFactory.createUnaryCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.listDocumentsPagedCallable = + callableFactory.createPagedCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.updateDocumentCallable = + callableFactory.createUnaryCallable( + updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); + this.deleteDocumentCallable = + callableFactory.createUnaryCallable( + deleteDocumentTransportSettings, settings.deleteDocumentSettings(), clientContext); + this.batchGetDocumentsCallable = + callableFactory.createServerStreamingCallable( + batchGetDocumentsTransportSettings, + settings.batchGetDocumentsSettings(), + clientContext); + this.beginTransactionCallable = + callableFactory.createUnaryCallable( + beginTransactionTransportSettings, settings.beginTransactionSettings(), clientContext); + this.commitCallable = + callableFactory.createUnaryCallable( + commitTransportSettings, settings.commitSettings(), clientContext); + this.rollbackCallable = + callableFactory.createUnaryCallable( + rollbackTransportSettings, settings.rollbackSettings(), clientContext); + this.runQueryCallable = + callableFactory.createServerStreamingCallable( + runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.executePipelineCallable = + callableFactory.createServerStreamingCallable( + executePipelineTransportSettings, settings.executePipelineSettings(), clientContext); + this.runAggregationQueryCallable = + callableFactory.createServerStreamingCallable( + runAggregationQueryTransportSettings, + settings.runAggregationQuerySettings(), + 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); + this.listenCallable = + callableFactory.createBidiStreamingCallable( + listenTransportSettings, settings.listenSettings(), clientContext); + this.listCollectionIdsCallable = + callableFactory.createUnaryCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.listCollectionIdsPagedCallable = + callableFactory.createPagedCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.batchWriteCallable = + callableFactory.createUnaryCallable( + batchWriteTransportSettings, settings.batchWriteSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; + } + + @Override + public UnaryCallable listDocumentsCallable() { + return listDocumentsCallable; + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; + } + + @Override + public UnaryCallable updateDocumentCallable() { + return updateDocumentCallable; + } + + @Override + public UnaryCallable deleteDocumentCallable() { + return deleteDocumentCallable; + } + + @Override + public ServerStreamingCallable + batchGetDocumentsCallable() { + return batchGetDocumentsCallable; + } + + @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 ServerStreamingCallable + executePipelineCallable() { + return executePipelineCallable; + } + + @Override + public ServerStreamingCallable + runAggregationQueryCallable() { + return runAggregationQueryCallable; + } + + @Override + public UnaryCallable partitionQueryCallable() { + return partitionQueryCallable; + } + + @Override + public UnaryCallable + partitionQueryPagedCallable() { + return partitionQueryPagedCallable; + } + + @Override + public BidiStreamingCallable writeCallable() { + return writeCallable; + } + + @Override + public BidiStreamingCallable listenCallable() { + return listenCallable; + } + + @Override + public UnaryCallable + listCollectionIdsCallable() { + return listCollectionIdsCallable; + } + + @Override + public UnaryCallable + listCollectionIdsPagedCallable() { + return listCollectionIdsPagedCallable; + } + + @Override + public UnaryCallable batchWriteCallable() { + return batchWriteCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java new file mode 100644 index 000000000000..c1ee72f3746d --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreCallableFactory.java @@ -0,0 +1,101 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.stub; + +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the Firestore service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class HttpJsonFirestoreCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java new file mode 100644 index 000000000000..148c9c0d5386 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/java/com/google/cloud/firestore/v1/stub/HttpJsonFirestoreStub.java @@ -0,0 +1,1154 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1.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.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.BackgroundResourceAggregation; +import com.google.api.gax.httpjson.ApiMethodDescriptor; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.ProtoMessageRequestFormatter; +import com.google.api.gax.httpjson.ProtoMessageResponseParser; +import com.google.api.gax.httpjson.ProtoRestSerializer; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.RequestParamsBuilder; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.Empty; +import com.google.protobuf.TypeRegistry; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST stub implementation for the Firestore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class HttpJsonFirestoreStub extends FirestoreStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + getDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/GetDocument") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + serializer.putQueryParam( + fields, "transaction", request.getTransaction()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ListDocuments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents/*/**}/{collectionId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "collectionId", request.getCollectionId()); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents}/{collectionId}") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + serializer.putQueryParam(fields, "readTime", request.getReadTime()); + serializer.putQueryParam( + fields, "showMissing", request.getShowMissing()); + serializer.putQueryParam( + fields, "transaction", request.getTransaction()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/UpdateDocument") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{document.name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "document.name", request.getDocument().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "currentDocument", request.getCurrentDocument()); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/DeleteDocument") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/databases/*/documents/*/**}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "currentDocument", request.getCurrentDocument()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchGetDocumentsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BatchGetDocuments") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:batchGet", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchGetDocumentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + beginTransactionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BeginTransaction") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:beginTransaction", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BeginTransactionResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor commitMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/Commit") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:commit", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CommitResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor rollbackMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/Rollback") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:rollback", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/RunQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:runQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RunQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + executePipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ExecutePipeline") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:executePipeline", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ExecutePipelineResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runAggregationQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/RunAggregationQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.SERVER_STREAMING) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RunAggregationQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + partitionQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/PartitionQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:partitionQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PartitionQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listCollectionIdsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/ListCollectionIds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setAdditionalPaths( + "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds") + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListCollectionIdsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + batchWriteMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/BatchWrite") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{database=projects/*/databases/*}/documents:batchWrite", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "database", request.getDatabase()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearDatabase().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BatchWriteResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDocumentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.firestore.v1.Firestore/CreateDocument") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/databases/*/documents/**}/{collectionId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "collectionId", request.getCollectionId()); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "documentId", request.getDocumentId()); + serializer.putQueryParam(fields, "mask", request.getMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("document", request.getDocument(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Document.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable getDocumentCallable; + private final UnaryCallable listDocumentsCallable; + private final UnaryCallable + listDocumentsPagedCallable; + private final UnaryCallable updateDocumentCallable; + private final UnaryCallable deleteDocumentCallable; + private final ServerStreamingCallable + batchGetDocumentsCallable; + private final UnaryCallable + beginTransactionCallable; + private final UnaryCallable commitCallable; + private final UnaryCallable rollbackCallable; + private final ServerStreamingCallable runQueryCallable; + private final ServerStreamingCallable + executePipelineCallable; + private final ServerStreamingCallable + runAggregationQueryCallable; + private final UnaryCallable partitionQueryCallable; + private final UnaryCallable + partitionQueryPagedCallable; + private final UnaryCallable + listCollectionIdsCallable; + private final UnaryCallable + listCollectionIdsPagedCallable; + private final UnaryCallable batchWriteCallable; + private final UnaryCallable createDocumentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + private static final PathTemplate EXECUTE_PIPELINE_0_PATH_TEMPLATE = + PathTemplate.create("projects/{project_id=*}/**"); + private static final PathTemplate EXECUTE_PIPELINE_1_PATH_TEMPLATE = + PathTemplate.create("projects/*/databases/{database_id=*}/**"); + + public static final HttpJsonFirestoreStub create(FirestoreStubSettings settings) + throws IOException { + return new HttpJsonFirestoreStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonFirestoreStub create(ClientContext clientContext) throws IOException { + return new HttpJsonFirestoreStub( + FirestoreStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonFirestoreStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonFirestoreStub( + FirestoreStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonFirestoreStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonFirestoreStub(FirestoreStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonFirestoreCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonFirestoreStub, using the given settings. This is protected so + * that it is easy to make a subclass, but otherwise, the static factory methods should be + * preferred. + */ + protected HttpJsonFirestoreStub( + FirestoreStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings getDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("collection_id", String.valueOf(request.getCollectionId())); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings updateDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("document.name", String.valueOf(request.getDocument().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + batchGetDocumentsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchGetDocumentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + beginTransactionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(beginTransactionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings commitTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(commitMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings rollbackTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rollbackMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings runQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + executePipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getDatabase(), "project_id", EXECUTE_PIPELINE_0_PATH_TEMPLATE); + builder.add( + request.getDatabase(), "database_id", EXECUTE_PIPELINE_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + runAggregationQueryTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(runAggregationQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + partitionQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(partitionQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listCollectionIdsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listCollectionIdsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings batchWriteTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(batchWriteMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("database", String.valueOf(request.getDatabase())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings createDocumentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDocumentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("collection_id", String.valueOf(request.getCollectionId())); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + + this.getDocumentCallable = + callableFactory.createUnaryCallable( + getDocumentTransportSettings, settings.getDocumentSettings(), clientContext); + this.listDocumentsCallable = + callableFactory.createUnaryCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.listDocumentsPagedCallable = + callableFactory.createPagedCallable( + listDocumentsTransportSettings, settings.listDocumentsSettings(), clientContext); + this.updateDocumentCallable = + callableFactory.createUnaryCallable( + updateDocumentTransportSettings, settings.updateDocumentSettings(), clientContext); + this.deleteDocumentCallable = + callableFactory.createUnaryCallable( + deleteDocumentTransportSettings, settings.deleteDocumentSettings(), clientContext); + this.batchGetDocumentsCallable = + callableFactory.createServerStreamingCallable( + batchGetDocumentsTransportSettings, + settings.batchGetDocumentsSettings(), + clientContext); + this.beginTransactionCallable = + callableFactory.createUnaryCallable( + beginTransactionTransportSettings, settings.beginTransactionSettings(), clientContext); + this.commitCallable = + callableFactory.createUnaryCallable( + commitTransportSettings, settings.commitSettings(), clientContext); + this.rollbackCallable = + callableFactory.createUnaryCallable( + rollbackTransportSettings, settings.rollbackSettings(), clientContext); + this.runQueryCallable = + callableFactory.createServerStreamingCallable( + runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.executePipelineCallable = + callableFactory.createServerStreamingCallable( + executePipelineTransportSettings, settings.executePipelineSettings(), clientContext); + this.runAggregationQueryCallable = + callableFactory.createServerStreamingCallable( + runAggregationQueryTransportSettings, + settings.runAggregationQuerySettings(), + clientContext); + this.partitionQueryCallable = + callableFactory.createUnaryCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + this.partitionQueryPagedCallable = + callableFactory.createPagedCallable( + partitionQueryTransportSettings, settings.partitionQuerySettings(), clientContext); + this.listCollectionIdsCallable = + callableFactory.createUnaryCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.listCollectionIdsPagedCallable = + callableFactory.createPagedCallable( + listCollectionIdsTransportSettings, + settings.listCollectionIdsSettings(), + clientContext); + this.batchWriteCallable = + callableFactory.createUnaryCallable( + batchWriteTransportSettings, settings.batchWriteSettings(), clientContext); + this.createDocumentCallable = + callableFactory.createUnaryCallable( + createDocumentTransportSettings, settings.createDocumentSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(getDocumentMethodDescriptor); + methodDescriptors.add(listDocumentsMethodDescriptor); + methodDescriptors.add(updateDocumentMethodDescriptor); + methodDescriptors.add(deleteDocumentMethodDescriptor); + methodDescriptors.add(batchGetDocumentsMethodDescriptor); + methodDescriptors.add(beginTransactionMethodDescriptor); + methodDescriptors.add(commitMethodDescriptor); + methodDescriptors.add(rollbackMethodDescriptor); + methodDescriptors.add(runQueryMethodDescriptor); + methodDescriptors.add(executePipelineMethodDescriptor); + methodDescriptors.add(runAggregationQueryMethodDescriptor); + methodDescriptors.add(partitionQueryMethodDescriptor); + methodDescriptors.add(listCollectionIdsMethodDescriptor); + methodDescriptors.add(batchWriteMethodDescriptor); + methodDescriptors.add(createDocumentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable getDocumentCallable() { + return getDocumentCallable; + } + + @Override + public UnaryCallable listDocumentsCallable() { + return listDocumentsCallable; + } + + @Override + public UnaryCallable + listDocumentsPagedCallable() { + return listDocumentsPagedCallable; + } + + @Override + public UnaryCallable updateDocumentCallable() { + return updateDocumentCallable; + } + + @Override + public UnaryCallable deleteDocumentCallable() { + return deleteDocumentCallable; + } + + @Override + public ServerStreamingCallable + batchGetDocumentsCallable() { + return batchGetDocumentsCallable; + } + + @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 ServerStreamingCallable + executePipelineCallable() { + return executePipelineCallable; + } + + @Override + public ServerStreamingCallable + runAggregationQueryCallable() { + return runAggregationQueryCallable; + } + + @Override + public UnaryCallable partitionQueryCallable() { + return partitionQueryCallable; + } + + @Override + public UnaryCallable + partitionQueryPagedCallable() { + return partitionQueryPagedCallable; + } + + @Override + public UnaryCallable + listCollectionIdsCallable() { + return listCollectionIdsCallable; + } + + @Override + public UnaryCallable + listCollectionIdsPagedCallable() { + return listCollectionIdsPagedCallable; + } + + @Override + public UnaryCallable batchWriteCallable() { + return batchWriteCallable; + } + + @Override + public UnaryCallable createDocumentCallable() { + return createDocumentCallable; + } + + @Override + public BidiStreamingCallable writeCallable() { + throw new UnsupportedOperationException( + "Not implemented: writeCallable(). REST transport is not implemented for this method yet."); + } + + @Override + public BidiStreamingCallable listenCallable() { + throw new UnsupportedOperationException( + "Not implemented: listenCallable(). REST transport is not implemented for this method" + + " yet."); + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json new file mode 100644 index 000000000000..01d5baceb93e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud.firestore.v1/reflect-config.json @@ -0,0 +1,3116 @@ +[ + { + "name": "com.google.api.ClientLibraryDestination", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibraryOrganization", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibrarySettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ClientLibrarySettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CommonLanguageSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CommonLanguageSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CppSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CppSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CustomHttpPattern", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.CustomHttpPattern$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.DotnetSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.DotnetSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.FieldBehavior", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.GoSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.GoSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Http", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Http$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.HttpRule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.HttpRule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.JavaSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.JavaSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.LaunchStage", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$LongRunning", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.MethodSettings$LongRunning$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.NodeSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.NodeSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PhpSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PhpSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Publishing", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.Publishing$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.PythonSettings$ExperimentalFeatures$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$History", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceDescriptor$Style", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceReference", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.ResourceReference$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingParameter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingParameter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingRule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RoutingRule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RubySettings", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.RubySettings$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.SelectiveGapicGeneration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.api.SelectiveGapicGeneration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.GetLocationRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.GetLocationRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.ListLocationsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.Location", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.cloud.location.Location$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.AggregationResult", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.AggregationResult$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ArrayValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ArrayValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchGetDocumentsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchGetDocumentsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchGetDocumentsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchGetDocumentsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchWriteRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchWriteRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchWriteResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BatchWriteResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BeginTransactionRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BeginTransactionRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BeginTransactionResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BeginTransactionResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BitSequence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BitSequence$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BloomFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.BloomFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CommitRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CommitRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CommitResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CommitResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CreateDocumentRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.CreateDocumentRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Cursor", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Cursor$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DeleteDocumentRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DeleteDocumentRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Document", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Document$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentChange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentChange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentDelete", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentDelete$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentMask", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentMask$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentRemove", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentRemove$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentTransform", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentTransform$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentTransform$FieldTransform", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentTransform$FieldTransform$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.DocumentTransform$FieldTransform$ServerValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutePipelineResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutionStats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExecutionStats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExistenceFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExistenceFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainMetrics", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainMetrics$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainStats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ExplainStats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Function", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Function$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.GetDocumentRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.GetDocumentRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListCollectionIdsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListCollectionIdsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListCollectionIdsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListCollectionIdsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListDocumentsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListDocumentsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListDocumentsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListDocumentsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListenRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListenRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListenResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.ListenResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.MapValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.MapValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PartitionQueryRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PartitionQueryRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PartitionQueryResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PartitionQueryResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Stage", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Pipeline$Stage$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PlanSummary", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.PlanSummary$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Precondition", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Precondition$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RollbackRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RollbackRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunAggregationQueryRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunAggregationQueryRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunAggregationQueryResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunAggregationQueryResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunQueryRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunQueryRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunQueryResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.RunQueryResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Avg", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Avg$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Count", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Count$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Sum", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Aggregation$Sum$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredAggregationQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredPipeline", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredPipeline$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$CollectionSelector", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$CollectionSelector$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$CompositeFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$CompositeFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$CompositeFilter$Operator", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Direction", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FieldFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FieldFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FieldFilter$Operator", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FieldReference", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FieldReference$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Filter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Filter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$FindNearest$DistanceMeasure", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Order", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Order$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Projection", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$Projection$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$UnaryFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$UnaryFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.StructuredQuery$UnaryFilter$Operator", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target$DocumentsTarget", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target$DocumentsTarget$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target$QueryTarget", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Target$QueryTarget$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TargetChange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TargetChange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TargetChange$TargetChangeType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions$ReadOnly", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions$ReadOnly$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions$ReadWrite", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.TransactionOptions$ReadWrite$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.UpdateDocumentRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.UpdateDocumentRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Write", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.Write$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteResult", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.v1.WriteResult$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Any", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Any$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.BoolValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.BoolValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.BytesValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.BytesValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ExtensionRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ReservedRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$DescriptorProto$ReservedRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$Edition", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$EnumReservedRange", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumDescriptorProto$EnumReservedRange$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$EnumValueOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Declaration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$Declaration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ExtensionRangeOptions$VerificationState", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$EnforceNamingStyle", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$EnumType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$FieldPresence", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$JsonFormat", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$MessageEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$RepeatedFieldEncoding", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$Utf8Validation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSet$VisibilityFeature$DefaultSymbolVisibility", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FeatureSetDefaults$FeatureSetEditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Label", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldDescriptorProto$Type", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$CType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$EditionDefault$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$FeatureSupport", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$FeatureSupport$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$JSType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$OptionRetention", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FieldOptions$OptionTargetType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorSet", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileDescriptorSet$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$FileOptions$OptimizeMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Annotation$Semantic", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$GeneratedCodeInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MessageOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MessageOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$MethodOptions$IdempotencyLevel", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$OneofOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceDescriptorProto", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceDescriptorProto$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$ServiceOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Location", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SourceCodeInfo$Location$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$SymbolVisibility", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$NamePart", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DescriptorProtos$UninterpretedOption$NamePart$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DoubleValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.DoubleValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Duration", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Duration$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Empty", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Empty$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.FloatValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.FloatValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Int32Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Int32Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Int64Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Int64Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.ListValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.ListValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.NullValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.StringValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.StringValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Struct", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Struct$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Timestamp", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Timestamp$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.UInt32Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.UInt32Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.UInt64Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.UInt64Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.protobuf.Value$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.rpc.Status", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.rpc.Status$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.type.LatLng", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.type.LatLng$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + } +] \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/native-image.properties b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/native-image.properties new file mode 100644 index 000000000000..96207424d396 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/native-image.properties @@ -0,0 +1,5 @@ +# FirestoreImpl uses a random number generator so it needs to be initialized at +# run-time. +Args = --initialize-at-run-time=com.google.cloud.firestore.FirestoreImpl \ +--initialize-at-build-time=org.junit.runner.RunWith,java.lang.annotation.Annotation \ +--initialize-at-build-time=org.junit.Ignore,org.junit.runners.model.FrameworkField \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/reflect-config.json b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/reflect-config.json new file mode 100644 index 000000000000..551707894286 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/main/resources/META-INF/native-image/com.google.cloud/google-cloud-firestore/reflect-config.json @@ -0,0 +1,110 @@ +[ + { + "name": "com.google.firestore.bundle.BundleElement", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundleElement$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundleMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundleMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.NamedQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.NamedQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledDocumentMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledDocumentMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledQuery$LimitType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.firestore.bundle.BundledQuery$QueryTypeCase", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods":true, + "allDeclaredClasses": true, + "allPublicClasses": true + } +] \ No newline at end of file diff --git a/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordDocumentReferenceTest.java b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordDocumentReferenceTest.java new file mode 100644 index 000000000000..21baf69cc49f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordDocumentReferenceTest.java @@ -0,0 +1,407 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.assertCommitEquals; +import static com.google.cloud.firestore.LocalFirestoreHelper.commit; +import static com.google.cloud.firestore.LocalFirestoreHelper.create; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAllResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.LocalFirestoreHelper.serverTimestamp; +import static com.google.cloud.firestore.LocalFirestoreHelper.set; +import static com.google.cloud.firestore.LocalFirestoreHelper.transform; +import static com.google.cloud.firestore.RecordTestHelper.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; + +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.Value; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +@RunWith(MockitoJUnitRunner.class) +public class RecordDocumentReferenceTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor commitCapture; + + @Captor private ArgumentCaptor getAllCapture; + + @Captor private ArgumentCaptor> streamObserverCapture; + + private DocumentReference documentReference; + + @Before + public void before() { + documentReference = firestoreMock.document("coll/doc"); + } + + @Test + public void serializeBasicTypes() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(ALL_SUPPORTED_TYPES_OBJECT).get(); + + CommitRequest expectedCommit = commit(set(ALL_SUPPORTED_TYPES_PROTO)); + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(0)); + } + + @Test + public void doesNotSerializeAdvancedNumberTypes() { + Map expectedErrorMessages = new HashMap<>(); + + InvalidRecord record = new InvalidRecord(new BigInteger("0"), null, null); + expectedErrorMessages.put( + record, + "Could not serialize object. Numbers of type BigInteger are not supported, please use an int, long, float, double or BigDecimal (found in field 'bigIntegerValue')"); + + record = new InvalidRecord(null, (byte) 0, null); + expectedErrorMessages.put( + record, + "Could not serialize object. Numbers of type Byte are not supported, please use an int, long, float, double or BigDecimal (found in field 'byteValue')"); + + record = new InvalidRecord(null, null, (short) 0); + expectedErrorMessages.put( + record, + "Could not serialize object. Numbers of type Short are not supported, please use an int, long, float, double or BigDecimal (found in field 'shortValue')"); + + for (Map.Entry testCase : expectedErrorMessages.entrySet()) { + try { + documentReference.set(testCase.getKey()); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(testCase.getValue(), e.getMessage()); + } + } + } + + @Test + public void doesNotDeserializeAdvancedNumberTypes() throws Exception { + Map fieldNamesToTypeNames = + map("bigIntegerValue", "BigInteger", "shortValue", "Short", "byteValue", "Byte"); + + for (Map.Entry testCase : fieldNamesToTypeNames.entrySet()) { + String fieldName = testCase.getKey(); + String typeName = testCase.getValue(); + Map response = map(fieldName, Value.newBuilder().setIntegerValue(0).build()); + + doAnswer(getAllResponse(response)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + try { + snapshot.toObject(InvalidRecord.class); + fail(); + } catch (RuntimeException e) { + assertEquals( + String.format( + "Could not deserialize object. Deserializing values to %s is not supported (found in field '%s')", + typeName, fieldName), + e.getMessage()); + } + } + } + + @Test + public void createDocument() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.create(SINGLE_COMPONENT_OBJECT).get(); + + CommitRequest expectedCommit = commit(create(SINGLE_COMPONENT_PROTO)); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(expectedCommit, commitRequests.get(0)); + } + + @Test + public void createWithServerTimestamp() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.create(SERVER_TIMESTAMP_OBJECT).get(); + + CommitRequest create = + commit( + create(Collections.emptyMap()), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(create, commitRequests.get(0)); + } + + @Test + public void setWithServerTimestamp() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(SERVER_TIMESTAMP_OBJECT).get(); + + CommitRequest set = + commit( + set(SERVER_TIMESTAMP_PROTO), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(set, commitRequests.get(0)); + } + + @Test + public void mergeWithServerTimestamps() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference + .set(SERVER_TIMESTAMP_OBJECT, SetOptions.mergeFields("inner.bar")) + .get(); + + CommitRequest set = + commit( + set(SERVER_TIMESTAMP_PROTO, new ArrayList<>()), + transform("inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(set, commitRequests.get(0)); + } + + @Test + public void setDocumentWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(SINGLE_COMPONENT_OBJECT, SetOptions.merge()).get(); + documentReference.set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields("foo")).get(); + documentReference + .set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields(Arrays.asList("foo"))) + .get(); + documentReference + .set( + ALL_SUPPORTED_TYPES_OBJECT, + SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("foo")))) + .get(); + + CommitRequest expectedCommit = commit(set(SINGLE_COMPONENT_PROTO, Arrays.asList("foo"))); + + for (int i = 0; i < 4; ++i) { + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(i)); + } + } + + @Test + public void setDocumentWithNestedMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(NESTED_RECORD_OBJECT, SetOptions.mergeFields("first.foo")).get(); + documentReference + .set(NESTED_RECORD_OBJECT, SetOptions.mergeFields(Arrays.asList("first.foo"))) + .get(); + documentReference + .set( + NESTED_RECORD_OBJECT, + SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("first", "foo")))) + .get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first.foo"))); + + for (int i = 0; i < 3; ++i) { + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(i)); + } + } + + @Test + public void setMultipleFieldsWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference + .set( + NESTED_RECORD_OBJECT, + SetOptions.mergeFields("first.foo", "second.foo", "second.trueValue")) + .get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto + .getMapValueBuilder() + .putFields("trueValue", Value.newBuilder().setBooleanValue(true).build()); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = + commit(set(nestedUpdate, Arrays.asList("first.foo", "second.foo", "second.trueValue"))); + + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void setNestedMapWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(NESTED_RECORD_OBJECT, SetOptions.mergeFields("first", "second")).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first", "second"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void extractFieldMaskFromMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(NESTED_RECORD_OBJECT, SetOptions.merge()).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + List updateMask = Arrays.asList( + "first.foo", + "second.arrayValue", + "second.bytesValue", + "second.dateValue", + "second.doubleValue", + "second.falseValue", + "second.foo", + "second.geoPointValue", + "second.infValue", + "second.longValue", + "second.nanValue", + "second.negInfValue", + "second.nullValue", + "second.objectValue.foo", + "second.timestampValue", + "second.trueValue", + "second.model.foo"); + + CommitRequest expectedCommit = commit(set(nestedUpdate, updateMask)); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void setNestedRecordWithPojoMapWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), ArgumentMatchers.>any()); + + documentReference.set(NESTED_RECORD_WITH_POJO_OBJECT, SetOptions.mergeFields("first", "second")).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first", "second"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void setNestedPojoWithRecordMapWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(NESTED_POJO_WITH_RECORD_OBJECT, SetOptions.mergeFields("first", "second")).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_COMPONENT_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first", "second"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordMapperTest.java b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordMapperTest.java new file mode 100644 index 000000000000..daa5df99d3f0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordMapperTest.java @@ -0,0 +1,1134 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.firestore.annotation.DocumentId; +import com.google.cloud.firestore.annotation.PropertyName; +import com.google.cloud.firestore.annotation.ThrowOnExtraProperties; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.DatabaseRootName; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static com.google.cloud.firestore.LocalFirestoreHelper.fromSingleQuotedString; +import static com.google.cloud.firestore.LocalFirestoreHelper.mapAnyType; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +@SuppressWarnings({"unused", "WeakerAccess", "SpellCheckingInspection"}) +@RunWith(MockitoJUnitRunner.class) +public class RecordMapperTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + private static final double EPSILON = 0.0003; + + public record StringBean ( + String value + ){} + + public record DoubleBean ( + double value + ){} + + public record BigDecimalBean ( + BigDecimal value + ){} + + public record FloatBean ( + float value + ){} + + public record LongBean ( + long value + ){} + + public record IntBean ( + int value + ){} + + public record BooleanBean ( + boolean value + ){} + + public record ShortBean ( + short value + ){} + + public record ByteBean ( + byte value + ){} + + public record CharBean ( + char value + ){} + + public record IntArrayBean ( + int[] values + ){} + + public record StringArrayBean ( + String[] values + ){} + + public record XMLAndURLBean ( + String XMLAndURL + ){} + + public record CaseSensitiveFieldBean1 ( + String VALUE + ){} + + public record CaseSensitiveFieldBean2 ( + String value + ){} + + public record CaseSensitiveFieldBean3 ( + String Value + ){} + + public record CaseSensitiveFieldBean4 ( + String valUE + ){} + + public record NestedBean ( + StringBean bean + ){} + + public record ObjectBean ( + Object value + ){} + + public record GenericBean ( + B value + ){} + + public record DoubleGenericBean ( + A valueA, + B valueB + ){} + + public record ListBean ( + List values + ){} + + public record SetBean ( + Set values + ){} + + public record CollectionBean ( + Collection values + ){} + + public record MapBean ( + Map values + ){} + + /** + * This form is not terribly useful in Java, but Kotlin Maps are immutable and are rewritten into + * this form (b/67470108 has more details). + */ + public record UpperBoundedMapBean ( + Map values + ){} + + public record MultiBoundedMapBean ( + Map values + ){} + + public record MultiBoundedMapHolderBean ( + MultiBoundedMapBean map + ){} + + public record UnboundedMapBean ( + Map values + ){} + + public record UnboundedTypeVariableMapBean ( + Map values + ){} + + public record UnboundedTypeVariableMapHolderBean ( + UnboundedTypeVariableMapBean map + ){} + + public record NestedListBean ( + List values + ){} + + public record NestedMapBean ( + Map values + ){} + + public record IllegalKeyMapBean ( + Map values + ){} + + @ThrowOnExtraProperties + public record ThrowOnUnknownPropertiesBean ( + String value + ){} + + @ThrowOnExtraProperties + public record NoFieldBean( + ){} + + public record PropertyNameBean ( + @PropertyName("my_key") + String key, + + @PropertyName("my_value") + String value + ){} + + @SuppressWarnings({"NonAsciiCharacters"}) + public record UnicodeBean ( + String 漢字 + ){} + + private static T deserialize(String jsonString, Class clazz) { + return deserialize(jsonString, clazz, /*docRef=*/ null); + } + + private static T deserialize(Map json, Class clazz) { + return deserialize(json, clazz, /*docRef=*/ null); + } + + private static T deserialize(String jsonString, Class clazz, DocumentReference docRef) { + Map json = fromSingleQuotedString(jsonString); + return CustomClassMapper.convertToCustomClass(json, clazz, docRef); + } + + private static T deserialize( + Map json, Class clazz, DocumentReference docRef) { + return CustomClassMapper.convertToCustomClass(json, clazz, docRef); + } + + private static Object serialize(Object object) { + return CustomClassMapper.convertToPlainJavaTypes(object); + } + + private static void assertJson(String expected, Object actual) { + assertEquals(fromSingleQuotedString(expected), actual); + } + + private static void assertExceptionContains(String partialMessage, Runnable run) { + try { + run.run(); + fail("Expected exception not thrown"); + } catch (RuntimeException e) { + assertTrue(e.getMessage().contains(partialMessage)); + } + } + + private static T convertToCustomClass( + Object object, Class clazz, DocumentReference docRef) { + return CustomClassMapper.convertToCustomClass(object, clazz, docRef); + } + + private static T convertToCustomClass(Object object, Class clazz) { + return CustomClassMapper.convertToCustomClass(object, clazz, null); + } + + @Test + public void primitiveDeserializeString() { + StringBean bean = deserialize("{'value': 'foo'}", StringBean.class); + assertEquals("foo", bean.value()); + + // Double + try { + deserialize("{'value': 1.1}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Int + try { + deserialize("{'value': 1}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeBoolean() { + BooleanBean beanBoolean = deserialize("{'value': true}", BooleanBean.class); + assertEquals(true, beanBoolean.value()); + + // Double + try { + deserialize("{'value': 1.1}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Int + try { + deserialize("{'value': 1}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeDouble() { + DoubleBean beanDouble = deserialize("{'value': 1.1}", DoubleBean.class); + assertEquals(1.1, beanDouble.value(), EPSILON); + + // Int + DoubleBean beanInt = deserialize("{'value': 1}", DoubleBean.class); + assertEquals(1, beanInt.value(), EPSILON); + // Long + DoubleBean beanLong = deserialize("{'value': 1234567890123}", DoubleBean.class); + assertEquals(1234567890123L, beanLong.value(), EPSILON); + + // Boolean + try { + deserialize("{'value': true}", DoubleBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", DoubleBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeBigDecimal() { + BigDecimalBean beanBigdecimal = deserialize("{'value': 123}", BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(123.0), beanBigdecimal.value()); + + beanBigdecimal = deserialize("{'value': '123'}", BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(123), beanBigdecimal.value()); + + // Int + BigDecimalBean beanInt = + deserialize(Collections.singletonMap("value", 1), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1), beanInt.value()); + + // Long + BigDecimalBean beanLong = + deserialize(Collections.singletonMap("value", 1234567890123L), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1234567890123L), beanLong.value()); + + // Double + BigDecimalBean beanDouble = + deserialize(Collections.singletonMap("value", 1.1), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1.1), beanDouble.value()); + + // BigDecimal + BigDecimalBean beanBigDecimal = + deserialize( + Collections.singletonMap("value", BigDecimal.valueOf(1.2)), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1.2), beanBigDecimal.value()); + + // Boolean + try { + deserialize("{'value': true}", BigDecimalBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", BigDecimalBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeFloat() { + FloatBean beanFloat = deserialize("{'value': 1.1}", FloatBean.class); + assertEquals(1.1, beanFloat.value(), EPSILON); + + // Int + FloatBean beanInt = deserialize(Collections.singletonMap("value", 1), FloatBean.class); + assertEquals(1, beanInt.value(), EPSILON); + // Long + FloatBean beanLong = + deserialize(Collections.singletonMap("value", 1234567890123L), FloatBean.class); + assertEquals((float) 1234567890123L, beanLong.value(), EPSILON); + + // Boolean + try { + deserialize("{'value': true}", FloatBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", FloatBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeInt() { + IntBean beanInt = deserialize("{'value': 1}", IntBean.class); + assertEquals(1, beanInt.value()); + + // Double + IntBean beanDouble = deserialize("{'value': 1.1}", IntBean.class); + assertEquals(1, beanDouble.value()); + + // Large doubles + try { + deserialize("{'value': 1e10}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeLong() { + LongBean beanLong = deserialize("{'value': 1234567890123}", LongBean.class); + assertEquals(1234567890123L, beanLong.value()); + + // Int + LongBean beanInt = deserialize("{'value': 1}", LongBean.class); + assertEquals(1, beanInt.value()); + + // Double + LongBean beanDouble = deserialize("{'value': 1.1}", LongBean.class); + assertEquals(1, beanDouble.value()); + + // Large doubles + try { + deserialize("{'value': 1e300}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeWrongTypeMap() { + String expectedExceptionMessage = + ".* Failed to convert value of type .*Map to String \\(found in field 'value'\\).*"; + Throwable exception = + assertThrows( + RuntimeException.class, + () -> deserialize("{'value': {'foo': 'bar'}}", StringBean.class)); + assertTrue(exception.getMessage().matches(expectedExceptionMessage)); + } + + @Test + public void primitiveDeserializeWrongTypeList() { + assertExceptionContains( + "Failed to convert value of type java.util.ArrayList to String" + + " (found in field 'value')", + () -> deserialize("{'value': ['foo']}", StringBean.class)); + } + + @Test + public void noFieldDeserialize() { + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.RecordMapperTest$NoFieldBean", + () -> deserialize("{'value': 'foo'}", NoFieldBean.class)); + } + + @Test + public void throwOnUnknownProperties() { + assertExceptionContains( + "No accessor for unknown found on class " + + "com.google.cloud.firestore.RecordMapperTest$ThrowOnUnknownPropertiesBean", + () -> + deserialize("{'value': 'foo', 'unknown': 'bar'}", ThrowOnUnknownPropertiesBean.class)); + } + + @Test + public void XMLAndURLBean() { + XMLAndURLBean bean = + deserialize("{'XMLAndURL': 'foo'}", XMLAndURLBean.class); + assertEquals("foo", bean.XMLAndURL()); + } + + public record AllCapsDefaultHandlingBean ( + String UUID + ){} + + @Test + public void allCapsSerializesToUppercaseByDefault() { + AllCapsDefaultHandlingBean bean = new AllCapsDefaultHandlingBean("value"); + assertJson("{'UUID': 'value'}", serialize(bean)); + AllCapsDefaultHandlingBean deserialized = + deserialize("{'UUID': 'value'}", AllCapsDefaultHandlingBean.class); + assertEquals("value", deserialized.UUID()); + } + + public record AllCapsWithPropertyName ( + @PropertyName("uuid") + String UUID + ){} + + @Test + public void allCapsWithPropertyNameSerializesToLowercase() { + AllCapsWithPropertyName bean = new AllCapsWithPropertyName("value"); + assertJson("{'uuid': 'value'}", serialize(bean)); + AllCapsWithPropertyName deserialized = + deserialize("{'uuid': 'value'}", AllCapsWithPropertyName.class); + assertEquals("value", deserialized.UUID()); + } + + @Test + public void nestedParsingWorks() { + NestedBean bean = deserialize("{'bean': {'value': 'foo'}}", NestedBean.class); + assertEquals("foo", bean.bean().value()); + } + + @Test + public void beansCanContainLists() { + ListBean bean = deserialize("{'values': ['foo', 'bar']}", ListBean.class); + assertEquals(Arrays.asList("foo", "bar"), bean.values()); + } + + @Test + public void beansCanContainMaps() { + MapBean bean = deserialize("{'values': {'foo': 'bar'}}", MapBean.class); + Map expected = fromSingleQuotedString("{'foo': 'bar'}"); + assertEquals(expected, bean.values()); + } + + @Test + public void beansCanContainUpperBoundedMaps() { + Date date = new Date(1491847082123L); + Map source = mapAnyType("values", mapAnyType("foo", date)); + UpperBoundedMapBean bean = convertToCustomClass(source, UpperBoundedMapBean.class); + Map expected = mapAnyType("foo", date); + assertEquals(expected, bean.values()); + } + + @Test + public void beansCanContainMultiBoundedMaps() { + Date date = new Date(1491847082123L); + Map source = mapAnyType("map", mapAnyType("values", mapAnyType("foo", date))); + MultiBoundedMapHolderBean bean = convertToCustomClass(source, MultiBoundedMapHolderBean.class); + + Map expected = mapAnyType("foo", date); + assertEquals(expected, bean.map().values()); + } + + @Test + public void beansCanContainUnboundedMaps() { + UnboundedMapBean bean = deserialize("{'values': {'foo': 'bar'}}", UnboundedMapBean.class); + Map expected = mapAnyType("foo", "bar"); + assertEquals(expected, bean.values()); + } + + @Test + public void beansCanContainUnboundedTypeVariableMaps() { + Map source = mapAnyType("map", mapAnyType("values", mapAnyType("foo", "bar"))); + UnboundedTypeVariableMapHolderBean bean = + convertToCustomClass(source, UnboundedTypeVariableMapHolderBean.class); + + Map expected = mapAnyType("foo", "bar"); + assertEquals(expected, bean.map().values()); + } + + @Test + public void beansCanContainNestedUnboundedMaps() { + UnboundedMapBean bean = + deserialize("{'values': {'foo': {'bar': 'baz'}}}", UnboundedMapBean.class); + Map expected = mapAnyType("foo", mapAnyType("bar", "baz")); + assertEquals(expected, bean.values()); + } + + @Test + public void beansCanContainBeanLists() { + NestedListBean bean = deserialize("{'values': [{'value': 'foo'}]}", NestedListBean.class); + assertEquals(1, bean.values().size()); + assertEquals("foo", bean.values().get(0).value()); + } + + @Test + public void beansCanContainBeanMaps() { + NestedMapBean bean = deserialize("{'values': {'key': {'value': 'foo'}}}", NestedMapBean.class); + assertEquals(1, bean.values().size()); + assertEquals("foo", bean.values().get("key").value()); + } + + @Test + public void beanMapsMustHaveStringKeys() { + assertExceptionContains( + "Only Maps with string keys are supported, but found Map with key type class " + + "java.lang.Integer (found in field 'values')", + () -> deserialize("{'values': {'1': 'bar'}}", IllegalKeyMapBean.class)); + } + + @Test + public void serializeStringBean() { + StringBean bean = new StringBean("foo"); + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void serializeDoubleBean() { + DoubleBean bean = new DoubleBean(1.1); + assertJson("{'value': 1.1}", serialize(bean)); + } + + @Test + public void serializeIntBean() { + IntBean bean = new IntBean(1); + assertJson("{'value': 1}", serialize(Collections.singletonMap("value", 1.0))); + } + + @Test + public void serializeLongBean() { + LongBean bean = new LongBean(1234567890123L); + assertJson( + "{'value': 1.234567890123E12}", + serialize(Collections.singletonMap("value", 1.234567890123E12))); + } + + @Test + public void serializeBigDecimalBean() { + BigDecimalBean bean = new BigDecimalBean(BigDecimal.valueOf(1.1)); + assertEquals(mapAnyType("value", "1.1"), serialize(bean)); + } + + @Test + public void bigDecimalRoundTrip() { + BigDecimal doubleMaxPlusOne = BigDecimal.valueOf(Double.MAX_VALUE).add(BigDecimal.ONE); + BigDecimalBean a = new BigDecimalBean(doubleMaxPlusOne); + Map serialized = (Map) serialize(a); + BigDecimalBean b = convertToCustomClass(serialized, BigDecimalBean.class); + assertEquals(a, b); + } + + @Test + public void serializeBooleanBean() { + BooleanBean bean = new BooleanBean(true); + assertJson("{'value': true}", serialize(bean)); + } + + @Test + public void serializeFloatBean() { + FloatBean bean = new FloatBean(0.5f); + + // We don't use assertJson as it converts all floating point numbers to Double. + assertEquals(mapAnyType("value", 0.5f), serialize(bean)); + } + + @Test + public void serializePrivateFieldBean() { + final NoFieldBean bean = new NoFieldBean(); + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.RecordMapperTest$NoFieldBean", + () -> serialize(bean)); + } + + @Test + public void nestedSerializingWorks() { + NestedBean bean = new NestedBean(new StringBean("foo")); + assertJson("{'bean': {'value': 'foo'}}", serialize(bean)); + } + + @Test + public void serializingListsWorks() { + ListBean bean = new ListBean(Arrays.asList("foo", "bar")); + assertJson("{'values': ['foo', 'bar']}", serialize(bean)); + } + + @Test + public void serializingMapsWorks() { + MapBean bean = new MapBean(new HashMap<>()); + bean.values().put("foo", "bar"); + assertJson("{'values': {'foo': 'bar'}}", serialize(bean)); + } + + @Test + public void serializingUpperBoundedMapsWorks() { + Date date = new Date(1491847082123L); + UpperBoundedMapBean bean = new UpperBoundedMapBean(Map.of("foo", date)); + Map expected = + mapAnyType("values", mapAnyType("foo", new Date(date.getTime()))); + assertEquals(expected, serialize(bean)); + } + + @Test + public void serializingMultiBoundedObjectsWorks() { + Date date = new Date(1491847082123L); + + HashMap values = new HashMap(); + values.put("foo", date); + + MultiBoundedMapHolderBean holder = new MultiBoundedMapHolderBean(new MultiBoundedMapBean<>(values)); + + Map expected = + mapAnyType("map", mapAnyType("values", mapAnyType("foo", new Date(date.getTime())))); + assertEquals(expected, serialize(holder)); + } + + @Test + public void serializeListOfBeansWorks() { + StringBean stringBean = new StringBean("foo"); + + NestedListBean bean = new NestedListBean(new ArrayList<>()); + bean.values().add(stringBean); + + assertJson("{'values': [{'value': 'foo'}]}", serialize(bean)); + } + + @Test + public void serializeMapOfBeansWorks() { + StringBean stringBean = new StringBean("foo"); + + NestedMapBean bean = new NestedMapBean(new HashMap<>()); + bean.values().put("key", stringBean); + + assertJson("{'values': {'key': {'value': 'foo'}}}", serialize(bean)); + } + + @Test + public void beanMapsMustHaveStringKeysForSerializing() { + StringBean stringBean = new StringBean("foo"); + + final IllegalKeyMapBean bean = new IllegalKeyMapBean(new HashMap<>()); + bean.values().put(1, stringBean); + + assertExceptionContains( + "Maps with non-string keys are not supported (found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void serializeUPPERCASE() { + XMLAndURLBean bean = new XMLAndURLBean("foo"); + assertJson("{'XMLAndURL': 'foo'}", serialize(bean)); + } + + @Test + public void roundTripCaseSensitiveFieldBean1() { + CaseSensitiveFieldBean1 bean = new CaseSensitiveFieldBean1("foo"); + assertJson("{'VALUE': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean1 deserialized = + deserialize("{'VALUE': 'foo'}", CaseSensitiveFieldBean1.class); + assertEquals("foo", deserialized.VALUE()); + } + + @Test + public void roundTripCaseSensitiveFieldBean2() { + CaseSensitiveFieldBean2 bean = new CaseSensitiveFieldBean2("foo"); + assertJson("{'value': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean2 deserialized = + deserialize("{'value': 'foo'}", CaseSensitiveFieldBean2.class); + assertEquals("foo", deserialized.value()); + } + + @Test + public void roundTripCaseSensitiveFieldBean3() { + CaseSensitiveFieldBean3 bean = new CaseSensitiveFieldBean3("foo"); + assertJson("{'Value': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean3 deserialized = + deserialize("{'Value': 'foo'}", CaseSensitiveFieldBean3.class); + assertEquals("foo", deserialized.Value()); + } + + @Test + public void roundTripCaseSensitiveFieldBean4() { + CaseSensitiveFieldBean4 bean = new CaseSensitiveFieldBean4("foo"); + assertJson("{'valUE': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean4 deserialized = + deserialize("{'valUE': 'foo'}", CaseSensitiveFieldBean4.class); + assertEquals("foo", deserialized.valUE()); + } + + @Test + public void roundTripUnicodeBean() { + UnicodeBean bean = new UnicodeBean("foo"); + assertJson("{'漢字': 'foo'}", serialize(bean)); + UnicodeBean deserialized = deserialize("{'漢字': 'foo'}", UnicodeBean.class); + assertEquals("foo", deserialized.漢字()); + } + + @Test + public void shortsCantBeSerialized() { + final ShortBean bean = new ShortBean((short) 1); + assertExceptionContains( + "Numbers of type Short are not supported, please use an int, long, float, double or BigDecimal (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void bytesCantBeSerialized() { + final ByteBean bean = new ByteBean((byte) 1); + assertExceptionContains( + "Numbers of type Byte are not supported, please use an int, long, float, double or BigDecimal (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void charsCantBeSerialized() { + final CharBean bean = new CharBean((char) 1); + assertExceptionContains( + "Characters are not supported, please use Strings (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void intArraysCantBeSerialized() { + final IntArrayBean bean = new IntArrayBean(new int[] {1}); + assertExceptionContains( + "Serializing Arrays is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void objectArraysCantBeSerialized() { + final StringArrayBean bean = new StringArrayBean(new String[] {"foo"}); + assertExceptionContains( + "Serializing Arrays is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void shortsCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to short is not supported (found in field 'value')", + () -> deserialize("{'value': 1}", ShortBean.class)); + } + + @Test + public void bytesCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to byte is not supported (found in field 'value')", + () -> deserialize("{'value': 1}", ByteBean.class)); + } + + @Test + public void charsCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to char is not supported (found in field 'value')", + () -> deserialize("{'value': '1'}", CharBean.class)); + } + + @Test + public void intArraysCantBeDeserialized() { + assertExceptionContains( + "Converting to Arrays is not supported, please use Lists instead (found in field 'values')", + () -> deserialize("{'values': [1]}", IntArrayBean.class)); + } + + @Test + public void objectArraysCantBeDeserialized() { + assertExceptionContains( + "Could not deserialize object. Converting to Arrays is not supported, please use Lists " + + "instead (found in field 'values')", + () -> deserialize("{'values': ['foo']}", StringArrayBean.class)); + } + + @Test + public void objectAcceptsAnyObject() { + ObjectBean stringValue = deserialize("{'value': 'foo'}", ObjectBean.class); + assertEquals("foo", stringValue.value()); + ObjectBean listValue = deserialize("{'value': ['foo']}", ObjectBean.class); + assertEquals(Collections.singletonList("foo"), listValue.value()); + ObjectBean mapValue = deserialize("{'value': {'foo':'bar'}}", ObjectBean.class); + assertEquals(fromSingleQuotedString("{'foo':'bar'}"), mapValue.value()); + String complex = "{'value': {'foo':['bar', ['baz'], {'bam': 'qux'}]}, 'other':{'a': ['b']}}"; + ObjectBean complexValue = deserialize(complex, ObjectBean.class); + assertEquals(fromSingleQuotedString(complex).get("value"), complexValue.value()); + } + + @Test + public void passingInGenericBeanTopLevelThrows() { + assertExceptionContains( + "Class com.google.cloud.firestore.RecordMapperTest$GenericBean has generic type " + + "parameters, please use GenericTypeIndicator instead", + () -> deserialize("{'value': 'foo'}", GenericBean.class)); + } + + @Test + public void collectionsCanBeSerializedWhenList() { + CollectionBean bean = new CollectionBean(Collections.singletonList("foo")); + assertJson("{'values': ['foo']}", serialize(bean)); + } + + @Test + public void collectionsCantBeSerializedWhenSet() { + final CollectionBean bean = new CollectionBean(Collections.singleton("foo")); + assertExceptionContains( + "Serializing Collections is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void collectionsCantBeDeserialized() { + assertExceptionContains( + "Collections are not supported, please use Lists instead (found in field 'values')", + () -> deserialize("{'values': ['foo']}", CollectionBean.class)); + } + + @Test + public void serializingGenericBeansSupported() { + GenericBean stringBean = new GenericBean("foo"); + assertJson("{'value': 'foo'}", serialize(stringBean)); + + GenericBean> mapBean = new GenericBean>(Collections.singletonMap("foo", "bar")); + assertJson("{'value': {'foo': 'bar'}}", serialize(mapBean)); + + GenericBean> listBean = new GenericBean>(Collections.singletonList("foo")); + assertJson("{'value': ['foo']}", serialize(listBean)); + + GenericBean> recursiveBean = new GenericBean>(new GenericBean<>("foo")); + assertJson("{'value': {'value': 'foo'}}", serialize(recursiveBean)); + + DoubleGenericBean doubleBean = new DoubleGenericBean("foo", 1.0); + assertJson("{'valueB': 1, 'valueA': 'foo'}", serialize(doubleBean)); + } + + @Test + public void propertyNamesAreSerialized() { + PropertyNameBean bean = new PropertyNameBean("foo", "bar"); + + assertJson("{'my_key': 'foo', 'my_value': 'bar'}", serialize(bean)); + } + + @Test + public void propertyNamesAreParsed() { + PropertyNameBean bean = + deserialize("{'my_key': 'foo', 'my_value': 'bar'}", PropertyNameBean.class); + assertEquals("foo", bean.key()); + assertEquals("bar", bean.value()); + } + + // Bean definitions with @DocumentId applied to wrong type. + public record FieldWithDocumentIdOnWrongTypeBean ( + @DocumentId Integer intField + ){} + + public record PropertyWithDocumentIdOnWrongTypeBean ( + @PropertyName("intField") + @DocumentId + int intField + ){} + + @Test + public void documentIdAnnotateWrongTypeThrows() { + final String expectedErrorMessage = "instead of String or DocumentReference"; + assertExceptionContains( + expectedErrorMessage, () -> serialize(new FieldWithDocumentIdOnWrongTypeBean(100))); + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'intField': 1}", FieldWithDocumentIdOnWrongTypeBean.class)); + + assertExceptionContains( + expectedErrorMessage, () -> serialize(new PropertyWithDocumentIdOnWrongTypeBean(100))); + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'intField': 1}", PropertyWithDocumentIdOnWrongTypeBean.class)); + } + + public record DocumentIdOnStringField ( + @DocumentId String docId + ){} + + public record DocumentIdOnStringFieldAsProperty ( + @PropertyName("docIdProperty") + @DocumentId + String docId, + + @PropertyName("anotherProperty") + int someOtherProperty + ){} + + public record DocumentIdOnNestedObjects ( + @PropertyName("nestedDocIdHolder") + DocumentIdOnStringField nestedDocIdHolder + ){} + + @Test + public void documentIdsDeserialize() { + DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertEquals("doc123", deserialize("{}", DocumentIdOnStringField.class, ref).docId()); + + assertEquals( + "doc123", + deserialize(Collections.singletonMap("property", 100), DocumentIdOnStringField.class, ref) + .docId()); + + DocumentIdOnStringFieldAsProperty target = + deserialize("{'anotherProperty': 100}", DocumentIdOnStringFieldAsProperty.class, ref); + assertEquals("doc123", target.docId()); + assertEquals(100, target.someOtherProperty()); + + assertEquals( + "doc123", + deserialize("{'nestedDocIdHolder': {}}", DocumentIdOnNestedObjects.class, ref) + .nestedDocIdHolder() + .docId()); + } + + @Test + public void documentIdsRoundTrip() { + // Implicitly verifies @DocumentId is ignored during serialization. + + final DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertEquals( + Collections.emptyMap(), serialize(deserialize("{}", DocumentIdOnStringField.class, ref))); + + assertEquals( + Collections.singletonMap("anotherProperty", 100), + serialize( + deserialize("{'anotherProperty': 100}", DocumentIdOnStringFieldAsProperty.class, ref))); + + assertEquals( + Collections.singletonMap("nestedDocIdHolder", Collections.emptyMap()), + serialize(deserialize("{'nestedDocIdHolder': {}}", DocumentIdOnNestedObjects.class, ref))); + } + + @Test + public void documentIdsDeserializeConflictThrows() { + final String expectedErrorMessage = "cannot apply @DocumentId on this property"; + final DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'docId': 'toBeOverwritten'}", DocumentIdOnStringField.class, ref)); + + assertExceptionContains( + expectedErrorMessage, + () -> + deserialize( + "{'docIdProperty': 'toBeOverwritten', 'anotherProperty': 100}", + DocumentIdOnStringFieldAsProperty.class, + ref)); + + assertExceptionContains( + expectedErrorMessage, + () -> + deserialize( + "{'nestedDocIdHolder': {'docId': 'toBeOverwritten'}}", + DocumentIdOnNestedObjects.class, + ref)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordTestHelper.java b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordTestHelper.java new file mode 100644 index 000000000000..6bfe845bed5e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test-jdk17/java/com/google/cloud/firestore/RecordTestHelper.java @@ -0,0 +1,224 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.core.ApiFuture; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.LocalFirestoreHelper.SingleField; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import com.google.protobuf.NullValue; +import com.google.type.LatLng; + +import static com.google.cloud.firestore.LocalFirestoreHelper.commitResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; + +import java.math.BigInteger; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; + + +public final class RecordTestHelper { + + public static final String DATABASE_NAME; + public static final String DOCUMENT_PATH; + public static final String DOCUMENT_NAME; + public static final String DOCUMENT_ROOT; + + public static final SingleComponent SINGLE_COMPONENT_OBJECT; + public static final Map SINGLE_COMPONENT_PROTO; + + public static final NestedRecord NESTED_RECORD_OBJECT; + public static final NestedRecordWithPOJO NESTED_RECORD_WITH_POJO_OBJECT; + public static final NestedPOJOWithRecord NESTED_POJO_WITH_RECORD_OBJECT; + + public static final ServerTimestamp SERVER_TIMESTAMP_OBJECT; + public static final Map SERVER_TIMESTAMP_PROTO; + + public static final AllSupportedTypes ALL_SUPPORTED_TYPES_OBJECT; + public static final Map ALL_SUPPORTED_TYPES_PROTO; + + public static final ApiFuture SINGLE_WRITE_COMMIT_RESPONSE; + + public static final ApiFuture FIELD_TRANSFORM_COMMIT_RESPONSE; + + public static final Date DATE; + public static final Timestamp TIMESTAMP; + public static final GeoPoint GEO_POINT; + public static final Blob BLOB; + + + public record SingleComponent( + String foo) { + } + + public record NestedRecord( + SingleComponent first, + AllSupportedTypes second) { + } + + public record NestedRecordWithPOJO( + SingleField first, + AllSupportedTypes second) { + } + + public static class NestedPOJOWithRecord { + public SingleField first = new SingleField(); + public AllSupportedTypes second = ALL_SUPPORTED_TYPES_OBJECT; + } + + public record ServerTimestamp ( + + @com.google.cloud.firestore.annotation.ServerTimestamp Date foo, + Inner inner + + ){ + record Inner ( + + @com.google.cloud.firestore.annotation.ServerTimestamp Date bar + ){} + } + + public record InvalidRecord ( + BigInteger bigIntegerValue, + Byte byteValue, + Short shortValue + ){} + + + public record AllSupportedTypes ( + + String foo, + Double doubleValue, + long longValue, + double nanValue, + double infValue, + double negInfValue, + boolean trueValue, + boolean falseValue, + SingleComponent objectValue, + Date dateValue, + Timestamp timestampValue, + List arrayValue, + String nullValue, + Blob bytesValue, + GeoPoint geoPointValue, + Map model + ){} + + static { + try { + DATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z").parse("1985-03-18 08:20:00.123 CET"); + } catch (ParseException e) { + throw new RuntimeException("Failed to parse date", e); + } + + TIMESTAMP = + Timestamp.ofTimeSecondsAndNanos( + TimeUnit.MILLISECONDS.toSeconds(DATE.getTime()), + 123000); // Firestore truncates to microsecond precision. + GEO_POINT = new GeoPoint(50.1430847, -122.9477780); + BLOB = Blob.fromBytes(new byte[] {1, 2, 3}); + + DATABASE_NAME = "projects/test-project/databases/(default)"; + DOCUMENT_PATH = "coll/doc"; + DOCUMENT_NAME = DATABASE_NAME + "/documents/" + DOCUMENT_PATH; + DOCUMENT_ROOT = DATABASE_NAME + "/documents/"; + + SINGLE_COMPONENT_OBJECT = new SingleComponent("bar"); + SINGLE_COMPONENT_PROTO = map("foo", Value.newBuilder().setStringValue("bar").build()); + + SERVER_TIMESTAMP_PROTO = Collections.emptyMap(); + SERVER_TIMESTAMP_OBJECT = new ServerTimestamp(null, new ServerTimestamp.Inner(null)); + + ALL_SUPPORTED_TYPES_OBJECT = new AllSupportedTypes("bar", 0.0, 0L, Double.NaN, Double.POSITIVE_INFINITY, + Double.NEGATIVE_INFINITY, true, false, + new SingleComponent("bar"), DATE, + TIMESTAMP, ImmutableList.of("foo"), null, BLOB, GEO_POINT, + ImmutableMap.of("foo", SINGLE_COMPONENT_OBJECT.foo())); + ALL_SUPPORTED_TYPES_PROTO = + ImmutableMap.builder() + .put("foo", Value.newBuilder().setStringValue("bar").build()) + .put("doubleValue", Value.newBuilder().setDoubleValue(0.0).build()) + .put("longValue", Value.newBuilder().setIntegerValue(0L).build()) + .put("nanValue", Value.newBuilder().setDoubleValue(Double.NaN).build()) + .put("infValue", Value.newBuilder().setDoubleValue(Double.POSITIVE_INFINITY).build()) + .put("negInfValue", Value.newBuilder().setDoubleValue(Double.NEGATIVE_INFINITY).build()) + .put("trueValue", Value.newBuilder().setBooleanValue(true).build()) + .put("falseValue", Value.newBuilder().setBooleanValue(false).build()) + .put( + "objectValue", + Value.newBuilder() + .setMapValue(MapValue.newBuilder().putAllFields(SINGLE_COMPONENT_PROTO)) + .build()) + .put( + "dateValue", + Value.newBuilder() + .setTimestampValue( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(479978400) + .setNanos(123000000)) // Dates only support millisecond precision. + .build()) + .put( + "timestampValue", + Value.newBuilder() + .setTimestampValue( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(479978400) + .setNanos(123000)) // Timestamps supports microsecond precision. + .build()) + .put( + "arrayValue", + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder().addValues(Value.newBuilder().setStringValue("foo"))) + .build()) + .put("nullValue", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()) + .put("bytesValue", Value.newBuilder().setBytesValue(BLOB.toByteString()).build()) + .put( + "geoPointValue", + Value.newBuilder() + .setGeoPointValue( + LatLng.newBuilder().setLatitude(50.1430847).setLongitude(-122.9477780)) + .build()) + .put( + "model", + Value.newBuilder() + .setMapValue(MapValue.newBuilder().putAllFields(SINGLE_COMPONENT_PROTO)) + .build()) + .build(); + SINGLE_WRITE_COMMIT_RESPONSE = commitResponse(/* adds= */ 1, /* deletes= */ 0); + + FIELD_TRANSFORM_COMMIT_RESPONSE = commitResponse(/* adds= */ 2, /* deletes= */ 0); + + NESTED_RECORD_OBJECT = new NestedRecord(SINGLE_COMPONENT_OBJECT, ALL_SUPPORTED_TYPES_OBJECT); + + NESTED_RECORD_WITH_POJO_OBJECT = new NestedRecordWithPOJO(new SingleField(), ALL_SUPPORTED_TYPES_OBJECT); + + NESTED_POJO_WITH_RECORD_OBJECT = new NestedPOJOWithRecord(); + } + +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateFieldTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateFieldTest.java new file mode 100644 index 000000000000..3b86b1f967c7 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateFieldTest.java @@ -0,0 +1,93 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class AggregateFieldTest { + + @Test + public void staticCountCreatesCountAggregateField() { + Object count = AggregateField.count(); + assertThat(count instanceof AggregateField.CountAggregateField).isTrue(); + } + + @Test + public void staticSumCreatesSumAggregateField() { + Object sum = AggregateField.sum("foo"); + assertThat(sum instanceof AggregateField.SumAggregateField).isTrue(); + } + + @Test + public void staticAverageCreatesAverageAggregateField() { + Object average = AggregateField.average("foo"); + assertThat(average instanceof AggregateField.AverageAggregateField).isTrue(); + } + + @Test + public void setsProperFieldPathForSum() { + AggregateField.SumAggregateField sum = AggregateField.sum("foo"); + assertThat(sum.getFieldPath().equals("foo")).isTrue(); + } + + @Test + public void setsProperFieldPathForAverage() { + AggregateField.AverageAggregateField average = AggregateField.average("foo"); + assertThat(average.getFieldPath().equals("foo")).isTrue(); + } + + @Test + public void setsProperOperatorForCount() { + AggregateField.CountAggregateField count = AggregateField.count(); + assertThat(count.getOperator().equals("count")).isTrue(); + } + + @Test + public void setsProperOperatorForSum() { + AggregateField.SumAggregateField sum = AggregateField.sum("foo"); + assertThat(sum.getOperator().equals("sum")).isTrue(); + } + + @Test + public void setsProperOperatorForAverage() { + AggregateField.AverageAggregateField average = AggregateField.average("foo"); + assertThat(average.getOperator().equals("average")).isTrue(); + } + + @Test + public void setsProperFieldPathWithEscapeChars() { + AggregateField.SumAggregateField sum = AggregateField.sum("has`invalid"); + assertThat(sum.getFieldPath().equals("`has\\`invalid`")).isTrue(); + } + + @Test + public void sumSetsProperAliasWithEscapeChars() { + AggregateField.SumAggregateField sum = AggregateField.sum("has`invalid"); + assertThat(sum.getAlias().equals("sum_`has\\`invalid`")).isTrue(); + } + + @Test + public void averageSetsProperAliasWithEscapeChars() { + AggregateField.AverageAggregateField average = AggregateField.average("has`invalid"); + assertThat(average.getAlias().equals("average_`has\\`invalid`")).isTrue(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQuerySnapshotTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQuerySnapshotTest.java new file mode 100644 index 000000000000..5fd1e822b923 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQuerySnapshotTest.java @@ -0,0 +1,174 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.Timestamp; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class AggregateQuerySnapshotTest { + + @Mock private Query mockQuery; + @Mock private Query mockQuery2; + + private AggregateQuery sampleAggregateQuery; + private AggregateQuery sampleAggregateQuery2; + private Timestamp sampleTimestamp; + private Timestamp sampleTimestamp2; + + private Map data42; + private Map data24; + + @Before + public void initializeSampleObjects() { + sampleAggregateQuery = + new AggregateQuery(mockQuery, Collections.singletonList(AggregateField.count())); + sampleAggregateQuery2 = + new AggregateQuery(mockQuery2, Collections.singletonList(AggregateField.count())); + sampleTimestamp = Timestamp.ofTimeSecondsAndNanos(42, 42); + sampleTimestamp2 = Timestamp.ofTimeSecondsAndNanos(24, 24); + data42 = new HashMap<>(); + data42.put("count", Value.newBuilder().setIntegerValue(42).build()); + data24 = new HashMap<>(); + data24.put("count", Value.newBuilder().setIntegerValue(24).build()); + } + + @Test + public void getQueryShouldReturnTheAggregateQuerySpecifiedToTheConstructor() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.getQuery()).isSameInstanceAs(sampleAggregateQuery); + } + + @Test + public void getReadTimeShouldReturnTheTimestampSpecifiedToTheConstructor() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.getReadTime()).isSameInstanceAs(sampleTimestamp); + } + + @Test + public void getCountShouldReturnTheCountSpecifiedToTheConstructor() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.getCount()).isEqualTo(42); + } + + @Test + public void hashCodeShouldReturnSameHashCodeWhenConstructedWithSameObjects() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot1.hashCode()).isEqualTo(snapshot2.hashCode()); + } + + @Test + public void hashCodeShouldReturnDifferentHashCodeWhenConstructedDifferentAggregateQuery() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery2, sampleTimestamp, data42); + assertThat(snapshot1.hashCode()).isNotEqualTo(snapshot2.hashCode()); + } + + @Test + public void hashCodeShouldReturnSameHashCodeWhenConstructedDifferentTimestamp() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp2, data42); + assertThat(snapshot1.hashCode()).isEqualTo(snapshot2.hashCode()); + } + + @Test + public void hashCodeShouldReturnDifferentHashCodeWhenConstructedDifferentCount() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data24); + assertThat(snapshot1.hashCode()).isNotEqualTo(snapshot2.hashCode()); + } + + @Test + public void equalsShouldReturnFalseWhenGivenNull() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.equals(null)).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenADifferentObject() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.equals("Not An AggregateQuerySnapshot")).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenAnAggregateQuerySnapshotWithADifferentQuery() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery2, sampleTimestamp, data42); + assertThat(snapshot1.equals(snapshot2)).isFalse(); + } + + @Test + public void equalsShouldReturnTrueWhenGivenAnAggregateQuerySnapshotWithADifferentReadTime() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp2, data42); + assertThat(snapshot1.equals(snapshot2)).isTrue(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenAnAggregateQuerySnapshotWithADifferentCount() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data24); + assertThat(snapshot1.equals(snapshot2)).isFalse(); + } + + @Test + public void equalsShouldReturnTrueWhenGivenTheSameAggregateQuerySnapshotInstance() { + AggregateQuerySnapshot snapshot = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot.equals(snapshot)).isTrue(); + } + + @Test + public void + equalsShouldReturnTrueWhenGivenAnAggregateQuerySnapshotConstructedWithTheSameArguments() { + AggregateQuerySnapshot snapshot1 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + AggregateQuerySnapshot snapshot2 = + new AggregateQuerySnapshot(sampleAggregateQuery, sampleTimestamp, data42); + assertThat(snapshot1.equals(snapshot2)).isTrue(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQueryTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQueryTest.java new file mode 100644 index 000000000000..9423ad1bb705 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/AggregateQueryTest.java @@ -0,0 +1,133 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.AggregateField.average; +import static com.google.cloud.firestore.AggregateField.count; +import static com.google.cloud.firestore.AggregateField.sum; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; +import static org.mockito.Mockito.mock; + +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import java.util.List; +import java.util.Objects; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class AggregateQueryTest { + + @Mock private Query mockQuery; + @Mock private Query mockQuery2; + + @Test + public void getQueryShouldReturnTheQuerySpecifiedToTheConstructor() { + AggregateQuery aggregateQuery = new AggregateQuery(mockQuery, singletonList(count())); + assertThat(aggregateQuery.getQuery()).isSameInstanceAs(mockQuery); + } + + @Test + public void hashCodeShouldReturnHashCodeOfUnderlyingQueryAndAggregateFieldList() { + List list = asList(count(), sum("foo"), average("bar")); + AggregateQuery aggregateQuery = new AggregateQuery(mockQuery, list); + assertThat(aggregateQuery.hashCode()).isEqualTo(Objects.hash(mockQuery, list)); + } + + @Test + public void equalsShouldReturnFalseWhenGivenNull() { + AggregateQuery aggregateQuery = + new AggregateQuery(mockQuery, asList(count(), sum("foo"), average("bar"))); + assertThat(aggregateQuery.equals(null)).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenADifferentObject() { + AggregateQuery aggregateQuery = + new AggregateQuery(mockQuery, asList(count(), sum("foo"), average("bar"))); + assertThat(aggregateQuery.equals("Not An AggregateQuery")).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenAnAggregateQueryWithADifferentQuery() { + AggregateQuery aggregateQuery1 = new AggregateQuery(mockQuery, singletonList(count())); + AggregateQuery aggregateQuery2 = new AggregateQuery(mockQuery2, singletonList(count())); + assertThat(aggregateQuery1.equals(aggregateQuery2)).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenAnAggregateQueryWithDifferentAggregations() { + AggregateQuery aggregateQuery1 = new AggregateQuery(mockQuery, singletonList(count())); + AggregateQuery aggregateQuery2 = new AggregateQuery(mockQuery, singletonList(sum("foo"))); + assertThat(aggregateQuery1.equals(aggregateQuery2)).isFalse(); + } + + @Test + public void equalsShouldReturnFalseWhenGivenAnAggregateQueryWithDifferentAggregationOrder() { + AggregateQuery aggregateQuery1 = + new AggregateQuery(mockQuery, asList(sum("foo"), average("bar"))); + AggregateQuery aggregateQuery2 = + new AggregateQuery(mockQuery, asList(average("bar"), sum("foo"))); + assertThat(aggregateQuery1.equals(aggregateQuery2)).isFalse(); + } + + @Test + public void equalsShouldReturnTrueWhenGivenTheSameAggregateQueryInstance() { + AggregateQuery aggregateQuery = new AggregateQuery(mockQuery, singletonList(count())); + assertThat(aggregateQuery.equals(aggregateQuery)).isTrue(); + } + + @Test + public void equalsShouldReturnTrueWhenGivenAnAggregateQueryWithTheSameQuery() { + AggregateQuery aggregateQuery1 = new AggregateQuery(mockQuery, singletonList(count())); + AggregateQuery aggregateQuery2 = new AggregateQuery(mockQuery, singletonList(count())); + assertThat(aggregateQuery1.equals(aggregateQuery2)).isTrue(); + } + + @Test + public void equalsShouldReturnTrueWhenGivenMultipleAggregationsWithTheSameQuery() { + AggregateQuery aggregateQuery1 = + new AggregateQuery(mockQuery, asList(count(), sum("foo"), average("bar"))); + AggregateQuery aggregateQuery2 = + new AggregateQuery(mockQuery, asList(count(), sum("foo"), average("bar"))); + assertThat(aggregateQuery1.equals(aggregateQuery2)).isTrue(); + } + + @Test + public void toProtoFromProtoRoundTripShouldProduceEqualAggregateQueryObjects() { + FirestoreImpl firestore = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + mock(FirestoreRpc.class)); + Query query1 = firestore.collection("abc"); + Query query2 = firestore.collection("def").whereEqualTo("age", 42).limit(5000).orderBy("name"); + AggregateQuery countQuery1 = query1.count(); + AggregateQuery countQuery2 = query2.count(); + AggregateQuery countQuery1Recreated = + AggregateQuery.fromProto(firestore, countQuery1.toProto()); + AggregateQuery countQuery2Recreated = + AggregateQuery.fromProto(firestore, countQuery2.toProto()); + assertThat(countQuery1).isNotSameInstanceAs(countQuery1Recreated); + assertThat(countQuery2).isNotSameInstanceAs(countQuery2Recreated); + assertThat(countQuery1).isEqualTo(countQuery1Recreated); + assertThat(countQuery2).isEqualTo(countQuery2Recreated); + assertThat(countQuery1).isNotEqualTo(countQuery2); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java new file mode 100644 index 000000000000..645c854b1791 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/BulkWriterTest.java @@ -0,0 +1,1432 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.batchWrite; +import static com.google.cloud.firestore.LocalFirestoreHelper.create; +import static com.google.cloud.firestore.LocalFirestoreHelper.delete; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.LocalFirestoreHelper.set; +import static com.google.cloud.firestore.LocalFirestoreHelper.update; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.*; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.LocalFirestoreHelper.ResponseStubber; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import io.grpc.Status; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class BulkWriterTest { + + public static final ApiFuture FAILED_FUTURE = + ApiFutures.immediateFailedFuture( + new ApiException( + new IllegalStateException("Mock batchWrite failed in test"), + GrpcStatusCode.of(Status.Code.UNKNOWN), + false)); + + private static final ApiFuture RETRYABLE_FAILED_FUTURE = + ApiFutures.immediateFailedFuture( + new ApiException( + new IllegalStateException("Mock batchWrite failed in test"), + GrpcStatusCode.of(Status.Code.ABORTED), + true)); + + private static final ApiFuture RESOURCE_EXHAUSTED_FAILED_FUTURE = + ApiFutures.immediateFailedFuture( + new ApiException( + new IllegalStateException("Mock batchWrite failed in test"), + GrpcStatusCode.of(Status.Code.RESOURCE_EXHAUSTED), + true)); + + @Rule public Timeout timeout = new Timeout(2, TimeUnit.SECONDS); + + private ScheduledExecutorService testExecutor; + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor batchWriteCapture; + + private BulkWriter bulkWriter; + private DocumentReference doc1; + private DocumentReference doc2; + + private ScheduledExecutorService timeoutExecutor; + + public static ApiFuture successResponse(int updateTimeSeconds) { + BatchWriteResponse.Builder response = BatchWriteResponse.newBuilder(); + response.addWriteResultsBuilder().getUpdateTimeBuilder().setSeconds(updateTimeSeconds).build(); + response.addStatusBuilder().build(); + return ApiFutures.immediateFuture(response.build()); + } + + public static ApiFuture failedResponse(int code) { + BatchWriteResponse.Builder response = BatchWriteResponse.newBuilder(); + response.addWriteResultsBuilder().build(); + response.addStatusBuilder().setCode(code).build(); + return ApiFutures.immediateFuture(response.build()); + } + + private ApiFuture failedResponse() { + return failedResponse(Code.DEADLINE_EXCEEDED_VALUE); + } + + public static ApiFuture mergeResponses( + ApiFuture... responses) throws Exception { + BatchWriteResponse.Builder response = BatchWriteResponse.newBuilder(); + for (ApiFuture future : responses) { + BatchWriteResponse res = future.get(); + response.addStatus(res.getStatus(0)); + response.addWriteResults(res.getWriteResults(0)); + } + return ApiFutures.immediateFuture(response.build()); + } + + @Before + public void before() { + testExecutor = Executors.newSingleThreadScheduledExecutor(); + + timeoutExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setExecutor(timeoutExecutor).build()); + + doc1 = firestoreMock.document("coll/doc1"); + doc2 = firestoreMock.document("coll/doc2"); + } + + @After + public void after() throws InterruptedException { + shutdownScheduledExecutorService(testExecutor); + shutdownScheduledExecutorService(timeoutExecutor); + } + + void shutdownScheduledExecutorService(ScheduledExecutorService executorService) + throws InterruptedException { + executorService.shutdown(); + // Wait for the executor to finish after each test. + // + // This ensures the executor service is shut down properly within the given timeout, and thereby + // avoids potential hangs caused by lingering threads. Note that if a given thread is terminated + // because of the timeout, the associated test will fail, which is what we want. + executorService.awaitTermination(100, TimeUnit.MILLISECONDS); + assertTrue(executorService.isTerminated()); + } + + @Test + public void hasSetMethod() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result = + bulkWriter.set(doc1, (Object) LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result.get().getUpdateTime()); + } + + @Test + public void hasUpdateMethod() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + update( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + com.google.firestore.v1.Precondition.newBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.newBuilder().build()) + .build(), + "coll/doc1")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result = + bulkWriter.update( + doc1, + LocalFirestoreHelper.SINGLE_FIELD_MAP, + Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(0, 0))); + bulkWriter.flush().get(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result.get().getUpdateTime()); + } + + @Test + public void hasDeleteMethod() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put(batchWrite(delete("coll/doc1")), successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result = bulkWriter.delete(doc1, Precondition.NONE); + bulkWriter.close(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result.get().getUpdateTime()); + } + + @Test + public void hasCreateMethod() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result = + bulkWriter.create(doc1, (Object) LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush().get(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result.get().getUpdateTime()); + } + + @Test + public void surfacesErrors() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse()); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + responseStubber.verifyAllRequestsSent(); + try { + result.get(); + fail("set() should have failed"); + } catch (Exception e) { + assertTrue(e.getCause() instanceof BulkWriterException); + assertEquals(Status.DEADLINE_EXCEEDED, ((BulkWriterException) e.getCause()).getStatus()); + } + } + + @Test + public void flushResolvesImmediatelyIfNoWrites() throws Exception { + bulkWriter.flush().get(); + } + + @Test + public void addsWritesToNewBatchAfterFlush() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(1)); + put( + batchWrite( + set( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + "coll/doc2")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result1 = bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush(); + ApiFuture result2 = + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP, SetOptions.merge()); + bulkWriter.close(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 0), result1.get().getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result2.get().getUpdateTime()); + } + + @Test + public void cannotCallMethodsAfterClose() throws Exception { + String expected = "BulkWriter has already been closed."; + bulkWriter.close(); + try { + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + fail("set() should have failed"); + } catch (Exception e) { + assertEquals(expected, e.getMessage()); + } + try { + bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + fail("create() should have failed"); + } catch (Exception e) { + assertEquals(expected, e.getMessage()); + } + try { + bulkWriter.update(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + fail("update() should have failed"); + } catch (Exception e) { + assertEquals(expected, e.getMessage()); + } + try { + bulkWriter.delete(doc1); + fail("delete() should have failed"); + } catch (Exception e) { + assertEquals(expected, e.getMessage()); + } + try { + bulkWriter.flush(); + fail("flush() should have failed"); + } catch (Exception e) { + assertEquals(expected, e.getMessage()); + } + // Close is idempotent and can be called multiple time. + bulkWriter.close(); + } + + @Test + public void closeWillShutdownExecutor() throws Exception { + // We ONLY shutdown executor when the executor was created within the BulkWriter. + // To simulate this, we set the autoShutdownBulkWriterExecutor field to true. + bulkWriter.autoShutdownBulkWriterExecutor = true; + + assertFalse(timeoutExecutor.isShutdown()); + bulkWriter.close(); + assertTrue(timeoutExecutor.isShutdown()); + } + + @Test + public void sendsWritesToSameDocInDifferentBatches() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(1)); + put( + batchWrite( + update( + map( + "foo", + Value.newBuilder().setStringValue("bar").build(), + "boo", + Value.newBuilder().setStringValue("far").build()), + Arrays.asList("boo", "foo"), + com.google.firestore.v1.Precondition.newBuilder().setExists(true).build(), + "coll/doc1")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + // Create another document reference pointing to the same document. + DocumentReference sameDoc = firestoreMock.document(doc1.getPath()); + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.update(sameDoc, "foo", "bar", "boo", "far"); + bulkWriter.close(); + + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 0), result1.get().getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result2.get().getUpdateTime()); + + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void sendWritesToDifferentDocsInSameBatch() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + mergeResponses(successResponse(1), successResponse(2))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.update(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + responseStubber.verifyAllRequestsSent(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 0), result1.get().getUpdateTime()); + 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 = + new ResponseStubber() { + { + put( + batchWrite( + create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2"), + update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3"), + delete("coll/doc4")), + mergeResponses( + successResponse(1), + successResponse(2), + successResponse(3), + successResponse(4))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + final List writeResults = new ArrayList(); + DocumentReference doc3 = firestoreMock.document("coll/doc3"); + DocumentReference doc4 = firestoreMock.document("coll/doc4"); + bulkWriter.addWriteResultListener( + (documentReference, result) -> writeResults.add((int) result.getUpdateTime().getSeconds())); + bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.update(doc3, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.delete(doc4); + bulkWriter.close(); + assertArrayEquals(new Integer[] {1, 2, 3, 4}, writeResults.toArray()); + } + + @Test + public void retriesFailedOperationsWithGlobalErrorCallback() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2"), + update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3"), + delete("coll/doc4")), + mergeResponses( + successResponse(1), + failedResponse(Code.INTERNAL_VALUE), + failedResponse(Code.INTERNAL_VALUE), + failedResponse(Code.INTERNAL_VALUE))); + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2"), + update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3"), + delete("coll/doc4")), + mergeResponses(successResponse(2), successResponse(3), successResponse(4))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + final List writeResults = new ArrayList<>(); + final List operations = new ArrayList<>(); + DocumentReference doc3 = firestoreMock.document("coll/doc3"); + DocumentReference doc4 = firestoreMock.document("coll/doc4"); + Executor userCallbackExecutor = Executors.newSingleThreadExecutor(); + bulkWriter.addWriteErrorListener( + userCallbackExecutor, + error -> { + operations.add(error.getOperationType().name()); + return true; + }); + bulkWriter.addWriteResultListener( + (documentReference, result) -> { + operations.add("SUCCESS"); + writeResults.add((int) result.getUpdateTime().getSeconds()); + }); + bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.update(doc3, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.delete(doc4); + bulkWriter.close(); + assertArrayEquals(new Integer[] {1, 2, 3, 4}, writeResults.toArray()); + assertArrayEquals( + new String[] {"SUCCESS", "SET", "UPDATE", "DELETE", "SUCCESS", "SUCCESS", "SUCCESS"}, + operations.toArray()); + } + + @Test + public void errorSurfacedEvenWithRetryFunction() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(update(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + final boolean[] errorListenerCalled = {false}; + bulkWriter.addWriteErrorListener( + error -> { + errorListenerCalled[0] = true; + assertEquals(Status.INTERNAL, error.getStatus()); + return false; + }); + + ApiFuture result = bulkWriter.update(doc1, FieldPath.of("foo"), "bar"); + bulkWriter.close(); + assertTrue(errorListenerCalled[0]); + try { + result.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertEquals(Status.INTERNAL, ((BulkWriterException) e.getCause()).getStatus()); + } + } + + @Test + public void surfacesExceptionsThrownByUserProvidedErrorListener() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.addWriteErrorListener( + error -> { + throw new UnsupportedOperationException("Test code threw UnsupportedOperationException"); + }); + + ApiFuture result = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + try { + result.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Test code threw UnsupportedOperationException")); + } + } + + @Test + public void writeFailsIfUserProvidedSuccessListenerFails() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + update( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + com.google.firestore.v1.Precondition.newBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.newBuilder().build()) + .build(), + "coll/doc1")), + successResponse(1)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.addWriteResultListener( + (documentReference, result) -> { + throw new UnsupportedOperationException("Test code threw UnsupportedOperationException"); + }); + + ApiFuture result = + bulkWriter.update( + doc1, Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(0, 0)), "foo", "bar"); + bulkWriter.close(); + try { + result.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Test code threw UnsupportedOperationException")); + } + } + + @Test + public void cannotChangeExecutorOnceWriteEnqueued() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + try { + bulkWriter.addWriteResultListener( + MoreExecutors.directExecutor(), (documentReference, result) -> {}); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue( + e.getMessage().contains("The executor cannot be changed once writes have been enqueued")); + } + + try { + bulkWriter.addWriteErrorListener(MoreExecutors.directExecutor(), error -> false); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue( + e.getMessage().contains("The executor cannot be changed once writes have been enqueued")); + } + + bulkWriter.close(); + } + + @Test + public void retriesMultipleTimes() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(1)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.addWriteErrorListener(error -> true); + + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 0), result1.get().getUpdateTime()); + } + + @Test + public void retriesWithSmallerBatchSize() throws Exception { + + final List writes = new ArrayList<>(); + final List> successResponses = new ArrayList<>(); + final List> failedResponses = new ArrayList<>(); + for (int i = 0; i < 15; i++) { + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc" + i)); + failedResponses.add(failedResponse(Code.ABORTED_VALUE)); + successResponses.add(successResponse(1)); + } + + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(writes.toArray(new Write[0])), + mergeResponses(failedResponses.toArray(new ApiFuture[0]))); + put( + batchWrite( + writes.subList(0, BulkWriter.RETRY_MAX_BATCH_SIZE).toArray(new Write[0])), + mergeResponses(successResponses.subList(0, 10).toArray(new ApiFuture[0]))); + put( + batchWrite( + writes.subList(BulkWriter.RETRY_MAX_BATCH_SIZE, 15).toArray(new Write[0])), + mergeResponses(successResponses.subList(10, 15).toArray(new ApiFuture[0]))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + for (int i = 0; i < 15; i++) { + bulkWriter.set(firestoreMock.document("coll/doc" + i), LocalFirestoreHelper.SINGLE_FIELD_MAP); + } + bulkWriter.close(); + } + + @Test + public void retryResolvesBeforeFlush() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(1)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + // Use separate futures to track listener completion since the callbacks are run on a different + // thread than the BulkWriter operations. + final SettableApiFuture flushComplete = SettableApiFuture.create(); + + final List operations = new ArrayList<>(); + bulkWriter.addWriteErrorListener(testExecutor, error -> true); + bulkWriter.addWriteResultListener(testExecutor, (reference, result) -> operations.add("DOC")); + + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter + .flush() + .addListener( + () -> { + operations.add("FLUSH"); + flushComplete.set(null); + }, + testExecutor); + flushComplete.get(); + + assertArrayEquals(new String[] {"DOC", "FLUSH"}, operations.toArray()); + } + + @Test + public void returnsTheErrorIfNoRetrySpecified() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.INTERNAL_VALUE)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.addWriteErrorListener(error -> error.getFailedAttempts() < 3); + + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + try { + result1.get(); + fail("Operation should have failed"); + } catch (Exception e) { + assertEquals(Status.INTERNAL, ((BulkWriterException) e.getCause()).getStatus()); + } + } + + @Test + public void sendBatchesWhenSizeLimitIsReached() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + update( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + com.google.firestore.v1.Precondition.newBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.newBuilder().build()) + .build(), + "coll/doc2"), + create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3")), + mergeResponses(successResponse(1), successResponse(2), successResponse(3))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.setMaxBatchSize(3); + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = + bulkWriter.update( + doc2, + Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(0, 0)), + FieldPath.of("foo"), + "bar"); + ApiFuture result3 = + bulkWriter.create( + firestoreMock.document("coll/doc3"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + + // The 4th write should not be sent because it should be in a new batch. + bulkWriter.delete(firestoreMock.document("coll/doc4")); + + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 0), result1.get().getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result2.get().getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(3, 0), result3.get().getUpdateTime()); + } + + @Test + public void retriesIndividualWritesThatFailWithAbortedOrUnavailable() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.UPDATED_FIELD_PROTO, "coll/doc2"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3")), + mergeResponses( + failedResponse(), + failedResponse(Code.UNAVAILABLE_VALUE), + failedResponse(Code.ABORTED_VALUE))); + put( + batchWrite( + set(LocalFirestoreHelper.UPDATED_FIELD_PROTO, "coll/doc2"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3")), + mergeResponses(successResponse(2), failedResponse(Code.ABORTED_VALUE))); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc3")), + successResponse(3)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + // Test writes to the same document in order to verify that retry logic unaffected by document + // key. + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.set(doc2, LocalFirestoreHelper.UPDATED_FIELD_MAP); + ApiFuture result3 = + bulkWriter.set(firestoreMock.document("coll/doc3"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + try { + result1.get(); + fail("set() should have failed"); + } catch (Exception e) { + assertTrue(e.getCause() instanceof BulkWriterException); + assertEquals(Status.DEADLINE_EXCEEDED, ((BulkWriterException) e.getCause()).getStatus()); + } + assertEquals(Timestamp.ofTimeSecondsAndNanos(2, 0), result2.get().getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(3, 0), result3.get().getUpdateTime()); + + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void writesCompleteInCorrectOrderBeforeFlush() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + set( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + mergeResponses(successResponse(1), failedResponse(Code.ABORTED_VALUE))); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + final List completions = new ArrayList<>(); + final SettableApiFuture flushComplete = SettableApiFuture.create(); + + bulkWriter + .set(doc1, (Object) LocalFirestoreHelper.SINGLE_FIELD_MAP, SetOptions.merge()) + .addListener(() -> completions.add("doc1"), testExecutor); + bulkWriter + .set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP) + .addListener(() -> completions.add("doc2"), testExecutor); + + ApiFuture flush = bulkWriter.flush(); + flush.addListener( + () -> { + completions.add("flush"); + flushComplete.set(null); + }, + testExecutor); + + flushComplete.get(); + assertEquals("doc1", completions.get(0)); + assertEquals("doc2", completions.get(1)); + assertEquals("flush", completions.get(2)); + } + + @Test + public void flushCompletesWhenAllWritesComplete() 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(failedResponse(), successResponse(1), successResponse(1))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result3 = + bulkWriter.set(firestoreMock.document("coll/doc3"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture flush = bulkWriter.flush(); + try { + result1.get(); + } catch (ExecutionException e) { + // Ignore + } + result2.get(); + result3.get(); + // `flush()` should now be complete, but it might resolve a tick later since we wrap flush + // in another future to suppress any errors. + flush.get(100, TimeUnit.MILLISECONDS); + } + + @Test + public void doesNotSendBatchesIfDoingSoExceedsRateLimit() throws Exception { + // This future is completed when the BulkWriter schedules a timeout. This test waits on the + // future at the end of the test to ensure that the timeout was called. + final SettableApiFuture timeoutCalledFuture = SettableApiFuture.create(); + + final ScheduledExecutorService customExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + if (delay > 0) { + timeoutCalledFuture.set(null); + } + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + // Stub responses for the BulkWriter batches. + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc")), + successResponse(5)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + BulkWriter bulkWriter = + firestoreMock.bulkWriter( + BulkWriterOptions.builder() + .setInitialOpsPerSecond(5) + .setExecutor(customExecutor) + .build()); + + for (int i = 0; i < 600; ++i) { + bulkWriter.set(firestoreMock.document("coll/doc"), LocalFirestoreHelper.SINGLE_FIELD_MAP); + } + bulkWriter.flush(); + timeoutCalledFuture.get(); + shutdownScheduledExecutorService(customExecutor); + } + + @Test + public void flushSucceedsEvenIfBulkCommitFails() throws Exception { + doReturn(FAILED_FUTURE) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush().get(); + } + + @Test + public void closeSucceedsEvenIfBulkCommitFails() throws Exception { + doReturn(FAILED_FUTURE) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + } + + @Test + public void individualWritesErrorIfBulkCommitFails() throws Exception { + doReturn(FAILED_FUTURE) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + int opCount = 0; + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + for (ApiFuture result : Arrays.asList(result1, result2)) { + try { + result.get(); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Mock batchWrite failed in test")); + ++opCount; + } + } + assertEquals(2, opCount); + } + + @Test + public void individualWritesErrorIfBulkCommitFailsWithNonFirestoreException() throws Exception { + doReturn(FAILED_FUTURE) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + int opCount = 0; + ApiFuture result1 = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + ApiFuture result2 = bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + for (ApiFuture result : Arrays.asList(result1, result2)) { + try { + result.get(); + } catch (Exception e) { + assertTrue( + e.getMessage() + .contains("java.lang.IllegalStateException: Mock batchWrite failed in test")); + ++opCount; + } + } + assertEquals(2, opCount); + } + + @Test + public void retriesWritesWhenBatchWriteFailsWithRetryableError() throws Exception { + doReturn(RETRYABLE_FAILED_FUTURE) + .doReturn(RETRYABLE_FAILED_FUTURE) + .doReturn(RETRYABLE_FAILED_FUTURE) + .doReturn(successResponse(3)) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + ApiFuture result = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + + assertEquals(Timestamp.ofTimeSecondsAndNanos(3, 0), result.get().getUpdateTime()); + } + + @Test + public void failsWritesAfterAllRetryAttemptsFail() throws Exception { + final int[] retryAttempts = {0}; + final int[] scheduleWithDelayCount = {0}; + final ScheduledExecutorService customExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + if (delay > 0) { + int expected = + (int) + (BulkWriterOperation.DEFAULT_BACKOFF_INITIAL_DELAY_MS + * Math.pow(1.5, retryAttempts[0] - 1)); + + assertTrue(delay >= (1 - BulkWriter.DEFAULT_JITTER_FACTOR) * expected); + assertTrue(delay <= (1 + BulkWriter.DEFAULT_JITTER_FACTOR) * expected); + scheduleWithDelayCount[0]++; + } + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + doAnswer( + mock -> { + retryAttempts[0]++; + return RETRYABLE_FAILED_FUTURE; + }) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setExecutor(customExecutor).build()); + ApiFuture result = bulkWriter.set(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush().get(); + + try { + result.get(); + Assert.fail("Expected set() operation to fail"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Mock batchWrite failed in test")); + assertEquals(BulkWriter.MAX_RETRY_ATTEMPTS + 1, retryAttempts[0]); + // The first attempt should not have a delay. + assertEquals(BulkWriter.MAX_RETRY_ATTEMPTS, scheduleWithDelayCount[0]); + } finally { + shutdownScheduledExecutorService(customExecutor); + } + } + + @Test + public void appliesMaxBackoffOnRetriesForResourceExhausted() throws Exception { + final int[] retryAttempts = {0}; + final int[] scheduleWithDelayCount = {0}; + final ScheduledExecutorService customExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + if (delay > 0) { + assertTrue( + delay + >= (1 - BulkWriter.DEFAULT_JITTER_FACTOR) + * BulkWriterOperation.DEFAULT_BACKOFF_MAX_DELAY_MS); + assertTrue( + delay + <= (1 + BulkWriter.DEFAULT_JITTER_FACTOR) + * BulkWriterOperation.DEFAULT_BACKOFF_MAX_DELAY_MS); + scheduleWithDelayCount[0]++; + } + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + doAnswer( + mock -> { + retryAttempts[0]++; + return RESOURCE_EXHAUSTED_FAILED_FUTURE; + }) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setExecutor(customExecutor).build()); + bulkWriter.addWriteErrorListener(error -> error.getFailedAttempts() < 5); + + ApiFuture result = bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush().get(); + + try { + result.get(); + Assert.fail("Expected create() operation to fail"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Mock batchWrite failed in test")); + assertEquals(5, retryAttempts[0]); + // The first attempt should not have a delay. + assertEquals(4, scheduleWithDelayCount[0]); + } finally { + shutdownScheduledExecutorService(customExecutor); + } + } + + @Test + public void usesHighestBackoffFoundInBatch() throws Exception { + final int[] expected = { + BulkWriterOperation.DEFAULT_BACKOFF_MAX_DELAY_MS, + (int) + (BulkWriterOperation.DEFAULT_BACKOFF_INITIAL_DELAY_MS + * BulkWriterOperation.DEFAULT_BACKOFF_FACTOR) + }; + final int[] retryAttempts = {0}; + final ScheduledExecutorService customExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + if (delay > 0) { + // The 1st batch should have max backoff. 2nd batch should have 1 round of backoff + // applied. + assertTrue( + delay >= (1 - BulkWriter.DEFAULT_JITTER_FACTOR) * expected[retryAttempts[0]]); + assertTrue( + delay <= (1 + BulkWriter.DEFAULT_JITTER_FACTOR) * expected[retryAttempts[0]]); + retryAttempts[0]++; + } + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + mergeResponses( + failedResponse(Code.RESOURCE_EXHAUSTED_VALUE), + failedResponse(Code.UNAVAILABLE_VALUE))); + put( + batchWrite( + create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1"), + set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + mergeResponses(successResponse(1), failedResponse(Code.UNAVAILABLE_VALUE))); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + successResponse(2)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setExecutor(customExecutor).build()); + bulkWriter.addWriteErrorListener(error -> error.getFailedAttempts() < 5); + + bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); + assertEquals(2, retryAttempts[0]); + shutdownScheduledExecutorService(customExecutor); + } + + @Test + @Ignore("b/329596806") + public void sendsBackoffBatchAfterOtherEnqueuedBatches() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + failedResponse(Code.RESOURCE_EXHAUSTED_VALUE)); + put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc2")), + successResponse(0)); + put( + batchWrite(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc1")), + successResponse(0)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + bulkWriter.addWriteErrorListener(error -> error.getFailedAttempts() < 5); + bulkWriter.create(doc1, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.flush(); + bulkWriter.set(doc2, LocalFirestoreHelper.SINGLE_FIELD_MAP); + bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void optionsRequiresPositiveInteger() throws Exception { + try { + firestoreMock.bulkWriter(BulkWriterOptions.builder().setInitialOpsPerSecond(-1).build()); + fail("bulkWriter() call should have failed"); + } catch (Exception e) { + assertEquals( + e.getMessage(), + "Value for argument 'initialOpsPerSecond' must be greater than 1, but was: -1"); + } + + try { + firestoreMock.bulkWriter(BulkWriterOptions.builder().setMaxOpsPerSecond(-1).build()); + fail("bulkWriter() call should have failed"); + } catch (Exception e) { + assertEquals( + e.getMessage(), + "Value for argument 'maxOpsPerSecond' must be greater than 1, but was: -1"); + } + } + + @Test + public void optionsRequiresMaxGreaterThanInitial() throws Exception { + try { + firestoreMock.bulkWriter( + BulkWriterOptions.builder().setInitialOpsPerSecond(550).setMaxOpsPerSecond(500).build()); + fail("bulkWriter() call should have failed"); + } catch (Exception e) { + assertEquals(e.getMessage(), "'maxOpsPerSecond' cannot be less than 'initialOpsPerSecond'."); + } + } + + @Test + public void cannotSetThrottlingOptionsWithThrottlingDisabled() throws Exception { + try { + firestoreMock.bulkWriter( + BulkWriterOptions.builder() + .setThrottlingEnabled(false) + .setInitialOpsPerSecond(500) + .build()); + fail("bulkWriter() call should have failed"); + } catch (Exception e) { + assertEquals( + e.getMessage(), + "Cannot set 'initialOpsPerSecond' or 'maxOpsPerSecond' when 'throttlingEnabled' is set to" + + " false."); + } + + try { + firestoreMock.bulkWriter( + BulkWriterOptions.builder().setThrottlingEnabled(false).setMaxOpsPerSecond(500).build()); + fail("bulkWriter() call should have failed"); + } catch (Exception e) { + assertEquals( + e.getMessage(), + "Cannot set 'initialOpsPerSecond' or 'maxOpsPerSecond' when 'throttlingEnabled' is set to" + + " false."); + } + } + + @Test + public void optionsInitialAndMaxRatesAreProperlySet() throws Exception { + BulkWriter bulkWriter = + firestoreMock.bulkWriter( + BulkWriterOptions.builder() + .setInitialOpsPerSecond(500) + .setMaxOpsPerSecond(550) + .build()); + assertEquals(bulkWriter.getRateLimiter().getInitialCapacity(), 500); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), 550); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setMaxOpsPerSecond(1000).build()); + assertEquals(bulkWriter.getRateLimiter().getInitialCapacity(), 500); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), 1000); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setInitialOpsPerSecond(100).build()); + assertEquals(bulkWriter.getRateLimiter().getInitialCapacity(), 100); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), Integer.MAX_VALUE); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setMaxOpsPerSecond(100).build()); + assertEquals(bulkWriter.getRateLimiter().getInitialCapacity(), 100); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), 100); + + bulkWriter = firestoreMock.bulkWriter(); + assertEquals( + bulkWriter.getRateLimiter().getInitialCapacity(), + BulkWriter.DEFAULT_STARTING_MAXIMUM_OPS_PER_SECOND); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), Integer.MAX_VALUE); + + bulkWriter = + firestoreMock.bulkWriter(BulkWriterOptions.builder().setThrottlingEnabled(false).build()); + assertEquals(bulkWriter.getRateLimiter().getInitialCapacity(), Integer.MAX_VALUE); + assertEquals(bulkWriter.getRateLimiter().getMaximumRate(), Integer.MAX_VALUE); + } + + @Test + public void closeHandlesLargeNumberOfBufferedOps() throws Exception { + final int numOps = 100; + + bulkWriter.setMaxPendingOpCount(5); + bulkWriter.setMaxBatchSize(1); + bulkWriter.autoShutdownBulkWriterExecutor = true; + + ResponseStubber responseStubber = new ResponseStubber(); + + for (int i = 0; i < numOps; i += 1) { + responseStubber.put( + batchWrite(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, "coll/doc" + i)), + successResponse(1)); + } + + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + for (int i = 0; i < numOps; ++i) { + bulkWriter.set(firestoreMock.document("coll/doc" + i), LocalFirestoreHelper.SINGLE_FIELD_MAP); + } + bulkWriter.close(); + responseStubber.verifyAllRequestsSent(); + assertEquals(numOps, responseStubber.actualRequestList.size()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/CollectionReferenceTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/CollectionReferenceTest.java new file mode 100644 index 000000000000..9e22b40a74e7 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/CollectionReferenceTest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doReturn; + +import com.google.api.core.ApiFuture; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class CollectionReferenceTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor argCaptor; + + private CollectionReference collectionReference; + + @Before + public void before() { + collectionReference = firestoreMock.collection("coll"); + } + + public boolean matchesIgnoresName(CommitRequest o) { + CommitRequest.Builder actual = o.toBuilder(); + actual.getWritesBuilder(0).getUpdateBuilder().clearName().build(); + CommitRequest.Builder expected = LocalFirestoreHelper.SINGLE_CREATE_COMMIT_REQUEST.toBuilder(); + expected.getWritesBuilder(0).getUpdateBuilder().clearName().build(); + return actual.build().equals(expected.build()); + } + + @Test + public void getDocument() { + DocumentReference documentReference = collectionReference.document("doc"); + assertEquals("doc", documentReference.getId()); + documentReference = collectionReference.document(); + assertEquals(20, documentReference.getId().length()); + + try { + collectionReference.document(""); + fail(); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().endsWith("'path' must be a non-empty String")); + } + } + + @Test + public void getParent() { + DocumentReference documentReference = collectionReference.getParent(); + assertNull(documentReference); + CollectionReference subcollection = collectionReference.document("doc").collection("subcoll"); + assertEquals("subcoll", subcollection.getId()); + assertEquals("coll/doc/subcoll", subcollection.getPath()); + documentReference = subcollection.getParent(); + assertEquals("doc", documentReference.getId()); + } + + @Test + public void addDocument() throws Exception { + doReturn(LocalFirestoreHelper.SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + argCaptor.capture(), + ArgumentMatchers.>any()); + + ApiFuture future = + collectionReference.add(LocalFirestoreHelper.SINGLE_FIELD_MAP); + DocumentReference documentReference = future.get(); + assertEquals(20, documentReference.getId().length()); + + future = collectionReference.add(LocalFirestoreHelper.SINGLE_FIELD_OBJECT); + documentReference = future.get(); + assertEquals(20, documentReference.getId().length()); + + assertTrue(matchesIgnoresName(argCaptor.getValue())); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceConversions.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceConversions.java new file mode 100644 index 000000000000..6290bc65be45 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceConversions.java @@ -0,0 +1,127 @@ +/* + * Copyright 2019 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.cloud.Timestamp; +import com.google.cloud.conformance.firestore.v1.TestDefinition; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +final class ConformanceConversions { + + private static final Gson gson = new Gson(); + + private ConformanceConversions() {} + + /** Converts a Protobuf Precondition to its API counterpart. */ + static Precondition convertPrecondition(com.google.firestore.v1.Precondition precondition) { + switch (precondition.getConditionTypeCase()) { + case EXISTS: + return Precondition.exists(precondition.getExists()); + case UPDATE_TIME: + return Precondition.updatedAt(Timestamp.fromProto(precondition.getUpdateTime())); + default: + return Precondition.NONE; + } + } + + /** Converts a list of Proto FieldPaths to its API counterpart. */ + static List convertPaths(List fieldsList) { + List convertedPaths = new ArrayList<>(); + for (TestDefinition.FieldPath fieldPath : fieldsList) { + convertedPaths.add(convertPath(fieldPath)); + } + return convertedPaths; + } + + /** Converts a Proto FieldPath to its API counterpart. */ + static FieldPath convertPath(TestDefinition.FieldPath fieldPath) { + return FieldPath.of(fieldPath.getFieldList().toArray(new String[0])); + } + + /** Converts a JSON string into a Java Map. */ + static Map convertInput(String jsonMap) { + Type type = new TypeToken>() {}.getType(); + Map parsedData = gson.fromJson(jsonMap, type); + return convertMap(parsedData); + } + + /** Converts a list of Strings into a Java Object. Parses JSON when provided. */ + static List convertInput(List jsonValues) { + List result = new ArrayList<>(); + for (String input : jsonValues) { + if (input.matches("^\\{.*}$")) { + result.add(convertInput(input)); + } else { + // We need to "fake" a proper JSON object to let GSON convert to native types. + result.add(convertInput("{a:" + input + "}").get("a")); + } + } + return result; + } + + /** Helper function to convert test values in a nested Map to Firestore API types. */ + private static Map convertMap(Map parsedData) { + parsedData.replaceAll((k, v) -> convertValue(v)); + return parsedData; + } + + /** + * Converts test values to Firestore API types. Replaces sentinel values with their FieldValue + * constants. + */ + @SuppressWarnings("unchecked") + private static Object convertValue(Object data) { + if (data instanceof Map) { + return convertMap((Map) data); + } else if (data instanceof List) { + return convertArray((List) data); + } else if ("NaN".equals(data)) { + return Double.NaN; + } else if ("Delete".equals(data)) { + return FieldValue.delete(); + } else if ("ServerTimestamp".equals(data)) { + return FieldValue.serverTimestamp(); + } else if (data instanceof Double + && Double.compare((double) data, Math.floor((double) data)) == 0) { + return (long) (double) data; + } else { + return data; + } + } + + /** Helper function to convert test values in a list to Firestore API types. */ + @SuppressWarnings("unchecked") + private static Object convertArray(List list) { + if (!list.isEmpty() && list.get(0).equals("ArrayUnion")) { + return FieldValue.arrayUnion( + ((List) convertArray(list.subList(1, list.size()))).toArray()); + } else if (!list.isEmpty() && list.get(0).equals("ArrayRemove")) { + return FieldValue.arrayRemove( + ((List) convertArray(list.subList(1, list.size()))).toArray()); + } else { + for (int i = 0; i < list.size(); ++i) { + list.set(i, convertValue(list.get(i))); + } + return list; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java new file mode 100644 index 000000000000..8b759e10da09 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ConformanceTest.java @@ -0,0 +1,755 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.conformance.ConformanceTestLocator.newMatchPattern; +import static com.google.cloud.firestore.ConformanceConversions.convertInput; +import static com.google.cloud.firestore.ConformanceConversions.convertPath; +import static com.google.cloud.firestore.ConformanceConversions.convertPaths; +import static com.google.cloud.firestore.ConformanceConversions.convertPrecondition; +import static com.google.cloud.firestore.LocalFirestoreHelper.commitResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAllResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static com.google.cloud.firestore.UserDataConverter.NO_DELETES; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; + +import com.google.api.core.ApiFuture; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.cloud.Timestamp; +import com.google.cloud.conformance.ConformanceTestLocator; +import com.google.cloud.conformance.ConformanceTestLocator.MatchPattern; +import com.google.cloud.conformance.firestore.v1.TestDefinition; +import com.google.cloud.conformance.firestore.v1.TestDefinition.Clause; +import com.google.cloud.conformance.firestore.v1.TestDefinition.CreateTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.Cursor; +import com.google.cloud.conformance.firestore.v1.TestDefinition.DeleteTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.DocChange; +import com.google.cloud.conformance.firestore.v1.TestDefinition.DocChange.Kind; +import com.google.cloud.conformance.firestore.v1.TestDefinition.DocSnapshot; +import com.google.cloud.conformance.firestore.v1.TestDefinition.GetTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.ListenTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.OrderBy; +import com.google.cloud.conformance.firestore.v1.TestDefinition.SetTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.Snapshot; +import com.google.cloud.conformance.firestore.v1.TestDefinition.UpdatePathsTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.UpdateTest; +import com.google.cloud.conformance.firestore.v1.TestDefinition.Where; +import com.google.cloud.firestore.Query.Direction; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.base.Preconditions; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.protobuf.Message; +import com.google.protobuf.util.JsonFormat; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import junit.framework.Test; +import junit.framework.TestResult; +import junit.framework.TestSuite; +import org.junit.Assert; +import org.junit.runner.Describable; +import org.junit.runner.Description; +import org.junit.runner.RunWith; +import org.junit.runners.AllTests; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; + +@RunWith(AllTests.class) +public class ConformanceTest { + + /** Excluded tests by test description. */ + private static final Set excludedTests = Collections.emptySet(); + + /** If non-empty, only runs tests included in this set. */ + private static final Set includedTests = Collections.emptySet(); + + /** If true, prints debug information to System.out. */ + private static final boolean DEBUG_MODE = !includedTests.isEmpty(); + + public ConformanceTest() {} + + /** Generate the test suite based on the tests defined in test_data.binprotos. */ + public static TestSuite suite() throws Exception { + TestSuite suite = new TestSuite(); + final TestDefinition.TestFile testSuite = parseTests(); + for (Test test : initTests(testSuite)) { + suite.addTest(test); + } + return suite; + } + + private static List initTests(TestDefinition.TestFile testSuite) { + final List tests = new ArrayList<>(); + for (final TestDefinition.Test testDefinition : testSuite.getTestsList()) { + if (!includedTests.isEmpty() && !includedTests.contains(testDefinition.getDescription()) + || excludedTests.contains(testDefinition.getDescription())) { + continue; + } + tests.add(buildTest(testDefinition)); + } + + return tests; + } + + /** Reads the test definition from the Proto file. */ + private static TestDefinition.TestFile parseTests() throws IOException, URISyntaxException { + final ClassLoader cl = Thread.currentThread().getContextClassLoader(); + final MatchPattern matchPattern = + newMatchPattern("com/google/cloud/conformance/firestore/v1", ".json"); + final List jsonResources = + ConformanceTestLocator.findAllResourcePaths(matchPattern, cl); + + final TestDefinition.TestFile.Builder suite = TestDefinition.TestFile.newBuilder(); + + for (String jsonResource : jsonResources) { + final InputStream is = cl.getResourceAsStream(jsonResource); + Assert.assertNotNull(String.format("Unable to load test definition: '%s'", jsonResource), is); + final InputStreamReader reader = new InputStreamReader(is); + final TestDefinition.TestFile.Builder testBuilder = TestDefinition.TestFile.newBuilder(); + JsonFormat.parser().merge(reader, testBuilder); + suite.addAllTests(testBuilder.build().getTestsList()); + } + return suite.build(); + } + + /** Returns the test case for the provided test definition. */ + private static Test buildTest(final TestDefinition.Test td) { + switch (td.getTestCase()) { + case GET: + return new ConformanceGetTestRunner(td.getDescription(), td.getGet()); + case CREATE: + return new ConformanceCreateTestRunner(td.getDescription(), td.getCreate()); + case SET: + return new ConformanceSetTestRunner(td.getDescription(), td.getSet()); + case UPDATE: + return new ConformanceUpdateTestRunner(td.getDescription(), td.getUpdate()); + case UPDATE_PATHS: + return new ConformanceUpdatePathsTestRunner(td.getDescription(), td.getUpdatePaths()); + case DELETE: + return new ConformanceDeleteTestRunner(td.getDescription(), td.getDelete()); + case QUERY: + return new ConformanceQueryTestRunner(td.getDescription(), td.getQuery()); + case LISTEN: + return new ConformanceListenTestRunner(td.getDescription(), td.getListen()); + default: + throw new UnsupportedOperationException("Unknown test case type: " + td.getTestCase()); + } + } + + private abstract static class BaseConformanceTestRunner implements Test, Describable { + private static final String DEBUG_MESSAGE_FORMAT = + "--- Test Description -----------------------------------------------------------%n" + + "%s%n" + + "--- Test Case ------------------------------------------------------------------%n" + + "%s%n" + + "--------------------------------------------------------------------------------%n"; + + protected static final String ROOT_COLLECTION_PATH = + "projects/projectID/databases/(default)/documents/"; + + private final Description description; + protected final T testParameters; + protected final FirestoreImpl firestore; + + protected BaseConformanceTestRunner(final String description, final T testParameters) { + this.description = + Description.createTestDescription(ConformanceTest.class.getName(), description); + this.testParameters = testParameters; + ScheduledExecutorService firestoreExecutor = Executors.newSingleThreadScheduledExecutor(); + FirestoreRpc firestoreRpc = Mockito.mock(FirestoreRpc.class); + when(firestoreRpc.getExecutor()).thenReturn(firestoreExecutor); + this.firestore = + Mockito.spy( + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("projectID").build(), firestoreRpc)); + } + + @Override + public final Description getDescription() { + return description; + } + + @Override + public final int countTestCases() { + return 1; + } + + @Override + public final void run(TestResult testResult) { + testResult.startTest(this); + testResult.runProtected( + this, + () -> { + if (DEBUG_MODE) { + System.out.printf(DEBUG_MESSAGE_FORMAT, description, testParameters); + } + try (AutoCloseable mocks = MockitoAnnotations.openMocks(this)) { + runTest(); + } + }); + testResult.endTest(this); + } + + public abstract void runTest() throws Throwable; + + @Override + public final String toString() { + return getClass().getSimpleName() + "{" + "description=" + description.getDisplayName() + '}'; + } + + /** Creates a document reference from an absolute path. */ + final DocumentReference document(final String absolutePath) { + Preconditions.checkState(absolutePath.startsWith(ROOT_COLLECTION_PATH)); + return firestore.document(absolutePath.substring(ROOT_COLLECTION_PATH.length())); + } + + /** Creates a collection reference from an absolute path. */ + final CollectionReference collection(final String absolutePath) { + Preconditions.checkState(absolutePath.startsWith(ROOT_COLLECTION_PATH)); + return firestore.collection(absolutePath.substring(ROOT_COLLECTION_PATH.length())); + } + } + + private static final class ConformanceGetTestRunner extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor getAllCapture; + @Captor private ArgumentCaptor> streamObserverCapture; + + private ConformanceGetTestRunner(String description, GetTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() throws Throwable { + doAnswer(getAllResponse(Collections.emptyMap())) + .when(firestore) + .streamRequest(getAllCapture.capture(), streamObserverCapture.capture(), any()); + + document(testParameters.getDocRefPath()).get().get(); + + BatchGetDocumentsRequest request = getAllCapture.getValue(); + + Assert.assertEquals(1, request.getDocumentsCount()); + Assert.assertEquals(testParameters.getRequest().getName(), request.getDocuments(0)); + } + } + + private static final class ConformanceCreateTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor commitCapture; + + private ConformanceCreateTestRunner(String description, CreateTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() { + doReturn(commitResponse(testParameters.getRequest().getWritesCount(), 0)) + .when(firestore) + .sendRequest(commitCapture.capture(), any()); + + try { + ApiFuture apiCall = + document(testParameters.getDocRefPath()) + .create(convertInput(testParameters.getJsonData())); + + Assert.assertFalse(testParameters.getIsError()); + apiCall.get(); + + CommitRequest request = commitCapture.getValue(); + Assert.assertEquals(testParameters.getRequest(), request); + + } catch (Exception e) { + Assert.assertTrue(testParameters.getIsError()); + } + } + } + + private static final class ConformanceSetTestRunner extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor commitCapture; + + private ConformanceSetTestRunner(String description, SetTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() { + doReturn(commitResponse(testParameters.getRequest().getWritesCount(), 0)) + .when(firestore) + .sendRequest(commitCapture.capture(), any()); + ApiFuture apiCall; + + try { + if (testParameters.hasOption() && testParameters.getOption().getAll()) { + apiCall = + document(testParameters.getDocRefPath()) + .set(convertInput(testParameters.getJsonData()), SetOptions.merge()); + } else if (testParameters.hasOption() && testParameters.getOption().getFieldsCount() > 0) { + apiCall = + document(testParameters.getDocRefPath()) + .set( + convertInput(testParameters.getJsonData()), + SetOptions.mergeFieldPaths( + convertPaths(testParameters.getOption().getFieldsList()))); + } else { + apiCall = + document(testParameters.getDocRefPath()) + .set(convertInput(testParameters.getJsonData())); + } + + Assert.assertFalse(testParameters.getIsError()); + apiCall.get(); + + CommitRequest request = commitCapture.getValue(); + Assert.assertEquals(testParameters.getRequest(), request); + } catch (Exception e) { + Assert.assertTrue(testParameters.getIsError()); + } + } + } + + private static final class ConformanceUpdateTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor commitCapture; + + private ConformanceUpdateTestRunner(String description, UpdateTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() { + doReturn(commitResponse(testParameters.getRequest().getWritesCount(), 0)) + .when(firestore) + .sendRequest(commitCapture.capture(), any()); + + try { + ApiFuture apiCall; + + if (testParameters.hasPrecondition()) { + apiCall = + document(testParameters.getDocRefPath()) + .update( + convertInput(testParameters.getJsonData()), + convertPrecondition(testParameters.getPrecondition())); + } else { + apiCall = + document(testParameters.getDocRefPath()) + .update(convertInput(testParameters.getJsonData())); + } + + Assert.assertFalse(testParameters.getIsError()); + + apiCall.get(); + CommitRequest request = commitCapture.getValue(); + Assert.assertEquals(testParameters.getRequest(), request); + } catch (Exception e) { + Assert.assertTrue(testParameters.getIsError()); + } + } + } + + private static final class ConformanceUpdatePathsTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor commitCapture; + + private ConformanceUpdatePathsTestRunner(String description, UpdatePathsTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() { + doReturn(commitResponse(testParameters.getRequest().getWritesCount(), 0)) + .when(firestore) + .sendRequest(commitCapture.capture(), any()); + + try { + ApiFuture apiCall; + + List fieldPaths = convertPaths(testParameters.getFieldPathsList()); + FieldPath firstField = fieldPaths.remove(0); + + List values = convertInput(testParameters.getJsonValuesList()); + Object firstValue = values.remove(0); + + Object[] moreFieldsAndValues = new Object[2 * fieldPaths.size()]; + + for (int i = 0; i < fieldPaths.size(); ++i) { + moreFieldsAndValues[2 * i] = fieldPaths.get(i); + moreFieldsAndValues[2 * i + 1] = values.get(i); + } + + if (testParameters.hasPrecondition()) { + apiCall = + document(testParameters.getDocRefPath()) + .update( + convertPrecondition(testParameters.getPrecondition()), + firstField, + firstValue, + moreFieldsAndValues); + } else { + apiCall = + document(testParameters.getDocRefPath()) + .update(firstField, firstValue, moreFieldsAndValues); + } + + Assert.assertFalse(testParameters.getIsError()); + + apiCall.get(); + CommitRequest request = commitCapture.getValue(); + Assert.assertEquals(testParameters.getRequest(), request); + } catch (Exception e) { + Assert.assertTrue(testParameters.getIsError()); + } + } + } + + private static final class ConformanceDeleteTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor commitCapture; + + private ConformanceDeleteTestRunner(String description, DeleteTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() throws Throwable { + doReturn(commitResponse(0, testParameters.getRequest().getWritesCount())) + .when(firestore) + .sendRequest(commitCapture.capture(), any()); + + if (!testParameters.hasPrecondition()) { + document(testParameters.getDocRefPath()).delete().get(); + } else { + document(testParameters.getDocRefPath()) + .delete(convertPrecondition(testParameters.getPrecondition())) + .get(); + } + + CommitRequest request = commitCapture.getValue(); + Assert.assertEquals(testParameters.getRequest(), request); + } + } + + private static final class ConformanceQueryTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor runQueryCapture; + @Captor private ArgumentCaptor> streamObserverCapture; + + private ConformanceQueryTestRunner( + String description, TestDefinition.QueryTest testParameters) { + super(description, testParameters); + } + + @Override + public void runTest() { + doAnswer(queryResponse()) + .when(firestore) + .streamRequest(runQueryCapture.capture(), streamObserverCapture.capture(), any()); + + Query query = collection(testParameters.getCollPath()); + + try { + for (Clause clause : testParameters.getClausesList()) { + query = applyClause(query, clause); + } + + ApiFuture apiCall = query.get(); + Assert.assertFalse(testParameters.getIsError()); + + apiCall.get(); + RunQueryRequest request = runQueryCapture.getValue(); + Assert.assertEquals(testParameters.getQuery(), request.getStructuredQuery()); + } catch (Exception e) { + Assert.assertTrue(testParameters.getIsError()); + } + } + + /** Returns a new query with 'clause' applied. */ + private Query applyClause(Query query, Clause clause) { + FieldPath fieldPath; + Object value; + Cursor cursor; + + switch (clause.getClauseCase()) { + case SELECT: + query = + query.select( + convertPaths(clause.getSelect().getFieldsList()).toArray(new FieldPath[] {})); + break; + case WHERE: + Where whereClause = clause.getWhere(); + fieldPath = convertPath(whereClause.getPath()); + value = convertInput(Collections.singletonList(whereClause.getJsonValue())).get(0); + switch (whereClause.getOp()) { + case "<": + query = query.whereLessThan(fieldPath, value); + break; + case "<=": + query = query.whereLessThanOrEqualTo(fieldPath, value); + break; + case "==": + query = query.whereEqualTo(fieldPath, value); + break; + case ">=": + query = query.whereGreaterThanOrEqualTo(fieldPath, value); + break; + case ">": + query = query.whereGreaterThan(fieldPath, value); + break; + case "!=": + query = query.whereNotEqualTo(fieldPath, value); + break; + default: + throw new UnsupportedOperationException(); + } + break; + case ORDER_BY: + OrderBy orderClause = clause.getOrderBy(); + fieldPath = convertPath(orderClause.getPath()); + switch (orderClause.getDirection()) { + case "asc": + query = query.orderBy(fieldPath, Direction.ASCENDING); + break; + case "desc": + query = query.orderBy(fieldPath, Direction.DESCENDING); + break; + default: + throw new UnsupportedOperationException(); + } + break; + case OFFSET: + query = query.offset(clause.getOffset()); + break; + case LIMIT: + query = query.limit(clause.getLimit()); + break; + case START_AT: + cursor = clause.getStartAt(); + if (cursor.hasDocSnapshot()) { + query = query.startAt(convertDocument(cursor.getDocSnapshot())); + } else { + query = query.startAt(convertInput(cursor.getJsonValuesList()).toArray()); + } + break; + case START_AFTER: + cursor = clause.getStartAfter(); + if (cursor.hasDocSnapshot()) { + query = query.startAfter(convertDocument(cursor.getDocSnapshot())); + } else { + query = query.startAfter(convertInput(cursor.getJsonValuesList()).toArray()); + } + break; + case END_AT: + cursor = clause.getEndAt(); + if (cursor.hasDocSnapshot()) { + query = query.endAt(convertDocument(cursor.getDocSnapshot())); + } else { + query = query.endAt(convertInput(cursor.getJsonValuesList()).toArray()); + } + break; + case END_BEFORE: + cursor = clause.getEndBefore(); + if (cursor.hasDocSnapshot()) { + query = query.endBefore(convertDocument(cursor.getDocSnapshot())); + } else { + query = query.endBefore(convertInput(cursor.getJsonValuesList()).toArray()); + } + break; + default: + throw new UnsupportedOperationException(); + } + return query; + } + + /** Converts a DocumentSnapshot proto into a DocumentSnapshot. */ + private DocumentSnapshot convertDocument(DocSnapshot snapshot) { + return DocumentSnapshot.fromObject( + firestore, + document(snapshot.getPath()), + convertInput(snapshot.getJsonData()), + NO_DELETES); + } + } + + private static final class ConformanceListenTestRunner + extends BaseConformanceTestRunner { + + @Captor private ArgumentCaptor> streamObserverCapture; + @Mock private ClientStream noOpRequestObserver; + + private final Query watchQuery; + + private ConformanceListenTestRunner( + String description, TestDefinition.ListenTest testParameters) { + super(description, testParameters); + watchQuery = collection(ROOT_COLLECTION_PATH + "C").orderBy("a"); + } + + @Override + public void runTest() throws Throwable { + final SettableApiFuture testCaseStarted = SettableApiFuture.create(); + final SettableApiFuture testCaseFinished = SettableApiFuture.create(); + + doAnswer( + invocationOnMock -> { + testCaseStarted.set(null); + return noOpRequestObserver; + }) + .when(firestore) + .streamRequest(streamObserverCapture.capture(), any()); + + final List expectedSnapshots = new ArrayList<>(testParameters.getSnapshotsList()); + + final ListenerRegistration registration = + watchQuery.addSnapshotListener( + (actualSnapshot, error) -> { + try { + if (actualSnapshot != null) { + Assert.assertNull(error); + Assert.assertFalse(expectedSnapshots.isEmpty()); + Snapshot expectedSnapshot = expectedSnapshots.remove(0); + Assert.assertEquals(convertQuerySnapshot(expectedSnapshot), actualSnapshot); + if (expectedSnapshots.isEmpty()) { + if (!testParameters.getIsError()) { + testCaseFinished.set(null); + } + } + } else { // Error case + Assert.assertNotNull(error); + Assert.assertTrue(expectedSnapshots.isEmpty()); + Assert.assertTrue(testParameters.getIsError()); + testCaseFinished.set(null); + } + } catch (AssertionError e) { + testCaseFinished.setException(e); + } + }); + + testCaseStarted.get(); + + for (ListenResponse response : testParameters.getResponsesList()) { + streamObserverCapture.getValue().onResponse(response); + } + + testCaseFinished.get(); + registration.remove(); + } + + /** Converts a test snapshot to its API representation. */ + private QuerySnapshot convertQuerySnapshot(Snapshot testSnapshot) { + Timestamp readTime = Timestamp.fromProto(testSnapshot.getReadTime()); + + final List documentSnapshots = new ArrayList<>(); + + for (Document document : testSnapshot.getDocsList()) { + documentSnapshots.add( + QueryDocumentSnapshot.fromDocument( + firestore, Timestamp.fromProto(testSnapshot.getReadTime()), document)); + } + + DocumentSet documentSet = + DocumentSet.emptySet( + (o1, o2) -> { + // Comparator that preserves the insertion order as defined in the test case. + for (QueryDocumentSnapshot snapshot : documentSnapshots) { + if (o1.equals(o2)) { + return 0; + } else if (o1.equals(snapshot)) { + return -1; + } else if (o2.equals(snapshot)) { + return 1; + } + } + + Assert.fail("Unable to find position for document snapshot"); + return 0; + }); + + for (QueryDocumentSnapshot snapshot : documentSnapshots) { + documentSet = documentSet.add(snapshot); + } + + List documentChanges = new ArrayList<>(); + + for (DocChange documentChange : testSnapshot.getChangesList()) { + QueryDocumentSnapshot documentSnapshot = + QueryDocumentSnapshot.fromDocument( + firestore, + Timestamp.fromProto(testSnapshot.getReadTime()), + documentChange.getDoc()); + DocumentChange.Type changeType = convertKind(documentChange.getKind()); + documentChanges.add( + new DocumentChange( + documentSnapshot, + changeType, + documentChange.getOldIndex(), + documentChange.getNewIndex())); + } + + return QuerySnapshot.withChanges(watchQuery, readTime, documentSet, documentChanges); + } + + /** Converts a Kind into a DocumentChange.Type */ + private static DocumentChange.Type convertKind(Kind kind) { + DocumentChange.Type changeType = null; + + switch (kind) { + case ADDED: + changeType = DocumentChange.Type.ADDED; + break; + case REMOVED: + changeType = DocumentChange.Type.REMOVED; + break; + case MODIFIED: + changeType = DocumentChange.Type.MODIFIED; + break; + default: + Assert.fail("Unable to convert document change for kind: " + kind); + break; + } + + return changeType; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/DocumentReferenceTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/DocumentReferenceTest.java new file mode 100644 index 000000000000..b425e5879407 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/DocumentReferenceTest.java @@ -0,0 +1,1173 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.ALL_SUPPORTED_TYPES_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.ALL_SUPPORTED_TYPES_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.ALL_SUPPORTED_TYPES_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.BLOB; +import static com.google.cloud.firestore.LocalFirestoreHelper.DATE; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_PATH; +import static com.google.cloud.firestore.LocalFirestoreHelper.FIELD_TRANSFORM_COMMIT_RESPONSE; +import static com.google.cloud.firestore.LocalFirestoreHelper.FOO_LIST; +import static com.google.cloud.firestore.LocalFirestoreHelper.FOO_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.GEO_POINT; +import static com.google.cloud.firestore.LocalFirestoreHelper.NESTED_CLASS_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.SERVER_TIMESTAMP_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_DELETE_COMMIT_RESPONSE; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_WRITE_COMMIT_RESPONSE; +import static com.google.cloud.firestore.LocalFirestoreHelper.TIMESTAMP; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_POJO; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_POJO_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATE_PRECONDITION; +import static com.google.cloud.firestore.LocalFirestoreHelper.arrayRemove; +import static com.google.cloud.firestore.LocalFirestoreHelper.arrayUnion; +import static com.google.cloud.firestore.LocalFirestoreHelper.assertCommitEquals; +import static com.google.cloud.firestore.LocalFirestoreHelper.commit; +import static com.google.cloud.firestore.LocalFirestoreHelper.create; +import static com.google.cloud.firestore.LocalFirestoreHelper.delete; +import static com.google.cloud.firestore.LocalFirestoreHelper.get; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAllResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.increment; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.LocalFirestoreHelper.object; +import static com.google.cloud.firestore.LocalFirestoreHelper.serverTimestamp; +import static com.google.cloud.firestore.LocalFirestoreHelper.set; +import static com.google.cloud.firestore.LocalFirestoreHelper.streamingResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.string; +import static com.google.cloud.firestore.LocalFirestoreHelper.transform; +import static com.google.cloud.firestore.LocalFirestoreHelper.update; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; + +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.LocalFirestoreHelper.InvalidPOJO; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.ExecutionException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class DocumentReferenceTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor commitCapture; + + @Captor private ArgumentCaptor getAllCapture; + + @Captor private ArgumentCaptor> streamObserverCapture; + + private DocumentReference documentReference; + + @Before + public void before() { + documentReference = firestoreMock.document("coll/doc"); + } + + @Test + public void equals() { + DocumentReference doc1 = documentReference.collection("subcoll").document("doc"); + DocumentReference doc2 = documentReference.collection("subcoll").document("doc"); + assertEquals(doc1, doc2); + } + + @Test + public void getCollection() { + CollectionReference collectionReference = documentReference.collection("subcoll"); + assertEquals("subcoll", collectionReference.getId()); + } + + @Test + public void getPath() { + assertEquals(DOCUMENT_PATH, documentReference.getPath()); + } + + @Test + public void getParent() { + CollectionReference collectionReference = documentReference.getParent(); + assertEquals("coll", collectionReference.getId()); + } + + @Test + public void serializeBasicTypes() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(ALL_SUPPORTED_TYPES_MAP).get(); + documentReference.set(ALL_SUPPORTED_TYPES_OBJECT).get(); + + CommitRequest expectedCommit = commit(set(ALL_SUPPORTED_TYPES_PROTO)); + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(0)); + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(1)); + } + + @Test + public void serializeDocumentReference() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(map("docRef", documentReference)).get(); + + Map documentReferenceFields = new HashMap<>(); + documentReferenceFields.put( + "docRef", Value.newBuilder().setReferenceValue(DOCUMENT_NAME).build()); + + assertCommitEquals(commit(set(documentReferenceFields)), commitCapture.getValue()); + } + + @Test + public void doesNotSerializeAdvancedNumberTypes() { + Map expectedErrorMessages = new HashMap<>(); + + InvalidPOJO pojo = new InvalidPOJO(); + pojo.bigIntegerValue = new BigInteger("0"); + expectedErrorMessages.put( + pojo, + "Could not serialize object. Numbers of type BigInteger are not supported, please use an" + + " int, long, float, double or BigDecimal (found in field 'bigIntegerValue')"); + + pojo = new InvalidPOJO(); + pojo.byteValue = 0; + expectedErrorMessages.put( + pojo, + "Could not serialize object. Numbers of type Byte are not supported, please use an int," + + " long, float, double or BigDecimal (found in field 'byteValue')"); + + pojo = new InvalidPOJO(); + pojo.shortValue = 0; + expectedErrorMessages.put( + pojo, + "Could not serialize object. Numbers of type Short are not supported, please use an int," + + " long, float, double or BigDecimal (found in field 'shortValue')"); + + for (Map.Entry testCase : expectedErrorMessages.entrySet()) { + try { + documentReference.set(testCase.getKey()); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(testCase.getValue(), e.getMessage()); + } + } + } + + @Test + public void deserializeBasicTypes() throws Exception { + doAnswer(getAllResponse(ALL_SUPPORTED_TYPES_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + assertEquals(snapshot.getData(), ALL_SUPPORTED_TYPES_MAP); + + LocalFirestoreHelper.AllSupportedTypes pojo = + snapshot.toObject(LocalFirestoreHelper.AllSupportedTypes.class); + assertEquals(new LocalFirestoreHelper.AllSupportedTypes(), pojo); + + assertEquals("bar", snapshot.get("foo")); + assertEquals("bar", snapshot.get(FieldPath.of("foo"))); + assertTrue(snapshot.contains("foo")); + assertTrue(snapshot.contains(FieldPath.of("foo"))); + assertEquals("bar", snapshot.getString("foo")); + assertEquals("bar", snapshot.getString("objectValue.foo")); + assertEquals("bar", snapshot.get(FieldPath.of("objectValue", "foo"))); + assertTrue(snapshot.contains("objectValue.foo")); + assertTrue(snapshot.contains(FieldPath.of("objectValue", "foo"))); + assertEquals((Double) 0.0, snapshot.getDouble("doubleValue")); + assertEquals((Long) 0L, snapshot.getLong("longValue")); + assertEquals(true, snapshot.getBoolean("trueValue")); + assertEquals(DATE, snapshot.getDate("dateValue")); + assertEquals(TIMESTAMP, snapshot.getTimestamp("timestampValue")); + + assertEquals(BLOB, snapshot.getBlob("bytesValue")); + assertEquals(BLOB.hashCode(), snapshot.getBlob("bytesValue").hashCode()); + assertArrayEquals(new byte[] {1, 2, 3}, snapshot.getBlob("bytesValue").toBytes()); + + assertEquals(GEO_POINT, snapshot.getGeoPoint("geoPointValue")); + assertEquals(GEO_POINT.hashCode(), snapshot.getGeoPoint("geoPointValue").hashCode()); + assertEquals(GEO_POINT.getLatitude(), snapshot.getGeoPoint("geoPointValue").getLatitude(), 0); + assertEquals(GEO_POINT.getLongitude(), snapshot.getGeoPoint("geoPointValue").getLongitude(), 0); + + assertNull(snapshot.get("nullValue")); + assertTrue(snapshot.contains("nullValue")); + + assertTrue(snapshot.contains("objectValue.foo")); + assertFalse(snapshot.contains("objectValue.bar")); + assertTrue(snapshot.exists()); + + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 2), snapshot.getCreateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(3, 4), snapshot.getUpdateTime()); + assertEquals(Timestamp.ofTimeSecondsAndNanos(5, 6), snapshot.getReadTime()); + + assertEquals(get(), getAllCapture.getValue()); + assertEquals("bar", ((Map) snapshot.get("model")).get("foo")); + } + + @Test + public void deserializeDocumentReference() throws Exception { + doAnswer( + getAllResponse( + map("docRef", Value.newBuilder().setReferenceValue(DOCUMENT_NAME).build()))) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + assertEquals(documentReference, snapshot.getData().get("docRef")); + assertEquals(documentReference, snapshot.getReference()); + } + + @Test + public void getFieldWithFieldMask() throws Exception { + doAnswer(getAllResponse(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + DocumentSnapshot snapshot = documentReference.get(FieldMask.of(FieldPath.of("foo"))).get(); + assertEquals("foo", getAllCapture.getValue().getMask().getFieldPaths(0)); + assertEquals("bar", snapshot.get("foo")); + } + + @Test + public void deserializesDates() throws Exception { + doAnswer(getAllResponse(ALL_SUPPORTED_TYPES_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + + assertEquals(Timestamp.of(DATE), snapshot.get("dateValue")); + assertEquals(TIMESTAMP, snapshot.get("timestampValue")); + assertEquals(Timestamp.of(DATE), snapshot.getData().get("dateValue")); + assertEquals(TIMESTAMP, snapshot.getData().get("timestampValue")); + } + + @Test + public void doesNotDeserializeAdvancedNumberTypes() throws Exception { + Map fieldNamesToTypeNames = + map("bigIntegerValue", "BigInteger", "shortValue", "Short", "byteValue", "Byte"); + + for (Entry testCase : fieldNamesToTypeNames.entrySet()) { + String fieldName = testCase.getKey(); + String typeName = testCase.getValue(); + Map response = map(fieldName, Value.newBuilder().setIntegerValue(0).build()); + + doAnswer(getAllResponse(response)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + try { + snapshot.toObject(InvalidPOJO.class); + fail(); + } catch (RuntimeException e) { + assertEquals( + String.format( + "Could not deserialize object. Deserializing values to %s is not supported (found" + + " in field '%s')", + typeName, fieldName), + e.getMessage()); + } + } + } + + @Test + public void notFound() throws Exception { + final BatchGetDocumentsResponse.Builder getDocumentResponse = + BatchGetDocumentsResponse.newBuilder(); + getDocumentResponse.setMissing(DOCUMENT_NAME); + getDocumentResponse.setReadTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(5).setNanos(6)); + + doAnswer( + streamingResponse( + new BatchGetDocumentsResponse[] {getDocumentResponse.build()}, + /* throwable= */ null)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentSnapshot snapshot = documentReference.get().get(); + assertEquals(documentReference, snapshot.getReference()); + assertFalse(snapshot.exists()); + assertEquals(snapshot.getReadTime(), Timestamp.ofTimeSecondsAndNanos(5, 6)); + assertNull(snapshot.getData()); + } + + @Test + public void deleteDocument() throws Exception { + doReturn(SINGLE_DELETE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.delete().get(); + documentReference + .delete(Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(479978400, 123000000))) + .get(); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(commit(delete()), commitRequests.get(0)); + + com.google.firestore.v1.Precondition.Builder precondition = + com.google.firestore.v1.Precondition.newBuilder(); + precondition.getUpdateTimeBuilder().setSeconds(479978400).setNanos(123000000); + assertCommitEquals(commit(delete(precondition.build())), commitRequests.get(1)); + } + + @Test + public void createDocument() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.create(SINGLE_FIELD_MAP).get(); + documentReference.create(SINGLE_FIELD_OBJECT).get(); + + CommitRequest expectedCommit = commit(create(SINGLE_FIELD_PROTO)); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(expectedCommit, commitRequests.get(0)); + assertCommitEquals(expectedCommit, commitRequests.get(1)); + } + + @Test + public void createWithServerTimestamp() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.create(LocalFirestoreHelper.SERVER_TIMESTAMP_MAP).get(); + documentReference.create(LocalFirestoreHelper.SERVER_TIMESTAMP_OBJECT).get(); + + CommitRequest create = + commit( + create(Collections.emptyMap()), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(create, commitRequests.get(0)); + assertCommitEquals(create, commitRequests.get(1)); + } + + @Test + public void setWithServerTimestamp() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(LocalFirestoreHelper.SERVER_TIMESTAMP_MAP).get(); + documentReference.set(LocalFirestoreHelper.SERVER_TIMESTAMP_OBJECT).get(); + + CommitRequest set = + commit( + set(SERVER_TIMESTAMP_PROTO), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(set, commitRequests.get(0)); + assertCommitEquals(set, commitRequests.get(1)); + } + + @Test + public void updateWithServerTimestamp() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update(LocalFirestoreHelper.SERVER_TIMESTAMP_MAP).get(); + + CommitRequest update = + commit( + update(Collections.emptyMap(), Collections.singletonList("inner")), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + assertCommitEquals(update, commitCapture.getValue()); + + documentReference.update( + "foo", FieldValue.serverTimestamp(), "inner.bar", FieldValue.serverTimestamp()); + + update = + commit( + update(Collections.emptyMap(), new ArrayList<>(), UPDATE_PRECONDITION), + transform("foo", serverTimestamp(), "inner.bar", serverTimestamp())); + + assertCommitEquals(update, commitCapture.getValue()); + } + + @Test + public void mergeWithServerTimestamps() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference + .set(LocalFirestoreHelper.SERVER_TIMESTAMP_MAP, SetOptions.mergeFields("inner.bar")) + .get(); + documentReference + .set(LocalFirestoreHelper.SERVER_TIMESTAMP_OBJECT, SetOptions.mergeFields("inner.bar")) + .get(); + + CommitRequest set = + commit( + set(SERVER_TIMESTAMP_PROTO, new ArrayList<>()), + transform("inner.bar", serverTimestamp())); + + List commitRequests = commitCapture.getAllValues(); + assertCommitEquals(set, commitRequests.get(0)); + assertCommitEquals(set, commitRequests.get(1)); + } + + @Test + public void setWithIncrement() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference + .set(map("integer", FieldValue.increment(1), "double", FieldValue.increment(1.1))) + .get(); + + CommitRequest set = + commit( + set(Collections.emptyMap()), + transform( + "integer", + increment(Value.newBuilder().setIntegerValue(1).build()), + "double", + increment(Value.newBuilder().setDoubleValue(1.1).build()))); + + CommitRequest commitRequest = commitCapture.getValue(); + assertCommitEquals(set, commitRequest); + } + + @Test + public void setWithArrayUnion() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(map("foo", FieldValue.arrayUnion("bar", map("foo", "baz")))).get(); + + CommitRequest set = + commit( + set(Collections.emptyMap()), + transform("foo", arrayUnion(string("bar"), object("foo", string("baz"))))); + + CommitRequest commitRequest = commitCapture.getValue(); + assertCommitEquals(set, commitRequest); + } + + @Test + public void setWithArrayRemove() throws Exception { + doReturn(FIELD_TRANSFORM_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(map("foo", FieldValue.arrayRemove("bar", map("foo", "baz")))).get(); + + CommitRequest set = + commit( + set(Collections.emptyMap()), + transform("foo", arrayRemove(string("bar"), object("foo", string("baz"))))); + + CommitRequest commitRequest = commitCapture.getValue(); + assertCommitEquals(set, commitRequest); + } + + @Test + public void serverTimestampInArray() { + Map list = new HashMap<>(); + list.put("foo", ImmutableList.of(FieldValue.serverTimestamp())); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage() + .endsWith("FieldValue.serverTimestamp() is not supported inside of an array.")); + } + + list.clear(); + list.put("a", ImmutableList.of(ImmutableList.of("b", map("c", FieldValue.serverTimestamp())))); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage() + .endsWith("FieldValue.serverTimestamp() is not supported inside of an array.")); + } + } + + @Test + public void deleteInArray() { + Map list = new HashMap<>(); + list.put("foo", ImmutableList.of(FieldValue.delete())); + + try { + documentReference.create(list); + fail(); + } catch (IllegalArgumentException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.delete() is not supported at field 'foo.`0`'.")); + } + + list.clear(); + list.put("a", ImmutableList.of(ImmutableList.of("b", map("c", FieldValue.delete())))); + + try { + documentReference.create(list); + fail(); + } catch (IllegalArgumentException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.delete() is not supported at field 'a.`0`.`1`.c'.")); + } + } + + @Test + public void arrayUnionInArray() { + Map list = new HashMap<>(); + list.put("foo", ImmutableList.of(FieldValue.arrayUnion("foo"))); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.arrayUnion() is not supported inside of an array.")); + } + + list.clear(); + list.put("a", ImmutableList.of(ImmutableList.of("b", map("c", FieldValue.arrayUnion("foo"))))); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.arrayUnion() is not supported inside of an array.")); + } + } + + @Test + public void arrayUnionInArrayUnion() { + Map data = new HashMap<>(); + data.put("foo", FieldValue.arrayUnion(FieldValue.arrayUnion("foo"))); + + try { + documentReference.create(data); + fail(); + } catch (IllegalArgumentException e) { + assertTrue( + e.getMessage() + .endsWith("Cannot use FieldValue.arrayUnion() as an argument at field 'foo'.")); + } + } + + @Test + public void deleteInArrayUnion() { + Map data = new HashMap<>(); + data.put("foo", FieldValue.arrayUnion(FieldValue.delete())); + + try { + documentReference.set(data, SetOptions.merge()); + fail(); + } catch (IllegalArgumentException e) { + assertTrue(e.getMessage().endsWith("FieldValue.delete() is not supported at field 'foo'.")); + } + } + + @Test + public void arrayRemoveInArray() { + Map list = new HashMap<>(); + list.put("foo", ImmutableList.of(FieldValue.arrayRemove("foo"))); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.arrayRemove() is not supported inside of an array.")); + } + + list.clear(); + list.put("a", ImmutableList.of(ImmutableList.of("b", map("c", FieldValue.arrayRemove("foo"))))); + + try { + documentReference.create(list); + fail(); + } catch (FirestoreException e) { + assertTrue( + e.getMessage().endsWith("FieldValue.arrayRemove() is not supported inside of an array.")); + } + } + + @Test + public void setDocumentWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(SINGLE_FIELD_MAP, SetOptions.merge()).get(); + documentReference.set(SINGLE_FIELD_OBJECT, SetOptions.merge()).get(); + documentReference.set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields("foo")).get(); + documentReference + .set(ALL_SUPPORTED_TYPES_OBJECT, SetOptions.mergeFields(Arrays.asList("foo"))) + .get(); + documentReference + .set( + ALL_SUPPORTED_TYPES_OBJECT, + SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("foo")))) + .get(); + + CommitRequest expectedCommit = commit(set(SINGLE_FIELD_PROTO, Arrays.asList("foo"))); + + for (int i = 0; i < 5; ++i) { + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(i)); + } + } + + @Test + public void setDocumentWithEmptyMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(map(), SetOptions.merge()).get(); + + assertCommitEquals( + commit(set(Collections.emptyMap(), Collections.emptyList())), commitCapture.getValue()); + } + + @Test + public void setDocumentWithNestedMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(NESTED_CLASS_OBJECT, SetOptions.mergeFields("first.foo")).get(); + documentReference + .set(NESTED_CLASS_OBJECT, SetOptions.mergeFields(Arrays.asList("first.foo"))) + .get(); + documentReference + .set( + NESTED_CLASS_OBJECT, + SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("first", "foo")))) + .get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO); + nestedUpdate.put("first", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first.foo"))); + + for (int i = 0; i < 3; ++i) { + assertCommitEquals(expectedCommit, commitCapture.getAllValues().get(i)); + } + } + + @Test + public void setMultipleFieldsWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference + .set( + NESTED_CLASS_OBJECT, + SetOptions.mergeFields("first.foo", "second.foo", "second.trueValue")) + .get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto + .getMapValueBuilder() + .putFields("trueValue", Value.newBuilder().setBooleanValue(true).build()); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = + commit(set(nestedUpdate, Arrays.asList("first.foo", "second.foo", "second.trueValue"))); + + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void setNestedMapWithMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(NESTED_CLASS_OBJECT, SetOptions.mergeFields("first", "second")).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("first", "second"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void mergeWithDotsInFieldName() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference + .set( + map("a.b.c", map("d.e", "foo", "f.g", "bar")), + SetOptions.mergeFieldPaths(Arrays.asList(FieldPath.of("a.b.c", "d.e")))) + .get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto + .getMapValueBuilder() + .putFields("d.e", Value.newBuilder().setStringValue("foo").build()); + nestedUpdate.put("a.b.c", nestedProto.build()); + + CommitRequest expectedCommit = commit(set(nestedUpdate, Arrays.asList("`a.b.c`.`d.e`"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void extractFieldMaskFromMerge() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.set(NESTED_CLASS_OBJECT, SetOptions.merge()).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder nestedProto = Value.newBuilder(); + nestedProto.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO); + nestedUpdate.put("first", nestedProto.build()); + nestedProto.getMapValueBuilder().putAllFields(ALL_SUPPORTED_TYPES_PROTO); + nestedUpdate.put("second", nestedProto.build()); + + List updateMask = + Arrays.asList( + "first.foo", + "second.arrayValue", + "second.bytesValue", + "second.dateValue", + "second.doubleValue", + "second.falseValue", + "second.foo", + "second.geoPointValue", + "second.infValue", + "second.instantValue", + "second.longValue", + "second.nanValue", + "second.negInfValue", + "second.nullValue", + "second.objectValue.foo", + "second.timestampValue", + "second.trueValue", + "second.model.foo", + "second.vectorValue"); + + CommitRequest expectedCommit = commit(set(nestedUpdate, updateMask)); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateDocument() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update(SINGLE_FIELD_MAP); + documentReference.update("foo", "bar").get(); + + CommitRequest expectedCommit = + commit(update(SINGLE_FIELD_PROTO, Collections.singletonList("foo"))); + + for (CommitRequest request : commitCapture.getAllValues()) { + assertCommitEquals(expectedCommit, request); + } + } + + @Test + public void updateWithDotsInFieldName() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update(map("a.b.c", map("d.e", "foo"))).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder valueProto = Value.newBuilder(); + valueProto + .getMapValueBuilder() + .putFields("d.e", Value.newBuilder().setStringValue("foo").build()); + Value.Builder cProto = Value.newBuilder(); + cProto.getMapValueBuilder().putFields("c", valueProto.build()); + Value.Builder bProto = Value.newBuilder(); + bProto.getMapValueBuilder().putFields("b", cProto.build()); + nestedUpdate.put("a", bProto.build()); + + CommitRequest expectedCommit = commit(update(nestedUpdate, Arrays.asList("a.b.c"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateNestedMap() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update("a.b", "foo", "a.c", FieldValue.delete()).get(); + + Map nestedUpdate = new HashMap<>(); + Value.Builder valueProto = Value.newBuilder(); + valueProto + .getMapValueBuilder() + .putFields("b", Value.newBuilder().setStringValue("foo").build()); + nestedUpdate.put("a", valueProto.build()); + + CommitRequest expectedCommit = commit(update(nestedUpdate, Arrays.asList("a.b", "a.c"))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateConflictingFields() throws Exception { + try { + documentReference.update("a.b", "foo", "a", "foo").get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "Detected ambiguous definition for field 'a'."); + } + + try { + documentReference.update("a.b", "foo", "a.b.c", "foo").get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "Detected ambiguous definition for field 'a.b'."); + } + + try { + documentReference.update("a.b", SINGLE_FIELD_MAP, "a", SINGLE_FIELD_MAP).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "Detected ambiguous definition for field 'a'."); + } + + try { + documentReference.update("a.b", SINGLE_FIELD_MAP, "a.b.c", SINGLE_FIELD_MAP).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "Detected ambiguous definition for field 'a.b'."); + } + } + + @Test + public void deleteField() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update("foo", "bar", "bar.foo", FieldValue.delete()).get(); + + Value.Builder emptyMap = Value.newBuilder(); + emptyMap.getMapValueBuilder(); + + Map fieldMap = new HashMap<>(); + fieldMap.put("foo", string("bar")); + + CommitRequest expectedCommit = commit(update(fieldMap, Arrays.asList("foo", "bar.foo"))); + + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateNestedDocument() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + Map nestedObject = new HashMap<>(); + nestedObject.put("a", "b"); + nestedObject.put("c.d", "e"); + nestedObject.put("f.g.h", "i"); + + Map expandedObject = new HashMap<>(); + expandedObject.put("a", string("b")); + expandedObject.put("c", object("d", string("e"))); + expandedObject.put("f", object("g", object("h", string("i")))); + + documentReference.update(nestedObject).get(); + + CommitRequest expectedCommit = + commit(update(expandedObject, new ArrayList<>(nestedObject.keySet()))); + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateDocumentWithTwoFields() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + documentReference.update("a", "b", "c", "d").get(); + + CommitRequest expectedCommit = + commit( + update( + map( + "a", + Value.newBuilder().setStringValue("b").build(), + "c", + Value.newBuilder().setStringValue("d").build()), + Arrays.asList("a", "c"))); + + assertCommitEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void updateDocumentWithPreconditions() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + Precondition options = + Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(479978400, 123000000)); + + documentReference.update(SINGLE_FIELD_MAP, options).get(); + documentReference.update(options, "foo", "bar").get(); + + com.google.firestore.v1.Precondition.Builder precondition = + com.google.firestore.v1.Precondition.newBuilder(); + precondition.getUpdateTimeBuilder().setSeconds(479978400).setNanos(123000000); + + CommitRequest expectedCommit = + commit(update(SINGLE_FIELD_PROTO, Collections.singletonList("foo"), precondition.build())); + + for (CommitRequest request : commitCapture.getAllValues()) { + assertCommitEquals(expectedCommit, request); + } + } + + @Test + public void updateIndividualPojo() throws ExecutionException, InterruptedException { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + documentReference.update(UPDATED_POJO); + documentReference.update(UPDATED_POJO).get(); + CommitRequest expectedCommit = + commit(update(UPDATED_POJO_PROTO, Collections.singletonList("model"))); + + for (CommitRequest request : commitCapture.getAllValues()) { + assertCommitEquals(expectedCommit, request); + } + } + + @Test + public void deleteNestedFieldUsingFieldPath() throws Exception { + doReturn(SINGLE_WRITE_COMMIT_RESPONSE) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + FieldPath path = FieldPath.of("a.b", "c.d"); + documentReference.update(path, FieldValue.delete()).get(); + CommitRequest expectedCommit = + commit(update(Collections.emptyMap(), Collections.singletonList("`a.b`.`c.d`"))); + assertEquals(expectedCommit, commitCapture.getValue()); + } + + @Test + public void deserializeCustomList() throws ExecutionException, InterruptedException { + ImmutableMap CUSTOM_LIST_PROTO = + ImmutableMap.builder() + .put( + "fooList", + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder() + .addValues( + Value.newBuilder() + .setMapValue( + MapValue.newBuilder().putAllFields(SINGLE_FIELD_PROTO)) + .build())) + .build()) + .build(); + doAnswer(getAllResponse(CUSTOM_LIST_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + DocumentSnapshot snapshot = documentReference.get().get(); + LocalFirestoreHelper.CustomList customList = + snapshot.toObject(LocalFirestoreHelper.CustomList.class); + + assertEquals(FOO_LIST, customList.fooList); + assertEquals(SINGLE_FIELD_OBJECT, customList.fooList.get(0)); + } + + @Test + public void deserializeCustomMap() throws ExecutionException, InterruptedException { + ImmutableMap CUSTOM_MAP_PROTO = + ImmutableMap.builder() + .put( + "fooMap", + Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields( + "customMap", + Value.newBuilder() + .setMapValue( + MapValue.newBuilder().putAllFields(SINGLE_FIELD_PROTO)) + .build()) + .build()) + .build()) + .build(); + doAnswer(getAllResponse(CUSTOM_MAP_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + DocumentSnapshot snapshot = documentReference.get().get(); + LocalFirestoreHelper.CustomMap customMap = + snapshot.toObject(LocalFirestoreHelper.CustomMap.class); + + assertEquals(FOO_MAP, customMap.fooMap); + assertEquals(SINGLE_FIELD_OBJECT, customMap.fooMap.get("customMap")); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java new file mode 100644 index 000000000000..1314ec490270 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/EmulatorCredentials.java @@ -0,0 +1,35 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertEquals; + +import com.google.api.gax.core.CredentialsProvider; +import com.google.api.gax.core.FixedCredentialsProvider; +import java.io.IOException; +import org.junit.Test; + +public class EmulatorCredentials { + @Test + public void implementsCredentials() throws IOException { + CredentialsProvider emulatorCredentials = + FixedCredentialsProvider.create(new FirestoreOptions.EmulatorCredentials()); + assertEquals("Unauthenticated", emulatorCredentials.getCredentials().getAuthenticationType()); + assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadata()); + assertEquals(true, emulatorCredentials.getCredentials().hasRequestMetadataOnly()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ExplainOptionsTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ExplainOptionsTest.java new file mode 100644 index 000000000000..38cb7e10ce93 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ExplainOptionsTest.java @@ -0,0 +1,39 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class ExplainOptionsTest { + @Test + public void defaultOptionsDoNotAnalyze() { + ExplainOptions options = ExplainOptions.builder().build(); + assertFalse(options.getAnalyze()); + } + + @Test + public void setsAnalyzeCorrectly() { + ExplainOptions plan = ExplainOptions.builder().setAnalyze(false).build(); + assertFalse(plan.getAnalyze()); + + ExplainOptions profile = ExplainOptions.builder().setAnalyze(true).build(); + assertTrue(profile.getAnalyze()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreBundleTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreBundleTest.java new file mode 100644 index 000000000000..5dfbe90914d8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreBundleTest.java @@ -0,0 +1,324 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.COLLECTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_SNAPSHOT; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_SINGLE_FIELD_SNAPSHOT; +import static com.google.cloud.firestore.LocalFirestoreHelper.bundleToElementList; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.collect.Lists; +import com.google.firestore.bundle.BundleElement; +import com.google.firestore.bundle.BundleMetadata; +import com.google.firestore.bundle.BundledDocumentMetadata; +import com.google.firestore.bundle.BundledQuery; +import com.google.firestore.bundle.BundledQuery.LimitType; +import com.google.firestore.bundle.NamedQuery; +import com.google.firestore.v1.Document; +import com.google.protobuf.InvalidProtocolBufferException; +import com.google.protobuf.Timestamp; +import com.google.protobuf.util.JsonFormat; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class FirestoreBundleTest { + private static final String TEST_BUNDLE_ID = "test-bundle"; + private static final int TEST_BUNDLE_VERSION = 1; + private static final JsonFormat.Parser parser = JsonFormat.parser(); + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + private Query query; + + @Before + public void before() { + query = firestoreMock.collection(COLLECTION_ID); + } + + public static void verifyMetadata( + BundleMetadata meta, Timestamp createTime, int totalDocuments, boolean expectEmptyContent) { + if (!expectEmptyContent) { + assertTrue(meta.getTotalBytes() > 0); + } else { + assertEquals(0, meta.getTotalBytes()); + } + assertEquals(TEST_BUNDLE_ID, meta.getId()); + assertEquals(TEST_BUNDLE_VERSION, meta.getVersion()); + assertEquals(totalDocuments, meta.getTotalDocuments()); + assertEquals(createTime, meta.getCreateTime()); + } + + public static void verifyDocumentAndMeta( + BundledDocumentMetadata documentMetadata, + Document document, + String expectedDocumentName, + List expectedQueries, + DocumentSnapshot equivalentSnapshot) { + verifyDocumentAndMeta( + documentMetadata, + document, + expectedDocumentName, + expectedQueries, + equivalentSnapshot, + equivalentSnapshot.getReadTime().toProto()); + } + + public static void verifyDocumentAndMeta( + BundledDocumentMetadata documentMetadata, + Document document, + String expectedDocumentName, + List expectedQueries, + DocumentSnapshot equivalentSnapshot, + Timestamp readTime) { + assertEquals( + BundledDocumentMetadata.newBuilder() + .setExists(true) + .setName(expectedDocumentName) + .setReadTime(readTime) + .addAllQueries(expectedQueries) + .build(), + documentMetadata); + assertEquals( + Document.newBuilder() + .putAllFields(equivalentSnapshot.getProtoFields()) + .setCreateTime(equivalentSnapshot.getCreateTime().toProto()) + .setUpdateTime(equivalentSnapshot.getUpdateTime().toProto()) + .setName(expectedDocumentName) + .build(), + document); + } + + public static void verifyNamedQuery( + NamedQuery namedQuery, String name, Timestamp readTime, Query query, LimitType limitType) { + assertEquals( + NamedQuery.newBuilder() + .setName(name) + .setReadTime(readTime) + .setBundledQuery( + BundledQuery.newBuilder() + .setParent(query.toProto().getParent()) + .setStructuredQuery(query.toProto().getStructuredQuery()) + .setLimitType(limitType) + .build()) + .build(), + namedQuery); + } + + @Test + public void bundleToElementListWorks() { + String bundleString = + "20{\"a\":\"string value\"}9{\"b\":123}26{\"c\":{\"d\":\"nested value\"}}"; + List elements = + bundleToElementList(ByteBuffer.wrap(bundleString.getBytes(StandardCharsets.UTF_8))); + assertArrayEquals( + new String[] { + "{\"a\":\"string value\"}", "{\"b\":123}", "{\"c\":{\"d\":\"nested value\"}}" + }, + elements.toArray()); + } + + public static List toBundleElements(ByteBuffer bundleBuffer) { + ArrayList result = new ArrayList<>(); + for (String s : bundleToElementList(bundleBuffer)) { + BundleElement.Builder b = BundleElement.newBuilder(); + try { + parser.merge(s, b); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException(e); + } + result.add(b.build()); + } + + return result; + } + + @Test + public void bundleWithDocumentSnapshots() { + FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder(TEST_BUNDLE_ID); + bundleBuilder.add(UPDATED_SINGLE_FIELD_SNAPSHOT); + bundleBuilder.add(SINGLE_FIELD_SNAPSHOT); + ByteBuffer bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata, meta of UPDATED_SINGLE_FIELD_SNAPSHOT, + // UPDATED_SINGLE_FIELD_SNAPSHOT] + // because UPDATED_SINGLE_FIELD_SNAPSHOT is newer. + List elements = toBundleElements(bundleBuffer); + assertEquals(3, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + // Even this snapshot is not included, its read time is still used as create time + // because it is the largest read time came across. + UPDATED_SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + /*totalDocuments*/ 1, + /*expectEmptyContent*/ false); + + verifyDocumentAndMeta( + elements.get(1).getDocumentMetadata(), + elements.get(2).getDocument(), + DOCUMENT_NAME, + Lists.newArrayList(), + UPDATED_SINGLE_FIELD_SNAPSHOT); + } + + @Test + public void bundleWithQuerySnapshot() { + FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder(TEST_BUNDLE_ID); + QuerySnapshot snapshot = + QuerySnapshot.withDocuments( + query, + SINGLE_FIELD_SNAPSHOT.getReadTime(), + Lists.newArrayList( + QueryDocumentSnapshot.fromDocument( + null, + SINGLE_FIELD_SNAPSHOT.getReadTime(), + SINGLE_FIELD_SNAPSHOT.toDocumentPb().build()))); + bundleBuilder.add("test-query", snapshot); + ByteBuffer bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata, named query, meta of SINGLE_FIELD_SNAPSHOT, + // SINGLE_FIELD_SNAPSHOT] + List elements = toBundleElements(bundleBuffer); + assertEquals(4, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + /*totalDocuments*/ 1, + /*expectEmptyContent*/ false); + + verifyNamedQuery( + elements.get(1).getNamedQuery(), + "test-query", + SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + query, + LimitType.FIRST); + + verifyDocumentAndMeta( + elements.get(2).getDocumentMetadata(), + elements.get(3).getDocument(), + DOCUMENT_NAME, + Lists.newArrayList("test-query"), + SINGLE_FIELD_SNAPSHOT); + } + + @Test + public void bundleWithQueryReturningNoResult() { + FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder(TEST_BUNDLE_ID); + QuerySnapshot snapshot = + QuerySnapshot.withDocuments( + query, SINGLE_FIELD_SNAPSHOT.getReadTime(), Collections.emptyList()); + bundleBuilder.add("test-query", snapshot); + ByteBuffer bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata, named query] + List elements = toBundleElements(bundleBuffer); + assertEquals(2, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + /*totalDocuments*/ 0, + /*expectEmptyContent*/ false); + + verifyNamedQuery( + elements.get(1).getNamedQuery(), + "test-query", + SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + query, + LimitType.FIRST); + } + + @Test + public void bundleBuiltMultipleTimes() { + FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder(TEST_BUNDLE_ID); + bundleBuilder.add(SINGLE_FIELD_SNAPSHOT); + ByteBuffer bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata, meta of SINGLE_FIELD_SNAPSHOT, + // SINGLE_FIELD_SNAPSHOT] + List elements = toBundleElements(bundleBuffer); + assertEquals(3, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + /*totalDocuments*/ 1, + /*expectEmptyContent*/ false); + + verifyDocumentAndMeta( + elements.get(1).getDocumentMetadata(), + elements.get(2).getDocument(), + DOCUMENT_NAME, + Lists.newArrayList(), + SINGLE_FIELD_SNAPSHOT); + + bundleBuilder.add(UPDATED_SINGLE_FIELD_SNAPSHOT); + bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata, meta of UPDATED_SINGLE_FIELD_SNAPSHOT, + // UPDATED_SINGLE_FIELD_SNAPSHOT] + elements = toBundleElements(bundleBuffer); + assertEquals(3, elements.size()); + verifyMetadata( + elements.get(0).getMetadata(), + UPDATED_SINGLE_FIELD_SNAPSHOT.getReadTime().toProto(), + /*totalDocuments*/ 1, + /*expectEmptyContent*/ false); + verifyDocumentAndMeta( + elements.get(1).getDocumentMetadata(), + elements.get(2).getDocument(), + DOCUMENT_NAME, + Lists.newArrayList(), + UPDATED_SINGLE_FIELD_SNAPSHOT); + } + + @Test + public void bundleWithNothingAdded() { + FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder(TEST_BUNDLE_ID); + ByteBuffer bundleBuffer = bundleBuilder.build().toByteBuffer(); + + // Expected bundle elements are [bundleMetadata] + List elements = toBundleElements(bundleBuffer); + assertEquals(1, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + com.google.cloud.Timestamp.MIN_VALUE.toProto(), + /*totalDocuments*/ 0, + /*expectEmptyContent*/ true); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreExceptionTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreExceptionTest.java new file mode 100644 index 000000000000..a57605d1bcb8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreExceptionTest.java @@ -0,0 +1,164 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.StatusCode; +import io.grpc.Status; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +/** Unit tests for the FirestoreException class. */ +@RunWith(MockitoJUnitRunner.class) +public class FirestoreExceptionTest { + @Test + public void testConstructorWithReasonAndStatus() { + String reason = "Aborted operation"; + Status status = Status.ABORTED; + FirestoreException exception = new FirestoreException(reason, status); + + assertEquals(reason, exception.getMessage()); + assertEquals(status, exception.getStatus()); + assertNull(exception.getCause()); + assertEquals(status.getCode().value(), exception.getCode()); + assertFalse(exception.isRetryable()); + } + + @Test + public void testForInvalidArgument() { + String messageTemplate = "Invalid argument supplied: %s"; + String argument = "collectionId"; + String expectedMessage = String.format(messageTemplate, argument); + + FirestoreException exception = FirestoreException.forInvalidArgument(messageTemplate, argument); + + assertEquals(expectedMessage, exception.getMessage()); + assertEquals(Status.INVALID_ARGUMENT, exception.getStatus()); + assertNull(exception.getCause()); + assertEquals(Status.INVALID_ARGUMENT.getCode().value(), exception.getCode()); + assertFalse(exception.isRetryable()); + } + + @Test + public void testForServerRejection() { + Status status = Status.PERMISSION_DENIED; + String expectedMessage = "User is not authorized."; + + FirestoreException exception = FirestoreException.forServerRejection(status, expectedMessage); + + assertEquals(expectedMessage, exception.getMessage()); + assertEquals(status, exception.getStatus()); + assertNull(exception.getCause()); + assertEquals(status.getCode().value(), exception.getCode()); + assertFalse(exception.isRetryable()); + } + + @Test + public void testForServerRejectionWithCause() { + Status status = Status.INTERNAL; + String expectedMessage = "Database connection lost."; + Throwable cause = new IllegalStateException("DB connection failed"); + + FirestoreException exception = + FirestoreException.forServerRejection(status, cause, expectedMessage); + + assertEquals(expectedMessage, exception.getMessage()); + assertEquals(status, exception.getStatus()); + assertEquals(cause, exception.getCause()); + assertEquals(status.getCode().value(), exception.getCode()); + assertFalse(exception.isRetryable()); + } + + @Test + public void testForIOException() { + IOException ioException = new IOException("Simulated network read error"); + // The 'retryable' argument is passed, but BaseGrpcServiceException determines actual + // retryability for IOExceptions. + boolean retryable = true; + + FirestoreException exception = FirestoreException.forIOException(ioException, retryable); + + assertEquals(ioException.getMessage(), exception.getMessage()); + assertEquals(ioException, exception.getCause()); + // BaseGrpcServiceException classifies generic IOExceptions as non-retryable. + assertFalse(exception.isRetryable()); + assertNull(exception.getStatus()); + // BaseGrpcServiceException extracts Code from HttpResponseException, or set it to + // UNKNOWN_CODE, which is 0. + assertEquals(0, exception.getCode()); + } + + @Test + public void testForApiException() { + String apiExceptionMessage = "Generic API error details"; + boolean apiExceptionRetryable = true; + final StatusCode.Code apiStatusCodeCode = StatusCode.Code.DEADLINE_EXCEEDED; + + ApiException realApiException = + new ApiException( + apiExceptionMessage, + new RuntimeException("Underlying cause for ApiException"), + GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), + apiExceptionRetryable); + + FirestoreException exception = FirestoreException.forApiException(realApiException); + + assertEquals(apiExceptionMessage, exception.getMessage()); + assertEquals(realApiException, exception.getCause()); + assertEquals(Status.DEADLINE_EXCEEDED.getCode(), exception.getStatus().getCode()); + assertTrue(exception.isRetryable()); + assertEquals(apiStatusCodeCode.getHttpStatusCode(), exception.getCode()); + } + + @Test + public void testForApiExceptionWithCustomMessage() { + String customMessage = "A specific problem occurred during API call."; + boolean apiExceptionRetryable = false; + final StatusCode.Code apiStatusCodeCode = StatusCode.Code.NOT_FOUND; + + ApiException realApiException = + new ApiException( + "This message from ApiException will be overridden by custom message", + new IllegalStateException("Original API problem"), + GrpcStatusCode.of(Status.Code.NOT_FOUND), + apiExceptionRetryable); + + FirestoreException exception = + FirestoreException.forApiException(realApiException, customMessage); + + assertEquals(customMessage, exception.getMessage()); + assertEquals(realApiException, exception.getCause()); + assertEquals(Status.NOT_FOUND.getCode(), exception.getStatus().getCode()); + assertFalse(exception.isRetryable()); + assertEquals(apiStatusCodeCode.getHttpStatusCode(), exception.getCode()); + } + + @Test + public void testGetStatusFromDirectStatusCreation() { + Status expectedStatus = Status.RESOURCE_EXHAUSTED.withDescription("Quota exceeded."); + FirestoreException exception = new FirestoreException("Quota limits hit.", expectedStatus); + assertEquals(expectedStatus, exception.getStatus()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreOptionsTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreOptionsTest.java new file mode 100644 index 000000000000..d7c345f8fe29 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreOptionsTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertThat; +import static org.mockito.Mockito.mock; + +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import org.junit.Test; + +public class FirestoreOptionsTest { + + @Test + public void instantiateWithProjectId() { + FirestoreOptions firestoreOptions = + FirestoreOptions.newBuilder().setProjectId("test-project").build(); + FirestoreImpl firestore = new FirestoreImpl(firestoreOptions, mock(FirestoreRpc.class)); + + DocumentReference document = firestore.document("coll/doc1"); + assertThat(document.getName()) + .isEqualTo("projects/test-project/databases/(default)/documents/coll/doc1"); + } + + @Test + public void instantiateWithProjectIdAndDatabaseId() { + FirestoreOptions firestoreOptions = + FirestoreOptions.newBuilder() + .setProjectId("test-project") + .setDatabaseId("test-database") + .build(); + FirestoreImpl firestore = new FirestoreImpl(firestoreOptions, mock(FirestoreRpc.class)); + + DocumentReference document = firestore.document("coll/doc1"); + assertThat(document.getName()) + .isEqualTo("projects/test-project/databases/test-database/documents/coll/doc1"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreSpy.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreSpy.java new file mode 100644 index 000000000000..bf02bc7d59ea --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreSpy.java @@ -0,0 +1,40 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientStream; + +public final class FirestoreSpy { + + public final FirestoreImpl spy; + public BidiStreamObserver streamRequestBidiStreamObserver; + + public FirestoreSpy(FirestoreOptions firestoreOptions) { + spy = + new FirestoreImpl(firestoreOptions) { + @Override + public ClientStream streamRequest( + BidiStreamObserver responseObserverT, + BidiStreamingCallable callable) { + streamRequestBidiStreamObserver = responseObserverT; + return super.streamRequest(responseObserverT, callable); + } + }; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreTest.java new file mode 100644 index 000000000000..638fa19ba025 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/FirestoreTest.java @@ -0,0 +1,225 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_VALUE; +import static com.google.cloud.firestore.LocalFirestoreHelper.arrayRemove; +import static com.google.cloud.firestore.LocalFirestoreHelper.arrayUnion; +import static com.google.cloud.firestore.LocalFirestoreHelper.commit; +import static com.google.cloud.firestore.LocalFirestoreHelper.commitResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAllResponseWithoutOnComplete; +import static com.google.cloud.firestore.LocalFirestoreHelper.transform; +import static com.google.cloud.firestore.LocalFirestoreHelper.update; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; + +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.protobuf.Message; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class FirestoreTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor getAllCapture; + + @Captor private ArgumentCaptor> streamObserverCapture; + + @Captor private ArgumentCaptor commitCapture; + + @Test + public void encodeFieldPath() { + assertEquals("foo", FieldPath.of("foo").getEncodedPath()); + assertEquals("foo.bar", FieldPath.of("foo", "bar").getEncodedPath()); + assertEquals("`.`", FieldPath.of(".").getEncodedPath()); + assertEquals("`\\``", FieldPath.of("`").getEncodedPath()); + assertEquals("foo.`.`.`\\\\`", FieldPath.of("foo", ".", "\\").getEncodedPath()); + assertEquals("`.\\\\.\\\\.`", FieldPath.of(".\\.\\.").getEncodedPath()); + } + + @Test + public void illegalFieldPath() throws Exception { + doAnswer(getAllResponseWithoutOnComplete(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentReference doc = firestoreMock.document("coll/doc"); + DocumentSnapshot snapshot = doc.get().get(); + + char[] prohibited = new char[] {'*', '~', '/', '[', ']'}; + + for (char c : prohibited) { + try { + snapshot.contains("foo" + c + "bar"); + fail(); + } catch (IllegalArgumentException e) { + assertEquals("Use FieldPath.of() for field names containing '˜*/[]'.", e.getMessage()); + } + } + } + + @Test + public void exposesOptions() { + assertEquals("test-project", firestoreMock.getOptions().getProjectId()); + } + + @Test + public void getAll() throws Exception { + doAnswer( + getAllResponseWithoutOnComplete( + SINGLE_FIELD_PROTO, SINGLE_FIELD_PROTO, SINGLE_FIELD_PROTO, SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentReference doc1 = firestoreMock.document("coll/doc1"); + DocumentReference doc2 = firestoreMock.document("coll/doc2"); + DocumentReference doc3 = firestoreMock.document("coll/doc3"); + DocumentReference doc4 = firestoreMock.document("coll/doc4"); + List snapshot = firestoreMock.getAll(doc1, doc2, doc4, doc3).get(); + assertEquals("doc1", snapshot.get(0).getId()); + assertEquals("doc2", snapshot.get(1).getId()); + // Note that we sort based on the order in the getAll() call. + assertEquals("doc4", snapshot.get(2).getId()); + assertEquals("doc3", snapshot.get(3).getId()); + } + + @Test + public void getAllWithFieldMask() throws Exception { + doAnswer(getAllResponseWithoutOnComplete(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + getAllCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + DocumentReference doc1 = firestoreMock.document("coll/doc1"); + FieldMask fieldMask = FieldMask.of(FieldPath.of("foo", "bar")); + + firestoreMock.getAll(new DocumentReference[] {doc1}, fieldMask).get(); + + BatchGetDocumentsRequest request = getAllCapture.getValue(); + assertEquals(1, request.getMask().getFieldPathsCount()); + assertEquals("foo.bar", request.getMask().getFieldPaths(0)); + } + + @Test + public void arrayUnionEquals() { + FieldValue arrayUnion1 = FieldValue.arrayUnion("foo", "bar"); + FieldValue arrayUnion2 = FieldValue.arrayUnion("foo", "bar"); + FieldValue arrayUnion3 = FieldValue.arrayUnion("foo", "baz"); + FieldValue arrayRemove = FieldValue.arrayRemove("foo", "bar"); + assertEquals(arrayUnion1, arrayUnion1); + assertEquals(arrayUnion1, arrayUnion2); + assertNotEquals(arrayUnion1, arrayUnion3); + assertNotEquals(arrayUnion1, arrayRemove); + } + + @Test + public void arrayRemoveEquals() { + FieldValue arrayRemove1 = FieldValue.arrayRemove("foo", "bar"); + FieldValue arrayRemove2 = FieldValue.arrayRemove("foo", "bar"); + FieldValue arrayRemove3 = FieldValue.arrayRemove("foo", "baz"); + FieldValue arrayUnion = FieldValue.arrayUnion("foo", "bar"); + assertEquals(arrayRemove1, arrayRemove1); + assertEquals(arrayRemove1, arrayRemove2); + assertNotEquals(arrayRemove1, arrayRemove3); + assertNotEquals(arrayRemove1, arrayUnion); + } + + @Test + public void incrementEquals() { + FieldValue increment1 = FieldValue.increment(42); + FieldValue increment2 = FieldValue.increment(42); + FieldValue increment3 = FieldValue.increment(42.0); + FieldValue increment4 = FieldValue.increment(42.0); + assertEquals(increment1, increment2); + assertEquals(increment3, increment4); + assertNotEquals(increment1, increment3); + assertNotEquals(increment2, increment4); + } + + @Test + public void arrayUnionWithPojo() throws ExecutionException, InterruptedException { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + DocumentReference doc = firestoreMock.document("coll/doc"); + doc.update("array", FieldValue.arrayUnion(SINGLE_FIELD_OBJECT)).get(); + + CommitRequest expectedRequest = + commit( + update(Collections.emptyMap(), new ArrayList<>()), + transform("array", arrayUnion(SINGLE_FIELD_VALUE))); + CommitRequest actualRequest = commitCapture.getValue(); + assertEquals(expectedRequest, actualRequest); + } + + @Test + public void arrayRemoveWithPojo() throws ExecutionException, InterruptedException { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + DocumentReference doc = firestoreMock.document("coll/doc"); + doc.update("array", FieldValue.arrayRemove(SINGLE_FIELD_OBJECT)).get(); + + CommitRequest expectedRequest = + commit( + update(Collections.emptyMap(), new ArrayList<>()), + transform("array", arrayRemove(SINGLE_FIELD_VALUE))); + CommitRequest actualRequest = commitCapture.getValue(); + assertEquals(expectedRequest, actualRequest); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java new file mode 100644 index 000000000000..500e35ff9607 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java @@ -0,0 +1,1345 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.StreamController; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.firestore.v1.AggregationResult; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.DatabaseRootName; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.DocumentTransform.FieldTransform; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Precondition; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredAggregationQuery; +import com.google.firestore.v1.StructuredAggregationQuery.Aggregation; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.StructuredQuery.CollectionSelector; +import com.google.firestore.v1.StructuredQuery.CompositeFilter; +import com.google.firestore.v1.StructuredQuery.FieldFilter; +import com.google.firestore.v1.StructuredQuery.UnaryFilter; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.google.protobuf.*; +import com.google.type.LatLng; +import java.lang.reflect.Type; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nullable; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.stubbing.Answer; +import org.mockito.stubbing.Stubber; + +public final class LocalFirestoreHelper { + + protected static RetrySettings IMMEDIATE_RETRY_SETTINGS = + RetrySettings.newBuilder() + .setInitialRetryDelayDuration(Duration.ZERO) + .setMaxRetryDelayDuration(Duration.ZERO) + .setRetryDelayMultiplier(1) + .setJittered(false) + .build(); + + public static final String DATABASE_NAME; + public static final String COLLECTION_ID; + public static final String DOCUMENT_PATH; + public static final String DOCUMENT_NAME; + public static final String DOCUMENT_ROOT; + public static final String TRANSACTION_ID; + + public static final Map EMPTY_MAP_PROTO; + + public static final Map SINGLE_FIELD_MAP; + public static final Map SINGLE_FILED_MAP_WITH_DOT; + public static final SingleField SINGLE_FIELD_OBJECT; + public static final Map SINGLE_FIELD_PROTO; + public static final DocumentSnapshot SINGLE_FIELD_SNAPSHOT; + public static final Value SINGLE_FIELD_VALUE; + public static final SingleField UPDATE_SINGLE_FIELD_OBJECT; + public static final Map UPDATED_FIELD_MAP; + public static final Map UPDATED_FIELD_PROTO; + public static final Map UPDATED_SINGLE_FIELD_PROTO; + public static final Map UPDATED_POJO_PROTO; + public static final DocumentSnapshot UPDATED_SINGLE_FIELD_SNAPSHOT; + + public static final Map SINGLE_FLOAT_MAP; + public static final Map SINGLE_FLOAT_PROTO; + + public static final NestedClass NESTED_CLASS_OBJECT; + + public static final Map SERVER_TIMESTAMP_MAP; + public static final ServerTimestamp SERVER_TIMESTAMP_OBJECT; + public static final Map SERVER_TIMESTAMP_PROTO; + + public static final Map ALL_SUPPORTED_TYPES_MAP; + public static final AllSupportedTypes ALL_SUPPORTED_TYPES_OBJECT; + public static final Map ALL_SUPPORTED_TYPES_PROTO; + + public static final CommitRequest SINGLE_CREATE_COMMIT_REQUEST; + public static final ApiFuture SINGLE_DELETE_COMMIT_RESPONSE; + public static final ApiFuture SINGLE_WRITE_COMMIT_RESPONSE; + + public static final ApiFuture FIELD_TRANSFORM_COMMIT_RESPONSE; + + public static final Map UPDATED_POJO; + + public static final Date DATE; + public static final Timestamp TIMESTAMP; + public static final Instant INSTANT; + public static final GeoPoint GEO_POINT; + public static final Blob BLOB; + public static final FooList FOO_LIST = new FooList<>(); + public static final FooMap FOO_MAP = new FooMap<>(); + + public static final Precondition UPDATE_PRECONDITION; + + public static class SingleField { + + public String foo = "bar"; + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + SingleField that = (SingleField) o; + + return foo.equals(that.foo); + } + } + + public static class FooList extends ArrayList { + public FooList() { + super(); + } + } + + public static class CustomList { + public CustomList() {} + + public FooList fooList; + } + + public static class FooMap extends HashMap { + public FooMap() { + super(); + } + } + + public static class CustomMap { + public CustomMap() {} + + public FooMap fooMap; + } + + public static class NestedClass { + public SingleField first = new SingleField(); + public AllSupportedTypes second = new AllSupportedTypes(); + } + + public static class ServerTimestamp { + + @com.google.cloud.firestore.annotation.ServerTimestamp public Date foo; + public Inner inner = new Inner(); + + class Inner { + + @com.google.cloud.firestore.annotation.ServerTimestamp public Date bar; + } + } + + public static class InvalidPOJO { + @Nullable BigInteger bigIntegerValue = null; + @Nullable Byte byteValue = null; + @Nullable Short shortValue = null; + + @Nullable + public BigInteger getBigIntegerValue() { + return bigIntegerValue; + } + + public void setBigIntegerValue(@Nullable BigInteger bigIntegerValue) { + this.bigIntegerValue = bigIntegerValue; + } + + @Nullable + public Byte getByteValue() { + return byteValue; + } + + public void setByteValue(@Nullable Byte byteValue) { + this.byteValue = byteValue; + } + + @Nullable + public Short getShortValue() { + return shortValue; + } + + public void setShortValue(@Nullable Short shortValue) { + this.shortValue = shortValue; + } + } + + public static Map map(K key, V value, Object... moreKeysAndValues) { + Map map = new HashMap<>(); + map.put(key, value); + + for (int i = 0; i < moreKeysAndValues.length; i += 2) { + map.put((K) moreKeysAndValues[i], (V) moreKeysAndValues[i + 1]); + } + + return map; + } + + public static Map map() { + return new HashMap<>(); + } + + public static Answer getAllResponse( + final Map... fields) { + return getAllResponseImpl(true, fields); + } + + public static Answer getAllResponseWithoutOnComplete( + final Map... fields) { + return getAllResponseImpl(false, fields); + } + + public static Answer getAllResponseImpl( + boolean withOnComplete, final Map... fields) { + BatchGetDocumentsResponse[] responses = new BatchGetDocumentsResponse[fields.length]; + + for (int i = 0; i < fields.length; ++i) { + String name = DOCUMENT_NAME; + if (fields.length > 1) { + name += i + 1; + } + BatchGetDocumentsResponse.Builder response = BatchGetDocumentsResponse.newBuilder(); + response + .getFoundBuilder() + .setCreateTime(com.google.protobuf.Timestamp.newBuilder().setSeconds(1).setNanos(2)); + response + .getFoundBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.newBuilder().setSeconds(3).setNanos(4)); + response.setReadTime(com.google.protobuf.Timestamp.newBuilder().setSeconds(5).setNanos(6)); + response.getFoundBuilder().setName(name).putAllFields(fields[i]); + responses[i] = response.build(); + } + + if (withOnComplete) { + return streamingResponse(responses, null); + } else { + // Verify with logical termination, the return of results no longer depends on calling + // OnComplete. + return streamingResponseWithoutOnComplete(responses); + } + } + + public static ApiFuture rollbackResponse() { + return ApiFutures.immediateFuture(Empty.getDefaultInstance()); + } + + public static Answer emptyQueryResponse() { + RunQueryResponse[] response = new RunQueryResponse[0]; + return streamingResponse(response, null); + } + + public static Answer queryResponse() { + return queryResponse(DOCUMENT_NAME); + } + + public static Answer queryResponse(String... documentNames) { + return queryResponse(/* throwable= */ null, documentNames); + } + + /** Returns a stream of documents followed by an optional exception. */ + public static Answer queryResponse( + @Nullable Throwable throwable, String... documentNames) { + RunQueryResponse[] responses = new RunQueryResponse[documentNames.length]; + + for (int i = 0; i < documentNames.length; ++i) { + final RunQueryResponse.Builder runQueryResponse = RunQueryResponse.newBuilder(); + runQueryResponse.setDocument( + Document.newBuilder().setName(documentNames[i]).putAllFields(SINGLE_FIELD_PROTO)); + runQueryResponse.setReadTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(1).setNanos(2)); + responses[i] = runQueryResponse.build(); + } + + return streamingResponse(responses, throwable); + } + + /** Returns a stream of responses when RunQueryResponse.done set to true */ + public static Answer queryResponseWithDone( + boolean callWithoutOnComplete, String... documentNames) { + RunQueryResponse[] responses = new RunQueryResponse[documentNames.length]; + + for (int i = 0; i < documentNames.length; ++i) { + final RunQueryResponse.Builder runQueryResponse = RunQueryResponse.newBuilder(); + runQueryResponse.setDocument( + Document.newBuilder().setName(documentNames[i]).putAllFields(SINGLE_FIELD_PROTO)); + runQueryResponse.setReadTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(1).setNanos(2)); + if (i == (documentNames.length - 1)) { + runQueryResponse.setDone(true); + } + responses[i] = runQueryResponse.build(); + } + if (callWithoutOnComplete) { + return streamingResponseWithoutOnComplete(responses); + } else { + return streamingResponse(responses, null); + } + } + + public static Answer countQueryResponse() { + return countQueryResponse(42); + } + + public static Answer countQueryResponse(int count) { + return countQueryResponse(count, null); + } + + public static Answer countQueryResponse( + int count, @Nullable Timestamp readTime) { + return streamingResponse( + new RunAggregationQueryResponse[] { + createCountQueryResponse(count, readTime), + }, + /* throwable= */ null); + } + + public static Answer countQueryResponse(Throwable throwable) { + return streamingResponse(new RunAggregationQueryResponse[] {}, throwable); + } + + public static Answer aggregationQueryResponses( + int count1, int count2) { + return streamingResponse( + new RunAggregationQueryResponse[] { + createCountQueryResponse(count1, null), createCountQueryResponse(count2, null), + }, + /* throwable= */ null); + } + + public static Answer aggregationQueryResponses( + int count1, Throwable throwable) { + return streamingResponse( + new RunAggregationQueryResponse[] { + createCountQueryResponse(count1, null), + }, + throwable); + } + + private static RunAggregationQueryResponse createCountQueryResponse( + int count, @Nullable Timestamp timestamp) { + RunAggregationQueryResponse.Builder builder = RunAggregationQueryResponse.newBuilder(); + builder.setResult( + AggregationResult.newBuilder() + .putAggregateFields("aggregate_0", Value.newBuilder().setIntegerValue(count).build()) + .build()); + if (timestamp != null) { + builder.setReadTime(timestamp.toProto()); + } + return builder.build(); + } + + /** Returns a stream of responses followed by an optional exception. */ + public static Answer streamingResponse( + final T[] response, @Nullable final Throwable throwable) { + return invocation -> { + Object[] args = invocation.getArguments(); + ResponseObserver observer = (ResponseObserver) args[1]; + observer.onStart(mock(StreamController.class)); + for (T resp : response) { + observer.onResponse(resp); + } + if (throwable != null) { + observer.onError(throwable); + } + observer.onComplete(); + return null; + }; + } + + /** Returns a stream of responses even though onComplete() wasn't triggered */ + public static Answer streamingResponseWithoutOnComplete(final T[] response) { + return invocation -> { + Object[] args = invocation.getArguments(); + ResponseObserver observer = (ResponseObserver) args[1]; + observer.onStart(mock(StreamController.class)); + for (T resp : response) { + observer.onResponse(resp); + } + return null; + }; + } + + public static ApiFuture commitResponse(int adds, int deletes) { + CommitResponse.Builder commitResponse = CommitResponse.newBuilder(); + commitResponse.getCommitTimeBuilder().setSeconds(0).setNanos(0); + for (int i = 0; i < adds; ++i) { + commitResponse.addWriteResultsBuilder().getUpdateTimeBuilder().setSeconds(i).setNanos(i); + } + for (int i = 0; i < deletes; ++i) { + commitResponse.addWriteResultsBuilder(); + } + return ApiFutures.immediateFuture(commitResponse.build()); + } + + public static BeginTransactionRequest begin() { + return begin(null); + } + + public static BeginTransactionRequest begin(@Nullable String previousTransactionId) { + BeginTransactionRequest.Builder begin = BeginTransactionRequest.newBuilder(); + begin.setDatabase(DATABASE_NAME); + + if (previousTransactionId != null) { + begin + .getOptionsBuilder() + .getReadWriteBuilder() + .setRetryTransaction(ByteString.copyFromUtf8(previousTransactionId)); + } + + return begin.build(); + } + + public static ApiFuture beginResponse() { + return beginResponse(TRANSACTION_ID); + } + + public static ApiFuture beginResponse(String transactionId) { + BeginTransactionResponse.Builder beginResponse = BeginTransactionResponse.newBuilder(); + beginResponse.setTransaction(ByteString.copyFromUtf8(transactionId)); + return ApiFutures.immediateFuture(beginResponse.build()); + } + + public static RollbackRequest rollback() { + return rollback(TRANSACTION_ID); + } + + public static RollbackRequest rollback(String transactionId) { + RollbackRequest.Builder rollback = RollbackRequest.newBuilder(); + rollback.setDatabase(DATABASE_NAME); + rollback.setTransaction(ByteString.copyFromUtf8(transactionId)); + return rollback.build(); + } + + public static FieldTransform serverTimestamp() { + return FieldTransform.newBuilder() + .setSetToServerValue(FieldTransform.ServerValue.REQUEST_TIME) + .build(); + } + + public static FieldTransform increment(Value value) { + return FieldTransform.newBuilder().setIncrement(value).build(); + } + + public static FieldTransform arrayUnion(Value... values) { + return FieldTransform.newBuilder() + .setAppendMissingElements(ArrayValue.newBuilder().addAllValues(Arrays.asList(values))) + .build(); + } + + public static FieldTransform arrayRemove(Value... values) { + return FieldTransform.newBuilder() + .setRemoveAllFromArray(ArrayValue.newBuilder().addAllValues(Arrays.asList(values))) + .build(); + } + + public static List transform( + String fieldPath, FieldTransform fieldTransform, Object... fieldPathOrTransform) { + + List transforms = new ArrayList<>(); + FieldTransform.Builder transformBuilder = FieldTransform.newBuilder(); + transformBuilder.setFieldPath(fieldPath).mergeFrom(fieldTransform); + + transforms.add(transformBuilder.build()); + + for (int i = 0; i < fieldPathOrTransform.length; i += 2) { + String path = (String) fieldPathOrTransform[i]; + FieldTransform transform = (FieldTransform) fieldPathOrTransform[i + 1]; + transforms.add(FieldTransform.newBuilder().setFieldPath(path).mergeFrom(transform).build()); + } + return transforms; + } + + public static Write create(Map fields, String docPath) { + Write.Builder write = Write.newBuilder(); + Document.Builder document = write.getUpdateBuilder(); + document.setName(DOCUMENT_ROOT + docPath); + document.putAllFields(fields); + write.getCurrentDocumentBuilder().setExists(false); + return write.build(); + } + + public static Write create(Map fields) { + return create(fields, DOCUMENT_PATH); + } + + public static Write set(Map fields) { + return set(fields, null, DOCUMENT_PATH); + } + + public static Write set(Map fields, String docPath) { + return set(fields, null, docPath); + } + + public static Write set(Map fields, @Nullable List fieldMap) { + return set(fields, fieldMap, DOCUMENT_PATH); + } + + public static Write set( + Map fields, @Nullable List fieldMap, String docPath) { + Write.Builder write = Write.newBuilder(); + Document.Builder document = write.getUpdateBuilder(); + document.setName(DOCUMENT_ROOT + docPath); + document.putAllFields(fields); + + if (fieldMap != null) { + write.getUpdateMaskBuilder().addAllFieldPaths(fieldMap); + } + + return write.build(); + } + + public static Write delete() { + return delete(DOCUMENT_PATH); + } + + public static Write delete(Precondition precondition) { + Write.Builder write = Write.newBuilder(); + write.setDelete(DOCUMENT_NAME); + write.getCurrentDocumentBuilder().mergeFrom(precondition); + return write.build(); + } + + public static Write delete(String docPath) { + Write.Builder write = Write.newBuilder(); + write.setDelete(DOCUMENT_ROOT + docPath); + return write.build(); + } + + public static Write update(Map fields, List fieldMap) { + return update(fields, fieldMap, UPDATE_PRECONDITION); + } + + public static Write update( + Map fields, List fieldMap, @Nullable Precondition precondition) { + return update(fields, fieldMap, precondition, DOCUMENT_PATH); + } + + public static Write update(Map fields, String docPath) { + return update(fields, Collections.singletonList("foo"), UPDATE_PRECONDITION, docPath); + } + + public static Write update( + Map fields, + @Nullable List fieldMap, + @Nullable Precondition precondition, + String docPath) { + Write.Builder write = Write.newBuilder(); + Document.Builder document = write.getUpdateBuilder(); + document.setName(DOCUMENT_ROOT + docPath); + document.putAllFields(fields); + write.getUpdateMaskBuilder().addAllFieldPaths(fieldMap); + if (precondition != null) { + write.getCurrentDocumentBuilder().mergeFrom(precondition); + } + return write.build(); + } + + public static CommitRequest commit(@Nullable String transactionId, Write... writes) { + CommitRequest.Builder commitRequest = CommitRequest.newBuilder(); + commitRequest.setDatabase(DATABASE_NAME); + commitRequest.addAllWrites(Arrays.asList(writes)); + + if (transactionId != null) { + commitRequest.setTransaction(ByteString.copyFromUtf8(transactionId)); + } + + return commitRequest.build(); + } + + public static CommitRequest commit(Write... writes) { + return commit(null, writes); + } + + public static CommitRequest commit(Write write, List transforms) { + return commit((String) null, write.toBuilder().addAllUpdateTransforms(transforms).build()); + } + + public static BatchWriteRequest batchWrite(Write... writes) { + BatchWriteRequest.Builder batchWriteRequest = BatchWriteRequest.newBuilder(); + batchWriteRequest.setDatabase(DATABASE_NAME); + batchWriteRequest.addAllWrites(Arrays.asList(writes)); + return batchWriteRequest.build(); + } + + public static StructuredQuery filter(StructuredQuery.FieldFilter.Operator operator) { + return filter(operator, "foo", "bar"); + } + + public static StructuredQuery findNearest( + String fieldPath, + double[] queryVector, + int limit, + StructuredQuery.FindNearest.DistanceMeasure measure) { + ArrayValue.Builder vectorArrayBuilder = ArrayValue.newBuilder(); + for (double d : queryVector) { + vectorArrayBuilder.addValues(Value.newBuilder().setDoubleValue(d)); + } + + StructuredQuery.FindNearest.Builder findNearest = + StructuredQuery.FindNearest.newBuilder() + .setVectorField(StructuredQuery.FieldReference.newBuilder().setFieldPath(fieldPath)) + .setQueryVector( + Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields( + "__type__", Value.newBuilder().setStringValue("__vector__").build()) + .putFields( + "value", + Value.newBuilder() + .setArrayValue(vectorArrayBuilder.build()) + .build()))) + .setLimit(Int32Value.newBuilder().setValue(limit)) + .setDistanceMeasure(measure); + + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.setFindNearest(findNearest.build()); + + return structuredQuery.build(); + } + + public static StructuredQuery filter( + StructuredQuery.FieldFilter.Operator operator, String path, String value) { + return filter(operator, path, string(value)); + } + + public static StructuredQuery.Filter fieldFilter( + String path, StructuredQuery.FieldFilter.Operator operator, String value) { + StructuredQuery.FieldFilter.Builder builder = + FieldFilter.newBuilder() + .setField(StructuredQuery.FieldReference.newBuilder().setFieldPath(path)) + .setOp(operator) + .setValue(Value.newBuilder().setStringValue(value).build()); + return StructuredQuery.Filter.newBuilder().setFieldFilter(builder).build(); + } + + public static StructuredQuery.Filter andFilters(StructuredQuery.Filter... filters) { + return compositeFilter(CompositeFilter.Operator.AND, Arrays.asList(filters)); + } + + public static StructuredQuery.Filter orFilters(StructuredQuery.Filter... filters) { + return compositeFilter(CompositeFilter.Operator.OR, Arrays.asList(filters)); + } + + private static StructuredQuery.Filter compositeFilter( + StructuredQuery.CompositeFilter.Operator operator, List filters) { + StructuredQuery.CompositeFilter.Builder builder = + StructuredQuery.CompositeFilter.newBuilder().setOp(operator).addAllFilters(filters); + return StructuredQuery.Filter.newBuilder().setCompositeFilter(builder).build(); + } + + public static StructuredQuery filter( + StructuredQuery.FieldFilter.Operator operator, String path, Value value) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + StructuredQuery.CompositeFilter.Builder compositeFilter = + structuredQuery.getWhereBuilder().getCompositeFilterBuilder(); + compositeFilter.setOp(StructuredQuery.CompositeFilter.Operator.AND); + + StructuredQuery.FieldFilter.Builder fieldFilter = + compositeFilter.addFiltersBuilder().getFieldFilterBuilder(); + fieldFilter.setField(StructuredQuery.FieldReference.newBuilder().setFieldPath(path)); + fieldFilter.setOp(operator); + fieldFilter.setValue(value); + + return structuredQuery.build(); + } + + public static StructuredQuery unaryFilter(StructuredQuery.UnaryFilter.Operator operator) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + StructuredQuery.CompositeFilter.Builder compositeFilter = + structuredQuery.getWhereBuilder().getCompositeFilterBuilder(); + compositeFilter.setOp(StructuredQuery.CompositeFilter.Operator.AND); + + StructuredQuery.UnaryFilter.Builder fieldFilter = + compositeFilter.addFiltersBuilder().getUnaryFilterBuilder(); + fieldFilter.setField(StructuredQuery.FieldReference.newBuilder().setFieldPath("foo")); + fieldFilter.setOp(operator); + + return structuredQuery.build(); + } + + public static RunQueryRequest query(StructuredQuery... query) { + return query(null, false, query); + } + + public static RunQueryRequest query( + @Nullable String transactionId, boolean allDescendants, StructuredQuery... query) { + return query(transactionId, /* parent= */ "", allDescendants, /* kindless= */ false, query); + } + + public static RunQueryRequest query( + @Nullable String transactionId, + boolean allDescendants, + boolean kindless, + StructuredQuery... query) { + return query(transactionId, /* parent= */ "", allDescendants, kindless, query); + } + + public static RunQueryRequest query( + @Nullable String transactionId, + String parent, + boolean allDescendants, + boolean kindless, + StructuredQuery... query) { + RunQueryRequest.Builder request = RunQueryRequest.newBuilder(); + if (!parent.equals("")) { + parent = '/' + parent; + } + request.setParent(LocalFirestoreHelper.DATABASE_NAME + "/documents" + parent); + StructuredQuery.Builder structuredQuery = request.getStructuredQueryBuilder(); + + CollectionSelector.Builder builder = + CollectionSelector.newBuilder().setAllDescendants(allDescendants); + if (!kindless) { + builder.setCollectionId("coll"); + } + structuredQuery.addFrom(builder); + + for (StructuredQuery option : query) { + structuredQuery.mergeFrom(option); + } + + CompositeFilter compositeFilter = structuredQuery.getWhere().getCompositeFilter(); + if (compositeFilter.getFiltersCount() == 1) { + if (compositeFilter.getFilters(0).hasFieldFilter()) { + FieldFilter fieldFilter = compositeFilter.getFilters(0).getFieldFilter(); + structuredQuery.getWhereBuilder().setFieldFilter(fieldFilter); + } else { + UnaryFilter unaryFilter = compositeFilter.getFilters(0).getUnaryFilter(); + structuredQuery.getWhereBuilder().setUnaryFilter(unaryFilter); + } + } + + if (transactionId != null) { + request.setTransaction(ByteString.copyFromUtf8(transactionId)); + } + + return request.build(); + } + + public static RunAggregationQueryRequest countQuery() { + return countQuery((String) null); + } + + public static RunAggregationQueryRequest countQuery(@Nullable String transactionId) { + RunQueryRequest runQueryRequest = query(TRANSACTION_ID, false); + + RunAggregationQueryRequest.Builder request = + RunAggregationQueryRequest.newBuilder() + .setParent(runQueryRequest.getParent()) + .setStructuredAggregationQuery( + StructuredAggregationQuery.newBuilder() + .setStructuredQuery(runQueryRequest.getStructuredQuery()) + .addAggregations( + Aggregation.newBuilder() + .setAlias("aggregate_0") + .setCount(Aggregation.Count.getDefaultInstance()))); + + if (transactionId != null) { + request.setTransaction(ByteString.copyFromUtf8(transactionId)); + } + + return request.build(); + } + + public static RunAggregationQueryRequest countQuery(RunQueryRequest runQueryRequest) { + return RunAggregationQueryRequest.newBuilder() + .setParent(runQueryRequest.getParent()) + .setStructuredAggregationQuery( + StructuredAggregationQuery.newBuilder() + .setStructuredQuery(runQueryRequest.getStructuredQuery()) + .addAggregations( + Aggregation.newBuilder() + .setAlias("aggregate_0") + .setCount(Aggregation.Count.getDefaultInstance()))) + .build(); + } + + public static BatchGetDocumentsRequest get() { + return getAll(null, DOCUMENT_NAME); + } + + public static BatchGetDocumentsRequest get(@Nullable String transactionId) { + return getAll(transactionId, DOCUMENT_NAME); + } + + public static BatchGetDocumentsRequest getAll( + @Nullable String transactionId, String... documentNames) { + BatchGetDocumentsRequest.Builder request = BatchGetDocumentsRequest.newBuilder(); + request.setDatabase(DATABASE_NAME); + + for (String documentName : documentNames) { + request.addDocuments(documentName); + } + + if (transactionId != null) { + request.setTransaction(ByteString.copyFromUtf8(transactionId)); + } + + return request.build(); + } + + public static StructuredQuery order(FieldPath fieldPath, StructuredQuery.Direction direction) { + return order(fieldPath.getEncodedPath(), direction); + } + + public static StructuredQuery order(String fieldPath, StructuredQuery.Direction direction) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.addOrderByBuilder().setField(field(fieldPath)).setDirection(direction); + return structuredQuery.build(); + } + + public static StructuredQuery select(String fieldPath) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.getSelectBuilder().addFields(field(fieldPath)); + return structuredQuery.build(); + } + + public static StructuredQuery select(FieldPath fieldPath) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.getSelectBuilder().addFields(field(fieldPath.getEncodedPath())); + return structuredQuery.build(); + } + + public static StructuredQuery startAt(boolean before) { + return startAt(string(), before); + } + + public static StructuredQuery startAt(Value value, boolean before) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.setStartAt(Cursor.newBuilder().setBefore(before).addValues(value)); + return structuredQuery.build(); + } + + public static StructuredQuery endAt(boolean before) { + return endAt(string(), before); + } + + public static StructuredQuery endAt(Value value, boolean before) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.setEndAt(Cursor.newBuilder().setBefore(before).addValues(value)); + return structuredQuery.build(); + } + + public static StructuredQuery limit(int n) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.getLimitBuilder().setValue(n); + return structuredQuery.build(); + } + + public static StructuredQuery offset(int n) { + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.setOffset(n); + return structuredQuery.build(); + } + + public static Value string() { + return string("bar"); + } + + public static Value string(String value) { + return Value.newBuilder().setStringValue(value).build(); + } + + public static Value object(String key, Value value) { + Value.Builder result = Value.newBuilder(); + result.getMapValueBuilder().putFields(key, value); + return result.build(); + } + + public static Value reference(String value) { + return Value.newBuilder().setReferenceValue(value).build(); + } + + public static StructuredQuery.FieldReference.Builder field(String fieldPath) { + return StructuredQuery.FieldReference.newBuilder().setFieldPath(fieldPath); + } + + public static void assertCommitEquals(CommitRequest expected, CommitRequest actual) { + assertEquals(sortCommit(expected), sortCommit(actual)); + } + + private static CommitRequest sortCommit(CommitRequest commit) { + CommitRequest.Builder builder = commit.toBuilder(); + + for (Write.Builder writes : builder.getWritesBuilderList()) { + if (writes.hasUpdateMask()) { + ArrayList updateMask = new ArrayList<>(writes.getUpdateMask().getFieldPathsList()); + Collections.sort(updateMask); + writes.setUpdateMask(DocumentMask.newBuilder().addAllFieldPaths(updateMask)); + } + + if (!writes.getUpdateTransformsList().isEmpty()) { + ArrayList transformList = new ArrayList<>(writes.getUpdateTransformsList()); + transformList.sort(Comparator.comparing(FieldTransform::getFieldPath)); + writes.clearUpdateTransforms().addAllUpdateTransforms(transformList); + } + } + + return builder.build(); + } + + public static class AllSupportedTypes { + + public String foo = "bar"; + public Double doubleValue = 0.0; + public long longValue = 0L; + public double nanValue = Double.NaN; + public double infValue = Double.POSITIVE_INFINITY; + public double negInfValue = Double.NEGATIVE_INFINITY; + public boolean trueValue = true; + public boolean falseValue = false; + public SingleField objectValue = new SingleField(); + public Date dateValue = DATE; + public Timestamp timestampValue = TIMESTAMP; + public Instant instantValue = INSTANT; + public List arrayValue = ImmutableList.of("foo"); + public String nullValue = null; + public Blob bytesValue = BLOB; + public GeoPoint geoPointValue = GEO_POINT; + public Map model = ImmutableMap.of("foo", SINGLE_FIELD_OBJECT.foo); + public VectorValue vectorValue = FieldValue.vector(new double[] {0.1, 0.2, 0.3}); + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AllSupportedTypes that = (AllSupportedTypes) o; + return longValue == that.longValue + && Double.compare(that.nanValue, nanValue) == 0 + && Double.compare(that.infValue, infValue) == 0 + && Double.compare(that.negInfValue, negInfValue) == 0 + && trueValue == that.trueValue + && falseValue == that.falseValue + && Objects.equals(foo, that.foo) + && Objects.equals(doubleValue, that.doubleValue) + && Objects.equals(objectValue, that.objectValue) + && Objects.equals(dateValue, that.dateValue) + && Objects.equals(timestampValue, that.timestampValue) + && Objects.equals(instantValue, that.instantValue) + && Objects.equals(arrayValue, that.arrayValue) + && Objects.equals(nullValue, that.nullValue) + && Objects.equals(bytesValue, that.bytesValue) + && Objects.equals(geoPointValue, that.geoPointValue) + && Objects.equals(model, that.model) + && Objects.equals(vectorValue, that.vectorValue); + } + } + + static { + TRANSACTION_ID = "foo"; + + try { + DATE = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z").parse("1985-03-18 08:20:00.123 CET"); + } catch (ParseException e) { + throw new RuntimeException("Failed to parse date", e); + } + + TIMESTAMP = + Timestamp.ofTimeSecondsAndNanos( + TimeUnit.MILLISECONDS.toSeconds(DATE.getTime()), + 123000); // Firestore truncates to microsecond precision. + INSTANT = + Instant.ofEpochSecond( + TimeUnit.MILLISECONDS.toSeconds(DATE.getTime()), + 123000); // Firestore truncates to microsecond precision. + GEO_POINT = new GeoPoint(50.1430847, -122.9477780); + BLOB = Blob.fromBytes(new byte[] {1, 2, 3}); + SINGLE_FLOAT_MAP = map("float", 0.1F); + SINGLE_FLOAT_PROTO = map("float", Value.newBuilder().setDoubleValue(0.1F).build()); + + DATABASE_NAME = "projects/test-project/databases/(default)"; + COLLECTION_ID = "coll"; + DOCUMENT_PATH = "coll/doc"; + DOCUMENT_NAME = DATABASE_NAME + "/documents/" + DOCUMENT_PATH; + DOCUMENT_ROOT = DATABASE_NAME + "/documents/"; + + EMPTY_MAP_PROTO = + map("inner", Value.newBuilder().setMapValue(MapValue.getDefaultInstance()).build()); + + SINGLE_FIELD_MAP = map("foo", "bar"); + SINGLE_FILED_MAP_WITH_DOT = map("c.d", "bar"); + SINGLE_FIELD_OBJECT = new SingleField(); + FOO_LIST.add(SINGLE_FIELD_OBJECT); + FOO_MAP.put("customMap", SINGLE_FIELD_OBJECT); + SINGLE_FIELD_PROTO = map("foo", Value.newBuilder().setStringValue("bar").build()); + UPDATED_POJO_PROTO = + map( + "model", + Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields("foo", Value.newBuilder().setStringValue("foobar").build())) + .build()); + SINGLE_FIELD_SNAPSHOT = + new DocumentSnapshot( + null, + new DocumentReference( + null, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc"))), + SINGLE_FIELD_PROTO, + Timestamp.ofTimeSecondsAndNanos(5, 6), + Timestamp.ofTimeSecondsAndNanos(3, 4), + Timestamp.ofTimeSecondsAndNanos(1, 2)); + + Value.Builder singleFieldValueBuilder = Value.newBuilder(); + singleFieldValueBuilder.getMapValueBuilder().putAllFields(SINGLE_FIELD_PROTO); + SINGLE_FIELD_VALUE = singleFieldValueBuilder.build(); + UPDATE_SINGLE_FIELD_OBJECT = new SingleField(); + UPDATE_SINGLE_FIELD_OBJECT.foo = "foobar"; + + UPDATED_FIELD_MAP = map("foo", "foobar"); + UPDATED_FIELD_PROTO = map("foo", Value.newBuilder().setStringValue("foobar").build()); + UPDATED_SINGLE_FIELD_PROTO = + ImmutableMap.builder() + .put( + "foo", + Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putFields("foo", Value.newBuilder().setStringValue("foobar").build())) + .build()) + .build(); + UPDATED_SINGLE_FIELD_SNAPSHOT = + new DocumentSnapshot( + null, + new DocumentReference( + null, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc"))), + UPDATED_SINGLE_FIELD_PROTO, + Timestamp.ofTimeSecondsAndNanos(50, 6), + Timestamp.ofTimeSecondsAndNanos(30, 4), + Timestamp.ofTimeSecondsAndNanos(10, 2)); + SERVER_TIMESTAMP_MAP = new HashMap<>(); + SERVER_TIMESTAMP_MAP.put("foo", FieldValue.serverTimestamp()); + SERVER_TIMESTAMP_MAP.put("inner", new HashMap()); + ((Map) SERVER_TIMESTAMP_MAP.get("inner")) + .put("bar", FieldValue.serverTimestamp()); + + Value.Builder mapValue = Value.newBuilder(); + mapValue.getMapValueBuilder(); + SERVER_TIMESTAMP_PROTO = Collections.emptyMap(); + SERVER_TIMESTAMP_OBJECT = new ServerTimestamp(); + + ALL_SUPPORTED_TYPES_MAP = new HashMap<>(); + ALL_SUPPORTED_TYPES_MAP.put("foo", "bar"); + ALL_SUPPORTED_TYPES_MAP.put("doubleValue", 0.0); + ALL_SUPPORTED_TYPES_MAP.put("longValue", 0L); + ALL_SUPPORTED_TYPES_MAP.put("nanValue", Double.NaN); + ALL_SUPPORTED_TYPES_MAP.put("infValue", Double.POSITIVE_INFINITY); + ALL_SUPPORTED_TYPES_MAP.put("negInfValue", Double.NEGATIVE_INFINITY); + ALL_SUPPORTED_TYPES_MAP.put("trueValue", true); + ALL_SUPPORTED_TYPES_MAP.put("falseValue", false); + ALL_SUPPORTED_TYPES_MAP.put("objectValue", map("foo", (Object) "bar")); + ALL_SUPPORTED_TYPES_MAP.put("dateValue", Timestamp.of(DATE)); + ALL_SUPPORTED_TYPES_MAP.put("timestampValue", TIMESTAMP); + ALL_SUPPORTED_TYPES_MAP.put("instantValue", TIMESTAMP); + ALL_SUPPORTED_TYPES_MAP.put("arrayValue", ImmutableList.of("foo")); + ALL_SUPPORTED_TYPES_MAP.put("nullValue", null); + ALL_SUPPORTED_TYPES_MAP.put("bytesValue", BLOB); + ALL_SUPPORTED_TYPES_MAP.put("geoPointValue", GEO_POINT); + ALL_SUPPORTED_TYPES_MAP.put("model", map("foo", SINGLE_FIELD_OBJECT.foo)); + ALL_SUPPORTED_TYPES_MAP.put("vectorValue", FieldValue.vector(new double[] {0.1, 0.2, 0.3})); + ALL_SUPPORTED_TYPES_PROTO = + ImmutableMap.builder() + .put("foo", Value.newBuilder().setStringValue("bar").build()) + .put("doubleValue", Value.newBuilder().setDoubleValue(0.0).build()) + .put("longValue", Value.newBuilder().setIntegerValue(0L).build()) + .put("nanValue", Value.newBuilder().setDoubleValue(Double.NaN).build()) + .put("infValue", Value.newBuilder().setDoubleValue(Double.POSITIVE_INFINITY).build()) + .put("negInfValue", Value.newBuilder().setDoubleValue(Double.NEGATIVE_INFINITY).build()) + .put("trueValue", Value.newBuilder().setBooleanValue(true).build()) + .put("falseValue", Value.newBuilder().setBooleanValue(false).build()) + .put( + "objectValue", + Value.newBuilder() + .setMapValue(MapValue.newBuilder().putAllFields(SINGLE_FIELD_PROTO)) + .build()) + .put( + "vectorValue", + Value.newBuilder() + .setMapValue( + MapValue.newBuilder() + .putAllFields( + map( + "__type__", + Value.newBuilder().setStringValue("__vector__").build(), + "value", + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder() + .addValues(Value.newBuilder().setDoubleValue(0.1)) + .addValues(Value.newBuilder().setDoubleValue(0.2)) + .addValues(Value.newBuilder().setDoubleValue(0.3))) + .build()))) + .build()) + .put( + "dateValue", + Value.newBuilder() + .setTimestampValue( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(479978400) + .setNanos(123000000)) // Dates only support millisecond precision. + .build()) + .put( + "timestampValue", + Value.newBuilder() + .setTimestampValue( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(479978400) + .setNanos(123000)) // Timestamps supports microsecond precision. + .build()) + .put( + "instantValue", + Value.newBuilder() + .setTimestampValue( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(479978400) + .setNanos(123000)) // Instants supports microsecond precision. + .build()) + .put( + "arrayValue", + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder().addValues(Value.newBuilder().setStringValue("foo"))) + .build()) + .put("nullValue", Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build()) + .put("bytesValue", Value.newBuilder().setBytesValue(BLOB.toByteString()).build()) + .put( + "geoPointValue", + Value.newBuilder() + .setGeoPointValue( + LatLng.newBuilder().setLatitude(50.1430847).setLongitude(-122.9477780)) + .build()) + .put( + "model", + Value.newBuilder() + .setMapValue(MapValue.newBuilder().putAllFields(SINGLE_FIELD_PROTO)) + .build()) + .build(); + ALL_SUPPORTED_TYPES_OBJECT = new AllSupportedTypes(); + SINGLE_WRITE_COMMIT_RESPONSE = commitResponse(/* adds= */ 1, /* deletes= */ 0); + SINGLE_DELETE_COMMIT_RESPONSE = commitResponse(/* adds= */ 0, /* deletes= */ 1); + SINGLE_CREATE_COMMIT_REQUEST = commit(create(SINGLE_FIELD_PROTO)); + + FIELD_TRANSFORM_COMMIT_RESPONSE = commitResponse(/* adds= */ 2, /* deletes= */ 0); + + NESTED_CLASS_OBJECT = new NestedClass(); + + UPDATE_PRECONDITION = Precondition.newBuilder().setExists(true).build(); + UPDATED_POJO = map("model", UPDATE_SINGLE_FIELD_OBJECT); + } + + public static String autoId() { + return FirestoreImpl.autoId(); + } + + @SuppressWarnings("unchecked") + public static Map mapAnyType(Object... entries) { + Map res = new HashMap<>(); + for (int i = 0; i < entries.length; i += 2) { + res.put((String) entries[i], (T) entries[i + 1]); + } + return res; + } + + private static Map fromJsonString(String json) { + Type type = new TypeToken>() {}.getType(); + Gson gson = new Gson(); + return gson.fromJson(json, type); + } + + public static Map fromSingleQuotedString(String json) { + return fromJsonString(json.replace("'", "\"")); + } + + public static String fullPath(DocumentReference ref, FirestoreOptions options) { + return ResourcePath.create( + DatabaseRootName.of(options.getProjectId(), options.getDatabaseId()), + ImmutableList.copyOf(ref.getPath().split("/"))) + .toString(); + } + + static class RequestResponsePair { + Message request; + ApiFuture response; + + public RequestResponsePair(Message request, ApiFuture response) { + this.request = request; + this.response = response; + } + } + + /** + * Contains a map of request/response pairs that are used to create stub responses when + * `sendRequest()` is called. + */ + static class ResponseStubber { + List operationList = new ArrayList<>(); + + List actualRequestList = new CopyOnWriteArrayList<>(); + + void put(Message request, ApiFuture response) { + operationList.add(new RequestResponsePair(request, response)); + } + + void initializeStub( + ArgumentCaptor argumentCaptor, FirestoreImpl firestoreMock) { + Stubber stubber = null; + for (final RequestResponsePair entry : operationList) { + Answer> answer = + invocationOnMock -> { + actualRequestList.add(invocationOnMock.getArguments()[0]); + return entry.response; + }; + stubber = (stubber != null) ? stubber.doAnswer(answer) : doAnswer(answer); + } + Preconditions.checkNotNull(stubber, "Stubber should not be null"); + stubber + .when(firestoreMock) + .sendRequest( + argumentCaptor.capture(), ArgumentMatchers.>any()); + } + + public void verifyAllRequestsSent() { + assertArrayEquals( + "Expected requests, but got actual requests", + operationList.stream().map(x -> x.request).toArray(), + actualRequestList.toArray()); + } + } + + /** + * Naive implementation to read bundle buffers into a list of JSON strings. + * + *

Only works with UTF-8 encoded bundle buffer. + */ + public static List bundleToElementList(ByteBuffer bundle) { + List result = new ArrayList<>(); + StringBuilder lengthStringBuilder = new StringBuilder(); + while (bundle.hasRemaining()) { + char b = (char) bundle.get(); + if (b >= '0' && b <= '9') { + lengthStringBuilder.append(b); + } else if (b == '{') { + // Rewind position for bulk reading. + bundle.position(bundle.position() - 1); + int length = Integer.parseInt(lengthStringBuilder.toString()); + // Reset lengthStringBuilder + lengthStringBuilder = new StringBuilder(); + byte[] element = new byte[length]; + bundle.get(element, 0, length); + result.add(new String(element, StandardCharsets.UTF_8)); + } else { + throw new RuntimeException("Bad bundle buffer."); + } + } + + return result; + } + + @FunctionalInterface + interface VoidFunction { + void apply(); + } + + static void assertException(VoidFunction voidFunction, String expectedErrorMessage) { + String errorMessage = ""; + try { + voidFunction.apply(); + } catch (Exception e) { + errorMessage = e.getMessage(); + } finally { + assertEquals(errorMessage, expectedErrorMessage); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/MapperTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/MapperTest.java new file mode 100644 index 000000000000..cf5a55c4ef4e --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/MapperTest.java @@ -0,0 +1,2606 @@ +/* + * Copyright 2019 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.fromSingleQuotedString; +import static com.google.cloud.firestore.LocalFirestoreHelper.mapAnyType; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.annotation.DocumentId; +import com.google.cloud.firestore.annotation.Exclude; +import com.google.cloud.firestore.annotation.PropertyName; +import com.google.cloud.firestore.annotation.ThrowOnExtraProperties; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.DatabaseRootName; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@SuppressWarnings({"unused", "WeakerAccess", "SpellCheckingInspection"}) +@RunWith(MockitoJUnitRunner.class) +public class MapperTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + private static final double EPSILON = 0.0003; + + private static class StringBean { + private String value; + + public String getValue() { + return value; + } + } + + private static class DoubleBean { + private double value; + + public double getValue() { + return value; + } + } + + private static class BigDecimalBean { + private BigDecimal value; + + public BigDecimal getValue() { + return value; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BigDecimalBean bean = (BigDecimalBean) o; + return Objects.equals(value, bean.value); + } + + @Override + public int hashCode() { + return Objects.hash(value); + } + } + + private static class FloatBean { + private float value; + + public float getValue() { + return value; + } + } + + private static class LongBean { + private long value; + + public long getValue() { + return value; + } + } + + private static class IntBean { + private int value; + + public int getValue() { + return value; + } + } + + private static class BooleanBean { + private boolean value; + + public boolean isValue() { + return value; + } + } + + private static class ShortBean { + private short value; + + public short getValue() { + return value; + } + } + + private static class ByteBean { + private byte value; + + public byte getValue() { + return value; + } + } + + private static class CharBean { + private char value; + + public char getValue() { + return value; + } + } + + private static class IntArrayBean { + private int[] values; + + public int[] getValues() { + return values; + } + } + + private static class StringArrayBean { + private String[] values; + + public String[] getValues() { + return values; + } + } + + private static class XMLAndURLBean { + private String XMLAndURL1; + public String XMLAndURL2; + + public String getXMLAndURL1() { + return XMLAndURL1; + } + + public void setXMLAndURL1(String value) { + XMLAndURL1 = value; + } + } + + private static class SetterBean { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = "setter:" + value; + } + } + + private static class PrivateSetterBean { + public String value; + + private void setValue(String value) { + this.value = "setter:" + value; + } + } + + private static class GetterBean { + private String value; + + public String getValue() { + return "getter:" + this.value; + } + } + + @ThrowOnExtraProperties + private static class GetterBeanNoField { + public String getValue() { + return "getter:value"; + } + } + + private static class GetterPublicFieldBean { + public String value; + + public String getValue() { + return "getter:" + value; + } + } + + private static class GetterPublicFieldBeanCaseSensitive { + public String valueCase; + + public String getValueCASE() { + return "getter:" + valueCase; + } + } + + private static class CaseSensitiveGetterBean1 { + private String value; + + public String getVALUE() { + return value; + } + } + + private static class CaseSensitiveGetterBean2 { + private String value; + + public String getvalue() { + return value; + } + } + + private static class CaseSensitiveGetterBean3 { + private String value; + + public String getVAlue() { + return value; + } + } + + private static class CaseSensitiveGetterBean4 { + private String value; + + public String getvaLUE() { + return value; + } + } + + private static class CaseSensitiveSetterBean1 { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = "setter:" + value; + } + + public void setVAlue(String value) { + this.value = "wrong setter!"; + } + } + + private static class CaseSensitiveSetterBean2 { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = "setter:" + value; + } + + public void setvalue(String value) { + this.value = "wrong setter!"; + } + } + + private static class CaseSensitiveSetterBean3 { + private String value; + + public String getValue() { + return value; + } + + public void setvalue(String value) { + this.value = "setter:" + value; + } + } + + private static class CaseSensitiveSetterBean4 { + private String value; + + public String getValue() { + return value; + } + + public void setVALUE(String value) { + this.value = "setter:" + value; + } + } + + private static class CaseSensitiveSetterBean5 { + private String value; + + public String getValue() { + return value; + } + + public void SETVALUE(String value) { + this.value = "wrong setter!"; + } + } + + private static class CaseSensitiveSetterBean6 { + private String value; + + public String getValue() { + return value; + } + + public void setVaLUE(String value) { + this.value = "setter:" + value; + } + } + + @SuppressWarnings("ConstantField") + private static class CaseSensitiveFieldBean1 { + public String VALUE; + } + + private static class CaseSensitiveFieldBean2 { + public String value; + } + + private static class CaseSensitiveFieldBean3 { + public String Value; + } + + private static class CaseSensitiveFieldBean4 { + public String valUE; + } + + private static class WrongSetterBean { + private String value; + + public String getValue() { + return value; + } + + public void setValue() { + this.value = "wrong setter!"; + } + + public void setValue(String one, String two) { + this.value = "wrong setter!"; + } + } + + private static class WrongTypeBean { + private Integer value; + + public String getValue() { + return "" + value; + } + } + + private static class NestedBean { + private StringBean bean; + + public StringBean getBean() { + return bean; + } + } + + private static class ObjectBean { + private Object value; + + public Object getValue() { + return value; + } + } + + private static class GenericBean { + private B value; + + public B getValue() { + return value; + } + } + + private static class DoubleGenericBean { + private A valueA; + private B valueB; + + public A getValueA() { + return valueA; + } + + public B getValueB() { + return valueB; + } + } + + private static class ListBean { + private List values; + + public List getValues() { + return values; + } + } + + private static class SetBean { + private Set values; + + public Set getValues() { + return values; + } + } + + private static class CollectionBean { + private Collection values; + + public Collection getValues() { + return values; + } + } + + private static class MapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + /** + * This form is not terribly useful in Java, but Kotlin Maps are immutable and are rewritten into + * this form (b/67470108 has more details). + */ + private static class UpperBoundedMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class MultiBoundedMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class MultiBoundedMapHolderBean { + private MultiBoundedMapBean map; + + public MultiBoundedMapBean getMap() { + return map; + } + } + + private static class UnboundedMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class UnboundedTypeVariableMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class UnboundedTypeVariableMapHolderBean { + private UnboundedTypeVariableMapBean map; + + public UnboundedTypeVariableMapBean getMap() { + return map; + } + } + + private static class NestedListBean { + private List values; + + public List getValues() { + return values; + } + } + + private static class NestedMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class IllegalKeyMapBean { + private Map values; + + public Map getValues() { + return values; + } + } + + private static class PublicFieldBean { + public String value; + } + + @ThrowOnExtraProperties + private static class ThrowOnUnknownPropertiesBean { + public String value; + } + + @ThrowOnExtraProperties + private static class PackageFieldBean { + String value; + } + + @ThrowOnExtraProperties + @SuppressWarnings("unused") // Unused, but required for the test + private static class PrivateFieldBean { + private String value; + } + + private static class PackageGetterBean { + private String packageValue; + private String publicValue; + + String getPackageValue() { + return packageValue; + } + + public String getPublicValue() { + return publicValue; + } + } + + private static class ExcludedBean { + @Exclude public String excludedField = "no-value"; + + private String excludedGetter = "no-value"; + + private String includedGetter = "no-value"; + + @Exclude + public String getExcludedGetter() { + return excludedGetter; + } + + public String getIncludedGetter() { + return includedGetter; + } + } + + private static class ExcludedSetterBean { + private String value; + + public String getValue() { + return value; + } + + @Exclude + public void setValue(String value) { + this.value = "wrong setter"; + } + } + + private static class PropertyNameBean { + + @PropertyName("my_key") + public String key; + + private String value; + + @PropertyName("my_value") + public String getValue() { + return value; + } + + @PropertyName("my_value") + public void setValue(String value) { + this.value = value; + } + } + + private static class PublicPrivateFieldBean { + public String value1; + String value2; + private String value3; + } + + private static class TwoSetterBean { + private String value; + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = "string:" + value; + } + + public void setValue(Integer value) { + this.value = "int:" + value; + } + } + + private static class TwoGetterBean { + private String value; + + public String getValue() { + return value; + } + + public String getVALUE() { + return value; + } + } + + private static class GetterArgumentsBean { + private String value; + + public String getValue1() { + return value + "1"; + } + + public void getValue2() {} + + public String getValue3(boolean flag) { + return value + "3"; + } + + public String getValue4() { + return value + "4"; + } + } + + @SuppressWarnings({"ConstantField", "NonAsciiCharacters"}) + private static class UnicodeBean { + private String 漢字; + + public String get漢字() { + return 漢字; + } + } + + private static class PublicConstructorBean { + private String value; + + public PublicConstructorBean() {} + + public String getValue() { + return value; + } + } + + private static class PrivateConstructorBean { + private String value; + + private PrivateConstructorBean() {} + + public String getValue() { + return value; + } + } + + private static class PackageConstructorBean { + private Timestamp value; + + PackageConstructorBean() {} + + public Timestamp getValue() { + return value; + } + } + + private static class ArgConstructorBean { + private String value; + + public ArgConstructorBean(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + private static class MultipleConstructorBean { + private String value; + + public MultipleConstructorBean(String value) { + this.value = "wrong-value"; + } + + public MultipleConstructorBean() {} + + public String getValue() { + return value; + } + } + + private static class StaticFieldBean { + public static String value1 = "static-value"; + public String value2; + } + + private static class StaticMethodBean { + private static String value1 = "static-value"; + public String value2; + + public static String getValue1() { + return StaticMethodBean.value1; + } + + public static void setValue1(String value1) { + StaticMethodBean.value1 = value1; + } + } + + private enum SimpleEnum { + Foo, + Bar + } + + private enum ComplexEnum { + One("one"), + Two("two"), + + @PropertyName("Three") + THREE("three"); + + private final String value; + + ComplexEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + } + + private enum PathologicalEnum { + @PropertyName("Two") + One, + + @PropertyName("One") + Two + } + + private static class EnumBean { + public SimpleEnum enumField; + + private SimpleEnum enumValue; + + public ComplexEnum complexEnum; + + public ComplexEnum enumUsingPropertyName; + + public PathologicalEnum pathologicalEnum; + + public SimpleEnum getEnumValue() { + return enumValue; + } + + public void setEnumValue(SimpleEnum enumValue) { + this.enumValue = enumValue; + } + } + + private static class BaseBean { + // Public field on base class + public String baseValue; + + // Value that is accessed through overridden methods in subclasses + public String overrideValue; + + // Field that is package private in base class + String packageBaseValue; + + // Private field that is used in getter/setter in base class + private String baseMethodValue; + + // Private field that has field with same name in subclasses + private String classPrivateValue; + + public String getClassPrivateValue() { + return classPrivateValue; + } + + public String getBaseMethod() { + return baseMethodValue; + } + + public String getPackageBaseValue() { + return packageBaseValue; + } + + public void setBaseMethod(String value) { + baseMethodValue = value; + } + } + + private static class InheritedBean extends BaseBean { + public String inheritedValue; + + private String inheritedMethodValue; + + private String classPrivateValue; + + @Override + public String getClassPrivateValue() { + return classPrivateValue; + } + + public String getInheritedMethod() { + return inheritedMethodValue; + } + + public void setInheritedMethod(String value) { + inheritedMethodValue = value; + } + + public String getOverrideValue() { + return overrideValue + "-inherited"; + } + + public void setOverrideValue(String value) { + overrideValue = value + "-inherited"; + } + } + + private static final class FinalBean extends InheritedBean { + public String finalValue; + + private String finalMethodValue; + + private String classPrivateValue; + + @Override + public String getClassPrivateValue() { + return classPrivateValue; + } + + public String getFinalMethod() { + return finalMethodValue; + } + + public void setFinalMethod(String value) { + finalMethodValue = value; + } + + @Override + public String getOverrideValue() { + return overrideValue + "-final"; + } + + @Override + public void setOverrideValue(String value) { + overrideValue = value + "-final"; + } + } + + // Conflicting setters are not supported. When inheriting from a base class we require all + // setters be an override of a base class + private static class ConflictingSetterBean { + public int value; + + // package private so override can be public + void setValue(int value) { + this.value = value; + } + } + + private static class ConflictingSetterSubBean extends ConflictingSetterBean { + public void setValue(String value) { + this.value = -1; + } + } + + private static class ConflictingSetterSubBean2 extends ConflictingSetterBean { + public void setValue(Integer value) { + this.value = -1; + } + } + + private static class NonConflictingSetterSubBean extends ConflictingSetterBean { + @Override + public void setValue(int value) { + this.value = value * -1; + } + } + + private static class GenericSetterBaseBean { + public T value; + + void setValue(T value) { + this.value = value; + } + } + + private static class ConflictingGenericSetterSubBean extends GenericSetterBaseBean { + public void setValue(String value) { + // wrong setter + } + } + + private static class NonConflictingGenericSetterSubBean extends GenericSetterBaseBean { + @Override + public void setValue(String value) { + this.value = "subsetter:" + value; + } + } + + private static T deserialize(String jsonString, Class clazz) { + return deserialize(jsonString, clazz, /* docRef= */ null); + } + + private static T deserialize(Map json, Class clazz) { + return deserialize(json, clazz, /* docRef= */ null); + } + + private static T deserialize(String jsonString, Class clazz, DocumentReference docRef) { + Map json = fromSingleQuotedString(jsonString); + return CustomClassMapper.convertToCustomClass(json, clazz, docRef); + } + + private static T deserialize( + Map json, Class clazz, DocumentReference docRef) { + return CustomClassMapper.convertToCustomClass(json, clazz, docRef); + } + + private static Object serialize(Object object) { + return CustomClassMapper.convertToPlainJavaTypes(object); + } + + private static void assertJson(String expected, Object actual) { + assertEquals(fromSingleQuotedString(expected), actual); + } + + private static void assertExceptionContains(String partialMessage, Runnable run) { + try { + run.run(); + fail("Expected exception not thrown"); + } catch (RuntimeException e) { + assertTrue(e.getMessage().contains(partialMessage)); + } + } + + private static T convertToCustomClass( + Object object, Class clazz, DocumentReference docRef) { + return CustomClassMapper.convertToCustomClass(object, clazz, docRef); + } + + private static T convertToCustomClass(Object object, Class clazz) { + return CustomClassMapper.convertToCustomClass(object, clazz, null); + } + + @Test + public void primitiveDeserializeString() { + StringBean bean = deserialize("{'value': 'foo'}", StringBean.class); + assertEquals("foo", bean.value); + + // Double + try { + deserialize("{'value': 1.1}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Int + try { + deserialize("{'value': 1}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", StringBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeBoolean() { + BooleanBean beanBoolean = deserialize("{'value': true}", BooleanBean.class); + assertEquals(true, beanBoolean.value); + + // Double + try { + deserialize("{'value': 1.1}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Int + try { + deserialize("{'value': 1}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", BooleanBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeDouble() { + DoubleBean beanDouble = deserialize("{'value': 1.1}", DoubleBean.class); + assertEquals(1.1, beanDouble.value, EPSILON); + + // Int + DoubleBean beanInt = deserialize("{'value': 1}", DoubleBean.class); + assertEquals(1, beanInt.value, EPSILON); + // Long + DoubleBean beanLong = deserialize("{'value': 1234567890123}", DoubleBean.class); + assertEquals(1234567890123L, beanLong.value, EPSILON); + + // Boolean + try { + deserialize("{'value': true}", DoubleBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", DoubleBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeBigDecimal() { + BigDecimalBean beanBigdecimal = deserialize("{'value': 123}", BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(123.0), beanBigdecimal.value); + + beanBigdecimal = deserialize("{'value': '123'}", BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(123), beanBigdecimal.value); + + // Int + BigDecimalBean beanInt = + deserialize(Collections.singletonMap("value", 1), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1), beanInt.value); + + // Long + BigDecimalBean beanLong = + deserialize(Collections.singletonMap("value", 1234567890123L), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1234567890123L), beanLong.value); + + // Double + BigDecimalBean beanDouble = + deserialize(Collections.singletonMap("value", 1.1), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1.1), beanDouble.value); + + // BigDecimal + BigDecimalBean beanBigDecimal = + deserialize( + Collections.singletonMap("value", BigDecimal.valueOf(1.2)), BigDecimalBean.class); + assertEquals(BigDecimal.valueOf(1.2), beanBigDecimal.value); + + // Boolean + try { + deserialize("{'value': true}", BigDecimalBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", BigDecimalBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeFloat() { + FloatBean beanFloat = deserialize("{'value': 1.1}", FloatBean.class); + assertEquals(1.1, beanFloat.value, EPSILON); + + // Int + FloatBean beanInt = deserialize(Collections.singletonMap("value", 1), FloatBean.class); + assertEquals(1, beanInt.value, EPSILON); + // Long + FloatBean beanLong = + deserialize(Collections.singletonMap("value", 1234567890123L), FloatBean.class); + assertEquals((float) 1234567890123L, beanLong.value, EPSILON); + + // Boolean + try { + deserialize("{'value': true}", FloatBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", FloatBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeInt() { + IntBean beanInt = deserialize("{'value': 1}", IntBean.class); + assertEquals(1, beanInt.value); + + // Double + IntBean beanDouble = deserialize("{'value': 1.1}", IntBean.class); + assertEquals(1, beanDouble.value); + + // Large doubles + try { + deserialize("{'value': 1e10}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Long + try { + deserialize("{'value': 1234567890123}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", IntBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeLong() { + LongBean beanLong = deserialize("{'value': 1234567890123}", LongBean.class); + assertEquals(1234567890123L, beanLong.value); + + // Int + LongBean beanInt = deserialize("{'value': 1}", LongBean.class); + assertEquals(1, beanInt.value); + + // Double + LongBean beanDouble = deserialize("{'value': 1.1}", LongBean.class); + assertEquals(1, beanDouble.value); + + // Large doubles + try { + deserialize("{'value': 1e300}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // Boolean + try { + deserialize("{'value': true}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + + // String + try { + deserialize("{'value': 'foo'}", LongBean.class); + fail("Should throw"); + } catch (RuntimeException e) { // ignore + } + } + + @Test + public void primitiveDeserializeWrongTypeMap() { + String expectedExceptionMessage = + ".* Failed to convert value of type .*Map to String \\(found in field 'value'\\).*"; + Throwable exception = + assertThrows( + RuntimeException.class, + () -> deserialize("{'value': {'foo': 'bar'}}", StringBean.class)); + assertTrue(exception.getMessage().matches(expectedExceptionMessage)); + } + + @Test + public void primitiveDeserializeWrongTypeList() { + assertExceptionContains( + "Failed to convert value of type java.util.ArrayList to String" + + " (found in field 'value')", + () -> deserialize("{'value': ['foo']}", StringBean.class)); + } + + @Test + public void publicFieldDeserialize() { + PublicFieldBean bean = deserialize("{'value': 'foo'}", PublicFieldBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void publicPrivateFieldDeserialize() { + PublicPrivateFieldBean bean = + deserialize( + "{'value1': 'foo', 'value2': 'bar', 'value3': 'baz'}", PublicPrivateFieldBean.class); + assertEquals("foo", bean.value1); + assertEquals(null, bean.value2); + assertEquals(null, bean.value3); + } + + @Test + public void packageFieldDeserialize() { + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.MapperTest$PackageFieldBean", + () -> deserialize("{'value': 'foo'}", PackageFieldBean.class)); + } + + @Test + public void privateFieldDeserialize() { + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.MapperTest$PrivateFieldBean", + () -> deserialize("{'value': 'foo'}", PrivateFieldBean.class)); + } + + @Test + public void packageGetterDeserialize() { + PackageGetterBean bean = + deserialize("{'publicValue': 'foo', 'packageValue': 'bar'}", PackageGetterBean.class); + assertEquals("foo", bean.publicValue); + assertNull(bean.packageValue); + } + + @Test + public void packageGetterSerialize() { + PackageGetterBean bean = new PackageGetterBean(); + bean.packageValue = "foo"; + bean.publicValue = "bar"; + assertJson("{'publicValue': 'bar'}", serialize(bean)); + } + + @Test + public void ignoreExtraProperties() { + PublicFieldBean bean = deserialize("{'value': 'foo', 'unknown': 'bar'}", PublicFieldBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void throwOnUnknownProperties() { + assertExceptionContains( + "No setter/field for unknown found on class " + + "com.google.cloud.firestore.MapperTest$ThrowOnUnknownPropertiesBean", + () -> + deserialize("{'value': 'foo', 'unknown': 'bar'}", ThrowOnUnknownPropertiesBean.class)); + } + + @Test + public void twoSetterBean() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$TwoSetterBean has multiple setter " + + "overloads", + () -> deserialize("{'value': 'foo'}", TwoSetterBean.class)); + } + + @Test + public void XMLAndURLBean() { + XMLAndURLBean bean = + deserialize("{'xmlandURL1': 'foo', 'XMLAndURL2': 'bar'}", XMLAndURLBean.class); + assertEquals("foo", bean.XMLAndURL1); + assertEquals("bar", bean.XMLAndURL2); + } + + /** Based on https://github.com/firebase/firebase-android-sdk/issues/252. */ + private static class AllCapsDefaultHandlingBean { + private String UUID; + + public String getUUID() { + return UUID; + } + + public void setUUID(String value) { + UUID = value; + } + } + + @Test + public void allCapsGetterSerializesToLowercaseByDefault() { + AllCapsDefaultHandlingBean bean = new AllCapsDefaultHandlingBean(); + bean.setUUID("value"); + assertJson("{'uuid': 'value'}", serialize(bean)); + AllCapsDefaultHandlingBean deserialized = + deserialize("{'uuid': 'value'}", AllCapsDefaultHandlingBean.class); + assertEquals("value", deserialized.getUUID()); + } + + private static class AllCapsWithPropertyName { + private String UUID; + + @PropertyName("UUID") + public String getUUID() { + return UUID; + } + + @PropertyName("UUID") + public void setUUID(String value) { + UUID = value; + } + } + + @Test + public void allCapsWithPropertyNameSerializesToUppercase() { + AllCapsWithPropertyName bean = new AllCapsWithPropertyName(); + bean.setUUID("value"); + assertJson("{'UUID': 'value'}", serialize(bean)); + AllCapsWithPropertyName deserialized = + deserialize("{'UUID': 'value'}", AllCapsWithPropertyName.class); + assertEquals("value", deserialized.getUUID()); + } + + @Test + public void setterIsCalledWhenPresent() { + SetterBean bean = deserialize("{'value': 'foo'}", SetterBean.class); + assertEquals("setter:foo", bean.value); + } + + @Test + public void privateSetterIsCalledWhenPresent() { + PrivateSetterBean bean = deserialize("{'value': 'foo'}", PrivateSetterBean.class); + assertEquals("setter:foo", bean.value); + } + + @Test + public void setterIsCaseSensitive1() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$CaseSensitiveSetterBean1 has " + + "multiple setter overloads", + () -> deserialize("{'value': 'foo'}", CaseSensitiveSetterBean1.class)); + } + + @Test + public void setterIsCaseSensitive2() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$CaseSensitiveSetterBean2 has " + + "multiple setter overloads", + () -> deserialize("{'value': 'foo'}", CaseSensitiveSetterBean2.class)); + } + + @Test + public void caseSensitiveSetterIsCalledWhenPresent1() { + CaseSensitiveSetterBean3 bean = deserialize("{'value': 'foo'}", CaseSensitiveSetterBean3.class); + assertEquals("setter:foo", bean.value); + } + + @Test + public void caseSensitiveSetterIsCalledWhenPresent2() { + CaseSensitiveSetterBean4 bean = deserialize("{'value': 'foo'}", CaseSensitiveSetterBean4.class); + assertEquals("setter:foo", bean.value); + } + + @Test + public void caseSensitiveSetterIsCalledWhenPresent3() { + CaseSensitiveSetterBean5 bean = deserialize("{'value': 'foo'}", CaseSensitiveSetterBean5.class); + assertEquals("foo", bean.value); + } + + @Test + public void caseSensitiveSetterMustHaveSameCaseAsSetter() { + assertExceptionContains( + "Found setter on com.google.cloud.firestore.MapperTest$CaseSensitiveSetterBean6 " + + "with invalid case-sensitive name: setVaLUE", + () -> deserialize("{'value': 'foo'}", CaseSensitiveSetterBean6.class)); + } + + @Test + public void wrongSetterIsNotCalledWhenPresent() { + WrongSetterBean bean = deserialize("{'value': 'foo'}", WrongSetterBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void nestedParsingWorks() { + NestedBean bean = deserialize("{'bean': {'value': 'foo'}}", NestedBean.class); + assertEquals("foo", bean.bean.value); + } + + @Test + public void beansCanContainLists() { + ListBean bean = deserialize("{'values': ['foo', 'bar']}", ListBean.class); + assertEquals(Arrays.asList("foo", "bar"), bean.values); + } + + @Test + public void beansCanContainMaps() { + MapBean bean = deserialize("{'values': {'foo': 'bar'}}", MapBean.class); + Map expected = fromSingleQuotedString("{'foo': 'bar'}"); + assertEquals(expected, bean.values); + } + + @Test + public void beansCanContainUpperBoundedMaps() { + Date date = new Date(1491847082123L); + Map source = mapAnyType("values", mapAnyType("foo", date)); + UpperBoundedMapBean bean = convertToCustomClass(source, UpperBoundedMapBean.class); + Map expected = mapAnyType("foo", date); + assertEquals(expected, bean.values); + } + + @Test + public void beansCanContainMultiBoundedMaps() { + Date date = new Date(1491847082123L); + Map source = mapAnyType("map", mapAnyType("values", mapAnyType("foo", date))); + MultiBoundedMapHolderBean bean = convertToCustomClass(source, MultiBoundedMapHolderBean.class); + + Map expected = mapAnyType("foo", date); + assertEquals(expected, bean.map.values); + } + + @Test + public void beansCanContainUnboundedMaps() { + UnboundedMapBean bean = deserialize("{'values': {'foo': 'bar'}}", UnboundedMapBean.class); + Map expected = mapAnyType("foo", "bar"); + assertEquals(expected, bean.values); + } + + @Test + public void beansCanContainUnboundedTypeVariableMaps() { + Map source = mapAnyType("map", mapAnyType("values", mapAnyType("foo", "bar"))); + UnboundedTypeVariableMapHolderBean bean = + convertToCustomClass(source, UnboundedTypeVariableMapHolderBean.class); + + Map expected = mapAnyType("foo", "bar"); + assertEquals(expected, bean.map.values); + } + + @Test + public void beansCanContainNestedUnboundedMaps() { + UnboundedMapBean bean = + deserialize("{'values': {'foo': {'bar': 'baz'}}}", UnboundedMapBean.class); + Map expected = mapAnyType("foo", mapAnyType("bar", "baz")); + assertEquals(expected, bean.values); + } + + @Test + public void beansCanContainBeanLists() { + NestedListBean bean = deserialize("{'values': [{'value': 'foo'}]}", NestedListBean.class); + assertEquals(1, bean.values.size()); + assertEquals("foo", bean.values.get(0).value); + } + + @Test + public void beansCanContainBeanMaps() { + NestedMapBean bean = deserialize("{'values': {'key': {'value': 'foo'}}}", NestedMapBean.class); + assertEquals(1, bean.values.size()); + assertEquals("foo", bean.values.get("key").value); + } + + @Test + public void beanMapsMustHaveStringKeys() { + assertExceptionContains( + "Only Maps with string keys are supported, but found Map with key type class " + + "java.lang.Integer (found in field 'values')", + () -> deserialize("{'values': {'1': 'bar'}}", IllegalKeyMapBean.class)); + } + + @Test + public void serializeStringBean() { + StringBean bean = new StringBean(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void serializeDoubleBean() { + DoubleBean bean = new DoubleBean(); + bean.value = 1.1; + assertJson("{'value': 1.1}", serialize(bean)); + } + + @Test + public void serializeIntBean() { + IntBean bean = new IntBean(); + bean.value = 1; + assertJson("{'value': 1}", serialize(Collections.singletonMap("value", 1.0))); + } + + @Test + public void serializeLongBean() { + LongBean bean = new LongBean(); + bean.value = 1234567890123L; + assertJson( + "{'value': 1.234567890123E12}", + serialize(Collections.singletonMap("value", 1.234567890123E12))); + } + + @Test + public void serializeBigDecimalBean() { + BigDecimalBean bean = new BigDecimalBean(); + bean.value = BigDecimal.valueOf(1.1); + assertEquals(mapAnyType("value", "1.1"), serialize(bean)); + } + + @Test + public void bigDecimalRoundTrip() { + BigDecimal doubleMaxPlusOne = BigDecimal.valueOf(Double.MAX_VALUE).add(BigDecimal.ONE); + BigDecimalBean a = new BigDecimalBean(); + a.value = doubleMaxPlusOne; + Map serialized = (Map) serialize(a); + BigDecimalBean b = convertToCustomClass(serialized, BigDecimalBean.class); + assertEquals(a, b); + } + + @Test + public void serializeBooleanBean() { + BooleanBean bean = new BooleanBean(); + bean.value = true; + assertJson("{'value': true}", serialize(bean)); + } + + @Test + public void serializeFloatBean() { + FloatBean bean = new FloatBean(); + bean.value = 0.5f; + + // We don't use assertJson as it converts all floating point numbers to Double. + assertEquals(mapAnyType("value", 0.5f), serialize(bean)); + } + + @Test + public void serializePublicFieldBean() { + PublicFieldBean bean = new PublicFieldBean(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void serializePrivateFieldBean() { + final PrivateFieldBean bean = new PrivateFieldBean(); + bean.value = "foo"; + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.MapperTest$PrivateFieldBean", + () -> serialize(bean)); + } + + @Test + public void serializePackageFieldBean() { + final PackageFieldBean bean = new PackageFieldBean(); + bean.value = "foo"; + assertExceptionContains( + "No properties to serialize found on class " + + "com.google.cloud.firestore.MapperTest$PackageFieldBean", + () -> serialize(bean)); + } + + @Test + public void serializePublicPrivateFieldBean() { + PublicPrivateFieldBean bean = new PublicPrivateFieldBean(); + bean.value1 = "foo"; + bean.value2 = "bar"; + bean.value3 = "baz"; + assertJson("{'value1': 'foo'}", serialize(bean)); + } + + @Test + public void getterOverridesField() { + GetterBean bean = new GetterBean(); + bean.value = "foo"; + assertJson("{'value': 'getter:foo'}", serialize(bean)); + } + + @Test + public void serializeGetterBeanWithNoBackingField() { + GetterBeanNoField bean = new GetterBeanNoField(); + assertJson("{'value': 'getter:value'}", serialize(bean)); + } + + @Test + public void deserializeGetterBeanWithNoBackingFieldThrows() { + assertExceptionContains( + "No setter/field", () -> deserialize("{'value': 'foo'}", GetterBeanNoField.class)); + } + + @Test + public void getterOverridesPublicField() { + GetterPublicFieldBean bean = new GetterPublicFieldBean(); + bean.value = "foo"; + assertJson("{'value': 'getter:foo'}", serialize(bean)); + } + + @Test + public void getterAndPublicFieldsConflictOnCaseSensitivity() { + final GetterPublicFieldBeanCaseSensitive bean = new GetterPublicFieldBeanCaseSensitive(); + bean.valueCase = "foo"; + assertExceptionContains( + "Found two getters or fields with conflicting case sensitivity for property: valuecase", + () -> serialize(bean)); + } + + @Test + public void caseSensitiveGetterBean1() { + CaseSensitiveGetterBean1 bean = new CaseSensitiveGetterBean1(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void caseSensitiveGetterBean2() { + CaseSensitiveGetterBean2 bean = new CaseSensitiveGetterBean2(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void caseSensitiveGetterBean3() { + CaseSensitiveGetterBean3 bean = new CaseSensitiveGetterBean3(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + } + + @Test + public void caseSensitiveGetterBean4() { + CaseSensitiveGetterBean4 bean = new CaseSensitiveGetterBean4(); + bean.value = "foo"; + assertJson("{'vaLUE': 'foo'}", serialize(bean)); + } + + @Test + public void nestedSerializingWorks() { + NestedBean bean = new NestedBean(); + bean.bean = new StringBean(); + bean.bean.value = "foo"; + assertJson("{'bean': {'value': 'foo'}}", serialize(bean)); + } + + @Test + public void serializingListsWorks() { + ListBean bean = new ListBean(); + bean.values = Arrays.asList("foo", "bar"); + assertJson("{'values': ['foo', 'bar']}", serialize(bean)); + } + + @Test + public void serializingMapsWorks() { + MapBean bean = new MapBean(); + bean.values = new HashMap<>(); + bean.values.put("foo", "bar"); + assertJson("{'values': {'foo': 'bar'}}", serialize(bean)); + } + + @Test + public void serializingUpperBoundedMapsWorks() { + Date date = new Date(1491847082123L); + UpperBoundedMapBean bean = new UpperBoundedMapBean(); + HashMap values = new HashMap<>(); + values.put("foo", date); + + bean.values = values; + Map expected = + mapAnyType("values", mapAnyType("foo", new Date(date.getTime()))); + assertEquals(expected, serialize(bean)); + } + + @Test + public void serializingMultiBoundedObjectsWorks() { + Date date = new Date(1491847082123L); + MultiBoundedMapHolderBean holder = new MultiBoundedMapHolderBean(); + + HashMap values = new HashMap<>(); + values.put("foo", date); + + holder.map = new MultiBoundedMapBean<>(); + holder.map.values = values; + + Map expected = + mapAnyType("map", mapAnyType("values", mapAnyType("foo", new Date(date.getTime())))); + assertEquals(expected, serialize(holder)); + } + + @Test + public void serializeListOfBeansWorks() { + StringBean stringBean = new StringBean(); + stringBean.value = "foo"; + + NestedListBean bean = new NestedListBean(); + bean.values = new ArrayList<>(); + bean.values.add(stringBean); + + assertJson("{'values': [{'value': 'foo'}]}", serialize(bean)); + } + + @Test + public void serializeMapOfBeansWorks() { + StringBean stringBean = new StringBean(); + stringBean.value = "foo"; + + NestedMapBean bean = new NestedMapBean(); + bean.values = new HashMap<>(); + bean.values.put("key", stringBean); + + assertJson("{'values': {'key': {'value': 'foo'}}}", serialize(bean)); + } + + @Test + public void beanMapsMustHaveStringKeysForSerializing() { + StringBean stringBean = new StringBean(); + stringBean.value = "foo"; + + final IllegalKeyMapBean bean = new IllegalKeyMapBean(); + bean.values = new HashMap<>(); + bean.values.put(1, stringBean); + + assertExceptionContains( + "Maps with non-string keys are not supported (found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void twoGettersThrows() { + final TwoGetterBean bean = new TwoGetterBean(); + bean.value = "foo"; + assertExceptionContains("Found conflicting getters", () -> serialize(bean)); + } + + @Test + public void serializeUPPERCASE() { + XMLAndURLBean bean = new XMLAndURLBean(); + bean.XMLAndURL1 = "foo"; + bean.XMLAndURL2 = "bar"; + assertJson("{'xmlandURL1': 'foo', 'XMLAndURL2': 'bar'}", serialize(bean)); + } + + @Test + public void onlySerializesGetterWithCorrectArguments() { + GetterArgumentsBean bean = new GetterArgumentsBean(); + bean.value = "foo"; + assertJson("{'value1': 'foo1', 'value4': 'foo4'}", serialize(bean)); + } + + @Test + public void roundTripCaseSensitiveFieldBean1() { + CaseSensitiveFieldBean1 bean = new CaseSensitiveFieldBean1(); + bean.VALUE = "foo"; + assertJson("{'VALUE': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean1 deserialized = + deserialize("{'VALUE': 'foo'}", CaseSensitiveFieldBean1.class); + assertEquals("foo", deserialized.VALUE); + } + + @Test + public void roundTripCaseSensitiveFieldBean2() { + CaseSensitiveFieldBean2 bean = new CaseSensitiveFieldBean2(); + bean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean2 deserialized = + deserialize("{'value': 'foo'}", CaseSensitiveFieldBean2.class); + assertEquals("foo", deserialized.value); + } + + @Test + public void roundTripCaseSensitiveFieldBean3() { + CaseSensitiveFieldBean3 bean = new CaseSensitiveFieldBean3(); + bean.Value = "foo"; + assertJson("{'Value': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean3 deserialized = + deserialize("{'Value': 'foo'}", CaseSensitiveFieldBean3.class); + assertEquals("foo", deserialized.Value); + } + + @Test + public void roundTripCaseSensitiveFieldBean4() { + CaseSensitiveFieldBean4 bean = new CaseSensitiveFieldBean4(); + bean.valUE = "foo"; + assertJson("{'valUE': 'foo'}", serialize(bean)); + CaseSensitiveFieldBean4 deserialized = + deserialize("{'valUE': 'foo'}", CaseSensitiveFieldBean4.class); + assertEquals("foo", deserialized.valUE); + } + + @Test + public void roundTripUnicodeBean() { + UnicodeBean bean = new UnicodeBean(); + bean.漢字 = "foo"; + assertJson("{'漢字': 'foo'}", serialize(bean)); + UnicodeBean deserialized = deserialize("{'漢字': 'foo'}", UnicodeBean.class); + assertEquals("foo", deserialized.漢字); + } + + @Test + public void shortsCantBeSerialized() { + final ShortBean bean = new ShortBean(); + bean.value = 1; + assertExceptionContains( + "Numbers of type Short are not supported, please use an int, long, float, double or" + + " BigDecimal (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void bytesCantBeSerialized() { + final ByteBean bean = new ByteBean(); + bean.value = 1; + assertExceptionContains( + "Numbers of type Byte are not supported, please use an int, long, float, double or" + + " BigDecimal (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void charsCantBeSerialized() { + final CharBean bean = new CharBean(); + bean.value = 1; + assertExceptionContains( + "Characters are not supported, please use Strings (found in field 'value')", + () -> serialize(bean)); + } + + @Test + public void intArraysCantBeSerialized() { + final IntArrayBean bean = new IntArrayBean(); + bean.values = new int[] {1}; + assertExceptionContains( + "Serializing Arrays is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void objectArraysCantBeSerialized() { + final StringArrayBean bean = new StringArrayBean(); + bean.values = new String[] {"foo"}; + assertExceptionContains( + "Serializing Arrays is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void shortsCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to short is not supported (found in field 'value')", + () -> deserialize("{'value': 1}", ShortBean.class)); + } + + @Test + public void bytesCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to byte is not supported (found in field 'value')", + () -> deserialize("{'value': 1}", ByteBean.class)); + } + + @Test + public void charsCantBeDeserialized() { + assertExceptionContains( + "Deserializing values to char is not supported (found in field 'value')", + () -> deserialize("{'value': '1'}", CharBean.class)); + } + + @Test + public void intArraysCantBeDeserialized() { + assertExceptionContains( + "Converting to Arrays is not supported, please use Lists instead (found in field 'values')", + () -> deserialize("{'values': [1]}", IntArrayBean.class)); + } + + @Test + public void objectArraysCantBeDeserialized() { + assertExceptionContains( + "Could not deserialize object. Converting to Arrays is not supported, please use Lists " + + "instead (found in field 'values')", + () -> deserialize("{'values': ['foo']}", StringArrayBean.class)); + } + + @Test + public void publicConstructorCanBeDeserialized() { + PublicConstructorBean bean = deserialize("{'value': 'foo'}", PublicConstructorBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void privateConstructorCanBeDeserialized() { + PrivateConstructorBean bean = deserialize("{'value': 'foo'}", PrivateConstructorBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void argConstructorCantBeDeserialized() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$ArgConstructorBean does not define " + + "a no-argument constructor.", + () -> deserialize("{'value': 'foo'}", ArgConstructorBean.class)); + } + + @Test + public void packageConstructorCanBeDeserialized() { + Timestamp timestamp = Timestamp.now(); + PackageConstructorBean bean = + deserialize(Collections.singletonMap("value", timestamp), PackageConstructorBean.class); + assertEquals(timestamp, bean.value); + } + + @Test + public void multipleConstructorsCanBeDeserialized() { + MultipleConstructorBean bean = deserialize("{'value': 'foo'}", MultipleConstructorBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void objectAcceptsAnyObject() { + ObjectBean stringValue = deserialize("{'value': 'foo'}", ObjectBean.class); + assertEquals("foo", stringValue.value); + ObjectBean listValue = deserialize("{'value': ['foo']}", ObjectBean.class); + assertEquals(Collections.singletonList("foo"), listValue.value); + ObjectBean mapValue = deserialize("{'value': {'foo':'bar'}}", ObjectBean.class); + assertEquals(fromSingleQuotedString("{'foo':'bar'}"), mapValue.value); + String complex = "{'value': {'foo':['bar', ['baz'], {'bam': 'qux'}]}, 'other':{'a': ['b']}}"; + ObjectBean complexValue = deserialize(complex, ObjectBean.class); + assertEquals(fromSingleQuotedString(complex).get("value"), complexValue.value); + } + + @Test + public void objectClassCanBePassedInAtTopLevel() { + assertEquals("foo", convertToCustomClass("foo", Object.class)); + assertEquals(1, convertToCustomClass(1, Object.class)); + assertEquals(1L, convertToCustomClass(1L, Object.class)); + assertEquals(true, convertToCustomClass(true, Object.class)); + assertEquals(1.1, convertToCustomClass(1.1, Object.class)); + List fooList = Collections.singletonList("foo"); + assertEquals(fooList, convertToCustomClass(fooList, Object.class)); + Map fooMap = Collections.singletonMap("foo", "bar"); + assertEquals(fooMap, convertToCustomClass(fooMap, Object.class)); + } + + @Test + public void primitiveClassesCanBePassedInTopLevel() { + assertEquals("foo", convertToCustomClass("foo", String.class)); + assertEquals((Integer) 1, convertToCustomClass(1, Integer.class)); + assertEquals((Long) 1L, convertToCustomClass(1L, Long.class)); + assertEquals(true, convertToCustomClass(true, Boolean.class)); + assertEquals((Double) 1.1, convertToCustomClass(1.1, Double.class)); + } + + @Test + public void passingInListTopLevelThrows() { + assertExceptionContains( + "Class java.util.List has generic type parameters, please use GenericTypeIndicator " + + "instead", + () -> convertToCustomClass(Collections.singletonList("foo"), List.class)); + } + + @Test + public void passingInMapTopLevelThrows() { + assertExceptionContains( + "Class java.util.Map has generic type parameters, please use GenericTypeIndicator " + + "instead", + () -> convertToCustomClass(Collections.singletonMap("foo", "bar"), Map.class)); + } + + @Test + public void passingInCharacterTopLevelThrows() { + assertExceptionContains( + "Deserializing values to Character is not supported", + () -> convertToCustomClass('1', Character.class)); + } + + @Test + public void passingInShortTopLevelThrows() { + assertExceptionContains( + "Deserializing values to Short is not supported", + () -> convertToCustomClass(1, Short.class)); + } + + @Test + public void passingInByteTopLevelThrows() { + assertExceptionContains( + "Deserializing values to Byte is not supported", () -> convertToCustomClass(1, Byte.class)); + } + + @Test + public void passingInGenericBeanTopLevelThrows() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$GenericBean has generic type " + + "parameters, please use GenericTypeIndicator instead", + () -> deserialize("{'value': 'foo'}", GenericBean.class)); + } + + @Test + public void collectionsCanBeSerializedWhenList() { + CollectionBean bean = new CollectionBean(); + bean.values = Collections.singletonList("foo"); + assertJson("{'values': ['foo']}", serialize(bean)); + } + + @Test + public void collectionsCantBeSerializedWhenSet() { + final CollectionBean bean = new CollectionBean(); + bean.values = Collections.singleton("foo"); + assertExceptionContains( + "Serializing Collections is not supported, please use Lists instead " + + "(found in field 'values')", + () -> serialize(bean)); + } + + @Test + public void collectionsCantBeDeserialized() { + assertExceptionContains( + "Collections are not supported, please use Lists instead (found in field 'values')", + () -> deserialize("{'values': ['foo']}", CollectionBean.class)); + } + + @Test + public void allowNullEverywhere() { + assertNull(convertToCustomClass(null, Integer.class)); + assertNull(convertToCustomClass(null, String.class)); + assertNull(convertToCustomClass(null, Double.class)); + assertNull(convertToCustomClass(null, Long.class)); + assertNull(convertToCustomClass(null, Boolean.class)); + assertNull(convertToCustomClass(null, StringBean.class)); + assertNull(convertToCustomClass(null, Object.class)); + } + + @Test + public void serializingGenericBeansSupported() { + GenericBean stringBean = new GenericBean<>(); + stringBean.value = "foo"; + assertJson("{'value': 'foo'}", serialize(stringBean)); + + GenericBean> mapBean = new GenericBean<>(); + mapBean.value = Collections.singletonMap("foo", "bar"); + assertJson("{'value': {'foo': 'bar'}}", serialize(mapBean)); + + GenericBean> listBean = new GenericBean<>(); + listBean.value = Collections.singletonList("foo"); + assertJson("{'value': ['foo']}", serialize(listBean)); + + GenericBean> recursiveBean = new GenericBean<>(); + recursiveBean.value = new GenericBean<>(); + recursiveBean.value.value = "foo"; + assertJson("{'value': {'value': 'foo'}}", serialize(recursiveBean)); + + DoubleGenericBean doubleBean = new DoubleGenericBean<>(); + doubleBean.valueA = "foo"; + doubleBean.valueB = 1.0; + assertJson("{'valueB': 1, 'valueA': 'foo'}", serialize(doubleBean)); + } + + @Test + public void deserializingWrongTypeThrows() { + assertExceptionContains( + "Failed to convert a value of type java.lang.String to int (found in field 'value')", + () -> deserialize("{'value': 'foo'}", WrongTypeBean.class)); + } + + @Test + public void serializingWrongTypeWorks() { + WrongTypeBean bean = new WrongTypeBean(); + bean.value = 1; + assertJson("{'value': '1'}", serialize(bean)); + } + + @Test + public void excludedFieldsAreExcluded() { + ExcludedBean bean = new ExcludedBean(); + assertJson("{'includedGetter': 'no-value'}", serialize(bean)); + } + + @Test + public void excludedFieldsAreNotParsed() { + ExcludedBean bean = + deserialize( + "{'includedGetter': 'foo', 'excludedField': 'bar', 'excludedGetter': 'qux'}", + ExcludedBean.class); + assertEquals("no-value", bean.excludedField); + assertEquals("no-value", bean.excludedGetter); + assertEquals("foo", bean.getIncludedGetter()); + } + + @Test + public void excludedSettersAreIgnored() { + ExcludedSetterBean bean = deserialize("{'value': 'foo'}", ExcludedSetterBean.class); + assertEquals("foo", bean.value); + } + + @Test + public void propertyNamesAreSerialized() { + PropertyNameBean bean = new PropertyNameBean(); + bean.key = "foo"; + bean.setValue("bar"); + + assertJson("{'my_key': 'foo', 'my_value': 'bar'}", serialize(bean)); + } + + @Test + public void propertyNamesAreParsed() { + PropertyNameBean bean = + deserialize("{'my_key': 'foo', 'my_value': 'bar'}", PropertyNameBean.class); + assertEquals("foo", bean.key); + assertEquals("bar", bean.getValue()); + } + + @Test + public void staticFieldsAreNotParsed() { + StaticFieldBean bean = deserialize("{'value1': 'foo', 'value2': 'bar'}", StaticFieldBean.class); + assertEquals("static-value", StaticFieldBean.value1); + assertEquals("bar", bean.value2); + } + + @Test + public void staticFieldsAreNotSerialized() { + StaticFieldBean bean = new StaticFieldBean(); + bean.value2 = "foo"; + assertJson("{'value2': 'foo'}", serialize(bean)); + } + + @Test + public void staticSettersAreNotUsed() { + StaticMethodBean bean = + deserialize("{'value1': 'foo', 'value2': 'bar'}", StaticMethodBean.class); + assertEquals("static-value", StaticMethodBean.value1); + assertEquals("bar", bean.value2); + } + + @Test + public void staticMethodsAreNotSerialized() { + StaticMethodBean bean = new StaticMethodBean(); + bean.value2 = "foo"; + assertJson("{'value2': 'foo'}", serialize(bean)); + } + + @Test + public void enumsAreSerialized() { + EnumBean bean = new EnumBean(); + bean.enumField = SimpleEnum.Bar; + bean.complexEnum = ComplexEnum.One; + bean.enumUsingPropertyName = ComplexEnum.THREE; + bean.pathologicalEnum = PathologicalEnum.One; + bean.setEnumValue(SimpleEnum.Foo); + assertJson( + "{'enumField': 'Bar', 'enumValue': 'Foo', 'complexEnum': 'One', 'enumUsingPropertyName':" + + " 'Three', 'pathologicalEnum': 'Two'}", + serialize(bean)); + } + + @Test + public void enumsAreParsed() { + String json = + "{'enumField': 'Bar', 'enumValue': 'Foo', 'complexEnum': 'One', 'enumUsingPropertyName':" + + " 'Three', 'pathologicalEnum': 'Two'}"; + EnumBean bean = deserialize(json, EnumBean.class); + assertEquals(bean.enumField, SimpleEnum.Bar); + assertEquals(bean.enumValue, SimpleEnum.Foo); + assertEquals(bean.complexEnum, ComplexEnum.One); + assertEquals(bean.enumUsingPropertyName, ComplexEnum.THREE); + assertEquals(bean.pathologicalEnum, PathologicalEnum.One); + } + + @Test + public void enumsCanBeParsedToNull() { + String json = "{'enumField': null}"; + EnumBean bean = deserialize(json, EnumBean.class); + assertNull(bean.enumField); + assertNull(bean.enumValue); + assertNull(bean.complexEnum); + } + + @Test + public void throwsOnUnmatchedEnums() { + final String json = "{'enumField': 'Unavailable', 'enumValue': 'Foo', 'complexEnum': 'One'}"; + assertExceptionContains( + "Could not find enum value of com.google.cloud.firestore.MapperTest$SimpleEnum for " + + "value \"Unavailable\" (found in field 'enumField')", + () -> deserialize(json, EnumBean.class)); + } + + @Test + public void inheritedFieldsAndGettersAreSerialized() { + FinalBean bean = new FinalBean(); + bean.finalValue = "final-value"; + bean.inheritedValue = "inherited-value"; + bean.baseValue = "base-value"; + bean.overrideValue = "override-value"; + bean.classPrivateValue = "private-value"; + bean.packageBaseValue = "package-base-value"; + bean.setFinalMethod("final-method"); + bean.setInheritedMethod("inherited-method"); + bean.setBaseMethod("base-method"); + assertJson( + "{'baseValue': 'base-value', " + + "'baseMethod': 'base-method', " + + "'classPrivateValue': 'private-value', " + + "'finalMethod': 'final-method', " + + "'finalValue': 'final-value', " + + "'inheritedMethod': 'inherited-method', " + + "'inheritedValue': 'inherited-value', " + + "'overrideValue': 'override-value-final', " + + "'packageBaseValue': 'package-base-value'}", + serialize(bean)); + } + + @Test + public void inheritedFieldsAndSettersAreParsed() { + String bean = + "{'baseValue': 'base-value', " + + "'baseMethod': 'base-method', " + + "'classPrivateValue': 'private-value', " + + "'finalMethod': 'final-method', " + + "'finalValue': 'final-value', " + + "'inheritedMethod': 'inherited-method', " + + "'inheritedValue': 'inherited-value', " + + "'overrideValue': 'override-value', " + + "'packageBaseValue': 'package-base-value'}"; + FinalBean finalBean = deserialize(bean, FinalBean.class); + assertEquals("base-value", finalBean.baseValue); + assertEquals("inherited-value", finalBean.inheritedValue); + assertEquals("final-value", finalBean.finalValue); + assertEquals("base-method", finalBean.getBaseMethod()); + assertEquals("inherited-method", finalBean.getInheritedMethod()); + assertEquals("final-method", finalBean.getFinalMethod()); + assertEquals("override-value-final", finalBean.overrideValue); + assertEquals("private-value", finalBean.classPrivateValue); + assertNull(((InheritedBean) finalBean).classPrivateValue); + assertNull(((BaseBean) finalBean).classPrivateValue); + + InheritedBean inheritedBean = deserialize(bean, InheritedBean.class); + assertEquals("base-value", inheritedBean.baseValue); + assertEquals("inherited-value", inheritedBean.inheritedValue); + assertEquals("base-method", inheritedBean.getBaseMethod()); + assertEquals("inherited-method", inheritedBean.getInheritedMethod()); + assertEquals("override-value-inherited", inheritedBean.overrideValue); + assertEquals("private-value", inheritedBean.classPrivateValue); + assertNull(((BaseBean) inheritedBean).classPrivateValue); + + BaseBean baseBean = deserialize(bean, BaseBean.class); + assertEquals("base-value", baseBean.baseValue); + assertEquals("base-method", baseBean.getBaseMethod()); + assertEquals("override-value", baseBean.overrideValue); + assertEquals("private-value", baseBean.classPrivateValue); + } + + @Test + public void settersFromSubclassConflictsWithBaseClass() { + final ConflictingSetterSubBean bean = new ConflictingSetterSubBean(); + bean.value = 1; + assertExceptionContains( + "Found conflicting setters with name: setValue (conflicts with setValue defined on " + + "com.google.cloud.firestore.MapperTest$ConflictingSetterSubBean)", + () -> serialize(bean)); + } + + @Test + public void settersFromSubclassConflictsWithBaseClass2() { + final ConflictingSetterSubBean2 bean = new ConflictingSetterSubBean2(); + bean.value = 1; + assertExceptionContains( + "Found conflicting setters with name: setValue (conflicts with setValue defined on " + + "com.google.cloud.firestore.MapperTest$ConflictingSetterSubBean2)", + () -> serialize(bean)); + } + + @Test + public void settersCanOverridePrimitiveSettersSerializing() { + NonConflictingSetterSubBean bean = new NonConflictingSetterSubBean(); + bean.value = 1; + assertJson("{'value': 1}", serialize(Collections.singletonMap("value", 1.0))); + } + + @Test + public void settersCanOverridePrimitiveSettersParsing() { + NonConflictingSetterSubBean bean = + deserialize("{'value': 2}", NonConflictingSetterSubBean.class); + // sub-bean converts to negative value + assertEquals(-2, bean.value); + } + + @Test + public void genericSettersFromSubclassConflictsWithBaseClass() { + final ConflictingGenericSetterSubBean bean = new ConflictingGenericSetterSubBean<>(); + bean.value = "hello"; + assertExceptionContains( + "Found conflicting setters with name: setValue (conflicts with setValue defined on " + + "com.google.cloud.firestore.MapperTest$ConflictingGenericSetterSubBean)", + () -> serialize(bean)); + } + + // This should work, but generics and subclassing are tricky to get right. For now we will just + // throw and we can add support for generics & subclassing if it becomes a high demand feature + @Test + public void settersCanOverrideGenericSettersParsingNot() { + assertExceptionContains( + "Class com.google.cloud.firestore.MapperTest$NonConflictingGenericSetterSubBean " + + "has multiple setter overloads", + () -> { + NonConflictingGenericSetterSubBean bean = + deserialize("{'value': 'value'}", NonConflictingGenericSetterSubBean.class); + assertEquals("subsetter:value", bean.value); + }); + } + + @Test + public void serializingRecursiveBeanThrows() { + final ObjectBean bean = new ObjectBean(); + bean.value = bean; + // It's sufficient to verify it's a RuntimeException since StackOverflowException is not. + assertExceptionContains( + "Exceeded maximum depth of 500, which likely indicates there's an object cycle", + () -> serialize(bean)); + } + + @Test + public void serializationFailureIncludesPath() { + ObjectBean innerBean = new ObjectBean(); + // Shorts aren't supported, so this should fail. + innerBean.value = Collections.singletonMap("short", (short) 1); + ObjectBean outerBean = new ObjectBean(); + outerBean.value = Collections.singletonMap("inner", innerBean); + try { + serialize(outerBean); + fail("should have thrown"); + } catch (RuntimeException e) { + assertEquals( + "Could not serialize object. Numbers of type Short are not supported, please use an int, " + + "long, float, double or BigDecimal (found in field 'value.inner.value.short')", + e.getMessage()); + } + } + + @Test + public void deserializationFailureIncludesPath() { + Object serialized = Collections.singletonMap("value", (short) 1); + + try { + convertToCustomClass(serialized, ShortBean.class); + fail("should have thrown"); + } catch (RuntimeException e) { + assertEquals( + "Could not deserialize object. Deserializing values to short is not supported " + + "(found in field 'value')", + e.getMessage()); + } + } + + // Bean definitions with @DocumentId applied to wrong type. + private static class FieldWithDocumentIdOnWrongTypeBean { + @DocumentId public Integer intField; + } + + private static class GetterWithDocumentIdOnWrongTypeBean { + private final int intField = 100; + + @DocumentId + public int getIntField() { + return intField; + } + } + + private static class PropertyWithDocumentIdOnWrongTypeBean { + @PropertyName("intField") + @DocumentId + public int intField = 100; + } + + @Test + public void documentIdAnnotateWrongTypeThrows() { + final String expectedErrorMessage = "instead of String or DocumentReference"; + assertExceptionContains( + expectedErrorMessage, () -> serialize(new FieldWithDocumentIdOnWrongTypeBean())); + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'intField': 1}", FieldWithDocumentIdOnWrongTypeBean.class)); + + assertExceptionContains( + expectedErrorMessage, () -> serialize(new GetterWithDocumentIdOnWrongTypeBean())); + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'intField': 1}", GetterWithDocumentIdOnWrongTypeBean.class)); + + assertExceptionContains( + expectedErrorMessage, () -> serialize(new PropertyWithDocumentIdOnWrongTypeBean())); + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'intField': 1}", PropertyWithDocumentIdOnWrongTypeBean.class)); + } + + private static class GetterWithoutBackingFieldOnDocumentIdBean { + @DocumentId + public String getDocId() { + return "doc-id"; + } + } + + @Test + public void documentIdAnnotateReadOnlyThrows() { + final String expectedErrorMessage = "but no field or public setter was found"; + // Serialization. + final GetterWithoutBackingFieldOnDocumentIdBean bean = + new GetterWithoutBackingFieldOnDocumentIdBean(); + assertExceptionContains(expectedErrorMessage, () -> serialize(bean)); + + // Deserialization. + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'docId': 'id'}", GetterWithoutBackingFieldOnDocumentIdBean.class)); + } + + private static class DocumentIdOnStringField { + @DocumentId public String docId = "doc-id"; + } + + private static class DocumentIdOnStringFieldAsProperty { + @PropertyName("docIdProperty") + @DocumentId + public String docId = "doc-id"; + + @PropertyName("anotherProperty") + public int someOtherProperty = 0; + } + + private static class DocumentIdOnDocRefGetter { + private DocumentReference docRef; + + @DocumentId + public DocumentReference getDocRef() { + return docRef; + } + + public void setDocRef(DocumentReference ref) { + docRef = ref; + } + } + + private static class DocumentIdOnInheritedDocRefSetter extends DocumentIdOnDocRefGetter { + + private DocumentReference inheritedDocRef; + + @DocumentId + public DocumentReference getInheritedDocRef() { + return inheritedDocRef; + } + + public void setInheritedDocRef(DocumentReference ref) { + inheritedDocRef = ref; + } + } + + private static class DocumentIdOnNestedObjects { + @PropertyName("nestedDocIdHolder") + public DocumentIdOnStringField nestedDocIdHolder; + } + + @Test + public void documentIdsDeserialize() { + DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertEquals("doc123", deserialize("{}", DocumentIdOnStringField.class, ref).docId); + + assertEquals( + "doc123", + deserialize(Collections.singletonMap("property", 100), DocumentIdOnStringField.class, ref) + .docId); + + DocumentIdOnStringFieldAsProperty target = + deserialize("{'anotherProperty': 100}", DocumentIdOnStringFieldAsProperty.class, ref); + assertEquals("doc123", target.docId); + assertEquals(100, target.someOtherProperty); + + assertEquals(ref, deserialize("{}", DocumentIdOnDocRefGetter.class, ref).getDocRef()); + + DocumentIdOnInheritedDocRefSetter target1 = + deserialize("{}", DocumentIdOnInheritedDocRefSetter.class, ref); + assertEquals(ref, target1.getInheritedDocRef()); + assertEquals(ref, target1.getDocRef()); + + assertEquals( + "doc123", + deserialize("{'nestedDocIdHolder': {}}", DocumentIdOnNestedObjects.class, ref) + .nestedDocIdHolder + .docId); + } + + @Test + public void documentIdsRoundTrip() { + // Implicitly verifies @DocumentId is ignored during serialization. + + final DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertEquals( + Collections.emptyMap(), serialize(deserialize("{}", DocumentIdOnStringField.class, ref))); + + assertEquals( + Collections.singletonMap("anotherProperty", 100), + serialize( + deserialize("{'anotherProperty': 100}", DocumentIdOnStringFieldAsProperty.class, ref))); + + assertEquals( + Collections.emptyMap(), serialize(deserialize("{}", DocumentIdOnDocRefGetter.class, ref))); + + assertEquals( + Collections.emptyMap(), + serialize(deserialize("{}", DocumentIdOnInheritedDocRefSetter.class, ref))); + + assertEquals( + Collections.singletonMap("nestedDocIdHolder", Collections.emptyMap()), + serialize(deserialize("{'nestedDocIdHolder': {}}", DocumentIdOnNestedObjects.class, ref))); + } + + @Test + public void documentIdsDeserializeConflictThrows() { + final String expectedErrorMessage = "cannot apply @DocumentId on this property"; + final DocumentReference ref = + new DocumentReference( + firestoreMock, + ResourcePath.create( + DatabaseRootName.of("test-project", "(default)"), + ImmutableList.of("coll", "doc123"))); + + assertExceptionContains( + expectedErrorMessage, + () -> deserialize("{'docId': 'toBeOverwritten'}", DocumentIdOnStringField.class, ref)); + + assertExceptionContains( + expectedErrorMessage, + () -> + deserialize( + "{'docIdProperty': 'toBeOverwritten', 'anotherProperty': 100}", + DocumentIdOnStringFieldAsProperty.class, + ref)); + + assertExceptionContains( + expectedErrorMessage, + () -> + deserialize( + "{'nestedDocIdHolder': {'docId': 'toBeOverwritten'}}", + DocumentIdOnNestedObjects.class, + ref)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OpenTelemetryOptionsTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OpenTelemetryOptionsTest.java new file mode 100644 index 000000000000..009e2457b83c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OpenTelemetryOptionsTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.firestore.telemetry.EnabledTraceUtil; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.TracerProvider; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import javax.annotation.Nullable; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class OpenTelemetryOptionsTest { + @Nullable private Firestore firestore; + + @Before + public void setUp() { + GlobalOpenTelemetry.resetForTest(); + } + + @After + public void tearDown() { + if (firestore != null) { + firestore.shutdown(); + firestore = null; + } + } + + FirestoreOptions.Builder getBaseOptions() { + return FirestoreOptions.newBuilder().setProjectId("test-project").setDatabaseId("(default)"); + } + + @Test + public void defaultOptionsUsesEnabledTraceUtilWithNoopOpenTelemetry() { + FirestoreOptions firestoreOptions = getBaseOptions().build(); + firestore = firestoreOptions.getService(); + assertThat(firestore.getOptions().getOpenTelemetryOptions().getOpenTelemetry()).isNull(); + assertThat(firestore.getOptions().getTraceUtil()).isNotNull(); + assertThat(firestore.getOptions().getTraceUtil() instanceof EnabledTraceUtil).isTrue(); + EnabledTraceUtil enabledTraceUtil = (EnabledTraceUtil) firestore.getOptions().getTraceUtil(); + // Assert that a Noop tracer provider is used by default. + assertThat(enabledTraceUtil.getOpenTelemetry().getTracerProvider()) + .isSameInstanceAs(TracerProvider.noop()); + } + + @Test + public void existenceOfGlobalOpenTelemetryEnablesTracingWithTheGlobalTracerProvider() { + // Make a custom TracerProvider. + Resource resource = + Resource.getDefault().merge(Resource.builder().put("service.name", "test").build()); + SdkTracerProvider myTracerProvider = SdkTracerProvider.builder().setResource(resource).build(); + + // Register a GlobalOpenTelemetry with the custom tracer provider. + OpenTelemetrySdk.builder().setTracerProvider(myTracerProvider).buildAndRegisterGlobal(); + + // Do NOT pass an OpenTelemetry instance to Firestore. + FirestoreOptions firestoreOptions = getBaseOptions().build(); + firestore = firestoreOptions.getService(); + + // An OpenTelemetry instance has not been set in options. + assertThat(firestore.getOptions().getOpenTelemetryOptions().getOpenTelemetry()).isNull(); + + // Assert that tracing is enabled and is using the custom tracer provider from the + // GlobalOpenTelemetry. + assertThat(firestore.getOptions().getTraceUtil()).isNotNull(); + assertThat(firestore.getOptions().getTraceUtil() instanceof EnabledTraceUtil).isTrue(); + EnabledTraceUtil enabledTraceUtil = (EnabledTraceUtil) firestore.getOptions().getTraceUtil(); + assertThat(enabledTraceUtil.getOpenTelemetry().getTracerProvider().equals(myTracerProvider)); + } + + @Test + public void canPassOpenTelemetrySdkInstanceToFirestore() { + // Make a custom TracerProvider and make an OpenTelemetry instance with it. + Resource resource = + Resource.getDefault().merge(Resource.builder().put("service.name", "test").build()); + SdkTracerProvider myTracerProvider = SdkTracerProvider.builder().setResource(resource).build(); + OpenTelemetrySdk myOpenTelemetrySdk = + OpenTelemetrySdk.builder().setTracerProvider(myTracerProvider).build(); + + // Pass it to Firestore. + FirestoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + FirestoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + firestore = firestoreOptions.getService(); + assertThat(firestore.getOptions().getOpenTelemetryOptions().getOpenTelemetry()) + .isEqualTo(myOpenTelemetrySdk); + assertThat(firestore.getOptions().getTraceUtil() instanceof EnabledTraceUtil).isTrue(); + EnabledTraceUtil enabledTraceUtil = (EnabledTraceUtil) firestore.getOptions().getTraceUtil(); + assertThat(enabledTraceUtil).isNotNull(); + assertThat(enabledTraceUtil.getOpenTelemetry()).isEqualTo(myOpenTelemetrySdk); + assertThat(enabledTraceUtil.getOpenTelemetry().getTracerProvider().equals(myTracerProvider)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OrderTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OrderTest.java new file mode 100644 index 000000000000..65e19d745f5b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/OrderTest.java @@ -0,0 +1,395 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.Order.compareByteStrings; +import static com.google.cloud.firestore.Order.compareUtf8Strings; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.MapValue; +import com.google.firestore.v1.Value; +import com.google.protobuf.ByteString; +import com.google.protobuf.NullValue; +import com.google.protobuf.Timestamp; +import com.google.type.LatLng; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; +import org.junit.Test; + +public class OrderTest { + + @Test + public void verifyOrder() { + Value[][] groups = new Value[67][]; + + groups[0] = new Value[] {nullValue()}; + + groups[1] = new Value[] {booleanValue(false)}; + groups[2] = new Value[] {booleanValue(true)}; + + // numbers + groups[3] = new Value[] {doubleValue(Double.NaN), doubleValue(Double.NaN)}; + groups[4] = new Value[] {doubleValue(Double.NEGATIVE_INFINITY)}; + groups[5] = new Value[] {doubleValue((double) Long.MIN_VALUE - 100)}; + groups[6] = new Value[] {intValue((long) Integer.MIN_VALUE - 1)}; + groups[7] = new Value[] {intValue(Integer.MIN_VALUE)}; + groups[8] = new Value[] {doubleValue(-1.1)}; + // Integers and Doubles order the same. + groups[9] = new Value[] {intValue(-1), doubleValue(-1.0)}; + groups[10] = new Value[] {doubleValue(-Double.MIN_VALUE)}; + // zeros all compare the same. + groups[11] = new Value[] {intValue(0), doubleValue(-0.0), doubleValue(0.0), doubleValue(+0.0)}; + groups[12] = new Value[] {doubleValue(Double.MIN_VALUE)}; + groups[13] = new Value[] {intValue(1), doubleValue(1.0)}; + groups[14] = new Value[] {doubleValue(1.1)}; + groups[15] = new Value[] {intValue(Integer.MAX_VALUE)}; + groups[16] = new Value[] {intValue((long) Integer.MAX_VALUE + 1)}; + groups[17] = new Value[] {doubleValue(((double) Long.MAX_VALUE) + 100)}; + groups[18] = new Value[] {doubleValue(Double.POSITIVE_INFINITY)}; + + groups[19] = new Value[] {timestampValue(123, 0)}; + groups[20] = new Value[] {timestampValue(123, 123)}; + groups[21] = new Value[] {timestampValue(345, 0)}; + + // strings + groups[22] = new Value[] {stringValue("")}; + groups[23] = new Value[] {stringValue("\u0000\ud7ff\ue000\uffff")}; + groups[24] = new Value[] {stringValue("(╯°□°)╯︵ ┻━┻")}; + groups[25] = new Value[] {stringValue("a")}; + groups[26] = new Value[] {stringValue("abc def")}; + // latin small letter e + combining acute accent + latin small letter b + groups[27] = new Value[] {stringValue("e\u0301b")}; + groups[28] = new Value[] {stringValue("æ")}; + // latin small letter e with acute accent + latin small letter a + groups[29] = new Value[] {stringValue("\u00e9a")}; + + // blobs + groups[30] = new Value[] {blobValue(new byte[] {})}; + groups[31] = new Value[] {blobValue(new byte[] {0})}; + groups[32] = new Value[] {blobValue(new byte[] {0, 1, 2, 3, 4})}; + groups[33] = new Value[] {blobValue(new byte[] {0, 1, 2, 4, 3})}; + groups[34] = new Value[] {blobValue(new byte[] {127})}; + + // resource names + groups[35] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c1/doc1")}; + groups[36] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c1/doc2")}; + groups[37] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c1/doc2/c2/doc1")}; + groups[38] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c1/doc2/c2/doc2")}; + groups[39] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c10/doc1")}; + groups[40] = new Value[] {referenceValue("projects/p1/databases/d1/documents/c2/doc1")}; + groups[41] = new Value[] {referenceValue("projects/p2/databases/d2/documents/c1/doc1")}; + groups[42] = new Value[] {referenceValue("projects/p2/databases/d2/documents/c1-/doc1")}; + groups[43] = new Value[] {referenceValue("projects/p2/databases/d3/documents/c1-/doc1")}; + + // geo points + groups[44] = new Value[] {geoPointValue(-90, -180)}; + groups[45] = new Value[] {geoPointValue(-90, 0)}; + groups[46] = new Value[] {geoPointValue(-90, 180)}; + groups[47] = new Value[] {geoPointValue(0, -180)}; + groups[48] = new Value[] {geoPointValue(0, 0)}; + groups[49] = new Value[] {geoPointValue(0, 180)}; + groups[50] = new Value[] {geoPointValue(1, -180)}; + groups[51] = new Value[] {geoPointValue(1, 0)}; + groups[52] = new Value[] {geoPointValue(1, 180)}; + groups[53] = new Value[] {geoPointValue(90, -180)}; + groups[54] = new Value[] {geoPointValue(90, 0)}; + groups[55] = new Value[] {geoPointValue(90, 180)}; + + // arrays + groups[56] = new Value[] {arrayValue()}; + groups[57] = new Value[] {arrayValue(stringValue("bar"))}; + groups[58] = new Value[] {arrayValue(stringValue("foo"))}; + groups[59] = new Value[] {arrayValue(stringValue("foo"), intValue(0))}; + groups[60] = new Value[] {arrayValue(stringValue("foo"), intValue(1))}; + groups[61] = new Value[] {arrayValue(stringValue("foo"), stringValue("0"))}; + + // objects + groups[62] = new Value[] {objectValue("bar", intValue(0))}; + groups[63] = new Value[] {objectValue("bar", intValue(0), "foo", intValue(1))}; + groups[64] = new Value[] {objectValue("bar", intValue(1))}; + groups[65] = new Value[] {objectValue("bar", intValue(2))}; + groups[66] = new Value[] {objectValue("bar", stringValue("0"))}; + + for (int left = 0; left < groups.length; left++) { + for (int right = 0; right < groups.length; right++) { + for (int i = 0; i < groups[left].length; i++) { + for (int j = 0; j < groups[right].length; j++) { + assertEquals( + String.format( + "Order does not match for: groups[%d][%d] and groups[%d][%d]", + left, i, right, j), + Integer.compare(left, right), + Integer.compare(Order.INSTANCE.compare(groups[left][i], groups[right][j]), 0)); + } + } + } + } + } + + private Value booleanValue(boolean b) { + return Value.newBuilder().setBooleanValue(b).build(); + } + + private Value doubleValue(double d) { + return Value.newBuilder().setDoubleValue(d).build(); + } + + private Value intValue(long l) { + return Value.newBuilder().setIntegerValue(l).build(); + } + + private Value stringValue(String s) { + return Value.newBuilder().setStringValue(s).build(); + } + + private Value referenceValue(String r) { + return Value.newBuilder().setReferenceValue(r).build(); + } + + private Value blobValue(byte[] b) { + return Value.newBuilder().setBytesValue(ByteString.copyFrom(b)).build(); + } + + private Value nullValue() { + return Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build(); + } + + private Value timestampValue(long seconds, int nanos) { + return Value.newBuilder() + .setTimestampValue(Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos).build()) + .build(); + } + + private Value geoPointValue(double latitude, double longitude) { + return Value.newBuilder() + .setGeoPointValue(LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build()) + .build(); + } + + private Value arrayValue(Value... values) { + return Value.newBuilder() + .setArrayValue(ArrayValue.newBuilder().addAllValues(Arrays.asList(values)).build()) + .build(); + } + + private Value objectValue(String key, Value value, Object... keysAndValues) { + MapValue.Builder mapBuilder = MapValue.newBuilder(); + mapBuilder.putFields(key, value); + + for (int i = 0; i < keysAndValues.length; i += 2) { + mapBuilder.putFields((String) keysAndValues[i], (Value) keysAndValues[i + 1]); + } + + return Value.newBuilder().setMapValue(mapBuilder.build()).build(); + } + + @Test + public void compareUtf8StringsShouldReturnCorrectValue() { + ArrayList errors = new ArrayList<>(); + int seed = new Random().nextInt(Integer.MAX_VALUE); + int passCount = 0; + StringGenerator stringGenerator = new StringGenerator(29750468); + StringPairGenerator stringPairGenerator = new StringPairGenerator(stringGenerator); + for (int i = 0; i < 1_000_000 && errors.size() < 10; i++) { + StringPairGenerator.StringPair stringPair = stringPairGenerator.next(); + final String s1 = stringPair.s1; + final String s2 = stringPair.s2; + + int actual = compareUtf8Strings(s1, s2); + + ByteString b1 = ByteString.copyFromUtf8(s1); + ByteString b2 = ByteString.copyFromUtf8(s2); + int expected = compareByteStrings(b1, b2); + + if (Integer.signum(actual) == Integer.signum(expected)) { + passCount++; + } else { + errors.add( + "compareUtf8Strings(s1=\"" + + s1 + + "\", s2=\"" + + s2 + + "\") returned " + + signName(actual) + + " (" + + actual + + ")" + + ", but expected " + + signName(expected) + + " (i=" + + i + + ", s1.length=" + + s1.length() + + ", s2.length=" + + s2.length() + + ")"); + } + } + + if (!errors.isEmpty()) { + StringBuilder sb = new StringBuilder(); + sb.append(errors.size()).append(" test cases failed, "); + sb.append(passCount).append(" test cases passed, "); + sb.append("seed=").append(seed).append(";"); + for (int i = 0; i < errors.size(); i++) { + sb.append("\nerrors[").append(i).append("]: ").append(errors.get(i)); + } + fail(sb.toString()); + } + } + + private static String signName(int value) { + if (value < 0) { + return "a negative value"; + } else if (value > 0) { + return "a positive value"; + } else { + return "0"; + } + } + + private static class StringPairGenerator { + + private final StringGenerator stringGenerator; + + public StringPairGenerator(StringGenerator stringGenerator) { + this.stringGenerator = stringGenerator; + } + + public StringPair next() { + String prefix = stringGenerator.next(); + String s1 = prefix + stringGenerator.next(); + String s2 = prefix + stringGenerator.next(); + return new StringPair(s1, s2); + } + + public static class StringPair { + public final String s1, s2; + + public StringPair(String s1, String s2) { + this.s1 = s1; + this.s2 = s2; + } + } + } + + private static class StringGenerator { + + private static final float DEFAULT_SURROGATE_PAIR_PROBABILITY = 0.33f; + private static final int DEFAULT_MAX_LENGTH = 20; + + private static final int MIN_HIGH_SURROGATE = 0xD800; + private static final int MAX_HIGH_SURROGATE = 0xDBFF; + private static final int MIN_LOW_SURROGATE = 0xDC00; + private static final int MAX_LOW_SURROGATE = 0xDFFF; + + private final Random rnd; + private final float surrogatePairProbability; + private final int maxLength; + + public StringGenerator(int seed) { + this(new Random(seed), DEFAULT_SURROGATE_PAIR_PROBABILITY, DEFAULT_MAX_LENGTH); + } + + public StringGenerator(Random rnd, float surrogatePairProbability, int maxLength) { + this.rnd = rnd; + this.surrogatePairProbability = validateProbability(surrogatePairProbability); + this.maxLength = validateLength(maxLength); + } + + private static float validateProbability(float probability) { + if (!Float.isFinite(probability)) { + throw new IllegalArgumentException( + "invalid surrogate pair probability: " + + probability + + " (must be between 0.0 and 1.0, inclusive)"); + } else if (probability < 0.0f) { + throw new IllegalArgumentException( + "invalid surrogate pair probability: " + + probability + + " (must be greater than or equal to zero)"); + } else if (probability > 1.0f) { + throw new IllegalArgumentException( + "invalid surrogate pair probability: " + + probability + + " (must be less than or equal to 1)"); + } + return probability; + } + + private static int validateLength(int length) { + if (length < 0) { + throw new IllegalArgumentException( + "invalid maximum string length: " + + length + + " (must be greater than or equal to zero)"); + } + return length; + } + + public String next() { + final int length = rnd.nextInt(maxLength + 1); + final StringBuilder sb = new StringBuilder(); + while (sb.length() < length) { + int codePoint = nextCodePoint(); + sb.appendCodePoint(codePoint); + } + return sb.toString(); + } + + private boolean isNextSurrogatePair() { + return nextBoolean(rnd, surrogatePairProbability); + } + + private static boolean nextBoolean(Random rnd, float probability) { + if (probability == 0.0f) { + return false; + } else if (probability == 1.0f) { + return true; + } else { + return rnd.nextFloat() < probability; + } + } + + private int nextCodePoint() { + if (isNextSurrogatePair()) { + return nextSurrogateCodePoint(); + } else { + return nextNonSurrogateCodePoint(); + } + } + + private int nextSurrogateCodePoint() { + int highSurrogate = + rnd.nextInt(MAX_HIGH_SURROGATE - MIN_HIGH_SURROGATE + 1) + MIN_HIGH_SURROGATE; + int lowSurrogate = rnd.nextInt(MAX_LOW_SURROGATE - MIN_LOW_SURROGATE + 1) + MIN_LOW_SURROGATE; + return Character.toCodePoint((char) highSurrogate, (char) lowSurrogate); + } + + private int nextNonSurrogateCodePoint() { + int codePoint; + do { + codePoint = rnd.nextInt(0x10000); // BMP range + } while (codePoint >= MIN_HIGH_SURROGATE + && codePoint <= MAX_LOW_SURROGATE); // Exclude surrogate range + return codePoint; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/PartitionQuery.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/PartitionQuery.java new file mode 100644 index 000000000000..4478ea9c97bd --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/PartitionQuery.java @@ -0,0 +1,207 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; + +import com.google.api.core.ApiFutures; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPage; +import com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; +import com.google.common.collect.ImmutableList; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.Value; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class PartitionQuery { + public static final String DATABASE_NAME = "projects/test-project/databases/(default)/documents"; + public static final Cursor CURSOR1 = + Cursor.newBuilder() + .addValues(Value.newBuilder().setReferenceValue(DATABASE_NAME + "/collection/doc1")) + .build(); + public static final Cursor PARTITION1 = CURSOR1.toBuilder().setBefore(true).build(); + public static final Cursor CURSOR2 = + Cursor.newBuilder() + .addValues(Value.newBuilder().setReferenceValue(DATABASE_NAME + "/collection/doc2")) + .build(); + public static final Cursor PARTITION2 = CURSOR2.toBuilder().setBefore(true).build(); + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Mock private UnaryCallable callable; + @Mock private PartitionQueryPagedResponse pagedResponse; + @Mock private PartitionQueryPage queryPage; + + @Captor private ArgumentCaptor runQuery; + @Captor private ArgumentCaptor> streamObserverCapture; + @Captor private ArgumentCaptor requestCaptor; + + @Test + public void requestsOneLessThanDesired() throws Exception { + int desiredPartitionsCount = 2; + + PartitionQueryRequest expectedRequest = + PartitionQueryRequest.newBuilder() + .setParent(DATABASE_NAME) + .setStructuredQuery( + StructuredQuery.newBuilder() + .addFrom( + StructuredQuery.CollectionSelector.newBuilder() + .setAllDescendants(true) + .setCollectionId("collectionId")) + .addOrderBy( + StructuredQuery.Order.newBuilder() + .setField( + StructuredQuery.FieldReference.newBuilder() + .setFieldPath("__name__")) + .setDirection(StructuredQuery.Direction.ASCENDING))) + .setPartitionCount(desiredPartitionsCount - 1) + .build(); + + PartitionQueryResponse response = + PartitionQueryResponse.newBuilder().addPartitions(CURSOR1).build(); + + when(pagedResponse.iterateAll()).thenReturn(ImmutableList.of(CURSOR1)); + when(queryPage.getResponse()).thenReturn(response); + doReturn(ApiFutures.immediateFuture(pagedResponse)) + .when(firestoreMock) + .sendRequest( + requestCaptor.capture(), + ArgumentMatchers + .>any()); + + firestoreMock.collectionGroup("collectionId").getPartitions(desiredPartitionsCount).get(); + + PartitionQueryRequest actualRequest = requestCaptor.getValue(); + assertEquals(actualRequest, expectedRequest); + } + + @Test + public void doesNotIssueRpcIfOnlyASinglePartitionIsRequested() throws Exception { + int desiredPartitionsCount = 1; + + List partitions = + firestoreMock.collectionGroup("collectionId").getPartitions(desiredPartitionsCount).get(); + + assertEquals(partitions.size(), 1); + assertNull(partitions.get(0).getStartAt()); + assertNull(partitions.get(0).getEndBefore()); + } + + @Test + public void validatesPartitionCount() { + int desiredPartitionsCount = 0; + try { + firestoreMock.collectionGroup("collectionId").getPartitions(desiredPartitionsCount); + fail(); + } catch (IllegalArgumentException e) { + assertEquals(e.getMessage(), "Desired partition count must be one or greater"); + } + } + + @Test + public void convertsPartitionsToQueries() throws Exception { + int desiredPartitionsCount = 3; + + PartitionQueryResponse response = + PartitionQueryResponse.newBuilder().addPartitions(CURSOR1).build(); + + when(pagedResponse.iterateAll()).thenReturn(ImmutableList.of(CURSOR1, CURSOR2)); + when(queryPage.getResponse()).thenReturn(response); + doReturn(ApiFutures.immediateFuture(pagedResponse)) + .when(firestoreMock) + .sendRequest( + requestCaptor.capture(), + ArgumentMatchers + .>any()); + + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest( + runQuery.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + List partitions = + firestoreMock.collectionGroup("collectionId").getPartitions(desiredPartitionsCount).get(); + + assertEquals(partitions.size(), 3); + for (QueryPartition partition : partitions) { + partition.createQuery().get(); + } + + assertEquals(runQuery.getAllValues().size(), 3); + + assertFalse(runQuery.getAllValues().get(0).getStructuredQuery().hasStartAt()); + assertEquals(runQuery.getAllValues().get(0).getStructuredQuery().getEndAt(), PARTITION1); + assertEquals(runQuery.getAllValues().get(1).getStructuredQuery().getStartAt(), PARTITION1); + assertEquals(runQuery.getAllValues().get(1).getStructuredQuery().getEndAt(), PARTITION2); + assertEquals(runQuery.getAllValues().get(2).getStructuredQuery().getStartAt(), PARTITION2); + assertFalse(runQuery.getAllValues().get(2).getStructuredQuery().hasEndAt()); + } + + @Test + public void sortsPartitions() throws Exception { + int desiredPartitionsCount = 3; + + PartitionQueryResponse response = + PartitionQueryResponse.newBuilder().addPartitions(CURSOR1).build(); + + when(pagedResponse.iterateAll()).thenReturn(ImmutableList.of(CURSOR2, CURSOR1)); + when(queryPage.getResponse()).thenReturn(response); + doReturn(ApiFutures.immediateFuture(pagedResponse)) + .when(firestoreMock) + .sendRequest( + requestCaptor.capture(), + ArgumentMatchers + .>any()); + + List partitions = + firestoreMock.collectionGroup("collectionId").getPartitions(desiredPartitionsCount).get(); + + assertEquals(((DocumentReference) partitions.get(0).getEndBefore()[0]).getId(), "doc1"); + assertEquals(((DocumentReference) partitions.get(1).getEndBefore()[0]).getId(), "doc2"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java new file mode 100644 index 000000000000..b6e91c291042 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryCountTest.java @@ -0,0 +1,282 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.COLLECTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.aggregationQueryResponses; +import static com.google.cloud.firestore.LocalFirestoreHelper.countQueryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.endAt; +import static com.google.cloud.firestore.LocalFirestoreHelper.limit; +import static com.google.cloud.firestore.LocalFirestoreHelper.order; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; +import static com.google.cloud.firestore.LocalFirestoreHelper.startAt; +import static com.google.cloud.firestore.LocalFirestoreHelper.string; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +import com.google.api.core.ApiClock; +import com.google.api.core.ApiFuture; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.StructuredQuery; +import io.grpc.Status; +import java.time.Duration; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class QueryCountTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor runAggregationQuery; + + @Captor + private ArgumentCaptor> streamObserverCapture; + + private Query query; + + @Before + public void before() { + doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration(); + query = firestoreMock.collection(COLLECTION_ID); + } + + @Test + public void countShouldBeZeroForEmptyCollection() throws Exception { + doAnswer(countQueryResponse(0)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuerySnapshot snapshot = query.count().get().get(); + + assertThat(snapshot.getCount()).isEqualTo(0); + } + + @Test + public void countShouldBe99ForCollectionWith99Documents() throws Exception { + doAnswer(countQueryResponse(99)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuerySnapshot snapshot = query.count().get().get(); + + assertThat(snapshot.getCount()).isEqualTo(99); + } + + @Test + public void countShouldMakeCorrectRequestForACollection() throws Exception { + doAnswer(countQueryResponse(0)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + CollectionReference collection = firestoreMock.collection(COLLECTION_ID); + collection.count().get(); + + assertThat(runAggregationQuery.getValue()).isEqualTo(LocalFirestoreHelper.countQuery()); + } + + @Test + public void countShouldMakeCorrectRequestForAComplexQuery() throws Exception { + doAnswer(countQueryResponse(0)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").startAt("foo").endAt("bar").limitToLast(42).count().get().get(); + + assertThat(runAggregationQuery.getValue()) + .isEqualTo( + LocalFirestoreHelper.countQuery( + query( + limit(42), + order("foo", StructuredQuery.Direction.DESCENDING), + endAt(string("foo"), false), + startAt(string("bar"), true)))); + } + + @Test + public void shouldReturnReadTimeFromResponse() throws Exception { + doAnswer(countQueryResponse(99, Timestamp.ofTimeSecondsAndNanos(123, 456))) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuerySnapshot snapshot = query.count().get().get(); + + assertThat(snapshot.getReadTime()).isEqualTo(Timestamp.ofTimeSecondsAndNanos(123, 456)); + } + + @Test + public void shouldIgnoreExtraRunAggregationQueryResponses() throws Exception { + doAnswer(aggregationQueryResponses(123, 456)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuerySnapshot snapshot = query.count().get().get(); + + assertThat(snapshot.getCount()).isEqualTo(123); + } + + @Test + public void shouldIgnoreExtraErrors() throws Exception { + doAnswer(aggregationQueryResponses(123, new Exception())) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuerySnapshot snapshot = query.count().get().get(); + + assertThat(snapshot.getCount()).isEqualTo(123); + } + + @Test + public void shouldPropagateErrors() throws Exception { + Exception exception = new Exception(); + doAnswer(countQueryResponse(exception)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + ExecutionException executionException = assertThrows(ExecutionException.class, future::get); + assertThat(executionException).hasCauseThat().isSameInstanceAs(exception); + } + + @Test + public void aggregateQueryGetQueryShouldReturnCorrectValue() throws Exception { + AggregateQuery aggregateQuery = query.count(); + assertThat(aggregateQuery.getQuery()).isSameInstanceAs(query); + } + + @Test + public void aggregateQuerySnapshotGetQueryShouldReturnCorrectValue() throws Exception { + doAnswer(countQueryResponse()) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + AggregateQuery aggregateQuery = query.count(); + AggregateQuerySnapshot snapshot = aggregateQuery.get().get(); + + assertThat(snapshot.getQuery()).isSameInstanceAs(aggregateQuery); + } + + @Test + public void shouldNotRetryIfExceptionIsNotFirestoreException() { + doAnswer(countQueryResponse(new NotFirestoreException())) + .doAnswer(countQueryResponse()) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + + assertThrows(ExecutionException.class, future::get); + } + + @Test + public void shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatus() throws Exception { + doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL))) + .doAnswer(countQueryResponse(42)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + AggregateQuerySnapshot snapshot = future.get(); + + assertThat(snapshot.getCount()).isEqualTo(42); + } + + @Test + public void shouldNotRetryIfExceptionIsFirestoreExceptionWithNonRetryableStatus() { + doAnswer(countQueryResponse(new FirestoreException("reason", Status.INVALID_ARGUMENT))) + .doAnswer(countQueryResponse()) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + + assertThrows(ExecutionException.class, future::get); + } + + @Test + public void + shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatusWithInfiniteTimeoutWindow() + throws Exception { + doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration(); + doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL))) + .doAnswer(countQueryResponse(42)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + AggregateQuerySnapshot snapshot = future.get(); + + assertThat(snapshot.getCount()).isEqualTo(42); + } + + @Test + public void shouldRetryIfExceptionIsFirestoreExceptionWithRetryableStatusWithinTimeoutWindow() + throws Exception { + doReturn(Duration.ofDays(999)).when(firestoreMock).getTotalRequestTimeoutDuration(); + doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL))) + .doAnswer(countQueryResponse(42)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + AggregateQuerySnapshot snapshot = future.get(); + + assertThat(snapshot.getCount()).isEqualTo(42); + } + + @Test + public void + shouldNotRetryIfExceptionIsFirestoreExceptionWithRetryableStatusBeyondTimeoutWindow() { + ApiClock clockMock = mock(ApiClock.class); + doReturn(clockMock).when(firestoreMock).getClock(); + doReturn(TimeUnit.SECONDS.toNanos(10)) + .doReturn(TimeUnit.SECONDS.toNanos(20)) + .doReturn(TimeUnit.SECONDS.toNanos(30)) + .when(clockMock) + .nanoTime(); + doReturn(Duration.ofSeconds(5)).when(firestoreMock).getTotalRequestTimeoutDuration(); + doAnswer(countQueryResponse(new FirestoreException("reason", Status.INTERNAL))) + .doAnswer(countQueryResponse(42)) + .when(firestoreMock) + .streamRequest(runAggregationQuery.capture(), streamObserverCapture.capture(), any()); + + ApiFuture future = query.count().get(); + + assertThrows(ExecutionException.class, future::get); + } + + private static final class NotFirestoreException extends Exception {} +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java new file mode 100644 index 000000000000..78591cddae63 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java @@ -0,0 +1,1524 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.Filter.*; +import static com.google.cloud.firestore.LocalFirestoreHelper.COLLECTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_PATH; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_SNAPSHOT; +import static com.google.cloud.firestore.LocalFirestoreHelper.andFilters; +import static com.google.cloud.firestore.LocalFirestoreHelper.endAt; +import static com.google.cloud.firestore.LocalFirestoreHelper.fieldFilter; +import static com.google.cloud.firestore.LocalFirestoreHelper.filter; +import static com.google.cloud.firestore.LocalFirestoreHelper.limit; +import static com.google.cloud.firestore.LocalFirestoreHelper.offset; +import static com.google.cloud.firestore.LocalFirestoreHelper.orFilters; +import static com.google.cloud.firestore.LocalFirestoreHelper.order; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponseWithDone; +import static com.google.cloud.firestore.LocalFirestoreHelper.reference; +import static com.google.cloud.firestore.LocalFirestoreHelper.select; +import static com.google.cloud.firestore.LocalFirestoreHelper.startAt; +import static com.google.cloud.firestore.LocalFirestoreHelper.string; +import static com.google.cloud.firestore.LocalFirestoreHelper.unaryFilter; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; + +import com.google.api.core.ApiClock; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Query.ComparisonFilterInternal; +import com.google.cloud.firestore.Query.FieldOrder; +import com.google.cloud.firestore.Query.FilterInternal; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.io.BaseEncoding; +import com.google.firestore.v1.ArrayValue; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.StructuredQuery.CollectionSelector; +import com.google.firestore.v1.StructuredQuery.Direction; +import com.google.firestore.v1.StructuredQuery.FieldFilter.Operator; +import com.google.firestore.v1.Value; +import com.google.protobuf.InvalidProtocolBufferException; +import io.grpc.Status; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Semaphore; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class QueryTest { + + static class MockClock implements ApiClock { + long nanoTime = 0; + + public void advance(long nanos) { + nanoTime += nanos; + } + + @Override + public long nanoTime() { + return nanoTime; + } + + @Override + public long millisTime() { + return nanoTime / 1000000; + } + } + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor runQuery; + + @Captor private ArgumentCaptor> streamObserverCapture; + + private Query query; + + private MockClock clock; + + @Before + public void before() { + clock = new MockClock(); + doReturn(clock).when(firestoreMock).getClock(); + doReturn(Duration.ZERO).when(firestoreMock).getTotalRequestTimeoutDuration(); + + query = firestoreMock.collection(COLLECTION_ID); + } + + @Test + public void withLimit() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.limit(42).get().get(); + + assertEquals(query(limit(42)), runQuery.getValue()); + } + + @Test + public void limitToLastReversesOrderingConstraints() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").limitToLast(42).get().get(); + + assertEquals( + query(limit(42), order("foo", StructuredQuery.Direction.DESCENDING)), runQuery.getValue()); + } + + @Test + public void limitToLastReversesCursors() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").startAt("foo").endAt("bar").limitToLast(42).get().get(); + + assertEquals( + query( + limit(42), + order("foo", StructuredQuery.Direction.DESCENDING), + endAt(string("foo"), false), + startAt(string("bar"), true)), + runQuery.getValue()); + } + + @Test + public void limitToLastReversesResults() throws Exception { + doAnswer(queryResponse(DOCUMENT_NAME + "2", DOCUMENT_NAME + "1")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + QuerySnapshot querySnapshot = query.orderBy("foo").limitToLast(2).get().get(); + + Iterator docIterator = querySnapshot.iterator(); + assertEquals("doc1", docIterator.next().getId()); + assertEquals("doc2", docIterator.next().getId()); + } + + @Test + public void limitToLastRequiresAtLeastOneOrderingConstraint() throws Exception { + try { + query.limitToLast(1).get().get(); + fail("Expected exception"); + } catch (IllegalStateException e) { + assertEquals( + e.getMessage(), + "limitToLast() queries require specifying at least one orderBy() clause."); + } + } + + @Test + public void limitToLastRejectsStream() { + try { + query.orderBy("foo").limitToLast(1).stream(null); + fail("Expected exception"); + } catch (IllegalStateException e) { + assertEquals( + e.getMessage(), + "Query results for queries that include limitToLast() constraints cannot be streamed. " + + "Use Query.get() instead."); + } + } + + @Test + public void withOffset() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.offset(42).get().get(); + + assertEquals(query(offset(42)), runQuery.getValue()); + } + + @Test + public void withFilter() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.whereEqualTo("foo", "bar").get().get(); + query.whereEqualTo("foo", null).get().get(); + query.whereEqualTo("foo", Double.NaN).get().get(); + query.whereEqualTo("foo", Float.NaN).get().get(); + query.whereNotEqualTo("foo", "bar").get().get(); + query.whereNotEqualTo("foo", null).get().get(); + query.whereNotEqualTo("foo", Double.NaN).get().get(); + query.whereNotEqualTo("foo", Float.NaN).get().get(); + query.whereGreaterThan("foo", "bar").get().get(); + query.whereGreaterThanOrEqualTo("foo", "bar").get().get(); + query.whereLessThan("foo", "bar").get().get(); + query.whereLessThanOrEqualTo("foo", "bar").get().get(); + query.whereArrayContains("foo", "bar").get().get(); + query.whereIn("foo", Collections.singletonList("bar")); + query.whereArrayContainsAny("foo", Collections.singletonList("bar")); + query.whereNotIn("foo", Collections.singletonList("bar")); + + Iterator expected = + Arrays.asList( + query(filter(StructuredQuery.FieldFilter.Operator.EQUAL)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NULL)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NAN)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NAN)), + query(filter(StructuredQuery.FieldFilter.Operator.NOT_EQUAL)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NOT_NULL)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NOT_NAN)), + query(unaryFilter(StructuredQuery.UnaryFilter.Operator.IS_NOT_NAN)), + query(filter(StructuredQuery.FieldFilter.Operator.GREATER_THAN)), + query(filter(StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.LESS_THAN)), + query(filter(StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS)), + query(filter(StructuredQuery.FieldFilter.Operator.IN)), + query(filter(StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY)), + query(filter(StructuredQuery.FieldFilter.Operator.NOT_IN))) + .iterator(); + + for (RunQueryRequest actual : runQuery.getAllValues()) { + assertEquals(expected.next(), actual); + } + } + + @Test + public void withFieldPathFilter() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.whereEqualTo(FieldPath.of("foo"), "bar").get().get(); + query.whereNotEqualTo(FieldPath.of("foo"), "bar").get().get(); + query.whereGreaterThan(FieldPath.of("foo"), "bar").get().get(); + query.whereGreaterThanOrEqualTo(FieldPath.of("foo"), "bar").get().get(); + query.whereLessThan(FieldPath.of("foo"), "bar").get().get(); + query.whereLessThanOrEqualTo(FieldPath.of("foo"), "bar").get().get(); + query.whereArrayContains(FieldPath.of("foo"), "bar").get().get(); + query.whereIn(FieldPath.of("foo"), Collections.singletonList("bar")); + query.whereNotIn(FieldPath.of("foo"), Collections.singletonList("bar")); + query.whereArrayContainsAny(FieldPath.of("foo"), Collections.singletonList("bar")); + + Iterator expected = + Arrays.asList( + query(filter(StructuredQuery.FieldFilter.Operator.EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.NOT_EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.GREATER_THAN)), + query(filter(StructuredQuery.FieldFilter.Operator.GREATER_THAN_OR_EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.LESS_THAN)), + query(filter(StructuredQuery.FieldFilter.Operator.LESS_THAN_OR_EQUAL)), + query(filter(StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS)), + query(filter(StructuredQuery.FieldFilter.Operator.IN)), + query(filter(StructuredQuery.FieldFilter.Operator.NOT_IN)), + query(filter(StructuredQuery.FieldFilter.Operator.ARRAY_CONTAINS_ANY))) + .iterator(); + + for (RunQueryRequest actual : runQuery.getAllValues()) { + assertEquals(expected.next(), actual); + } + } + + @Test + public void withCompositeFilter() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + // a == 10 && (b==20 || c==30 || (d==40 && e>50) || f==60) + query + .where( + and( + equalTo("a", "10"), + or( + equalTo("b", "20"), + equalTo("c", "30"), + and(equalTo("d", "40"), greaterThan("e", "50")), + and(equalTo("f", "60")), + or(and())))) + .get() + .get(); + + StructuredQuery.Filter a = fieldFilter("a", Operator.EQUAL, "10"); + StructuredQuery.Filter b = fieldFilter("b", Operator.EQUAL, "20"); + StructuredQuery.Filter c = fieldFilter("c", Operator.EQUAL, "30"); + StructuredQuery.Filter d = fieldFilter("d", Operator.EQUAL, "40"); + StructuredQuery.Filter e = fieldFilter("e", Operator.GREATER_THAN, "50"); + StructuredQuery.Filter f = fieldFilter("f", Operator.EQUAL, "60"); + StructuredQuery.Builder structuredQuery = StructuredQuery.newBuilder(); + structuredQuery.setWhere(andFilters(a, orFilters(b, c, andFilters(d, e), f))); + structuredQuery.addFrom(CollectionSelector.newBuilder().setCollectionId("coll").build()); + + assertEquals(structuredQuery.build(), runQuery.getValue().getStructuredQuery()); + } + + @Test + public void inQueriesWithReferenceArray() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query + .whereIn(FieldPath.documentId(), Arrays.asList("doc", firestoreMock.document("coll/doc"))) + .get() + .get(); + + Value value = + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder() + .addValues(reference(DOCUMENT_NAME)) + .addValues(reference(DOCUMENT_NAME)) + .build()) + .build(); + RunQueryRequest expectedRequest = query(filter(Operator.IN, "__name__", value)); + + assertEquals(expectedRequest, runQuery.getValue()); + } + + @Test + public void inQueriesFieldsNotUsedInOrderBy() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + // Field "foo" used in `whereIn` should not appear in implicit orderBys in the resulting query. + query + .whereIn(FieldPath.of("foo"), Arrays.asList("value1", "value2")) + .startAt(SINGLE_FIELD_SNAPSHOT) + .get() + .get(); + + Value value = + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder() + .addValues(Value.newBuilder().setStringValue("value1").build()) + .addValues(Value.newBuilder().setStringValue("value2").build()) + .build()) + .build(); + RunQueryRequest expectedRequest = + query( + filter(Operator.IN, "foo", value), + order("__name__", Direction.ASCENDING), + startAt(reference(DOCUMENT_NAME), true)); + + assertEquals(expectedRequest, runQuery.getValue()); + } + + @Test + public void validatesInQueries() { + try { + query.whereIn(FieldPath.documentId(), Arrays.asList("foo", 42)).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "The corresponding value for FieldPath.documentId() must be a String or a " + + "DocumentReference, but was: 42.", + e.getMessage()); + } + + try { + query.whereIn(FieldPath.documentId(), Arrays.asList()).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Invalid Query. A non-empty array is required for 'IN' filters.", e.getMessage()); + } + } + + @Test + public void notInQueriesWithReferenceArray() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query + .whereNotIn( + FieldPath.documentId(), Arrays.asList("doc", firestoreMock.document("coll/doc"))) + .get() + .get(); + + Value value = + Value.newBuilder() + .setArrayValue( + ArrayValue.newBuilder() + .addValues(reference(DOCUMENT_NAME)) + .addValues(reference(DOCUMENT_NAME)) + .build()) + .build(); + RunQueryRequest expectedRequest = query(filter(Operator.NOT_IN, "__name__", value)); + + assertEquals(expectedRequest, runQuery.getValue()); + } + + @Test + public void validatesNotInQueries() { + try { + query.whereNotIn(FieldPath.documentId(), Arrays.asList("foo", 42)).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "The corresponding value for FieldPath.documentId() must be a String or a " + + "DocumentReference, but was: 42.", + e.getMessage()); + } + + try { + query.whereNotIn(FieldPath.documentId(), Arrays.asList()).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Invalid Query. A non-empty array is required for 'NOT_IN' filters.", e.getMessage()); + } + } + + @Test + public void validatesQueryOperatorForFieldPathDocumentId() { + try { + query.whereArrayContains(FieldPath.documentId(), "bar"); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Invalid query. You cannot perform 'ARRAY_CONTAINS' queries on FieldPath.documentId().", + e.getMessage()); + } + + try { + query.whereArrayContainsAny(FieldPath.documentId(), Collections.singletonList("bar")); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Invalid query. You cannot perform 'ARRAY_CONTAINS_ANY' queries on" + + " FieldPath.documentId().", + e.getMessage()); + } + } + + @Test + public void withDocumentIdFilter() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.whereEqualTo(FieldPath.documentId(), "doc").get().get(); + + RunQueryRequest expectedRequest = + query(filter(Operator.EQUAL, "__name__", reference(DOCUMENT_NAME))); + + assertEquals(expectedRequest, runQuery.getValue()); + } + + @Test + public void withOrderBy() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").orderBy("foo.bar", Query.Direction.DESCENDING).get().get(); + + assertEquals( + query( + order("foo", StructuredQuery.Direction.ASCENDING), + order("foo.bar", StructuredQuery.Direction.DESCENDING)), + runQuery.getValue()); + } + + @Test + public void withFieldPathOrderBy() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query + .orderBy(FieldPath.of("foo")) + .orderBy(FieldPath.of("foo", "bar"), Query.Direction.DESCENDING) + .get() + .get(); + + assertEquals( + query( + order("foo", StructuredQuery.Direction.ASCENDING), + order("foo.bar", StructuredQuery.Direction.DESCENDING)), + runQuery.getValue()); + } + + @Test + public void withSelect() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.select(new String[] {}).get().get(); + query.select("foo", "foo.bar").get().get(); + + Iterator expectedQuery = + Arrays.asList( + query(select(FieldPath.documentId())), query(select("foo"), select("foo.bar"))) + .iterator(); + + for (RunQueryRequest actual : runQuery.getAllValues()) { + assertEquals(expectedQuery.next(), actual); + } + } + + @Test + public void withFieldPathSelect() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.select(new FieldPath[] {}).get().get(); + query.select(FieldPath.of("foo"), FieldPath.of("foo", "bar")).get().get(); + + Iterator expectedQuery = + Arrays.asList( + query(select(FieldPath.documentId())), query(select("foo"), select("foo.bar"))) + .iterator(); + + for (RunQueryRequest actual : runQuery.getAllValues()) { + assertEquals(expectedQuery.next(), actual); + } + } + + @Test + public void withDocumentSnapshotCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.startAt(SINGLE_FIELD_SNAPSHOT).get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + order("__name__", StructuredQuery.Direction.ASCENDING), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withDocumentIdAndDocumentSnapshotCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy(FieldPath.documentId()).startAt(SINGLE_FIELD_SNAPSHOT).get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + order("__name__", StructuredQuery.Direction.ASCENDING), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withDocumentReferenceCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + DocumentReference documentCursor = firestoreMock.document(DOCUMENT_PATH); + Value documentValue = reference(DOCUMENT_NAME); + + query.startAt(documentCursor).get(); + + RunQueryRequest queryRequest = + query(order("__name__", StructuredQuery.Direction.ASCENDING), startAt(documentValue, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withDocumentIdAndDocumentReferenceCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + DocumentReference documentCursor = firestoreMock.document(DOCUMENT_PATH); + Value documentValue = reference(DOCUMENT_NAME); + + query.orderBy(FieldPath.documentId()).startAt(documentCursor).get(); + + RunQueryRequest queryRequest = + query(order("__name__", StructuredQuery.Direction.ASCENDING), startAt(documentValue, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withExtractedDirectionForDocumentSnapshotCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo", Query.Direction.DESCENDING).startAt(SINGLE_FIELD_SNAPSHOT).get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + order("foo", Direction.DESCENDING), + order("__name__", StructuredQuery.Direction.DESCENDING), + startAt(true), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withInequalityFilterForDocumentSnapshotCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query + .whereEqualTo("a", "b") + .whereGreaterThanOrEqualTo("foo", "bar") + .whereEqualTo("c", "d") + .startAt(SINGLE_FIELD_SNAPSHOT) + .get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + filter(Operator.EQUAL, "a", "b"), + filter(Operator.GREATER_THAN_OR_EQUAL), + filter(Operator.EQUAL, "c", "d"), + order("foo", Direction.ASCENDING), + order("__name__", StructuredQuery.Direction.ASCENDING), + startAt(true), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withEqualityFilterForDocumentSnapshotCursor() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.whereEqualTo("foo", "bar").startAt(SINGLE_FIELD_SNAPSHOT).get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + filter(Operator.EQUAL), + order("__name__", StructuredQuery.Direction.ASCENDING), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withStartAt() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").orderBy(FieldPath.documentId()).startAt("bar", "doc").get().get(); + + Value documentBoundary = reference(DOCUMENT_NAME); + + RunQueryRequest queryRequest = + query( + order("foo", StructuredQuery.Direction.ASCENDING), + order("__name__", StructuredQuery.Direction.ASCENDING), + startAt(true), + startAt(documentBoundary, true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withInvalidStartAt() { + try { + query.orderBy(FieldPath.documentId()).startAt(42).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "The corresponding value for FieldPath.documentId() must be a String or a " + + "DocumentReference, but was: 42.", + e.getMessage()); + } + + try { + query.orderBy(FieldPath.documentId()).startAt("coll/doc/coll").get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Only a direct child can be used as a query boundary. Found: 'coll/coll/doc/coll'", + e.getMessage()); + } + + try { + query.orderBy(FieldPath.documentId()).startAt(firestoreMock.document("foo/bar")).get(); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "'foo/bar' is not part of the query result set and cannot be used as a query boundary.", + e.getMessage()); + } + } + + @Test + public void withStartAfter() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").startAfter("bar").get().get(); + + RunQueryRequest queryRequest = + query(order("foo", StructuredQuery.Direction.ASCENDING), startAt(false)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withEndBefore() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").endBefore("bar").get().get(); + + RunQueryRequest queryRequest = + query(order("foo", StructuredQuery.Direction.ASCENDING), endAt(true)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withEndAt() throws Exception { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.orderBy("foo").endAt("bar").get().get(); + + RunQueryRequest queryRequest = + query(order("foo", StructuredQuery.Direction.ASCENDING), endAt(false)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void withCollectionGroup() { + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + Query query = firestoreMock.collectionGroup(COLLECTION_ID); + query = query.whereGreaterThan(FieldPath.documentId(), "coll/doc"); + query = query.orderBy(FieldPath.documentId()); + query = query.endAt("coll/doc"); + query.get(); + + RunQueryRequest queryRequest = + query( + /* transactionId= */ null, + /* allDescendants= */ true, + filter(Operator.GREATER_THAN, "__name__", reference(DOCUMENT_NAME)), + order("__name__", StructuredQuery.Direction.ASCENDING), + endAt(reference(DOCUMENT_NAME), false)); + + assertEquals(queryRequest, runQuery.getValue()); + } + + @Test + public void collectionGroupCannotContainSlashes() { + try { + Query query = firestoreMock.collectionGroup("foo/bar"); + fail(); + } catch (IllegalArgumentException e) { + assertEquals( + "Invalid collectionId 'foo/bar'. Collection IDs must not contain '/'.", e.getMessage()); + } + } + + @Test(expected = IllegalStateException.class) + public void overspecifiedCursor() { + query.orderBy("foo").startAt("foo", "bar", "bar", "foo"); + } + + @Test(expected = IllegalStateException.class) + public void orderByWithCursor() { + query.startAt("foo").orderBy("foo"); + } + + @Test + public void getResult() throws Exception { + doAnswer(queryResponse(DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + QuerySnapshot result = query.get().get(); + + assertEquals(query, result.getQuery()); + + assertFalse(result.isEmpty()); + assertEquals(2, result.size()); + assertEquals(2, result.getDocuments().size()); + + Iterator docIterator = result.iterator(); + assertEquals("doc1", docIterator.next().getId()); + assertEquals("doc2", docIterator.next().getId()); + assertFalse(docIterator.hasNext()); + + Iterator changeIterator = result.getDocumentChanges().iterator(); + + DocumentChange documentChange = changeIterator.next(); + assertEquals("doc1", documentChange.getDocument().getId()); + assertEquals(DocumentChange.Type.ADDED, documentChange.getType()); + assertEquals(-1, documentChange.getOldIndex()); + assertEquals(0, documentChange.getNewIndex()); + + documentChange = changeIterator.next(); + assertEquals("doc2", documentChange.getDocument().getId()); + assertEquals(DocumentChange.Type.ADDED, documentChange.getType()); + assertEquals(-1, documentChange.getOldIndex()); + assertEquals(1, documentChange.getNewIndex()); + + assertFalse(changeIterator.hasNext()); + + assertEquals(Timestamp.ofTimeSecondsAndNanos(1, 2), result.getReadTime()); + + assertEquals( + Arrays.asList( + LocalFirestoreHelper.SINGLE_FIELD_OBJECT, LocalFirestoreHelper.SINGLE_FIELD_OBJECT), + result.toObjects(LocalFirestoreHelper.SINGLE_FIELD_OBJECT.getClass())); + + assertEquals(2, result.getDocumentChanges().size()); + } + + @Test + public void streamResult() throws Exception { + doAnswer(queryResponse(DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2").iterator(); + + query.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + } + + @Test + public void successfulReturnWithoutOnComplete() throws Exception { + doAnswer( + queryResponseWithDone( + /* callWithoutOnComplete */ true, DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2").iterator(); + + query.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + } + + @Test + /** + * onComplete() will be called twice. The first time is when it detects RunQueryResponse.done set + * to true. The second time is when it receives half close + */ + public void successfulReturnCallsOnCompleteTwice() throws Exception { + doAnswer( + queryResponseWithDone( + /* callWithoutOnComplete */ false, DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2").iterator(); + final int[] counter = {0}; + + query.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + counter[0]++; + semaphore.release(); + } + }); + + semaphore.acquire(); + + // Wait for some time to see whether onCompleted() has been called more than once + Thread.sleep(200); + assertEquals(1, counter[0]); + } + + @Test + public void retriesAfterRetryableError() throws Exception { + final boolean[] returnError = new boolean[] {true}; + + doAnswer( + invocation -> { + if (returnError[0]) { + returnError[0] = false; + return queryResponse( + FirestoreException.forServerRejection( + Status.DEADLINE_EXCEEDED, "Simulated test failure"), + DOCUMENT_NAME + "1", + DOCUMENT_NAME + "2") + .answer(invocation); + } else { + return queryResponse(DOCUMENT_NAME + "3").answer(invocation); + } + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + // Verify the responses + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2", "doc3").iterator(); + + query.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + + // Verify the requests + List requests = runQuery.getAllValues(); + assertEquals(2, requests.size()); + + assertFalse(requests.get(0).hasReadTime()); + assertFalse(requests.get(0).getStructuredQuery().hasStartAt()); + + assertEquals( + com.google.protobuf.Timestamp.newBuilder().setSeconds(1).setNanos(2).build(), + requests.get(1).getReadTime()); + assertFalse(requests.get(1).getStructuredQuery().getStartAt().getBefore()); + assertEquals( + DOCUMENT_NAME + "2", + requests.get(1).getStructuredQuery().getStartAt().getValues(0).getReferenceValue()); + } + + @Test + public void doesNotRetryAfterNonRetryableError() throws Exception { + doAnswer( + queryResponse( + FirestoreException.forServerRejection( + Status.PERMISSION_DENIED, "Simulated test failure"), + DOCUMENT_NAME + "1", + DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + // Verify the responses + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2").iterator(); + + query.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + semaphore.release(); + } + + @Override + public void onCompleted() {} + }); + + semaphore.acquire(); + + // Verify the request count + assertEquals(1, runQuery.getAllValues().size()); + } + + @Test + public void onlyRetriesWhenResultSent() throws Exception { + doAnswer( + queryResponse( + FirestoreException.forServerRejection( + Status.DEADLINE_EXCEEDED, "Simulated test failure"))) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + assertThrows(ExecutionException.class, () -> query.get().get()); + + // Verify the request count + assertEquals(1, runQuery.getAllValues().size()); + } + + @Test + public void retriesWithoutTimeout() throws Exception { + final boolean[] returnError = new boolean[] {true}; + + doAnswer( + invocation -> { + // Advance clock by an hour + clock.advance(Duration.ofHours(1).toNanos()); + + if (returnError[0]) { + returnError[0] = false; + return queryResponse( + FirestoreException.forServerRejection( + Status.DEADLINE_EXCEEDED, "Simulated test failure"), + DOCUMENT_NAME + "1") + .answer(invocation); + } else { + return queryResponse(DOCUMENT_NAME + "2").answer(invocation); + } + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + query.get().get(); + + // Verify the request count + assertEquals(2, runQuery.getAllValues().size()); + } + + @Test + public void doesNotRetryWithTimeout() { + doReturn(Duration.ofMinutes(1)).when(firestoreMock).getTotalRequestTimeoutDuration(); + + doAnswer( + invocation -> { + // Advance clock by an hour + clock.advance(Duration.ofHours(1).toNanos()); + + return queryResponse( + FirestoreException.forServerRejection( + Status.DEADLINE_EXCEEDED, "Simulated test failure"), + DOCUMENT_NAME + "1", + DOCUMENT_NAME + "2") + .answer(invocation); + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + assertThrows(ExecutionException.class, () -> query.get().get()); + + // Verify the request count + assertEquals(1, runQuery.getAllValues().size()); + } + + @Test + public void equalsTest() { + assertEquals(query.limit(42).offset(1337), query.offset(1337).limit(42)); + assertEquals(query.limit(42).offset(1337).hashCode(), query.offset(1337).limit(42).hashCode()); + } + + @Test + public void serializationTest() { + assertSerialization(query); + query = query.whereEqualTo("a", null); + assertSerialization(query); + query = query.whereEqualTo("b", Double.NaN); + assertSerialization(query); + query = query.whereGreaterThan("c", 1); + assertSerialization(query); + query = query.whereGreaterThanOrEqualTo(FieldPath.of("d", ".e."), 2); + assertSerialization(query); + query = query.whereLessThan("f", 3); + assertSerialization(query); + query = query.whereLessThanOrEqualTo(FieldPath.of("g", ".h."), 4); + assertSerialization(query); + query = query.whereIn("i", Collections.singletonList(5)); + assertSerialization(query); + query = query.whereArrayContains("j", Collections.singletonList(6)); + assertSerialization(query); + query = query.whereArrayContainsAny("k", Collections.singletonList(7)); + assertSerialization(query); + query = query.orderBy("l"); + assertSerialization(query); + query = query.orderBy(FieldPath.of("m", ".n."), Query.Direction.DESCENDING); + assertSerialization(query); + query = query.startAt("o"); + assertSerialization(query); + query = query.startAfter("p"); + assertSerialization(query); + query = query.endBefore("q"); + assertSerialization(query); + query = query.endAt("r"); + assertSerialization(query); + query = query.limit(8); + assertSerialization(query); + query = query.offset(9); + assertSerialization(query); + } + + @Test + public void serializationTestWithEmptyCompositeFilter() { + assertSerialization(query); + query.where(or()); + assertSerialization(query); + query.where(and()); + assertSerialization(query); + query.where(and(or(and(or())))); + assertSerialization(query); + } + + @Test + public void serializationTestWithSingleFilterCompositeFilters() { + // Test the special handling of a composite filter that has only 1 filter inside it. Such filter + // is equivalent to its sub-filter. For example: AND(a==10) is the same as a==10. + assertSerialization(query); + // a == 10 + query.where(or(equalTo("a", 10))); + assertSerialization(query); + + // b > 20 + query.where(and(greaterThan("b", 20))); + assertSerialization(query); + + // c == 30 + query.where(or(and(or(and(equalTo("c", 30)))))); + assertSerialization(query); + } + + @Test + public void serializationTestWithNestedCompositeFiltersOuterAnd() { + assertSerialization(query); + // a IN [1,2] + query.where(inArray("a", Arrays.asList(1, 2))); + assertSerialization(query); + // a IN [1,2] && (b==20 || c==30 || (d==40 && e>50) || f==60) + query.where( + or( + equalTo("b", 20), + equalTo("c", 30), + and(equalTo("d", 40), greaterThan("e", 50)), + and(equalTo("f", 60)), + or(and()))); + assertSerialization(query); + query = query.orderBy("l"); + assertSerialization(query); + query = query.startAt("o"); + assertSerialization(query); + query = query.startAfter("p"); + assertSerialization(query); + query = query.endBefore("q"); + assertSerialization(query); + query = query.endAt("r"); + assertSerialization(query); + query = query.limit(8); + assertSerialization(query); + query = query.offset(9); + assertSerialization(query); + } + + @Test + public void serializationTestWithNestedCompositeFiltersOuterOr() { + assertSerialization(query); + // a IN [1,2] || (b==20 && c==30 && (d==40 || e>50) && f==60) + query.where( + or( + inArray("a", Arrays.asList(1, 2)), + and( + equalTo("b", 20), + equalTo("c", 30), + or(equalTo("d", 40), greaterThan("e", 50)), + and(equalTo("f", 60)), + or(and())))); + assertSerialization(query); + query = query.orderBy("l"); + assertSerialization(query); + query = query.startAt("o"); + assertSerialization(query); + query = query.startAfter("p"); + assertSerialization(query); + query = query.endBefore("q"); + assertSerialization(query); + query = query.endAt("r"); + assertSerialization(query); + query = query.limit(8); + assertSerialization(query); + query = query.offset(9); + assertSerialization(query); + } + + private void assertSerialization(Query query) { + RunQueryRequest runQueryRequest = query.toProto(); + Query deserializedQuery = Query.fromProto(firestoreMock, runQueryRequest); + assertEquals(runQueryRequest, deserializedQuery.toProto()); + assertEquals(deserializedQuery, query); + } + + @Test + public void serializationVerifiesDatabaseName() { + RunQueryRequest runQueryRequest = query.toProto(); + runQueryRequest = + runQueryRequest.toBuilder().setParent("projects/foo/databases/(default)/documents").build(); + + try { + Query.fromProto(firestoreMock, runQueryRequest); + fail("Expected serializtion error"); + } catch (IllegalArgumentException e) { + assertEquals( + "Cannot deserialize query from different Firestore project " + + "(\"projects/test-project/databases/(default)\" vs " + + "\"projects/foo/databases/(default)\")", + e.getMessage()); + } + } + + @Test + public void ensureFromProtoWorksWithAProxy() throws InvalidProtocolBufferException { + Object o = + Proxy.newProxyInstance( + QueryTest.class.getClassLoader(), + new Class[] {Firestore.class, FirestoreRpcContext.class}, + (proxy, method, args) -> { + // use the reflection lookup of the method name so intellij will refactor it along + // with the method name if it ever happens. + Method getDatabaseNameMethod = + FirestoreRpcContext.class.getDeclaredMethod("getDatabaseName"); + if (method.equals(getDatabaseNameMethod)) { + return "projects/test-project/databases/(default)"; + } else { + return null; + } + }); + + assertTrue(o instanceof Firestore); + assertTrue(o instanceof FirestoreRpcContext); + + // Code used to generate the below base64 encoded RunQueryRequest + // RunQueryRequest proto = firestoreMock.collection("testing-collection") + // .whereEqualTo("enabled", true).toProto(); + // String base64String = BaseEncoding.base64().encode(proto.toByteArray()); + String base64Proto = + "CjNwcm9qZWN0cy90ZXN0LXByb2plY3QvZGF0YWJhc2VzLyhkZWZhdWx0KS9kb2N1bWVudHMSKxIUEhJ0ZXN0aW5nLWNvbGxlY3Rpb24aExIRCgkSB2VuYWJsZWQQBRoCCAE="; + + byte[] bytes = BaseEncoding.base64().decode(base64Proto); + RunQueryRequest runQueryRequest = RunQueryRequest.parseFrom(bytes); + + Query query = Query.fromProto((Firestore) o, runQueryRequest); + ResourcePath path = query.options.getParentPath(); + assertEquals("projects/test-project/databases/(default)/documents", path.getName()); + assertEquals("testing-collection", query.options.getCollectionId()); + FilterInternal next = query.options.getFilters().iterator().next(); + assertTrue(next instanceof ComparisonFilterInternal); + ComparisonFilterInternal comparisonFilter = (ComparisonFilterInternal) next; + assertEquals("enabled", comparisonFilter.fieldReference.getFieldPath()); + assertFalse(comparisonFilter.isInequalityFilter()); + assertEquals(Value.newBuilder().setBooleanValue(true).build(), comparisonFilter.value); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyOnCharacters() { + Query query_ = + query + .whereLessThan("a", "value") + .whereGreaterThanOrEqualTo("a", "value") + .whereGreaterThan("aa", "value") + .whereGreaterThan("b", "value") + .whereGreaterThan("A", "value"); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("A", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("aa", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("b", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyOnCharactersAndNumbers() { + Query query_ = + query + .whereLessThan("a", "value") + .whereGreaterThan("1", "value") + .whereGreaterThan("19", "value") + .whereGreaterThan("2", "value"); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("1", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("19", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("2", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyOnNestedFields() { + Query query_ = + query + .whereLessThan("a", "value") + .whereGreaterThan("aa", "value") + .whereGreaterThan("a.a", "value"); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a.a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("aa", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyOnSpecialCharacters() { + Query query_ = + query + .whereLessThan("a", "value") + .whereGreaterThan("_a", "value") + .whereGreaterThan("a.a", "value"); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("_a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a.a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyOnFieldNameWithDot() { + Query query_ = + query + .whereLessThan("a", "value") + .whereGreaterThan(FieldPath.of("a.a"), "value") + .whereGreaterThan("a.z", "value"); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a.z", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("`a.a`", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyInCompositeFilter() { + Query query_ = + query.where( + and( + lessThan("a", "value"), + and( + or(greaterThanOrEqualTo("b", "value"), lessThanOrEqualTo("c", "value")), + or(greaterThan("d", "value"), equalTo("e", "value"))))); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("b", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("c", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("d", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void inequalityFiltersImplicitlyOrderedLexicographicallyWithExplicitOrderBys() { + Query query_ = + query + .whereLessThan("b", "value") + .whereGreaterThan("a", "value") + .whereGreaterThan("z", "value") + .orderBy("z", Query.Direction.ASCENDING); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("z", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("b", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void + inequalityFiltersImplicitlyOrderedLexicographicallyFollowingExplicitOrderByDirection() { + Query query_ = + query + .whereLessThan("b", "value") + .whereGreaterThan("a", "value") + .orderBy("z", Query.Direction.DESCENDING); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("z", Query.Direction.DESCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.DESCENDING)); + orderFields.add(new FieldOrder("b", Query.Direction.DESCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.DESCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } + + @Test + public void + inequalityFiltersImplicitlyOrderedLexicographicallyFollowingLastExplicitOrderByDirection() { + Query query_ = + query + .whereLessThan("b", "value") + .whereGreaterThan("a", "value") + .orderBy("z", Query.Direction.DESCENDING) + .orderBy("c", Query.Direction.ASCENDING); + + List orderFields = new ArrayList<>(); + orderFields.add(new FieldOrder("z", Query.Direction.DESCENDING)); + orderFields.add(new FieldOrder("c", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("a", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder("b", Query.Direction.ASCENDING)); + orderFields.add(new FieldOrder(FieldPath.documentId().toProto(), Query.Direction.ASCENDING)); + + assertEquals(orderFields, query_.createImplicitOrderBy()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RateLimiterTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RateLimiterTest.java new file mode 100644 index 000000000000..afc487435305 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RateLimiterTest.java @@ -0,0 +1,116 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.util.Date; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class RateLimiterTest { + private RateLimiter limiter; + + @Before + public void before() { + limiter = + new RateLimiter( + /* initialCapacity= */ 500, + /* multiplier= */ 1.5, + /* multiplierMillis= */ 5 * 60 * 1000, + /* maximumCapacity= */ 1000000, + /* startTime= */ new Date(0).getTime()); + } + + @Test + public void processRequestsFromCapacity() { + assertTrue(limiter.tryMakeRequest(250, new Date(0).getTime())); + assertTrue(limiter.tryMakeRequest(250, new Date(0).getTime())); + + // Once tokens have been used, further requests should fail. + assertFalse(limiter.tryMakeRequest(1, new Date(0).getTime())); + + // Tokens will only refill up to max capacity. + assertFalse(limiter.tryMakeRequest(501, new Date(1 * 1000).getTime())); + assertTrue(limiter.tryMakeRequest(500, new Date(1 * 1000).getTime())); + + // Tokens will refill incrementally based on number of ms elapsed. + assertFalse(limiter.tryMakeRequest(250, new Date(1 * 1000 + 499).getTime())); + assertTrue(limiter.tryMakeRequest(249, new Date(1 * 1000 + 500).getTime())); + + // Scales with multiplier. + assertFalse(limiter.tryMakeRequest(751, new Date((5 * 60 - 1) * 1000).getTime())); + assertFalse(limiter.tryMakeRequest(751, new Date(5 * 60 * 1000).getTime())); + assertTrue(limiter.tryMakeRequest(750, new Date(5 * 60 * 1000).getTime())); + + // Tokens will never exceed capacity. + assertFalse(limiter.tryMakeRequest(751, new Date((5 * 60 + 3) * 1000).getTime())); + + // Rejects requests made before lastRefillTime. + try { + limiter.tryMakeRequest(751, new Date((5 * 60 + 2) * 1000).getTime()); + fail(); + } catch (IllegalArgumentException e) { + assertEquals("Request time should not be before the last token refill time", e.getMessage()); + } + } + + @Test + public void calculatesMsForNextRequest() { + // Should return 0 if there are enough tokens for the request to be made. + long timestamp = new Date(0).getTime(); + assertEquals(0, limiter.getNextRequestDelayMs(500, timestamp)); + + // Should factor in remaining tokens when calculating the time. + assertTrue(limiter.tryMakeRequest(250, timestamp)); + assertEquals(500, limiter.getNextRequestDelayMs(500, timestamp)); + + // Once tokens have been used, should calculate time before next request. + timestamp = new Date(1 * 1000).getTime(); + assertTrue(limiter.tryMakeRequest(500, timestamp)); + assertEquals(200, limiter.getNextRequestDelayMs(100, timestamp)); + assertEquals(500, limiter.getNextRequestDelayMs(250, timestamp)); + assertEquals(1000, limiter.getNextRequestDelayMs(500, timestamp)); + assertEquals(-1, limiter.getNextRequestDelayMs(501, timestamp)); + + // Scales with multiplier. + timestamp = new Date(5 * 60 * 1000).getTime(); + assertTrue(limiter.tryMakeRequest(750, timestamp)); + assertEquals(334, limiter.getNextRequestDelayMs(250, timestamp)); + assertEquals(667, limiter.getNextRequestDelayMs(500, timestamp)); + assertEquals(1000, limiter.getNextRequestDelayMs(750, timestamp)); + assertEquals(-1, limiter.getNextRequestDelayMs(751, timestamp)); + } + + @Test + public void calculatesMaxOperations() { + assertEquals(500, limiter.calculateCapacity(new Date(0).getTime())); + assertEquals(750, limiter.calculateCapacity(new Date(5 * 60 * 1000).getTime())); + assertEquals(1125, limiter.calculateCapacity(new Date(10 * 60 * 1000).getTime())); + assertEquals(1687, limiter.calculateCapacity(new Date(15 * 60 * 1000).getTime())); + assertEquals(738945, limiter.calculateCapacity(new Date(90 * 60 * 1000).getTime())); + + // Check that maximum rate limit is enforced. + assertEquals(1000000, limiter.calculateCapacity(new Date(1000 * 60 * 1000).getTime())); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RecursiveDeleteTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RecursiveDeleteTest.java new file mode 100644 index 000000000000..9d144cb15ce0 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/RecursiveDeleteTest.java @@ -0,0 +1,709 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.BulkWriterTest.failedResponse; +import static com.google.cloud.firestore.BulkWriterTest.mergeResponses; +import static com.google.cloud.firestore.BulkWriterTest.successResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.COLLECTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.DATABASE_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_ROOT; +import static com.google.cloud.firestore.LocalFirestoreHelper.batchWrite; +import static com.google.cloud.firestore.LocalFirestoreHelper.delete; +import static com.google.cloud.firestore.LocalFirestoreHelper.emptyQueryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.filter; +import static com.google.cloud.firestore.LocalFirestoreHelper.limit; +import static com.google.cloud.firestore.LocalFirestoreHelper.order; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.reference; +import static com.google.cloud.firestore.LocalFirestoreHelper.select; +import static com.google.cloud.firestore.LocalFirestoreHelper.startAt; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.lenient; + +import com.google.api.core.ApiAsyncFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.firestore.LocalFirestoreHelper.ResponseStubber; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredQuery.Direction; +import com.google.firestore.v1.StructuredQuery.FieldFilter.Operator; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import io.grpc.Status; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.stubbing.Answer; + +@RunWith(MockitoJUnitRunner.class) +public class RecursiveDeleteTest { + @Rule public Timeout timeout = new Timeout(10, TimeUnit.SECONDS); + + @Spy private final FirestoreRpc firestoreRpc = Mockito.mock(FirestoreRpc.class); + + /** Executor that executes delayed tasks without delay. */ + private final ScheduledExecutorService immediateExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), firestoreRpc); + + @Captor private ArgumentCaptor batchWriteCapture; + @Captor private ArgumentCaptor runQueryCapture; + @Captor private ArgumentCaptor> streamObserverCapture; + + private BulkWriter bulkWriter; + private ResponseStubber responseStubber; + + @Before + public void before() { + lenient().doReturn(immediateExecutor).when(firestoreRpc).getExecutor(); + + final ScheduledExecutorService timeoutExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + } + + private Value recursiveDeleteStartAt(String name) { + return Value.newBuilder() + .setReferenceValue( + DATABASE_NAME + "/documents/" + name + "/" + RecursiveDelete.REFERENCE_NAME_MIN_ID) + .build(); + } + + private Value recursiveDeleteEndAt(String name) { + return Value.newBuilder() + .setReferenceValue( + DOCUMENT_ROOT + name + '\0' + "/" + RecursiveDelete.REFERENCE_NAME_MIN_ID) + .build(); + } + + private String fullDocumentPath(String name) { + return DOCUMENT_ROOT + COLLECTION_ID + "/" + name; + } + + private void setupMocks(List childrenDocuments) throws Exception { + setupMocks(childrenDocuments, /* deleteDocRef= */ ""); + } + + private void setupMocks(List childrenDocuments, String deleteDocRef) throws Exception { + setupMocks(childrenDocuments, deleteDocRef, null); + } + + private void setupMocks( + List childrenDocuments, + final String deleteDocRef, + @Nullable final ApiFuture customResponse) + throws Exception { + + List fullDocumentPaths = new ArrayList<>(); + for (String documentName : childrenDocuments) { + fullDocumentPaths.add(fullDocumentPath(documentName)); + } + + doAnswer(queryResponse(fullDocumentPaths.toArray(new String[0]))) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + if (!deleteDocRef.equals("")) { + childrenDocuments = new ArrayList<>(childrenDocuments); + childrenDocuments.add(deleteDocRef); + } + + final List expectedRequests = new ArrayList<>(); + final List> returnedResponse = new ArrayList<>(); + for (String documentPath : childrenDocuments) { + expectedRequests.add(delete(COLLECTION_ID + "/" + documentPath)); + returnedResponse.add(successResponse(1)); + } + + final ApiFuture finalResponse = + customResponse != null + ? customResponse + : mergeResponses(returnedResponse.toArray(new ApiFuture[0])); + + responseStubber = + new ResponseStubber() { + { + put(batchWrite(expectedRequests.toArray(new Write[0])), finalResponse); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + } + + @Test + public void getAllDescendantsRootLevelCollection() throws Exception { + doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + RunQueryRequest expectedRequest = + query( + null, + /* allDescendants= */ true, + /* kindless= */ true, + select(FieldPath.documentId()), + filter( + Operator.GREATER_THAN_OR_EQUAL, + FieldPath.documentId().toString(), + recursiveDeleteStartAt("root")), + filter( + Operator.LESS_THAN, + FieldPath.documentId().toString(), + recursiveDeleteEndAt("root")), + limit(RecursiveDelete.MAX_PENDING_OPS)); + + firestoreMock.recursiveDelete(firestoreMock.collection("root")).get(); + assertEquals(expectedRequest, runQueryCapture.getValue()); + } + + @Test + public void getAllDescendantsNestedCollection() throws Exception { + doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + RunQueryRequest expectedRequest = + query( + null, + /* parent= */ "root/doc", + /* allDescendants= */ true, + /* kindless= */ true, + select(FieldPath.documentId()), + filter( + Operator.GREATER_THAN_OR_EQUAL, + FieldPath.documentId().toString(), + recursiveDeleteStartAt("root/doc/nestedCol")), + filter( + Operator.LESS_THAN, + FieldPath.documentId().toString(), + recursiveDeleteEndAt("root/doc/nestedCol")), + limit(RecursiveDelete.MAX_PENDING_OPS)); + + firestoreMock.recursiveDelete(firestoreMock.collection("root/doc/nestedCol")).get(); + assertEquals(expectedRequest, runQueryCapture.getValue()); + } + + @Test + public void getAllDescendantsDocument() throws Exception { + doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + // Include dummy response for the deleted fullDocumentPath reference. + doAnswer((Answer>) mock -> successResponse(1)) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + RunQueryRequest expectedRequest = + query( + null, + /* parent= */ "root/doc", + /* allDescendants= */ true, + /* kindless= */ true, + select(FieldPath.documentId()), + limit(RecursiveDelete.MAX_PENDING_OPS)); + + firestoreMock.recursiveDelete(firestoreMock.document("root/doc")).get(); + assertEquals(expectedRequest, runQueryCapture.getValue()); + } + + @Test + public void createsRetryQueryAfterStreamExceptionWithLastReceivedDoc() throws Exception { + doAnswer( + queryResponse( + new FirestoreException("Mock runQuery() failed in test", Status.UNAVAILABLE), + fullDocumentPath(("doc1")))) + .doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + doAnswer(mock -> successResponse(1)) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + RunQueryRequest expectedRequest = + query( + null, + /* allDescendants= */ true, + /* kindless= */ true, + select(FieldPath.documentId()), + order(FieldPath.documentId(), Direction.ASCENDING), + startAt(reference(fullDocumentPath("doc1")), /* before= */ false), + filter( + Operator.GREATER_THAN_OR_EQUAL, + FieldPath.documentId().toString(), + recursiveDeleteStartAt("coll")), + filter( + Operator.LESS_THAN, + FieldPath.documentId().toString(), + recursiveDeleteEndAt("coll")), + limit(RecursiveDelete.MAX_PENDING_OPS)); + + firestoreMock.recursiveDelete(firestoreMock.collection("coll")).get(); + assertEquals(expectedRequest, runQueryCapture.getAllValues().get(1)); + } + + @Test + @Ignore("b/323498886") + public void createsSecondQueryWithCorrectStartAfter() throws Exception { + // This test checks that the second query is created with the correct startAfter() once the + // RecursiveDelete instance is below the MIN_PENDING_OPS threshold to send the next batch. + + // Use lower limits than the actual RecursiveDelete class in order to make this test run fast. + int maxPendingOps = 100; + int minPendingOps = 11; + int maxBatchSize = 10; + + final int cutoff = maxPendingOps - minPendingOps; + final int[] numDeletesBuffered = {0}; + + // This future is used to delay the BatchWriteResponses from returning in order to create the + // situation where the number of pending operations is less than `minPendingOps`. + final SettableApiFuture bufferFuture = SettableApiFuture.create(); + + // This future completes when the second query is run. + final SettableApiFuture secondQueryFuture = SettableApiFuture.create(); + + List firstStream = new ArrayList<>(); + final List> batchWriteResponse = new ArrayList<>(); + for (int i = 0; i < maxPendingOps; i++) { + firstStream.add(fullDocumentPath("doc" + i)); + } + + for (int i = 0; i < maxBatchSize; i++) { + batchWriteResponse.add(successResponse(1)); + } + + doAnswer(queryResponse(firstStream.toArray(new String[0]))) + .doAnswer( + invocation -> { + secondQueryFuture.set(null); + Object[] args = invocation.getArguments(); + ResponseObserver observer = + (ResponseObserver) args[1]; + observer.onComplete(); + return null; + }) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + doAnswer( + mock -> { + if (numDeletesBuffered[0] < cutoff) { + numDeletesBuffered[0] += batchWriteResponse.size(); + // By waiting for `bufferFuture` to complete, we can guarantee that the writes + // complete after all documents are streamed. Without this future, the test can + // race and complete the writes before the stream is finished, which is a + // different scenario this test is not for. + return ApiFutures.transformAsync( + bufferFuture, + (ApiAsyncFunction) + unused -> mergeResponses(batchWriteResponse.toArray(new ApiFuture[0])), + MoreExecutors.directExecutor()); + } else { + // Once there are `cutoff` pending deletes, completing the future allows enough + // responses to be returned such that the number of pending deletes should be + // less than `minPendingOps`. This allows us to test that the second query is + // made. + bufferFuture.set(null); + return ApiFutures.transformAsync( + secondQueryFuture, + (ApiAsyncFunction) + unused -> mergeResponses(batchWriteResponse.toArray(new ApiFuture[0])), + MoreExecutors.directExecutor()); + } + }) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + BulkWriter bulkWriter = firestoreMock.bulkWriter(); + bulkWriter.setMaxBatchSize(maxBatchSize); + + RunQueryRequest expectedRequest = + query( + null, + /* allDescendants= */ true, + /* kindless= */ true, + select(FieldPath.documentId()), + order(FieldPath.documentId(), Direction.ASCENDING), + startAt(reference(fullDocumentPath("doc" + (maxPendingOps - 1))), /* before= */ false), + filter( + Operator.GREATER_THAN_OR_EQUAL, + FieldPath.documentId().toString(), + recursiveDeleteStartAt("coll")), + filter( + Operator.LESS_THAN, + FieldPath.documentId().toString(), + recursiveDeleteEndAt("coll")), + limit(maxPendingOps)); + + firestoreMock + .recursiveDelete( + firestoreMock.collection("coll").getResourcePath(), + bulkWriter, + maxPendingOps, + minPendingOps) + .get(); + assertEquals(2, runQueryCapture.getAllValues().size()); + assertEquals(expectedRequest, runQueryCapture.getAllValues().get(1)); + } + + @Test + public void deletesCollection() throws Exception { + List documents = + Arrays.asList("anna", "bob", "bob/children/charlie", "bob/children/daniel"); + setupMocks(documents); + firestoreMock.recursiveDelete(firestoreMock.collection(COLLECTION_ID)).get(); + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void deletesDocumentAndReference() throws Exception { + List documents = + Arrays.asList("bob/children/brian", "bob/children/charlie", "bob/children/daniel"); + setupMocks(documents, "bob"); + firestoreMock.recursiveDelete(firestoreMock.collection(COLLECTION_ID).document("bob")).get(); + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void exceptionContainsLastErrorCodeIfWritesFail() throws Exception { + List documents = + Arrays.asList("bob/children/brian", "bob/children/charlie", "bob/children/daniel"); + ApiFuture customResponse = + mergeResponses( + successResponse(1), + failedResponse(Code.CANCELLED_VALUE), + failedResponse(Code.PERMISSION_DENIED_VALUE), + successResponse(1)); + setupMocks(documents, "bob", customResponse); + try { + ApiFuture future = + firestoreMock.recursiveDelete(firestoreMock.collection(COLLECTION_ID).document("bob")); + future.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertEquals(Status.PERMISSION_DENIED, ((FirestoreException) e.getCause()).getStatus()); + assertTrue(e.getMessage().contains("2 deletes failed")); + } + } + + @Test + public void exceptionThrownIfBulkWriterSuccessHandlerFails() throws Exception { + List documents = Arrays.asList("bob/children/brian"); + setupMocks(documents, "bob"); + bulkWriter = firestoreMock.bulkWriter(); + bulkWriter.addWriteResultListener( + (documentReference, result) -> { + throw new UnsupportedOperationException("Test code threw UnsupportedOperationException"); + }); + try { + ApiFuture future = + firestoreMock.recursiveDelete( + firestoreMock.collection(COLLECTION_ID).document("bob"), bulkWriter); + future.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("2 deletes failed")); + } + } + + @Test + public void successHandlerProvidesCorrectReferencesAndResults() throws Exception { + List documents = Arrays.asList("bob/children/brian", "bob/children/charlie"); + ApiFuture customResponse = + mergeResponses(successResponse(1), successResponse(2), successResponse(3)); + setupMocks(documents, "bob", customResponse); + + final List results = new ArrayList<>(); + final List references = new ArrayList<>(); + bulkWriter = firestoreMock.bulkWriter(); + bulkWriter.addWriteResultListener( + (documentReference, result) -> { + results.add((int) result.getUpdateTime().getSeconds()); + references.add(documentReference.getPath()); + }); + ApiFuture future = + firestoreMock.recursiveDelete( + firestoreMock.collection(COLLECTION_ID).document("bob"), bulkWriter); + future.get(); + assertArrayEquals(new Integer[] {1, 2, 3}, results.toArray()); + assertArrayEquals( + new String[] { + "coll/bob/children/brian", "coll/bob/children/charlie", "coll/bob", + }, + references.toArray()); + } + + @Test + public void errorHandlerProvidesCorrectInformation() throws Exception { + List documents = Arrays.asList("bob/children/brian", "bob/children/charlie"); + ApiFuture customResponse = + mergeResponses( + failedResponse(Code.PERMISSION_DENIED_VALUE), + failedResponse(Code.UNAVAILABLE_VALUE), + failedResponse(Code.INTERNAL_VALUE)); + setupMocks(documents, "bob", customResponse); + + final List codes = new ArrayList<>(); + final List references = new ArrayList<>(); + bulkWriter = firestoreMock.bulkWriter(); + bulkWriter.addWriteErrorListener( + error -> { + codes.add(error.getStatus()); + references.add(error.getDocumentReference().getPath()); + return false; + }); + ApiFuture future = + firestoreMock.recursiveDelete( + firestoreMock.collection(COLLECTION_ID).document("bob"), bulkWriter); + try { + future.get(); + fail("Operation should have failed"); + } catch (Exception e) { + assertArrayEquals( + new Status[] {Status.PERMISSION_DENIED, Status.UNAVAILABLE, Status.INTERNAL}, + codes.toArray()); + assertArrayEquals( + new String[] { + "coll/bob/children/brian", "coll/bob/children/charlie", "coll/bob", + }, + references.toArray()); + } + } + + @Test + public void exceptionThrownIfProvidedReferenceWasNotDeleted() throws Exception { + doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + doReturn(BulkWriterTest.FAILED_FUTURE) + .when(firestoreMock) + .sendRequest( + batchWriteCapture.capture(), + ArgumentMatchers.>any()); + + ApiFuture future = firestoreMock.recursiveDelete(firestoreMock.document("root/doc")); + try { + future.get(); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Mock batchWrite failed in test")); + } + } + + @Test + public void handlesSuccessfulStreamErrorRetries() throws Exception { + FirestoreException mockException = + new FirestoreException("runQuery() failed in test", Status.UNAVAILABLE); + // Note that these mock responses differ from the Node implementation since Node retries + // queries that fail without streaming any documents in the SDK, whereas Java handles these + // retries at the GAX level. The Java SDK does not retry unless a document was streamed in the + // query. + final List> runQueryResponses = + new ArrayList<>( + Arrays.asList( + queryResponse(mockException, fullDocumentPath("a"), fullDocumentPath("b")), + queryResponse(mockException, fullDocumentPath("c")), + queryResponse(mockException, fullDocumentPath("d")), + queryResponse(fullDocumentPath("e")))); + + doAnswer(runQueryResponses.get(0)) + .doAnswer(runQueryResponses.get(1)) + .doAnswer(runQueryResponses.get(2)) + .doAnswer(runQueryResponses.get(3)) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + ResponseStubber responseStubber = + new ResponseStubber() { + { + put( + batchWrite( + delete("coll/a"), + delete("coll/b"), + delete("coll/c"), + delete("coll/d"), + delete("coll/e")), + mergeResponses( + successResponse(1), + successResponse(1), + successResponse(1), + successResponse(1), + successResponse(1))); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + firestoreMock.recursiveDelete(firestoreMock.collection(COLLECTION_ID)).get(); + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void handlesMultipleCallsToRecursiveDelete() throws Exception { + final List> runQueryResponses = + new ArrayList<>( + Arrays.asList( + queryResponse(fullDocumentPath("a")), + queryResponse(fullDocumentPath("b")), + queryResponse(fullDocumentPath("c")))); + + doAnswer(runQueryResponses.get(0)) + .doAnswer(runQueryResponses.get(1)) + .doAnswer(runQueryResponses.get(2)) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + ResponseStubber responseStubber = + new ResponseStubber() { + { + put(batchWrite(delete("coll/a")), successResponse(1)); + put(batchWrite(delete("coll/b")), successResponse(2)); + put(batchWrite(delete("coll/c")), successResponse(3)); + } + }; + responseStubber.initializeStub(batchWriteCapture, firestoreMock); + + firestoreMock.recursiveDelete(firestoreMock.collection("a")).get(); + firestoreMock.recursiveDelete(firestoreMock.collection("b")).get(); + firestoreMock.recursiveDelete(firestoreMock.collection("c")).get(); + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void usesSameBulkWriterInstanceAcrossCalls() throws Exception { + doAnswer(emptyQueryResponse()) + .when(firestoreMock) + .streamRequest( + runQueryCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + final int[] callCount = {0}; + final BulkWriter bulkWriter = firestoreMock.bulkWriter(); + doAnswer( + mock -> { + callCount[0]++; + return bulkWriter; + }) + .when(firestoreMock) + .bulkWriter(); + + firestoreMock.recursiveDelete(firestoreMock.collection("foo")).get(); + firestoreMock.recursiveDelete(firestoreMock.collection("boo")).get(); + firestoreMock.recursiveDelete(firestoreMock.collection("moo")).get(); + + // Only the first recursiveDelete() call should have called the constructor. Subsequent calls + // should have used the same bulkWriter. + assertEquals(1, callCount[0]); + } + + @Test + public void throwsErrorIfBulkWriterInstanceIsClosed() throws Exception { + bulkWriter = firestoreMock.bulkWriter(); + bulkWriter.close(); + try { + firestoreMock.recursiveDelete(firestoreMock.collection("foo"), bulkWriter); + fail("Operation should have failed in test"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("BulkWriter has already been closed")); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/SilenceableBidiStreamTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/SilenceableBidiStreamTest.java new file mode 100644 index 000000000000..948d8035f381 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/SilenceableBidiStreamTest.java @@ -0,0 +1,178 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertWithMessage; + +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.StreamController; +import java.util.function.Consumer; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class SilenceableBidiStreamTest { + + @Mock BidiStreamObserver mockObserver; + + @Mock ClientStream mockClientStream; + + SilenceableBidiStream sut; + + @Before + public void before() { + Consumer captureCall = Mockito.mock(Consumer.class); + sut = + new SilenceableBidiStream<>( + mockObserver, + o -> { + captureCall.accept(o); + return mockClientStream; + }); + // The lambda should pass itself as parameter + Mockito.verify(captureCall).accept(sut); + } + + @Test + public void byDefault_theStreamWillPassThroughData_onComplete() { + sut.onComplete(); + Mockito.verify(mockObserver, Mockito.times(1)).onComplete(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void byDefault_theStreamWillPassThroughData_onError() { + Exception e = new Exception("Something bad"); + sut.onError(e); + Mockito.verify(mockObserver, Mockito.times(1)).onError(e); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void byDefault_theStreamWillPassThroughData_onResponse() { + sut.onResponse("ABC"); + Mockito.verify(mockObserver, Mockito.times(1)).onResponse("ABC"); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void byDefault_theStreamWillPassThroughData_onStart() { + StreamController controller = Mockito.mock(StreamController.class); + sut.onStart(controller); + Mockito.verify(mockObserver, Mockito.times(1)).onStart(controller); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver, controller); + } + + @Test + public void byDefault_theStreamWillPassThroughData_onReady() { + ClientStream client = Mockito.mock(ClientStream.class); + sut.onReady(client); + Mockito.verify(mockObserver, Mockito.times(1)).onReady(client); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver, client); + } + + @Test + public void byDefault_theStreamWillPassThroughData_send() { + sut.send(7); + Mockito.verify(mockClientStream, Mockito.times(1)).send(7); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void closeMethod() { + assertWithMessage("Expect isSilenced() to be false by default") + .that(sut.isSilenced()) + .isFalse(); + sut.closeSend(); + assertWithMessage("Expect isSilenced() to be unaffected after close()") + .that(sut.isSilenced()) + .isFalse(); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void closeAndSilenceMethod() { + assertWithMessage("Expect isSilenced() to be false by default") + .that(sut.isSilenced()) + .isFalse(); + sut.closeSendAndSilence(); + assertWithMessage("Expect isSilenced() to be true after closeAndSilence()") + .that(sut.isSilenced()) + .isTrue(); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterClose_theStreamWillPassThroughData_onComplete() { + sut.closeSend(); + sut.onComplete(); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verify(mockObserver, Mockito.times(1)).onComplete(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterClose_theStreamWillPassThroughData_onError() { + Exception e = new Exception("Something bad"); + sut.closeSend(); + sut.onError(e); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verify(mockObserver, Mockito.times(1)).onError(e); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterClose_theStreamWillPassThroughData_onResponse() { + sut.closeSend(); + sut.onResponse("ABC"); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verify(mockObserver, Mockito.times(1)).onResponse("ABC"); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterCloseAndSilence_theStreamWillPassThroughData_onComplete() { + sut.closeSendAndSilence(); + sut.onComplete(); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterCloseAndSilence_theStreamWillPassThroughData_onError() { + Exception e = new Exception("Something bad"); + sut.closeSendAndSilence(); + sut.onError(e); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } + + @Test + public void afterCloseAndSilence_theStreamWillPassThroughData_onResponse() { + sut.closeSendAndSilence(); + sut.onResponse("ABC"); + Mockito.verify(mockClientStream, Mockito.times(1)).closeSend(); + Mockito.verifyNoMoreInteractions(mockClientStream, mockObserver); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TestUtil.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TestUtil.java new file mode 100644 index 000000000000..7bb671c1d2d8 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TestUtil.java @@ -0,0 +1,40 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import com.google.firestore.v1.Value; +import java.util.HashMap; +import java.util.Map; + +public final class TestUtil { + public static Map getAggregateSnapshotData(AggregateQuerySnapshot snapshot) { + Map result = new HashMap<>(); + for (Map.Entry entry : snapshot.getData().entrySet()) { + if (entry.getValue().hasIntegerValue()) { + result.put(entry.getKey(), entry.getValue().getIntegerValue()); + } else if (entry.getValue().hasDoubleValue()) { + result.put(entry.getKey(), entry.getValue().getDoubleValue()); + } else if (entry.getValue().hasNullValue()) { + result.put(entry.getKey(), null); + } else { + throw new IllegalArgumentException("AggregateSnapshot has unrecognized value type"); + } + } + + return result; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ToStringTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ToStringTest.java new file mode 100644 index 000000000000..dfeb883ce9c2 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/ToStringTest.java @@ -0,0 +1,112 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.encoding.CustomClassMapper; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.Value; +import java.util.Collections; +import java.util.Map; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +/** + * @author Eran Leshem + */ +@RunWith(MockitoJUnitRunner.class) +public class ToStringTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + private WriteBatch batch; + private DocumentReference documentReference; + + @Before + public void before() { + batch = firestoreMock.batch(); + documentReference = firestoreMock.document("coll/doc"); + } + + @Test + public void testDocumentSnapshot() { + Map fields = + Collections.singletonMap( + "key123", + UserDataConverter.encodeValue( + FieldPath.of("key456"), + CustomClassMapper.convertToPlainJavaTypes("value789"), + UserDataConverter.NO_DELETES)); + String toStringResult = + new DocumentSnapshot( + null, + documentReference, + fields, + Timestamp.ofTimeMicroseconds(1), + Timestamp.ofTimeMicroseconds(2), + Timestamp.ofTimeMicroseconds(3)) + .toString(); + assertThat(toStringResult).startsWith("DocumentSnapshot{"); + assertThat(toStringResult).containsMatch("doc=DocumentReference\\{path=.*/documents/coll/doc}"); + assertThat(toStringResult).containsMatch("(?s)fields=\\{key123=string_value:.*value789.*}"); + assertThat(toStringResult).contains("readTime=1970-01-01T00:00:00.000001000Z"); + assertThat(toStringResult).contains("updateTime=1970-01-01T00:00:00.000002000Z"); + assertThat(toStringResult).contains("createTime=1970-01-01T00:00:00.000003000Z"); + assertThat(toStringResult).endsWith("}"); + } + + @Test + public void testWriteOperation() { + String toStringResult = + new UpdateBuilder.WriteOperation( + documentReference, + DocumentSnapshot.fromObject( + null, + documentReference, + Collections.singletonMap("key", "value"), + UserDataConverter.NO_DELETES) + .toPb() + .build()) + .toString(); + assertThat(toStringResult).startsWith("WriteOperation{"); + assertThat(toStringResult) + .containsMatch("(?s)write=update\\s*\\{\\s*name:.*/documents/coll/doc.*}"); + assertThat(toStringResult).containsMatch("doc=DocumentReference\\{path=.*/documents/coll/doc}"); + assertThat(toStringResult).endsWith("}"); + } + + @Test + public void testWriteBatch() { + batch.update(documentReference, Collections.singletonMap("key", "value")); + String toStringResult = batch.toString(); + assertThat(toStringResult).startsWith("WriteBatch{"); + assertThat(toStringResult) + .containsMatch("(?s)writes=\\[WriteOperation\\{write=update.*/documents/coll/doc.*}]"); + assertThat(toStringResult).contains("committed=false"); + assertThat(toStringResult).endsWith("}"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TransactionTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TransactionTest.java new file mode 100644 index 000000000000..6c21b990c021 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/TransactionTest.java @@ -0,0 +1,1007 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.api.core.ApiFutures.immediateFailedFuture; +import static com.google.cloud.firestore.LocalFirestoreHelper.IMMEDIATE_RETRY_SETTINGS; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.TRANSACTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.begin; +import static com.google.cloud.firestore.LocalFirestoreHelper.beginResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.commit; +import static com.google.cloud.firestore.LocalFirestoreHelper.commitResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.countQuery; +import static com.google.cloud.firestore.LocalFirestoreHelper.countQueryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.create; +import static com.google.cloud.firestore.LocalFirestoreHelper.delete; +import static com.google.cloud.firestore.LocalFirestoreHelper.get; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAll; +import static com.google.cloud.firestore.LocalFirestoreHelper.getAllResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.rollback; +import static com.google.cloud.firestore.LocalFirestoreHelper.rollbackResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.set; +import static com.google.cloud.firestore.LocalFirestoreHelper.update; +import static com.google.cloud.firestore.it.ITQueryTest.map; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ResponseObserver; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.LocalFirestoreHelper.ResponseStubber; +import com.google.cloud.firestore.TransactionOptions.ReadOnlyOptionsBuilder; +import com.google.cloud.firestore.TransactionOptions.ReadWriteOptionsBuilder; +import com.google.cloud.firestore.TransactionOptions.TransactionOptionsType; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.Write; +import com.google.protobuf.Message; +import io.grpc.Status; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.function.Function; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@SuppressWarnings("deprecation") +@RunWith(MockitoJUnitRunner.class) +public class TransactionTest { + + private final ApiFuture RETRYABLE_API_EXCEPTION = + immediateFailedFuture( + new ApiException( + new Exception("Test exception"), GrpcStatusCode.of(Status.Code.UNKNOWN), true)); + + @Spy private final FirestoreRpc firestoreRpc = mock(FirestoreRpc.class); + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder() + .setProjectId("test-project") + .setRetrySettings(IMMEDIATE_RETRY_SETTINGS) + .build(), + firestoreRpc); + + @Captor private ArgumentCaptor requestCapture; + @Captor private ArgumentCaptor> streamObserverCapture; + + private DocumentReference documentReference; + private Query queryReference; + private AggregateQuery aggregateQueryReference; + private TransactionOptions options; + + @Before + public void before() { + doReturn(Executors.newSingleThreadScheduledExecutor()).when(firestoreRpc).getExecutor(); + + documentReference = firestoreMock.document("coll/doc"); + queryReference = firestoreMock.collection("coll"); + aggregateQueryReference = queryReference.count(); + options = + TransactionOptions.create( + Executors.newSingleThreadExecutor( + runnable -> { + Thread thread = new Thread(runnable); + thread.setName("user_provided"); + return thread; + })); + } + + @Test + public void returnsValue() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + assertEquals("user_provided", Thread.currentThread().getName()); + return "foo"; + }, + options); + + assertEquals("foo", transaction.get()); + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID), requests.get(1)); + } + + @Test + public void returnsValueAsync() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction( + t -> { + assertEquals("user_provided", Thread.currentThread().getName()); + return ApiFutures.immediateFuture("foo"); + }, + options); + + assertEquals("foo", transaction.get()); + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID), requests.get(1)); + } + + @Test + public void canReturnNull() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = firestoreMock.runTransaction(transaction1 -> null, options); + + assertNull(transaction.get()); + } + + @Test + public void canReturnNullAsync() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction(t -> ApiFutures.immediateFuture(null), options); + + assertNull(transaction.get()); + } + + @Test + public void rollbackOnCallbackError() { + doReturn(beginResponse()) + .doReturn(rollbackResponse()) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + throw new Exception("Expected exception"); + }, + options); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("Expected exception")); + } + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(rollback(), requests.get(1)); + } + + @Test + public void rollbackOnCallbackApiFutureErrorAsync() { + doReturn(beginResponse()) + .doReturn(rollbackResponse()) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction( + t -> immediateFailedFuture(new Exception("Expected exception")), options); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("Expected exception")); + } + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(rollback(), requests.get(1)); + } + + @Test + public void noRollbackOnBeginFailure() { + doReturn(immediateFailedFuture(new Exception("Expected exception"))) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + fail(); + return null; + }, + options); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("Expected exception")); + } + + List requests = requestCapture.getAllValues(); + assertEquals(1, requests.size()); + } + + @Test + public void noRollbackOnBeginFailureAsync() { + doReturn(immediateFailedFuture(new Exception("Expected exception"))) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction( + t -> { + fail(); + return null; + }, + options); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("Expected exception")); + } + + List requests = requestCapture.getAllValues(); + assertEquals(1, requests.size()); + } + + @Test + public void noRollbackOnThrownExceptionAsync() { + doReturn(beginResponse()) + .doReturn(rollbackResponse()) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction( + t -> { + throw new RuntimeException("User exception"); + }, + options); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("User exception")); + } + } + + @Test + public void limitsRetriesWithFailure() { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), RETRYABLE_API_EXCEPTION); + put(rollback("foo1"), rollbackResponse()); + put(begin("foo1"), beginResponse("foo2")); + put(commit("foo2"), RETRYABLE_API_EXCEPTION); + put(rollback("foo2"), rollbackResponse()); + put(begin("foo2"), beginResponse("foo3")); + put(commit("foo3"), RETRYABLE_API_EXCEPTION); + put(rollback("foo3"), rollbackResponse()); + put(begin("foo3"), beginResponse("foo4")); + put(commit("foo4"), RETRYABLE_API_EXCEPTION); + put(rollback("foo4"), rollbackResponse()); + put(begin("foo4"), beginResponse("foo5")); + put(commit("foo5"), RETRYABLE_API_EXCEPTION); + put(rollback("foo5"), rollbackResponse()); + } + }; + + responseStubber.initializeStub(requestCapture, firestoreMock); + + final AtomicInteger retryCount = new AtomicInteger(1); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> "foo" + retryCount.getAndIncrement(), + TransactionOptions.create(options.getExecutor(), 5)); + + try { + transaction.get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("Transaction was cancelled because of too many retries.")); + } + + responseStubber.verifyAllRequestsSent(); + } + + @Test + public void limitsRetriesWithSuccess() throws Exception { + ResponseStubber responseStubber = + new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), RETRYABLE_API_EXCEPTION); + put(rollback("foo1"), rollbackResponse()); + put(begin("foo1"), beginResponse("foo2")); + put(commit("foo2"), RETRYABLE_API_EXCEPTION); + put(rollback("foo2"), rollbackResponse()); + put(begin("foo2"), beginResponse("foo3")); + put(commit("foo3"), RETRYABLE_API_EXCEPTION); + put(rollback("foo3"), rollbackResponse()); + put(begin("foo3"), beginResponse("foo4")); + put(commit("foo4"), RETRYABLE_API_EXCEPTION); + put(rollback("foo4"), rollbackResponse()); + put(begin("foo4"), beginResponse("foo5")); + put(commit("foo5"), RETRYABLE_API_EXCEPTION); + put(rollback("foo5"), rollbackResponse()); + put(begin("foo5"), beginResponse("foo6")); + put(commit("foo6"), commitResponse(0, 0)); + } + }; + + responseStubber.initializeStub(requestCapture, firestoreMock); + + final AtomicInteger retryCount = new AtomicInteger(1); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> "foo" + retryCount.getAndIncrement(), + TransactionOptions.create(options.getExecutor(), 6)); + + assertEquals("foo6", transaction.get()); + + responseStubber.verifyAllRequestsSent(); + } + + private void verifyRetries( + Function expectedSequenceWithRetry, + Function expectedSequenceWithoutRetry) + throws ExecutionException, InterruptedException { + ApiException[] exceptionWithRetryBehavior = + new ApiException[] { + (exception(Status.Code.CANCELLED, true)), + (exception(Status.Code.UNKNOWN, true)), + (exception(Status.Code.INVALID_ARGUMENT, false)), + (exception( + Status.Code.INVALID_ARGUMENT, + "The referenced transaction has expired or is no longer valid.", + true)), + (exception(Status.Code.DEADLINE_EXCEEDED, true)), + (exception(Status.Code.NOT_FOUND, false)), + (exception(Status.Code.ALREADY_EXISTS, false)), + (exception(Status.Code.RESOURCE_EXHAUSTED, true)), + (exception(Status.Code.FAILED_PRECONDITION, false)), + (exception(Status.Code.ABORTED, true)), + (exception(Status.Code.OUT_OF_RANGE, false)), + (exception(Status.Code.UNIMPLEMENTED, false)), + (exception(Status.Code.INTERNAL, true)), + (exception(Status.Code.UNAVAILABLE, true)), + (exception(Status.Code.DATA_LOSS, false)), + (exception(Status.Code.UNAUTHENTICATED, true)) + }; + + for (ApiException apiException : exceptionWithRetryBehavior) { + if (apiException.isRetryable()) { + ResponseStubber stubber = expectedSequenceWithRetry.apply(apiException); + stubber.initializeStub(requestCapture, firestoreMock); + + final int[] attempts = new int[] {0}; + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + ++attempts[0]; + return null; + }); + + transaction.get(); + stubber.verifyAllRequestsSent(); + + assertEquals(2, attempts[0]); + } else { + ResponseStubber stubber = expectedSequenceWithoutRetry.apply(apiException); + stubber.initializeStub(requestCapture, firestoreMock); + + final int[] attempts = new int[] {0}; + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + ++attempts[0]; + return null; + }); + + try { + transaction.get(); + fail("Transaction should have failed"); + } catch (Exception ignored) { + } + + stubber.verifyAllRequestsSent(); + assertEquals(1, attempts[0]); + } + } + } + + @Test + public void retriesCommitBasedOnErrorCode() throws Exception { + verifyRetries( + /* expectedSequenceWithRetry= */ e -> + new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), immediateFailedFuture(e)); + put(rollback("foo1"), rollbackResponse()); + put(begin("foo1"), beginResponse("foo2")); + put(commit("foo2"), commitResponse(0, 0)); + } + }, + /* expectedSequenceWithoutRetry= */ e -> + new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), immediateFailedFuture(e)); + put(rollback("foo1"), rollbackResponse()); + } + }); + } + + @Test + public void retriesRollbackBasedOnErrorCode() throws Exception { + final ApiException retryable = exception(Status.Code.ABORTED, true); + + // Regardless of exception thrown by rollback, we should never retry + // calling rollback. Rollback is best effort, and will sometimes return + // ABORT error (which a transaction will retry) when transaction no longer + // exists on Firestore server side. Attempting to retry will in some cases + // simply exhaust retries with accumulated backoff delay, when a new + // transaction could simply be started (since the old transaction no longer + // exists server side). + verifyRetries( + /* expectedSequenceWithRetry= */ e -> { + return new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), immediateFailedFuture(e)); + put(rollback("foo1"), immediateFailedFuture(retryable)); + put(begin("foo1"), beginResponse("foo2")); + put(commit("foo2"), commitResponse(0, 0)); + } + }; + }, + /* expectedSequenceWithoutRetry= */ e -> { + return new ResponseStubber() { + { + put(begin(), beginResponse("foo1")); + put(commit("foo1"), immediateFailedFuture(e)); + put(rollback("foo1"), immediateFailedFuture(retryable)); + } + }; + }); + } + + @Test + public void getDocument() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(getAllResponse(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), streamObserverCapture.capture(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runTransaction(t -> t.get(documentReference).get(), options); + + assertEquals("doc", transaction.get().getId()); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(get(TRANSACTION_ID), requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void getDocumentAsync() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(getAllResponse(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), streamObserverCapture.capture(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runAsyncTransaction(t -> t.get(documentReference), options); + + assertEquals("doc", transaction.get().getId()); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(get(TRANSACTION_ID), requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void getMultipleDocuments() throws Exception { + final DocumentReference doc1 = firestoreMock.document("coll/doc1"); + final DocumentReference doc2 = firestoreMock.document("coll/doc2"); + + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(getAllResponse(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), streamObserverCapture.capture(), ArgumentMatchers.any()); + + ApiFuture> transaction = + firestoreMock.runTransaction(t -> t.getAll(doc1, doc2).get(), options); + + assertEquals(2, transaction.get().size()); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals( + getAll( + TRANSACTION_ID, doc1.getResourcePath().toString(), doc2.getResourcePath().toString()), + requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void getMultipleDocumentsWithFieldMask() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(getAllResponse(SINGLE_FIELD_PROTO)) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), + streamObserverCapture.capture(), + ArgumentMatchers.any()); + + final DocumentReference doc1 = firestoreMock.document("coll/doc1"); + final FieldMask fieldMask = FieldMask.of(FieldPath.of("foo", "bar")); + + ApiFuture> transaction = + firestoreMock.runTransaction( + t -> t.getAll(new DocumentReference[] {doc1}, fieldMask).get(), options); + transaction.get(); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + BatchGetDocumentsRequest expectedGetAll = + getAll(TRANSACTION_ID, doc1.getResourcePath().toString()); + expectedGetAll = + expectedGetAll.toBuilder() + .setMask(DocumentMask.newBuilder().addFieldPaths("foo.bar")) + .build(); + assertEquals(expectedGetAll, requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void getQuery() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(queryResponse()) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), streamObserverCapture.capture(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runTransaction(t -> t.get(queryReference).get(), options); + + assertEquals(1, transaction.get().size()); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(query(TRANSACTION_ID, /* allDescendants= */ false), requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void getAggregateQuery() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + doAnswer(countQueryResponse(42)) + .when(firestoreMock) + .streamRequest( + requestCapture.capture(), streamObserverCapture.capture(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runTransaction(t -> t.get(aggregateQueryReference).get(), options); + + assertEquals(42, transaction.get().getCount()); + + List requests = requestCapture.getAllValues(); + assertEquals(3, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(countQuery(TRANSACTION_ID), requests.get(1)); + assertEquals(commit(TRANSACTION_ID), requests.get(2)); + } + + @Test + public void updateDocument() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.update(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP); + t.update(documentReference, "foo", "bar"); + return "foo"; + }, + options); + + assertEquals("foo", transaction.get()); + + List writes = new ArrayList<>(); + + for (int i = 0; i < 2; ++i) { + writes.add(update(SINGLE_FIELD_PROTO, Collections.singletonList("foo"))); + } + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID, writes.toArray(new Write[] {})), requests.get(1)); + } + + @Test + public void setDocument() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT); + return "foo"; + }, + options); + + assertEquals("foo", transaction.get()); + + List writes = new ArrayList<>(); + + for (int i = 0; i < 2; ++i) { + writes.add(set(SINGLE_FIELD_PROTO)); + } + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID, writes.toArray(new Write[] {})), requests.get(1)); + } + + @Test + public void createDocument() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP) + .create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT); + return "foo"; + }, + options); + + assertEquals("foo", transaction.get()); + + List writes = new ArrayList<>(); + + for (int i = 0; i < 2; ++i) { + writes.add(create(SINGLE_FIELD_PROTO)); + } + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID, writes.toArray(new Write[] {})), requests.get(1)); + } + + @Test + public void deleteDocument() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.delete(documentReference); + t.delete( + documentReference, Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(1, 2))); + return "foo"; + }, + options); + + assertEquals("foo", transaction.get()); + + List writes = new ArrayList<>(); + writes.add(delete()); + + com.google.firestore.v1.Precondition.Builder precondition = + com.google.firestore.v1.Precondition.newBuilder(); + precondition.getUpdateTimeBuilder().setSeconds(1).setNanos(2); + writes.add(delete(precondition.build())); + + List requests = requestCapture.getAllValues(); + assertEquals(2, requests.size()); + + assertEquals(begin(), requests.get(0)); + assertEquals(commit(TRANSACTION_ID, writes.toArray(new Write[] {})), requests.get(1)); + } + + @Test + public void readOnlyTransactionOptionsBuilder_setReadTime() { + Executor executor = mock(Executor.class); + final com.google.protobuf.Timestamp.Builder readTime = + com.google.protobuf.Timestamp.getDefaultInstance().toBuilder().setSeconds(1).setNanos(0); + final ReadOnlyOptionsBuilder builder = + TransactionOptions.createReadOnlyOptionsBuilder() + .setExecutor(executor) + .setReadTime(readTime); + + final TransactionOptions transactionOptions = builder.build(); + + assertThat(builder.getExecutor()).isSameInstanceAs(executor); + assertThat(builder.getReadTime()).isSameInstanceAs(readTime); + + assertThat(transactionOptions.getExecutor()).isSameInstanceAs(executor); + + assertThat(transactionOptions.getType()).isEqualTo(TransactionOptionsType.READ_ONLY); + assertThat(transactionOptions.getReadTime()).isEqualTo(readTime.build()); + assertThat(transactionOptions.getNumberOfAttempts()).isEqualTo(1); + } + + @Test + public void readOnlyTransactionOptionsBuilder_defaults() { + final ReadOnlyOptionsBuilder builder = TransactionOptions.createReadOnlyOptionsBuilder(); + + final TransactionOptions transactionOptions = builder.build(); + + assertThat(builder.getExecutor()).isNull(); + assertThat(builder.getReadTime()).isNull(); + + assertThat(transactionOptions.getReadTime()).isNull(); + assertThat(transactionOptions.getNumberOfAttempts()).isEqualTo(1); + } + + @Test + public void readWriteTransactionOptionsBuilder_setNumberOfAttempts() { + Executor executor = mock(Executor.class); + final ReadWriteOptionsBuilder builder = + TransactionOptions.createReadWriteOptionsBuilder() + .setExecutor(executor) + .setNumberOfAttempts(2); + + final TransactionOptions transactionOptions = builder.build(); + + assertThat(builder.getExecutor()).isSameInstanceAs(executor); + assertThat(builder.getNumberOfAttempts()).isEqualTo(2); + + assertThat(transactionOptions.getExecutor()).isSameInstanceAs(executor); + + assertThat(transactionOptions.getType()).isEqualTo(TransactionOptionsType.READ_WRITE); + assertThat(transactionOptions.getNumberOfAttempts()).isEqualTo(2); + assertThat(transactionOptions.getReadTime()).isNull(); + } + + @Test + public void readWriteTransactionOptionsBuilder_defaults() { + final TransactionOptions transactionOptions = + TransactionOptions.createReadWriteOptionsBuilder().build(); + + assertThat(transactionOptions.getExecutor()).isNull(); + assertThat(transactionOptions.getNumberOfAttempts()).isEqualTo(5); + assertThat(transactionOptions.getReadTime()).isNull(); + } + + @Test + public void readWriteTransactionOptionsBuilder_errorAttemptingToSetNumAttemptsLessThanOne() { + try { + TransactionOptions.createReadWriteOptionsBuilder().setNumberOfAttempts(0); + fail("Error expected"); + } catch (IllegalArgumentException ignore) { + // expected + } + } + + @Test + public void getShouldThrowWhenInvokedAfterAWriteWithAQuery() throws Exception { + doReturn(beginResponse()) + .when(firestoreMock) + .sendRequest(ArgumentMatchers.any(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP); + t.get(queryReference); + return null; + }); + + ExecutionException executionException = + assertThrows(ExecutionException.class, transaction::get); + assertThat(executionException.getCause()).isInstanceOf(IllegalStateException.class); + } + + @Test + public void getShouldThrowWhenInvokedAfterAWriteWithAnAggregateQuery() throws Exception { + doReturn(beginResponse()) + .when(firestoreMock) + .sendRequest(ArgumentMatchers.any(), ArgumentMatchers.any()); + + ApiFuture transaction = + firestoreMock.runTransaction( + t -> { + t.set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP); + t.get(aggregateQueryReference); + return null; + }); + + ExecutionException executionException = + assertThrows(ExecutionException.class, transaction::get); + assertThat(executionException.getCause()).isInstanceOf(IllegalStateException.class); + } + + @Test + public void givesProperErrorMessageForCommittedTransaction() throws Exception { + doReturn(beginResponse()) + .doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + requestCapture.capture(), ArgumentMatchers.>any()); + String expectedErrorMessage = "Cannot modify a Transaction that has already been committed."; + + DocumentReference docRef = firestoreMock.collection("foo").document("bar"); + + // Commit a transaction. + Transaction t = firestoreMock.runTransaction(transaction -> transaction).get(); + + // Then run other operations in the same transaction. + LocalFirestoreHelper.assertException( + () -> { + t.set(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + t.update(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + t.create(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + t.delete(docRef); + }, + expectedErrorMessage); + } + + private ApiException exception(Status.Code code, boolean shouldRetry) { + return exception(code, "Test exception", shouldRetry); + } + + private ApiException exception(Status.Code code, String message, boolean shouldRetry) { + return new ApiException(new Exception(message), GrpcStatusCode.of(code), shouldRetry); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/VectorQueryTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/VectorQueryTest.java new file mode 100644 index 000000000000..717cf6e662b3 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/VectorQueryTest.java @@ -0,0 +1,482 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.COLLECTION_ID; +import static com.google.cloud.firestore.LocalFirestoreHelper.DOCUMENT_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.findNearest; +import static com.google.cloud.firestore.LocalFirestoreHelper.query; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.queryResponseWithDone; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; + +import com.google.api.gax.rpc.ResponseObserver; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredQuery; +import io.grpc.Status; +import java.util.List; +import java.util.concurrent.ExecutionException; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class VectorQueryTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor runQuery; + + @Captor private ArgumentCaptor> streamObserverCapture; + + private Query queryA; + private Query queryB; + + private QueryTest.MockClock clock; + + @Before + public void before() { + clock = new QueryTest.MockClock(); + doReturn(clock).when(firestoreMock).getClock(); + + queryA = firestoreMock.collection(COLLECTION_ID); + queryB = firestoreMock.collection(COLLECTION_ID).whereEqualTo("foo", "bar"); + } + + @Test + public void isEqual() { + Query queryA = firestoreMock.collection("collectionId").whereEqualTo("foo", "bar"); + Query queryB = firestoreMock.collection("collectionId").whereEqualTo("foo", "bar"); + Query queryC = firestoreMock.collection("collectionId"); + + assertEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE)); + + assertEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN)); + + assertEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(0.125).build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(0.125).build())); + + assertEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder() + .setDistanceThreshold(0.125) + .setDistanceResultField(FieldPath.of("foo")) + .build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder() + .setDistanceThreshold(0.125) + .setDistanceResultField(FieldPath.of("foo")) + .build())); + + assertEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder() + .setDistanceResultField(FieldPath.of("distance")) + .build())); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE), + queryC.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE)); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE), + queryB.findNearest( + "embedding", new double[] {40, 42}, 10, VectorQuery.DistanceMeasure.COSINE)); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 1000, VectorQuery.DistanceMeasure.COSINE)); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.COSINE), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN)); + + assertNotEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(0.125).build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(1.125).build())); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(1.0).build())); + + assertNotEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(1.0).build()), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN)); + + assertNotEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("result").build())); + + assertNotEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder() + .setDistanceResultField(FieldPath.of("distance")) + .build()), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder() + .setDistanceResultField(FieldPath.of("result")) + .build())); + + assertNotEquals( + queryA.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN), + queryB.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("result").build())); + + assertNotEquals( + queryA.findNearest( + "embedding", + new double[] {40, 41, 42}, + 10, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()), + queryB.findNearest( + "embedding", new double[] {40, 41, 42}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN)); + } + + @Test + public void validatesInputsLimit() { + String expectedExceptionMessage = ".*Not a valid positive `limit` number.*"; + Throwable exception = + assertThrows( + RuntimeException.class, + () -> + queryA.findNearest( + "embedding", new double[] {10, 100}, 0, VectorQuery.DistanceMeasure.EUCLIDEAN)); + assertTrue(exception.getMessage().matches(expectedExceptionMessage)); + } + + @Test + public void validatesInputsVectorSize() { + String expectedExceptionMessage = ".*Not a valid vector size.*"; + Throwable exception = + assertThrows( + RuntimeException.class, + () -> + queryA.findNearest( + "embedding", new double[0], 10, VectorQuery.DistanceMeasure.EUCLIDEAN)); + assertTrue(exception.getMessage().matches(expectedExceptionMessage)); + } + + @Test + public void successfulReturnWithoutOnComplete() throws Exception { + doAnswer( + queryResponseWithDone( + /* callWithoutOnComplete */ true, DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + VectorQuerySnapshot snapshot = + queryA + .findNearest("vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.COSINE) + .get() + .get(); + + assertEquals(2, snapshot.size()); + assertEquals(false, snapshot.isEmpty()); + assertTrue((DOCUMENT_NAME + "1").endsWith(snapshot.getDocuments().get(0).getId())); + assertTrue((DOCUMENT_NAME + "2").endsWith(snapshot.getDocuments().get(1).getId())); + assertEquals(2, snapshot.getDocumentChanges().size()); + assertEquals(1, snapshot.getReadTime().getSeconds()); + assertEquals(2, snapshot.getReadTime().getNanos()); + + assertEquals(1, runQuery.getAllValues().size()); + assertEquals( + query( + findNearest( + "vector", + new double[] {1, -9.5}, + 10, + StructuredQuery.FindNearest.DistanceMeasure.COSINE)), + runQuery.getValue()); + } + + @Test + public void successfulReturn() throws Exception { + doAnswer(queryResponse(DOCUMENT_NAME + "1", DOCUMENT_NAME + "2")) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + VectorQuerySnapshot snapshot = + queryA + .findNearest( + "vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get(); + + assertEquals(2, snapshot.size()); + assertEquals(false, snapshot.isEmpty()); + assertTrue((DOCUMENT_NAME + "1").endsWith(snapshot.getDocuments().get(0).getId())); + assertTrue((DOCUMENT_NAME + "2").endsWith(snapshot.getDocuments().get(1).getId())); + assertEquals(2, snapshot.getDocumentChanges().size()); + assertEquals(1, snapshot.getReadTime().getSeconds()); + assertEquals(2, snapshot.getReadTime().getNanos()); + + assertEquals(1, runQuery.getAllValues().size()); + assertEquals( + query( + findNearest( + "vector", + new double[] {1, -9.5}, + 10, + StructuredQuery.FindNearest.DistanceMeasure.DOT_PRODUCT)), + runQuery.getValue()); + } + + @Test + public void handlesStreamExceptionRetryableError() { + final boolean[] returnError = new boolean[] {true}; + + doAnswer( + invocation -> { + if (returnError[0]) { + returnError[0] = false; + return queryResponse( + FirestoreException.forServerRejection( + Status.DEADLINE_EXCEEDED, "Simulated test failure"), + DOCUMENT_NAME + "1", + DOCUMENT_NAME + "2") + .answer(invocation); + } else { + return queryResponse(DOCUMENT_NAME + "3").answer(invocation); + } + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + ExecutionException e = + assertThrows( + ExecutionException.class, + () -> + queryA + .findNearest( + "vector", + new double[] {1, -9.5}, + 10, + VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get()); + + // Verify the requests + List requests = runQuery.getAllValues(); + assertEquals(1, requests.size()); + + assertTrue(requests.get(0).getStructuredQuery().hasFindNearest()); + + assertEquals(e.getCause().getClass(), FirestoreException.class); + assertTrue(e.getCause().getMessage().matches(".*Simulated test failure.*")); + } + + @Test + public void handlesStreamExceptionNonRetryableError() { + final boolean[] returnError = new boolean[] {true}; + + doAnswer( + invocation -> { + if (returnError[0]) { + returnError[0] = false; + return queryResponse( + FirestoreException.forServerRejection( + Status.PERMISSION_DENIED, "Simulated test failure")) + .answer(invocation); + } else { + return queryResponse(DOCUMENT_NAME + "3").answer(invocation); + } + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + ExecutionException e = + assertThrows( + ExecutionException.class, + () -> + queryA + .findNearest( + "vector", + new double[] {1, -9.5}, + 10, + VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get()); + + // Verify the requests + List requests = runQuery.getAllValues(); + assertEquals(1, requests.size()); + + assertTrue(requests.get(0).getStructuredQuery().hasFindNearest()); + + assertEquals(e.getCause().getClass(), FirestoreException.class); + assertTrue(e.getCause().getMessage().matches(".*Simulated test failure.*")); + } + + @Test + public void vectorQuerySnapshotEquality() throws Exception { + final int[] count = {0}; + + doAnswer( + invocation -> { + switch (count[0]++) { + case 0: + return queryResponse(DOCUMENT_NAME + "3", DOCUMENT_NAME + "4").answer(invocation); + case 1: + return queryResponse(DOCUMENT_NAME + "3", DOCUMENT_NAME + "4").answer(invocation); + case 2: + return queryResponse(DOCUMENT_NAME + "3", DOCUMENT_NAME + "4").answer(invocation); + case 3: + return queryResponse(DOCUMENT_NAME + "4").answer(invocation); + default: + return queryResponse().answer(invocation); + } + }) + .when(firestoreMock) + .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); + + VectorQuerySnapshot snapshotA = + queryA + .findNearest( + "vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get(); + VectorQuerySnapshot snapshotB = + queryA + .findNearest( + "vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get(); + VectorQuerySnapshot snapshotC = + queryB + .findNearest( + "vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get(); + VectorQuerySnapshot snapshotD = + queryA + .findNearest( + "vector", new double[] {1, -9.5}, 10, VectorQuery.DistanceMeasure.DOT_PRODUCT) + .get() + .get(); + + assertEquals(snapshotA, snapshotB); + assertNotEquals(snapshotA, snapshotC); + assertNotEquals(snapshotA, snapshotD); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WatchTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WatchTest.java new file mode 100644 index 000000000000..91f79d97e615 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WatchTest.java @@ -0,0 +1,1050 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.DATABASE_NAME; +import static com.google.cloud.firestore.LocalFirestoreHelper.IMMEDIATE_RETRY_SETTINGS; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.SINGLE_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_FIELD_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.LocalFirestoreHelper.string; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.*; + +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.BidiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.ClientStream; +import com.google.api.gax.rpc.InternalException; +import com.google.cloud.firestore.Query.Direction; +import com.google.cloud.firestore.WatchTest.SnapshotDocument.ChangeType; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentChange; +import com.google.firestore.v1.DocumentDelete; +import com.google.firestore.v1.DocumentRemove; +import com.google.firestore.v1.ExistenceFilter; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.TargetChange; +import com.google.firestore.v1.TargetChange.TargetChangeType; +import com.google.firestore.v1.Value; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import io.grpc.Status.Code; +import io.grpc.StatusException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.stubbing.Answer; + +@RunWith(MockitoJUnitRunner.class) +public class WatchTest { + + @Rule public Timeout timeout = new Timeout(1, TimeUnit.SECONDS); + + /** The Target ID used by the Java Firestore SDK. */ + private static final int TARGET_ID = 0x1; + + /** The resume token used by this test harness. */ + private static final ByteString RESUME_TOKEN = ByteString.copyFromUtf8("token"); + + /** A counter of all document sent. Used to generate a unique update time. */ + private static int documentCount; + + @Spy private final FirestoreRpc firestoreRpc = Mockito.mock(FirestoreRpc.class); + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder() + .setProjectId("test-project") + .setRetrySettings(IMMEDIATE_RETRY_SETTINGS) + .build(), + firestoreRpc); + + @Captor + private ArgumentCaptor> streamObserverCapture; + + /** Executor that executes delayed tasks without delay. */ + private final ScheduledExecutorService immediateExecutor = + new ScheduledThreadPoolExecutor(1) { + @Override + @Nonnull + public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { + return super.schedule(command, 0, TimeUnit.MILLISECONDS); + } + }; + + private final BlockingQueue requests = new LinkedBlockingDeque<>(); + private final BlockingQueue exceptions = new LinkedBlockingDeque<>(); + private final BlockingQueue documentSnapshots = new LinkedBlockingDeque<>(); + private final BlockingQueue querySnapshots = new LinkedBlockingDeque<>(); + private final Semaphore closes = new Semaphore(0); + private QuerySnapshot lastSnapshot = null; + + private ListenerRegistration listenerRegistration; + + /** Holder class for the expected state of a document in a snapshot. */ + static class SnapshotDocument { + enum ChangeType { + UNCHANGED, + ADDED, + REMOVED, + MODIFIED + } + + ChangeType type; + String name; + Map data; + + SnapshotDocument(ChangeType type, String name, Map data) { + this.type = type; + this.name = name; + this.data = data; + } + } + + @Before + public void before() { + requests.clear(); + documentSnapshots.clear(); + exceptions.clear(); + querySnapshots.clear(); + closes.drainPermits(); + lastSnapshot = null; + + lenient().doReturn(immediateExecutor).when(firestoreRpc).getExecutor(); + doAnswer(newRequestObserver()) + .when(firestoreMock) + .streamRequest( + streamObserverCapture.capture(), ArgumentMatchers.any()); + } + + @After + public void after() { + Object[] emptyArray = new Object[0]; + assertArrayEquals(exceptions.toArray(), emptyArray); + // TODO(b/460778179): Re-enable, this line is flaky + // assertArrayEquals(requests.toArray(), emptyArray); + assertArrayEquals(documentSnapshots.toArray(), emptyArray); + assertArrayEquals(querySnapshots.toArray(), emptyArray); + listenerRegistration.remove(); + } + + /** Initializes a document listener at 'coll/doc'. */ + private void addDocumentListener() { + listenerRegistration = + firestoreMock + .document("coll/doc") + .addSnapshotListener( + (value, error) -> { + if (value != null) { + documentSnapshots.add(value); + } else { + exceptions.add(error); + } + }); + } + + /** Initializes a collection listener at 'coll'. */ + private void addQueryListener() { + listenerRegistration = + firestoreMock + .collection("coll") + .addSnapshotListener( + (value, error) -> { + if (value != null) { + querySnapshots.add(value); + } else { + exceptions.add(error); + } + }); + } + + @Test + public void documentWatchChange() throws InterruptedException { + addDocumentListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + send(snapshot()); + + awaitDocumentSnapshot(); + + send(doc("coll/doc", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitDocumentSnapshot("coll/doc", SINGLE_FIELD_MAP); + + send(doc("coll/doc", UPDATED_FIELD_PROTO)); + send(snapshot()); + + awaitDocumentSnapshot("coll/doc", UPDATED_FIELD_MAP); + + send(docDelete("coll/doc")); + send(snapshot()); + + awaitDocumentSnapshot(); + } + + @Test + public void documentWatchIgnoresNonMatchingDocument() throws InterruptedException { + addDocumentListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + send(doc("coll/nondoc", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitDocumentSnapshot(); + } + + @Test + public void documentWatchCombinesEventsForDocument() throws InterruptedException { + addDocumentListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + send(doc("coll/doc", SINGLE_FIELD_PROTO)); + send(doc("coll/doc", UPDATED_FIELD_PROTO)); + send(snapshot()); + + awaitDocumentSnapshot("coll/doc", UPDATED_FIELD_MAP); + } + + @Test + public void queryWatchRemoveTarget() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(removeTarget(null)); + + awaitException(null); + } + + @Test + public void queryWatchRemoveTargetWithStatus() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(removeTarget(Code.ABORTED)); + + awaitException(Code.ABORTED); + } + + @Test + public void queryWatchShutsDownStreamOnPermissionDenied() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(removeTarget(Code.PERMISSION_DENIED)); + awaitClose(); + + awaitException(Code.PERMISSION_DENIED); + } + + @Test + public void queryWatchReopensOnUnexceptedStreamEnd() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + + send(addTarget()); + send(current()); + send(snapshot()); + + awaitQuerySnapshot(); + + close(); + awaitClose(); + awaitAddTarget(); + + send(addTarget()); + send(current()); + send(doc("coll/doc", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchDoesntSendRaiseSnapshotOnReset() throws InterruptedException { + // This test is meant to reproduce https://github.com/googleapis/google-cloud-dotnet/issues/2542 + addQueryListener(); + + awaitAddTarget(); + + send(addTarget()); + send(current()); + send(snapshot()); + + awaitQuerySnapshot(); + + close(); + awaitClose(); + awaitAddTarget(); + + send(addTarget()); + send(current()); + // This should not raise a snapshot, since nothing has changed since the last snapshot. + send(snapshot()); + + send(doc("coll/doc", SINGLE_FIELD_PROTO)); + send(snapshot()); + + // Verify that we only receveived one snapshot. + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchDoesntReopenInactiveStream() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + + send(addTarget()); + send(current()); + send(snapshot()); + + awaitQuerySnapshot(); + + close(); + listenerRegistration.remove(); + } + + @Test + public void queryWatchRetriesBasedOnErrorCode() throws InterruptedException { + Map expectRetry = new HashMap<>(); + expectRetry.put(Code.CANCELLED, true); + expectRetry.put(Code.UNKNOWN, true); + expectRetry.put(Code.INVALID_ARGUMENT, false); + expectRetry.put(Code.DEADLINE_EXCEEDED, true); + expectRetry.put(Code.NOT_FOUND, false); + expectRetry.put(Code.ALREADY_EXISTS, false); + expectRetry.put(Code.PERMISSION_DENIED, false); + expectRetry.put(Code.RESOURCE_EXHAUSTED, true); + expectRetry.put(Code.FAILED_PRECONDITION, false); + expectRetry.put(Code.ABORTED, false); + expectRetry.put(Code.OUT_OF_RANGE, false); + expectRetry.put(Code.UNIMPLEMENTED, false); + expectRetry.put(Code.INTERNAL, true); + expectRetry.put(Code.UNAVAILABLE, true); + expectRetry.put(Code.DATA_LOSS, false); + expectRetry.put(Code.UNAUTHENTICATED, true); + + for (Entry entry : expectRetry.entrySet()) { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + destroy(entry.getKey()); + + if (entry.getValue()) { + awaitAddTarget(); + send(addTarget()); + send(current()); + send(snapshot()); + awaitQuerySnapshot(); + listenerRegistration.remove(); + } else { + awaitException(null); + } + } + } + + @Test + public void queryWatchRetriesOnInternalException() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + destroy(new InternalException(null, GrpcStatusCode.of(Code.INTERNAL), true)); + awaitAddTarget(); + send(addTarget()); + send(current()); + send(snapshot()); + awaitQuerySnapshot(); + } + + @Test + public void queryWatchHandlesDocumentChange() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + + send(doc("coll/doc1", UPDATED_FIELD_PROTO)); + send(doc("coll/doc3", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.MODIFIED, "coll/doc1", UPDATED_FIELD_MAP), + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc3", SINGLE_FIELD_MAP)); + + send(docDelete("coll/doc1")); + send(docRemove("coll/doc3")); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.REMOVED, "coll/doc1", null), + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.REMOVED, "coll/doc3", null)); + } + + @Test + public void queryWatchReconnectsWithResumeToken() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + + send(addTarget()); + send(current()); + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + // This update gets ignored. + send(doc("coll/doc1", UPDATED_FIELD_PROTO)); + close(); + + awaitResumeToken(); + send(addTarget()); + send(current()); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchSortsDocuments() throws InterruptedException { + listenerRegistration = + firestoreMock + .collection("coll") + .orderBy("foo") + .orderBy("bar", Direction.DESCENDING) + .addSnapshotListener((value, error) -> querySnapshots.add(value)); + + ListenResponse[] documents = + new ListenResponse[] { + doc("coll/doc1", map("foo", string("a"), "bar", string("b"))), + doc("coll/doc2", map("foo", string("a"), "bar", string("a"))), + doc("coll/doc3", map("foo", string("b"), "bar", string("b"))), + doc("coll/doc5", map("foo", string("b"), "bar", string("a"))), + // doc4 sorts after doc5 because __name__ uses the last specified sort direction. + doc("coll/doc4", map("foo", string("b"), "bar", string("a"))) + }; + + awaitAddTarget(); + + send(addTarget()); + send(current()); + + // Send document in any order + send(documents[4]); + send(documents[3]); + send(documents[2]); + send(documents[0]); + send(documents[1]); + + send(snapshot()); + + QuerySnapshot querySnapshot = querySnapshots.take(); + verifyOrder( + Arrays.asList("coll/doc1", "coll/doc2", "coll/doc3", "coll/doc5", "coll/doc4"), + querySnapshot.getDocuments()); + } + + @Test + public void queryWatchCombinesChangesForSameDocument() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(doc("coll/doc1", UPDATED_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", UPDATED_FIELD_MAP)); + + send(doc("coll/doc1", UPDATED_FIELD_PROTO)); + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.MODIFIED, "coll/doc1", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesDeletingNonExistingDocument() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(docDelete("coll/doc2")); + send(doc("coll/doc1", UPDATED_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.MODIFIED, "coll/doc1", UPDATED_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesDeletesAndAddInSingleSnapshot() throws InterruptedException { + ListenResponse document = doc("coll/doc1", SINGLE_FIELD_PROTO); + + addQueryListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(document); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(docDelete("coll/doc1")); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(document); + + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesAddAndDeleteInSingleSnapshot() throws InterruptedException { + addQueryListener(); + + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(snapshot()); + + awaitQuerySnapshot(); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(docDelete("coll/doc1")); + + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesReset() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(reset()); + + send(current()); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.REMOVED, "coll/doc1", null), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesFilterMatch() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(filter(1)); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesFilterMismatch() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(filter(2)); + awaitClose(); + + awaitAddTarget(); + send(doc("coll/doc2", SINGLE_FIELD_PROTO)); + send(current()); + send(snapshot()); + + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.REMOVED, "coll/doc1", null), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + } + + @Test + public void queryWatchHandlesTargetRemoval() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + + send(doc("coll/doc1", SINGLE_FIELD_PROTO)); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + ListenResponse.Builder request = doc("coll/doc1", SINGLE_FIELD_PROTO).toBuilder(); + request.getDocumentChangeBuilder().clearTargetIds(); + request.getDocumentChangeBuilder().addRemovedTargetIds(TARGET_ID); + + send(request.build()); + send(snapshot()); + + awaitQuerySnapshot(new SnapshotDocument(ChangeType.REMOVED, "coll/doc1", null)); + } + + @Test + public void queryWatchHandlesIgnoresDifferentTarget() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + + ListenResponse.Builder request = doc("coll/doc1", SINGLE_FIELD_PROTO).toBuilder(); + request.getDocumentChangeBuilder().clearTargetIds(); + request.getDocumentChangeBuilder().addTargetIds(0x2); + + send(request.build()); + send(snapshot()); + + awaitQuerySnapshot(); + } + + @Test + public void emptySnapshotEquals() throws InterruptedException { + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + send(snapshot()); + QuerySnapshot firstSnapshot = awaitQuerySnapshot(); + + restartWatch(); + + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(current()); + send(snapshot()); + QuerySnapshot secondSnapshot = awaitQuerySnapshot(); + + assertEquals(firstSnapshot, firstSnapshot); + assertEquals(firstSnapshot, secondSnapshot); + } + + @Test + public void snapshotWithChangesEquals() throws InterruptedException { + ListenResponse doc1 = doc("coll/doc1", SINGLE_FIELD_PROTO); + ListenResponse doc2 = doc("coll/doc2", SINGLE_FIELD_PROTO); + ListenResponse doc3 = doc("coll/doc3", SINGLE_FIELD_PROTO); + + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(doc1); + send(current()); + send(snapshot()); + QuerySnapshot firstSnapshot = + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP)); + + send(doc2); + send(doc3); + send(snapshot()); + QuerySnapshot secondSnapshot = + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc3", SINGLE_FIELD_MAP)); + assertNotEquals(secondSnapshot, firstSnapshot); + + send(docDelete("coll/doc3")); + send(snapshot()); + QuerySnapshot thirdSnapshot = + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.REMOVED, "coll/doc3", null)); + assertNotEquals(thirdSnapshot, firstSnapshot); + assertNotEquals(thirdSnapshot, secondSnapshot); + + restartWatch(); + + addQueryListener(); + awaitAddTarget(); + send(addTarget()); + send(doc2); + send(current()); + send(snapshot()); + QuerySnapshot currentSnapshot = + awaitQuerySnapshot(new SnapshotDocument(ChangeType.ADDED, "coll/doc2", SINGLE_FIELD_MAP)); + assertNotEquals(currentSnapshot, firstSnapshot); + + send(doc3); + send(doc1); + send(snapshot()); + currentSnapshot = + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.ADDED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.ADDED, "coll/doc3", SINGLE_FIELD_MAP)); + assertNotEquals(currentSnapshot, secondSnapshot); + + send(docDelete("coll/doc3")); + send(snapshot()); + currentSnapshot = + awaitQuerySnapshot( + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc1", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.UNCHANGED, "coll/doc2", SINGLE_FIELD_MAP), + new SnapshotDocument(ChangeType.REMOVED, "coll/doc3", null)); + assertEquals(currentSnapshot, thirdSnapshot); + } + + private void restartWatch() { + after(); + before(); + } + + private void awaitException(Code expectedCode) throws InterruptedException { + FirestoreException exception = exceptions.take(); + + if (expectedCode != null) { + assertEquals(expectedCode, exception.getStatus().getCode()); + } + } + + /** Awaits a DocumentSnapshot and validates its contents based on the provided document. */ + private void awaitDocumentSnapshot(String docPath, Map data) + throws InterruptedException { + DocumentSnapshot documentSnapshot = documentSnapshots.take(); + assertEquals(docPath, documentSnapshot.getReference().getPath()); + assertEquals(data, documentSnapshot.getData()); + } + + /** Awaits a QuerySnapshot and validates its contents based on the provided documents. */ + private QuerySnapshot awaitQuerySnapshot(SnapshotDocument... documents) + throws InterruptedException { + QuerySnapshot querySnapshot = querySnapshots.take(); + + // List of documents to use a base to replay all changes. Verifies oldIndex and newIndex. + List updatedDocuments = new ArrayList<>(); + + if (lastSnapshot != null) { + updatedDocuments.addAll(lastSnapshot.getDocuments()); + } + + // List of document names in the expected sorted order. + List expectedOrder = new ArrayList<>(); + + Iterator snapshotIterator = querySnapshot.getDocuments().iterator(); + + for (SnapshotDocument expected : documents) { + if (expected.type != ChangeType.REMOVED) { + DocumentSnapshot actual = snapshotIterator.next(); + assertEquals(expected.name, actual.getReference().getPath()); + assertEquals(expected.data, actual.getData()); + assertNotNull(actual.getReadTime()); + expectedOrder.add(expected.name); + } + + boolean found = false; + + for (com.google.cloud.firestore.DocumentChange change : querySnapshot.getDocumentChanges()) { + if (change.getDocument().getReference().getPath().equals(expected.name)) { + if (change.getOldIndex() != -1) { + updatedDocuments.remove(change.getOldIndex()); + } + if (change.getNewIndex() != -1) { + updatedDocuments.add(change.getNewIndex(), change.getDocument()); + } + assertEquals(expected.type.name(), change.getType().name()); + found = true; + break; + } + } + + if (!found) { + assertEquals(ChangeType.UNCHANGED, expected.type); + } + } + + assertFalse(snapshotIterator.hasNext()); + + lastSnapshot = querySnapshot; + + verifyOrder(expectedOrder, updatedDocuments); + + return querySnapshot; + } + + private void verifyOrder( + List expectedOrder, List updatedDocuments) { + assertEquals(expectedOrder.size(), updatedDocuments.size()); + + for (int i = 0; i < expectedOrder.size(); ++i) { + assertEquals(expectedOrder.get(i), updatedDocuments.get(i).getReference().getPath()); + } + } + + private void awaitDocumentSnapshot() throws InterruptedException { + DocumentSnapshot documentSnapshot = documentSnapshots.take(); + assertFalse(documentSnapshot.exists()); + } + + private void awaitClose() throws InterruptedException { + closes.acquire(); + } + + private void awaitAddTarget() throws InterruptedException { + ListenRequest listenRequest = requests.take(); + assertEquals(DATABASE_NAME, listenRequest.getDatabase()); + assertEquals(TARGET_ID, listenRequest.getAddTarget().getTargetId()); + } + + private void awaitResumeToken() throws InterruptedException { + ListenRequest listenRequest = requests.take(); + assertEquals(DATABASE_NAME, listenRequest.getDatabase()); + assertEquals(TARGET_ID, listenRequest.getAddTarget().getTargetId()); + assertEquals(RESUME_TOKEN, listenRequest.getAddTarget().getResumeToken()); + } + + private ListenResponse removeTarget(@Nullable Code code) { + TargetChange.Builder targetChange = + TargetChange.newBuilder() + .setTargetChangeType(TargetChangeType.REMOVE) + .addTargetIds(TARGET_ID); + + if (code != null) { + targetChange.setCause(Status.newBuilder().setCode(code.value())); + } + + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setTargetChange(targetChange); + return response.build(); + } + + private ListenResponse addTarget() { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setTargetChange( + TargetChange.newBuilder() + .setTargetChangeType(TargetChangeType.ADD) + .addTargetIds(TARGET_ID)); + return response.build(); + } + + private ListenResponse current() { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setTargetChange( + TargetChange.newBuilder() + .setTargetChangeType(TargetChangeType.CURRENT) + .addTargetIds(TARGET_ID)); + return response.build(); + } + + private ListenResponse reset() { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setTargetChange( + TargetChange.newBuilder() + .setTargetChangeType(TargetChangeType.RESET) + .addTargetIds(TARGET_ID)); + return response.build(); + } + + private ListenResponse filter(int documentCount) { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setFilter(ExistenceFilter.newBuilder().setCount(documentCount).build()); + return response.build(); + } + + private ListenResponse snapshot() { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setTargetChange( + TargetChange.newBuilder() + .setTargetChangeType(TargetChangeType.NO_CHANGE) + .setReadTime(Timestamp.getDefaultInstance()) + .setResumeToken(RESUME_TOKEN)); + return response.build(); + } + + private ListenResponse doc(String docPath, Map singleFieldProto) { + DocumentChange.Builder documentChange = DocumentChange.newBuilder(); + documentChange.addTargetIds(TARGET_ID); + documentChange.setDocument( + Document.newBuilder() + .setName(String.format("%s/documents/%s", DATABASE_NAME, docPath)) + .putAllFields(singleFieldProto) + .setUpdateTime(updateTime())); + + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setDocumentChange(documentChange); + + return response.build(); + } + + private Timestamp updateTime() { + return Timestamp.newBuilder().setSeconds(++documentCount).build(); + } + + private ListenResponse docDelete(String docPath) { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setDocumentDelete( + DocumentDelete.newBuilder() + .addRemovedTargetIds(TARGET_ID) + .setDocument(String.format("%s/documents/%s", DATABASE_NAME, docPath))); + + return response.build(); + } + + private ListenResponse docRemove(String docPath) { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setDocumentRemove( + DocumentRemove.newBuilder() + .addRemovedTargetIds(TARGET_ID) + .setDocument(String.format("%s/documents/%s", DATABASE_NAME, docPath))); + + return response.build(); + } + + private void send(ListenResponse response) { + streamObserverCapture.getValue().onResponse(response); + } + + private void destroy(Code code) { + destroy(new StatusException(io.grpc.Status.fromCode(code))); + } + + private void destroy(Exception e) { + streamObserverCapture.getValue().onError(e); + } + + private void close() { + streamObserverCapture.getValue().onComplete(); + } + + /** Returns a new request observer that persists its input. */ + private Answer> newRequestObserver() { + return invocationOnMock -> + new ClientStream() { + @Override + public void send(ListenRequest listenRequest) { + requests.add(listenRequest); + } + + @Override + public void closeSendWithError(Throwable throwable) {} + + @Override + public void closeSend() { + closes.release(); + } + + @Override + public boolean isSendReady() { + return true; + } + }; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WriteBatchTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WriteBatchTest.java new file mode 100644 index 000000000000..1fec528406ee --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/WriteBatchTest.java @@ -0,0 +1,383 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore; + +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATED_SINGLE_FIELD_PROTO; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATE_SINGLE_FIELD_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.commit; +import static com.google.cloud.firestore.LocalFirestoreHelper.commitResponse; +import static com.google.cloud.firestore.LocalFirestoreHelper.create; +import static com.google.cloud.firestore.LocalFirestoreHelper.delete; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.LocalFirestoreHelper.set; +import static com.google.cloud.firestore.LocalFirestoreHelper.update; +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.doReturn; + +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.spi.v1.FirestoreRpc; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.Write; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.ArgumentCaptor; +import org.mockito.ArgumentMatchers; +import org.mockito.Captor; +import org.mockito.Mockito; +import org.mockito.Spy; +import org.mockito.junit.MockitoJUnitRunner; + +@RunWith(MockitoJUnitRunner.class) +public class WriteBatchTest { + + @Spy + private final FirestoreImpl firestoreMock = + new FirestoreImpl( + FirestoreOptions.newBuilder().setProjectId("test-project").build(), + Mockito.mock(FirestoreRpc.class)); + + @Captor private ArgumentCaptor commitCapture; + @Captor private ArgumentCaptor batchWriteCapture; + + private WriteBatch batch; + private DocumentReference documentReference; + + @Before + public void before() { + batch = firestoreMock.batch(); + documentReference = firestoreMock.document("coll/doc"); + } + + @Test + public void updateDocument() throws Exception { + doReturn(commitResponse(4, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + List preconditions = + Arrays.asList( + com.google.firestore.v1.Precondition.newBuilder().setExists(true).build(), + com.google.firestore.v1.Precondition.newBuilder().setExists(true).build(), + com.google.firestore.v1.Precondition.newBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.getDefaultInstance()) + .build(), + com.google.firestore.v1.Precondition.newBuilder() + .setUpdateTime(com.google.protobuf.Timestamp.getDefaultInstance()) + .build()); + + Precondition updateTime = Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(0, 0)); + + batch.update(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP); + batch.update(documentReference, "foo", "bar"); + batch.update(documentReference, updateTime, "foo", "bar"); + batch.update(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP, updateTime); + + assertEquals(4, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + List writes = new ArrayList<>(); + + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + writes.add( + update( + LocalFirestoreHelper.SINGLE_FIELD_PROTO, + Collections.singletonList("foo"), + preconditions.get(i))); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void updateDocumentWithPOJO() throws Exception { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch.update(documentReference, "foo", UPDATE_SINGLE_FIELD_OBJECT); + assertEquals(1, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + assertEquals(1, writeResults.size()); + + CommitRequest actual = commitCapture.getValue(); + CommitRequest expected = + commit(update(UPDATED_SINGLE_FIELD_PROTO, Collections.singletonList("foo"))); + assertEquals(expected, actual); + } + + @Test + public void setDocument() throws Exception { + doReturn(commitResponse(4, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP, SetOptions.merge()) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT, SetOptions.merge()); + + List writes = new ArrayList<>(); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo"))); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo"))); + + assertEquals(4, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void setDocumentWithValue() throws Exception { + doReturn(commitResponse(4, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_PROTO) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_PROTO, SetOptions.merge()) + .set(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT, SetOptions.merge()); + + List writes = new ArrayList<>(); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo"))); + writes.add(set(LocalFirestoreHelper.SINGLE_FIELD_PROTO, Arrays.asList("foo"))); + + assertEquals(4, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void setDocumentWithFloat() throws Exception { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch.set(documentReference, LocalFirestoreHelper.SINGLE_FLOAT_MAP); + + List writes = new ArrayList<>(); + writes.add(set(LocalFirestoreHelper.SINGLE_FLOAT_PROTO)); + + assertEquals(1, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void omitWriteResultForDocumentTransforms() throws Exception { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch.set(documentReference, map("time", FieldValue.serverTimestamp())); + + assertEquals(1, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + assertEquals(1, writeResults.size()); + } + + @Test + public void createDocument() throws Exception { + doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch + .create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_MAP) + .create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT); + + assertEquals(2, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + List writes = new ArrayList<>(); + + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + writes.add(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void createDocumentWithValue() throws Exception { + doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch + .create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_PROTO) + .create(documentReference, LocalFirestoreHelper.SINGLE_FIELD_OBJECT); + + assertEquals(2, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + List writes = new ArrayList<>(); + + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + writes.add(create(LocalFirestoreHelper.SINGLE_FIELD_PROTO)); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void createDocumentWithFloat() throws Exception { + doReturn(commitResponse(1, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + batch.create(documentReference, LocalFirestoreHelper.SINGLE_FLOAT_MAP); + + assertEquals(1, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + List writes = new ArrayList<>(); + + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + writes.add(create(LocalFirestoreHelper.SINGLE_FLOAT_PROTO)); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void deleteDocument() throws Exception { + doReturn(commitResponse(2, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + List writes = new ArrayList<>(); + batch.delete(documentReference); + writes.add(delete()); + + batch.delete(documentReference, Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(1, 2))); + com.google.firestore.v1.Precondition.Builder precondition = + com.google.firestore.v1.Precondition.newBuilder(); + precondition.getUpdateTimeBuilder().setSeconds(1).setNanos(2); + writes.add(delete(precondition.build())); + + assertEquals(2, batch.getMutationsSize()); + + List writeResults = batch.commit().get(); + + for (int i = 0; i < writeResults.size(); ++i) { + assertEquals(Timestamp.ofTimeSecondsAndNanos(i, i), writeResults.get(i).getUpdateTime()); + } + + CommitRequest commitRequest = commitCapture.getValue(); + assertEquals(commit(writes.toArray(new Write[] {})), commitRequest); + } + + @Test + public void throwsWhenModifyingACommittedWriteBatch() throws Exception { + doReturn(commitResponse(0, 0)) + .when(firestoreMock) + .sendRequest( + commitCapture.capture(), + ArgumentMatchers.>any()); + + String expectedErrorMessage = "Cannot modify a WriteBatch that has already been committed."; + + DocumentReference docRef = firestoreMock.collection("foo").document("bar"); + + // Commit a batch. + WriteBatch batch = firestoreMock.batch(); + batch.commit().get(); + + // Then run other operations in the same batch. + LocalFirestoreHelper.assertException( + () -> { + batch.set(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + batch.update(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + batch.create(docRef, map("foo", "bar")); + }, + expectedErrorMessage); + LocalFirestoreHelper.assertException( + () -> { + batch.delete(docRef); + }, + expectedErrorMessage); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java new file mode 100644 index 000000000000..32c8ba852a2b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBaseTest.java @@ -0,0 +1,187 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.LocalFirestoreHelper.autoId; +import static com.google.cloud.firestore.it.ITQueryTest.map; + +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.FirestoreSpy; +import com.google.cloud.firestore.ListenerRegistration; +import com.google.common.base.Preconditions; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.junit.After; +import org.junit.Before; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public abstract class ITBaseTest { + + /** + * Firestore databases can be subject to a ~30s "cold start" delay if they have not been used + * recently, so before any tests run we "prime" the backend. + */ + private static final long PRIMING_TIMEOUT_MS = 45000; + + private static final Logger logger = Logger.getLogger(ITBaseTest.class.getName()); + + protected Firestore firestore; + protected FirestoreSpy firestoreSpy; + private FirestoreOptions firestoreOptions; + private boolean backendPrimed = false; + + protected enum FirestoreEdition { + STANDARD, + ENTERPRISE + } + + static String getTargetBackend() { + String targetPropertyName = "FIRESTORE_TARGET_BACKEND"; + String targetBackend = System.getProperty(targetPropertyName); + if (targetBackend == null) { + targetBackend = System.getenv(targetPropertyName); + } + + return targetBackend; + } + + static FirestoreEdition getFirestoreEdition() { + String editionPropertyName = "FIRESTORE_EDITION"; + String firestoreEdition = System.getProperty(editionPropertyName); + if (firestoreEdition == null) { + firestoreEdition = System.getenv(editionPropertyName); + } + + if (firestoreEdition == null) { + return FirestoreEdition.STANDARD; + } + return FirestoreEdition.valueOf(firestoreEdition.toUpperCase()); + } + + @Before + public void before() throws Exception { + FirestoreOptions.Builder optionsBuilder = FirestoreOptions.newBuilder(); + + String dbPropertyName = "FIRESTORE_NAMED_DATABASE"; + String namedDb = System.getProperty(dbPropertyName); + if (namedDb == null) { + namedDb = System.getenv(dbPropertyName); + } + if (namedDb != null) { + logger.log(Level.INFO, "Integration test using named database " + namedDb); + optionsBuilder = optionsBuilder.setDatabaseId(namedDb); + } else { + logger.log(Level.INFO, "Integration test using default database."); + } + + String targetBackend = getTargetBackend(); + TransportChannelProvider defaultProvider = optionsBuilder.build().getTransportChannelProvider(); + if (targetBackend != null) { + if (targetBackend.equals("PROD")) { + // do nothing to use the default + } else if (targetBackend.equals("QA")) { + optionsBuilder.setChannelProvider( + defaultProvider.withEndpoint("staging-firestore.sandbox.googleapis.com:443")); + } else if (targetBackend.equals("NIGHTLY")) { + optionsBuilder.setChannelProvider( + defaultProvider.withEndpoint("test-firestore.sandbox.googleapis.com:443")); + } else if (targetBackend.equals("EMULATOR")) { + optionsBuilder.setEmulatorHost("localhost:8080"); + } + } + + firestoreOptions = optionsBuilder.build(); + logger.log( + Level.INFO, + "Integration test against " + firestoreOptions.getTransportChannelProvider().getEndpoint()); + firestore = firestoreOptions.getService(); + primeBackend(); + } + + public void primeBackend() throws Exception { + if (backendPrimed) return; + + backendPrimed = true; + CompletableFuture watchInitialized = new CompletableFuture<>(); + CompletableFuture watchUpdateReceived = new CompletableFuture<>(); + DocumentReference docRef = firestore.collection(autoId()).document(); + ListenerRegistration listenerRegistration = + docRef.addSnapshotListener( + (snapshot, error) -> { + if (error != null) { + logger.log( + Level.SEVERE, "Prime backend received error in snapshot listener.", error); + if (!watchInitialized.isDone()) { + watchInitialized.completeExceptionally(error); + } else if (!watchUpdateReceived.isDone()) { + watchUpdateReceived.completeExceptionally(error); + } + } + if (snapshot != null) { + if ("done".equals(snapshot.get("value"))) { + watchUpdateReceived.complete(null); + } else { + watchInitialized.complete(null); + } + } + }); + + // Wait for watch to initialize and deliver first event. + watchInitialized.get(PRIMING_TIMEOUT_MS, TimeUnit.MILLISECONDS); + + // Use a transaction to perform a write without triggering any local events. + docRef + .getFirestore() + .runTransaction( + transaction -> { + transaction.set(docRef, map("value", "done")); + return null; + }); + + // Wait to see the write on the watch stream. + watchUpdateReceived.get(PRIMING_TIMEOUT_MS, TimeUnit.MILLISECONDS); + + listenerRegistration.remove(); + } + + @After + public void after() throws Exception { + Preconditions.checkNotNull( + firestore, + "Error instantiating Firestore. Check that the service account credentials were properly" + + " set."); + firestore.close(); + firestore = null; + firestoreOptions = null; + firestoreSpy = null; + } + + public FirestoreSpy useFirestoreSpy() { + if (firestoreSpy == null) { + firestoreSpy = new FirestoreSpy(firestoreOptions); + firestore = firestoreSpy.spy; + } + return firestoreSpy; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBulkWriterTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBulkWriterTest.java new file mode 100644 index 000000000000..931a28735107 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITBulkWriterTest.java @@ -0,0 +1,196 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.api.core.ApiFuture; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.BulkWriter; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.LocalFirestoreHelper; +import com.google.cloud.firestore.WriteResult; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class ITBulkWriterTest extends ITBaseTest { + private CollectionReference randomColl; + private DocumentReference randomDoc; + + @Rule public TestName testName = new TestName(); + + @Before + public void before() throws Exception { + super.before(); + randomColl = + firestore.collection( + String.format("java-%s-%s", testName.getMethodName(), LocalFirestoreHelper.autoId())); + randomDoc = randomColl.document(); + } + + @Test + public void bulkWriterCreate() throws Exception { + DocumentReference docRef = randomColl.document(); + firestore.bulkWriter(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.create(docRef, Collections.singletonMap("foo", "bar")); + writer.close(); + + assertNotNull(result.get().getUpdateTime()); + DocumentSnapshot snapshot = docRef.get().get(); + assertEquals("bar", snapshot.get("foo")); + } + + @Test + public void bulkWriterCreateAddsPrecondition() throws Exception { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("foo", "bar")).get(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.create(docRef, Collections.singletonMap("foo", "bar")); + writer.close(); + + try { + result.get(); + fail("Create operation should have thrown exception"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("already exists")); + } + } + + @Test + public void bulkWriterSet() throws Exception { + DocumentReference docRef = randomColl.document(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.set(docRef, Collections.singletonMap("foo", "bar")); + writer.close(); + + assertNotNull(result.get().getUpdateTime()); + DocumentSnapshot snapshot = docRef.get().get(); + assertEquals("bar", snapshot.get("foo")); + } + + @Test + public void bulkWriterUpdate() throws Exception { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("foo", "oldValue")).get(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.update(docRef, "foo", "newValue"); + writer.close(); + + assertNotNull(result.get().getUpdateTime()); + DocumentSnapshot snapshot = docRef.get().get(); + assertEquals("newValue", snapshot.get("foo")); + } + + @Test + public void bulkWriterUpdateAddsPrecondition() throws Exception { + DocumentReference docRef = randomColl.document(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.update(docRef, "foo", "newValue"); + writer.close(); + + try { + result.get(); + fail("Update operation should have thrown exception"); + } catch (Exception e) { + assertTrue(e.getMessage().contains("to update")); + } + } + + @Test + public void bulkWriterDelete() throws Exception { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("foo", "oldValue")).get(); + + BulkWriter writer = firestore.bulkWriter(); + ApiFuture result = writer.delete(docRef); + writer.close(); + + assertNotNull(result.get().getUpdateTime()); + // TODO(b/158502664): Remove this check once we can get write times. + assertEquals(Timestamp.ofTimeSecondsAndNanos(0, 0), result.get().getUpdateTime()); + DocumentSnapshot snapshot = docRef.get().get(); + assertNull(snapshot.get("foo")); + } + + @Test + public void bulkWriterOnResult() throws Exception { + class NamedThreadFactory implements ThreadFactory { + public Thread newThread(Runnable r) { + return new Thread(r, "bulkWriterSuccess"); + } + } + Executor executor = Executors.newSingleThreadExecutor(new NamedThreadFactory()); + final List operations = new ArrayList<>(); + + BulkWriter writer = firestore.bulkWriter(); + writer.addWriteResultListener( + executor, + (documentReference, result) -> { + operations.add("operation"); + assertTrue(Thread.currentThread().getName().contains("bulkWriterSuccess")); + }); + writer.set(randomDoc, Collections.singletonMap("foo", "bar")); + writer.flush().get(); + assertEquals("operation", operations.get(0)); + } + + @Test + public void bulkWriterOnError() throws Exception { + class NamedThreadFactory implements ThreadFactory { + public Thread newThread(Runnable r) { + return new Thread(r, "bulkWriterException"); + } + } + Executor executor = Executors.newSingleThreadExecutor(new NamedThreadFactory()); + final List operations = new ArrayList<>(); + + BulkWriter writer = firestore.bulkWriter(); + writer.addWriteErrorListener( + executor, + error -> { + operations.add("operation-error"); + assertTrue(Thread.currentThread().getName().contains("bulkWriterException")); + return false; + }); + + writer.addWriteResultListener( + executor, (documentReference, result) -> fail("The success listener shouldn't be called")); + writer.update(randomDoc, "foo", "bar"); + writer.flush().get(); + assertEquals("operation-error", operations.get(0)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTest.java new file mode 100644 index 000000000000..8f41c627f995 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTest.java @@ -0,0 +1,1229 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_BATCH_COMMIT; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_BULK_WRITER_COMMIT; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_COL_REF_LIST_DOCUMENTS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_CREATE; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_DELETE; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_GET; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_LIST_COLLECTIONS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_SET; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_DOC_REF_UPDATE; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_PARTITION_QUERY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_QUERY_GET; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_BEGIN; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_COMMIT; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_GET_AGGREGATION_QUERY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_GET_DOCUMENTS; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_GET_QUERY; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_ROLLBACK; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.METHOD_NAME_TRANSACTION_RUN; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + +import com.google.api.gax.rpc.NotFoundException; +import com.google.cloud.firestore.BulkWriter; +import com.google.cloud.firestore.BulkWriterOptions; +import com.google.cloud.firestore.CollectionGroup; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldMask; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOpenTelemetryOptions; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.Precondition; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.SetOptions; +import com.google.cloud.firestore.WriteBatch; +import com.google.cloud.firestore.it.ITTracingTest.Pojo; +import com.google.cloud.opentelemetry.trace.TraceConfiguration; +import com.google.cloud.opentelemetry.trace.TraceExporter; +import com.google.cloud.trace.v1.TraceServiceClient; +import com.google.common.base.Preconditions; +import com.google.devtools.cloudtrace.v1.Trace; +import com.google.devtools.cloudtrace.v1.TraceSpan; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanContext; +import io.opentelemetry.api.trace.TraceFlags; +import io.opentelemetry.api.trace.TraceState; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.context.Context; +import io.opentelemetry.context.Scope; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; +import io.opentelemetry.sdk.trace.export.SpanExporter; +import io.opentelemetry.sdk.trace.samplers.Sampler; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +// This End-to-End test verifies Client-side Tracing Functionality instrumented using the +// OpenTelemetry API. +// The test depends on the following external APIs/Services: +// 1. Java OpenTelemetry SDK +// 2. Cloud Trace Exporter +// 3. TraceServiceClient from Cloud Trace API v1. +// +// Permissions required to run this test (https://cloud.google.com/trace/docs/iam#trace-roles): +// 1. gcloud auth application-default login must be run with the test user. +// 2. To write traces, test user must have one of roles/cloudtrace.[admin|agent|user] roles. +// 3. To read traces, test user must have one of roles/cloudtrace.[admin|user] roles. +// +// Each test-case has the following workflow: +// 1. OpenTelemetry SDK is initialized with Cloud Trace Exporter and 100% Trace Sampling +// 2. On initialization, Firestore client is provided the OpenTelemetry SDK object from (1) +// 3. A custom TraceID is generated and injected using a custom SpanContext +// 4. Firestore operations are run inside a root TraceSpan created using the custom SpanContext from +// (3). +// 5. Traces are read-back using TraceServiceClient and verified against expected Call Stacks. +// TODO In the future it would be great to have a single test-driver for this test and +// ITTracingTest. +public abstract class ITE2ETracingTest extends ITBaseTest { + protected abstract boolean isUsingGlobalOpenTelemetrySDK(); + + // Helper class to track call-stacks in a trace + protected static class TraceContainer { + + // Maps Span ID to TraceSpan + private final Map idSpanMap; + + // Maps Parent Span ID to a list of Child SpanIDs, useful for top-down traversal + private final Map> parentChildIdMap; + + // Tracks the Root Span ID + private long rootId; + + public TraceContainer(String rootSpanName, Trace trace) { + idSpanMap = new TreeMap<>(); + parentChildIdMap = new TreeMap<>(); + for (TraceSpan span : trace.getSpansList()) { + long spanId = span.getSpanId(); + idSpanMap.put(spanId, span); + if (rootSpanName.equals(span.getName())) { + rootId = span.getSpanId(); + } + + // Add self as a child of the parent span + if (!parentChildIdMap.containsKey(span.getParentSpanId())) { + parentChildIdMap.put(span.getParentSpanId(), new ArrayList<>()); + } + parentChildIdMap.get(span.getParentSpanId()).add(spanId); + } + } + + String spanName(long spanId) { + return idSpanMap.get(spanId).getName(); + } + + List childSpans(long spanId) { + return parentChildIdMap.get(spanId); + } + + // This method only works for matching call stacks with traces which have children of distinct + // type at all levels. This is good enough as the intention is to validate if the e2e path is + // WAI - the intention is not to validate Cloud Trace's correctness w.r.t. durability of all + // kinds of traces. + boolean containsCallStack(String... callStack) throws RuntimeException { + List expectedCallStack = Arrays.asList(callStack); + if (expectedCallStack.isEmpty()) { + throw new RuntimeException("Input callStack is empty"); + } + return dfsContainsCallStack(rootId, expectedCallStack); + } + + // Depth-first check for call stack in the trace + private boolean dfsContainsCallStack(long spanId, List expectedCallStack) { + logger.info( + "span=" + + spanName(spanId) + + ", expectedCallStack[0]=" + + (expectedCallStack.isEmpty() ? "null" : expectedCallStack.get(0))); + if (expectedCallStack.isEmpty()) { + return false; + } + if (spanName(spanId).equals(expectedCallStack.get(0))) { + // Recursion termination + if (childSpans(spanId) == null) { + logger.info("No more children for " + spanName(spanId)); + return true; + } else { + // Examine the child spans + for (Long childSpan : childSpans(spanId)) { + int callStackListSize = expectedCallStack.size(); + logger.info( + "childSpan=" + + spanName(childSpan) + + ", expectedCallStackSize=" + + callStackListSize); + if (dfsContainsCallStack( + childSpan, + expectedCallStack.subList( + /* fromIndexInclusive= */ 1, /*toIndexExclusive*/ callStackListSize))) { + return true; + } + } + } + } else { + logger.info(spanName(spanId) + " didn't match " + expectedCallStack.get(0)); + } + return false; + } + } + + private static final Logger logger = Logger.getLogger(ITE2ETracingTest.class.getName()); + + private static final String SERVICE = "google.firestore.v1.Firestore/"; + + private static final String BATCH_GET_DOCUMENTS_RPC_NAME = "BatchGetDocuments"; + + private static final String BATCH_WRITE_RPC_NAME = "BatchWrite"; + + private static final String BEGIN_TRANSACTION_RPC_NAME = "BeginTransaction"; + + private static final String COMMIT_RPC_NAME = "Commit"; + + private static final String LIST_COLLECTIONS_RPC_NAME = "ListCollectionIds"; + + private static final String LIST_DOCUMENTS_RPC_NAME = "ListDocuments"; + + private static final String ROLLBACK_RPC_NAME = "Rollback"; + + private static final String RUN_AGGREGATION_QUERY_RPC_NAME = "RunAggregationQuery"; + + private static final String RUN_QUERY_RPC_NAME = "RunQuery"; + + private static final int NUM_TRACE_ID_BYTES = 32; + + private static final int NUM_SPAN_ID_BYTES = 16; + + private static final int GET_TRACE_RETRY_COUNT = 60; + + private static final int GET_TRACE_RETRY_BACKOFF_MILLIS = 1000; + + private static final int TRACE_FORCE_FLUSH_MILLIS = 3000; + + private static final int TRACE_PROVIDER_SHUTDOWN_MILLIS = 1000; + + // Random int generator for trace ID and span ID + private static Random random; + + private static SpanExporter traceExporter; + + // Required for reading back traces from Cloud Trace for validation + private static TraceServiceClient traceClient_v1; + + // Custom SpanContext for each test, required for TraceID injection + private static SpanContext customSpanContext; + + // Trace read back from Cloud Trace using traceClient_v1 for verification + private static Trace retrievedTrace; + + private static String rootSpanName; + private static Tracer tracer; + + // Required to set custom-root span + private static OpenTelemetrySdk openTelemetrySdk; + + private static boolean isNightlyTesting; + private static String projectId; + + private static Firestore firestore; + + @BeforeClass + public static void setup() throws IOException { + String jobType = System.getenv("GITHUB_ENV_VAR_KOKORO_JOB_TYPE"); + isNightlyTesting = jobType != null && jobType.equalsIgnoreCase("nightly"); + + projectId = FirestoreOptions.getDefaultProjectId(); + logger.info("projectId:" + projectId); + + // TODO(jimit) Make it re-usable w/ InMemorySpanExporter + traceExporter = + TraceExporter.createWithConfiguration( + TraceConfiguration.builder().setProjectId(projectId).build()); + + traceClient_v1 = TraceServiceClient.create(); + + random = new Random(); + } + + @Before + public void before() throws Exception { + // Set up OTel SDK + Resource resource = Resource.getDefault(); + + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + openTelemetrySdk = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build()) + .setSampler(Sampler.alwaysOn()) + .build()) + .buildAndRegisterGlobal(); + } else { + openTelemetrySdk = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(BatchSpanProcessor.builder(traceExporter).build()) + .setSampler(Sampler.alwaysOn()) + .build()) + .build(); + } + + // Initialize the Firestore DB w/ the OTel SDK. Ideally we'd do this is the @BeforeAll method + // but because gRPC traces need to be deterministically force-flushed, firestore.shutdown() + // must be called in @After for each test. + FirestoreOptions.Builder optionsBuilder = FirestoreOptions.newBuilder(); + if (!isUsingGlobalOpenTelemetrySDK()) { + optionsBuilder = + optionsBuilder.setOpenTelemetryOptions( + FirestoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(openTelemetrySdk) + .build()); + } + + String namedDb = System.getProperty("FIRESTORE_NAMED_DATABASE"); + if (namedDb != null) { + logger.log(Level.INFO, "Integration test using named database " + namedDb); + optionsBuilder = optionsBuilder.setDatabaseId(namedDb); + } else { + logger.log(Level.INFO, "Integration test using default database."); + } + firestore = optionsBuilder.build().getService(); + Preconditions.checkNotNull( + firestore, + "Error instantiating Firestore. Check that the service account credentials " + + "were properly set."); + + assumeFalse( + "ITTracingTest is not supported against the emulator.", + "EMULATOR".equals(getTargetBackend())); + + // Set up the tracer for custom TraceID injection + rootSpanName = + String.format("%s%d", this.getClass().getSimpleName(), System.currentTimeMillis()); + if (isUsingGlobalOpenTelemetrySDK()) { + tracer = GlobalOpenTelemetry.getTracer(rootSpanName); + } else { + tracer = + firestore + .getOptions() + .getOpenTelemetryOptions() + .getOpenTelemetry() + .getTracer(rootSpanName); + } + + // Get up a new SpanContext (ergo TraceId) for each test + customSpanContext = getNewSpanContext(); + assertNotNull(customSpanContext); + assertNull(retrievedTrace); + + // We only perform end-to-end tracing tests on a nightly basis. + assumeTrue(isNightlyTesting); + } + + @After + public void after() throws Exception { + firestore.shutdown(); + rootSpanName = null; + tracer = null; + retrievedTrace = null; + customSpanContext = null; + } + + @AfterClass + public static void teardown() throws Exception { + traceClient_v1.close(); + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().shutdown(); + completableResultCode.join(TRACE_PROVIDER_SHUTDOWN_MILLIS, TimeUnit.MILLISECONDS); + } + + // Generates a random hex string of length `numBytes` + private String generateRandomHexString(int numBytes) { + StringBuffer newTraceId = new StringBuffer(); + while (newTraceId.length() < numBytes) { + newTraceId.append(Integer.toHexString(random.nextInt())); + } + return newTraceId.substring(0, numBytes); + } + + protected String generateNewTraceId() { + return generateRandomHexString(NUM_TRACE_ID_BYTES); + } + + // Generates a random 16-byte hex string + protected String generateNewSpanId() { + return generateRandomHexString(NUM_SPAN_ID_BYTES); + } + + // Generates a new SpanContext w/ random traceId,spanId + protected SpanContext getNewSpanContext() { + String traceId = generateNewTraceId(); + String spanId = generateNewSpanId(); + logger.info("traceId=" + traceId + ", spanId=" + spanId); + + return SpanContext.create(traceId, spanId, TraceFlags.getSampled(), TraceState.getDefault()); + } + + protected Span getNewRootSpanWithContext() { + // Execute the DB operation in the context of the custom root span. + return tracer + .spanBuilder(rootSpanName) + .setParent(Context.root().with(Span.wrap(customSpanContext))) + .startSpan(); + } + + protected String grpcSpanName(String rpcName) { + return "Sent." + SERVICE + rpcName; + } + + protected void waitForTracesToComplete() throws Exception { + logger.info("Flushing traces..."); + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().forceFlush(); + completableResultCode.join(TRACE_FORCE_FLUSH_MILLIS, TimeUnit.MILLISECONDS); + } + + // Validates `retrievedTrace`. Cloud Trace indexes traces w/ eventual consistency, even when + // indexing traceId, therefore the test must retry a few times before the complete trace is + // available. + // For Transaction traces, there may be more spans than in the trace than specified in + // `callStack`. So `numExpectedSpans` is the expected total number of spans (and not just the + // spans in `callStack`) + protected void fetchAndValidateTrace( + String traceId, int numExpectedSpans, List> callStackList) + throws InterruptedException { + // Large enough count to accommodate eventually consistent Cloud Trace backend + int numRetries = GET_TRACE_RETRY_COUNT; + // Account for rootSpanName + numExpectedSpans++; + + // Fetch traces + do { + try { + retrievedTrace = traceClient_v1.getTrace(projectId, traceId); + assertEquals(traceId, retrievedTrace.getTraceId()); + + logger.info( + "expectedSpanCount=" + + numExpectedSpans + + ", retrievedSpanCount=" + + retrievedTrace.getSpansCount()); + } catch (NotFoundException notFound) { + logger.info("Trace not found, retrying in " + GET_TRACE_RETRY_BACKOFF_MILLIS + " ms"); + } catch (IndexOutOfBoundsException outOfBoundsException) { + logger.info("Call stack not found in trace. Retrying."); + } + if (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount()) { + Thread.sleep(GET_TRACE_RETRY_BACKOFF_MILLIS); + } + } while (numRetries-- > 0 + && (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount())); + + if (retrievedTrace == null || numExpectedSpans != retrievedTrace.getSpansCount()) { + throw new RuntimeException( + "Expected number of spans: " + + numExpectedSpans + + ", Actual number of spans: " + + (retrievedTrace != null + ? retrievedTrace.getSpansList().toString() + : "Trace NOT_FOUND")); + } + + TraceContainer traceContainer = new TraceContainer(rootSpanName, retrievedTrace); + + for (List callStack : callStackList) { + // Update all call stacks to be rooted at rootSpanName + ArrayList expectedCallStack = new ArrayList<>(callStack); + + // numExpectedSpans should account for rootSpanName (not passed in callStackList) + expectedCallStack.add(0, rootSpanName); + + // *May be* the full trace was returned + logger.info("Checking if TraceContainer contains the callStack"); + String[] expectedCallList = new String[expectedCallStack.size()]; + if (!traceContainer.containsCallStack(expectedCallStack.toArray(expectedCallList))) { + throw new RuntimeException( + "Expected spans: " + + expectedCallList.toString() + + ", Actual spans: " + + (retrievedTrace != null + ? retrievedTrace.getSpansList().toString() + : "Trace NOT_FOUND")); + } + logger.severe("CallStack not found in TraceContainer."); + } + } + + // Validates `retrievedTrace`. Cloud Trace indexes traces w/ eventual consistency, even when + // indexing traceId, therefore the test must retry a few times before the complete trace is + // available. + // For Non-Transaction traces, there is a 1:1 ratio of spans in `spanNames` and in the trace. + protected void fetchAndValidateTrace(String traceId, String... spanNames) + throws InterruptedException { + fetchAndValidateTrace(traceId, spanNames.length, Arrays.asList(Arrays.asList(spanNames))); + } + + @Test + public void traceContainerTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").whereEqualTo("foo", "my_non_existent_value").get().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + Trace traceResp = null; + int expectedSpanCount = 3; + + int numRetries = GET_TRACE_RETRY_COUNT; + do { + try { + traceResp = traceClient_v1.getTrace(projectId, customSpanContext.getTraceId()); + if (traceResp.getSpansCount() == expectedSpanCount) { + logger.info("Success: Got " + expectedSpanCount + " spans."); + break; + } + } catch (NotFoundException notFoundException) { + Thread.sleep(GET_TRACE_RETRY_BACKOFF_MILLIS); + logger.info("Trace not found, retrying in " + GET_TRACE_RETRY_BACKOFF_MILLIS + " ms"); + } + logger.info( + "Trace Found. The trace did not contain " + + expectedSpanCount + + " spans. Going to retry."); + numRetries--; + } while (numRetries > 0); + + // Make sure we got as many spans as we expected. + assertNotNull(traceResp); + assertEquals(expectedSpanCount, traceResp.getSpansCount()); + + TraceContainer traceCont = new TraceContainer(rootSpanName, traceResp); + + // Contains exact path + assertTrue( + traceCont.containsCallStack( + rootSpanName, METHOD_NAME_QUERY_GET, grpcSpanName(RUN_QUERY_RPC_NAME))); + + // Top-level mismatch + assertFalse(traceCont.containsCallStack(METHOD_NAME_QUERY_GET, RUN_QUERY_RPC_NAME)); + + // Mid-level match + assertFalse(traceCont.containsCallStack(rootSpanName, METHOD_NAME_QUERY_GET)); + + // Leaf-level mismatch/missing + assertFalse( + traceCont.containsCallStack( + rootSpanName, METHOD_NAME_QUERY_GET, RUN_AGGREGATION_QUERY_RPC_NAME)); + } + + @Test + // Trace an Aggregation.Get request + public void aggregateQueryGetTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + // Execute the Firestore SDK op + firestore.collection("col").count().get().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + "AggregationQuery.Get", + grpcSpanName(RUN_AGGREGATION_QUERY_RPC_NAME)); + } + + @Test + public void bulkWriterCommitTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + // Execute the Firestore SDK op + ScheduledExecutorService bulkWriterExecutor = Executors.newSingleThreadScheduledExecutor(); + BulkWriter bulkWriter = + firestore.bulkWriter(BulkWriterOptions.builder().setExecutor(bulkWriterExecutor).build()); + bulkWriter.set( + firestore.collection("col").document("foo"), + Collections.singletonMap("bulk-foo", "bulk-bar")); + bulkWriter.close(); + bulkWriterExecutor.awaitTermination(100, TimeUnit.MILLISECONDS); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_BULK_WRITER_COMMIT, + grpcSpanName(BATCH_WRITE_RPC_NAME)); + } + + @Test + public void partitionQueryTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + CollectionGroup collectionGroup = firestore.collectionGroup("col"); + collectionGroup.getPartitions(3).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_PARTITION_QUERY, + grpcSpanName(METHOD_NAME_PARTITION_QUERY)); + } + + @Test + public void collectionListDocumentsTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").listDocuments(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_COL_REF_LIST_DOCUMENTS, + grpcSpanName(LIST_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docRefCreateTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document().create(Collections.singletonMap("foo", "bar")).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_CREATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefCreate2TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document().create(new Pojo(1)).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_CREATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSetTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("foo").set(Collections.singletonMap("foo", "bar")).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_SET, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet2TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .set(Collections.singletonMap("foo", "bar"), SetOptions.merge()) + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_SET, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet3TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("foo").set(new Pojo(1)).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_SET, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet4TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("foo").set(new Pojo(1), SetOptions.merge()).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_SET, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdateTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .update(Collections.singletonMap("foo", "bar")) + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate2TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .update(Collections.singletonMap("foo", "bar"), Precondition.NONE) + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate3TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("foo").update("key", "value", "key2", "value2").get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate4TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .update(FieldPath.of("key"), "value", FieldPath.of("key2"), "value2") + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate5TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .update(Precondition.NONE, "key", "value", "key2", "value2") + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate6TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .collection("col") + .document("foo") + .update(Precondition.NONE, FieldPath.of("key"), "value", FieldPath.of("key2"), "value2") + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_UPDATE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefDeleteTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("doc0").delete().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_DELETE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefDelete2TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("doc0").delete(Precondition.NONE).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_DELETE, + METHOD_NAME_BATCH_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefGetTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("doc0").get().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_GET, + grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docRefGet2TraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("doc0").get(FieldMask.of("foo")).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_GET, + grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docListCollectionsTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").document("doc0").listCollections(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + // Read and validate traces + fetchAndValidateTrace( + customSpanContext.getTraceId(), + METHOD_NAME_DOC_REF_LIST_COLLECTIONS, + grpcSpanName(LIST_COLLECTIONS_RPC_NAME)); + } + + @Test + public void getAllTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + DocumentReference docRef0 = firestore.collection("col").document(); + DocumentReference docRef1 = firestore.collection("col").document(); + DocumentReference[] docs = {docRef0, docRef1}; + firestore.getAll(docs).get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + } + + @Test + public void queryGetTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore.collection("col").whereEqualTo("foo", "my_non_existent_value").get().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), METHOD_NAME_QUERY_GET, grpcSpanName(RUN_QUERY_RPC_NAME)); + } + + @Test + public void transactionTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .runTransaction( + transaction -> { + Query q = firestore.collection("col").whereGreaterThan("bla", ""); + DocumentReference d = firestore.collection("col").document("foo"); + // Document Query. + transaction.get(q).get(); + + // Aggregation Query. + transaction.get(q.count()); + + // Get multiple documents. + transaction.getAll(d, d).get(); + + // Commit 2 documents. + transaction.set( + firestore.collection("foo").document("bar"), + Collections.singletonMap("foo", "bar")); + transaction.set( + firestore.collection("foo").document("bar2"), + Collections.singletonMap("foo2", "bar2")); + return 0; + }) + .get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 11, + Arrays.asList( + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_BEGIN, + grpcSpanName(BEGIN_TRANSACTION_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_BEGIN, + grpcSpanName(BEGIN_TRANSACTION_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_QUERY, + grpcSpanName(RUN_QUERY_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_AGGREGATION_QUERY, + grpcSpanName(RUN_AGGREGATION_QUERY_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_DOCUMENTS, + grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_COMMIT, + grpcSpanName(COMMIT_RPC_NAME)))); + } + + @Test + public void transactionRollbackTraceTest() throws Exception { + String myErrorMessage = "My error message."; + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + firestore + .runTransaction( + transaction -> { + if (true) { + throw (new Exception(myErrorMessage)); + } + return 0; + }) + .get(); + } catch (Exception e) { + // Catch and move on. + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 5, + Arrays.asList( + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_BEGIN, + grpcSpanName(BEGIN_TRANSACTION_RPC_NAME)), + Arrays.asList( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_ROLLBACK, + grpcSpanName(ROLLBACK_RPC_NAME)))); + } + + @Test + public void writeBatchTraceTest() throws Exception { + // Make sure the test has a new SpanContext (and TraceId for injection) + assertNotNull(customSpanContext); + + // Inject new trace ID + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + WriteBatch batch = firestore.batch(); + DocumentReference docRef = firestore.collection("foo").document(); + batch.create(docRef, Collections.singletonMap("foo", "bar")); + batch.update(docRef, Collections.singletonMap("foo", "bar")); + batch.delete(docRef); + batch.commit().get(); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestGlobalOtel.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestGlobalOtel.java new file mode 100644 index 000000000000..85bfb5437837 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestGlobalOtel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.it; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITE2ETracingTestGlobalOtel extends ITE2ETracingTest { + @Override + protected boolean isUsingGlobalOpenTelemetrySDK() { + return true; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestNonGlobalOtel.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestNonGlobalOtel.java new file mode 100644 index 000000000000..21272ff2e97f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITE2ETracingTestNonGlobalOtel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.it; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITE2ETracingTestNonGlobalOtel extends ITE2ETracingTest { + @Override + protected boolean isUsingGlobalOpenTelemetrySDK() { + return false; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java new file mode 100644 index 000000000000..e14fa8a948f9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITPipelineTest.java @@ -0,0 +1,3617 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.FieldValue.vector; +import static com.google.cloud.firestore.it.ITQueryTest.map; +import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.arrayAgg; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.arrayAggDistinct; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.count; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.countAll; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.countDistinct; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.countIf; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.first; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.last; +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.sum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.add; +import static com.google.cloud.firestore.pipeline.expressions.Expression.and; +import static com.google.cloud.firestore.pipeline.expressions.Expression.array; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayContains; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayContainsAll; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayContainsAny; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayFirst; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayFirstN; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayGet; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayIndexOf; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayIndexOfAll; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayLast; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayLastIndexOf; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayLastN; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayMaximum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayMaximumN; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayMinimum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayMinimumN; +import static com.google.cloud.firestore.pipeline.expressions.Expression.arrayReverse; +import static com.google.cloud.firestore.pipeline.expressions.Expression.ceil; +import static com.google.cloud.firestore.pipeline.expressions.Expression.concat; +import static com.google.cloud.firestore.pipeline.expressions.Expression.conditional; +import static com.google.cloud.firestore.pipeline.expressions.Expression.constant; +import static com.google.cloud.firestore.pipeline.expressions.Expression.cosineDistance; +import static com.google.cloud.firestore.pipeline.expressions.Expression.dotProduct; +import static com.google.cloud.firestore.pipeline.expressions.Expression.endsWith; +import static com.google.cloud.firestore.pipeline.expressions.Expression.equal; +import static com.google.cloud.firestore.pipeline.expressions.Expression.euclideanDistance; +import static com.google.cloud.firestore.pipeline.expressions.Expression.exp; +import static com.google.cloud.firestore.pipeline.expressions.Expression.field; +import static com.google.cloud.firestore.pipeline.expressions.Expression.floor; +import static com.google.cloud.firestore.pipeline.expressions.Expression.greaterThan; +import static com.google.cloud.firestore.pipeline.expressions.Expression.lessThan; +import static com.google.cloud.firestore.pipeline.expressions.Expression.ln; +import static com.google.cloud.firestore.pipeline.expressions.Expression.log; +import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMaximum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.logicalMinimum; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapMerge; +import static com.google.cloud.firestore.pipeline.expressions.Expression.mapRemove; +import static com.google.cloud.firestore.pipeline.expressions.Expression.notEqual; +import static com.google.cloud.firestore.pipeline.expressions.Expression.nullValue; +import static com.google.cloud.firestore.pipeline.expressions.Expression.or; +import static com.google.cloud.firestore.pipeline.expressions.Expression.pow; +import static com.google.cloud.firestore.pipeline.expressions.Expression.rand; +import static com.google.cloud.firestore.pipeline.expressions.Expression.regexMatch; +import static com.google.cloud.firestore.pipeline.expressions.Expression.round; +import static com.google.cloud.firestore.pipeline.expressions.Expression.sqrt; +import static com.google.cloud.firestore.pipeline.expressions.Expression.startsWith; +import static com.google.cloud.firestore.pipeline.expressions.Expression.stringConcat; +import static com.google.cloud.firestore.pipeline.expressions.Expression.substring; +import static com.google.cloud.firestore.pipeline.expressions.Expression.subtract; +import static com.google.cloud.firestore.pipeline.expressions.Expression.timestampAdd; +import static com.google.cloud.firestore.pipeline.expressions.Expression.timestampToUnixMicros; +import static com.google.cloud.firestore.pipeline.expressions.Expression.timestampToUnixMillis; +import static com.google.cloud.firestore.pipeline.expressions.Expression.timestampToUnixSeconds; +import static com.google.cloud.firestore.pipeline.expressions.Expression.trunc; +import static com.google.cloud.firestore.pipeline.expressions.Expression.truncToPrecision; +import static com.google.cloud.firestore.pipeline.expressions.Expression.unixMicrosToTimestamp; +import static com.google.cloud.firestore.pipeline.expressions.Expression.unixMillisToTimestamp; +import static com.google.cloud.firestore.pipeline.expressions.Expression.unixSecondsToTimestamp; +import static com.google.cloud.firestore.pipeline.expressions.Expression.vectorLength; +import static com.google.cloud.firestore.pipeline.expressions.Expression.xor; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Collections.emptyList; +import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeFalse; + +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.StatusCode; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.Blob; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.GeoPoint; +import com.google.cloud.firestore.LocalFirestoreHelper; +import com.google.cloud.firestore.Pipeline; +import com.google.cloud.firestore.PipelineResult; +import com.google.cloud.firestore.pipeline.expressions.AggregateFunction; +import com.google.cloud.firestore.pipeline.expressions.Expression; +import com.google.cloud.firestore.pipeline.expressions.Field; +import com.google.cloud.firestore.pipeline.stages.Aggregate; +import com.google.cloud.firestore.pipeline.stages.AggregateHints; +import com.google.cloud.firestore.pipeline.stages.AggregateOptions; +import com.google.cloud.firestore.pipeline.stages.CollectionHints; +import com.google.cloud.firestore.pipeline.stages.CollectionOptions; +import com.google.cloud.firestore.pipeline.stages.ExplainOptions; +import com.google.cloud.firestore.pipeline.stages.FindNearest; +import com.google.cloud.firestore.pipeline.stages.FindNearestOptions; +import com.google.cloud.firestore.pipeline.stages.PipelineExecuteOptions; +import com.google.cloud.firestore.pipeline.stages.RawOptions; +import com.google.cloud.firestore.pipeline.stages.RawStage; +import com.google.cloud.firestore.pipeline.stages.Sample; +import com.google.cloud.firestore.pipeline.stages.UnnestOptions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITPipelineTest extends ITBaseTest { + private CollectionReference collection; + private Map> bookDocs; + + public CollectionReference testCollectionWithDocs(Map> docs) + throws ExecutionException, InterruptedException, TimeoutException { + CollectionReference collection = firestore.collection(LocalFirestoreHelper.autoId()); + for (Map.Entry> doc : docs.entrySet()) { + collection.document(doc.getKey()).set(doc.getValue()).get(5, TimeUnit.SECONDS); + } + return collection; + } + + List> data(List results) { + return results.stream().map(PipelineResult::getData).collect(Collectors.toList()); + } + + @Before + public void setup() throws Exception { + assumeFalse( + "This test suite only runs against the Enterprise edition.", + !getFirestoreEdition().equals(FirestoreEdition.ENTERPRISE)); + if (collection != null) { + return; + } + + bookDocs = + ImmutableMap.>builder() + .put( + "book1", + ImmutableMap.builder() + .put("title", "The Hitchhiker's Guide to the Galaxy") + .put("author", "Douglas Adams") + .put("genre", "Science Fiction") + .put("published", 1979) + .put("rating", 4.2) + .put("tags", ImmutableList.of("comedy", "space", "adventure")) + .put("awards", ImmutableMap.of("hugo", true, "nebula", false)) + .put( + "embedding", + vector(new double[] {10.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book2", + ImmutableMap.builder() + .put("title", "Pride and Prejudice") + .put("author", "Jane Austen") + .put("genre", "Romance") + .put("published", 1813) + .put("rating", 4.5) + .put("tags", ImmutableList.of("classic", "social commentary", "love")) + .put("awards", ImmutableMap.of("none", true)) + .put( + "embedding", + vector(new double[] {1.0, 10.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book3", + ImmutableMap.builder() + .put("title", "One Hundred Years of Solitude") + .put("author", "Gabriel García Márquez") + .put("genre", "Magical Realism") + .put("published", 1967) + .put("rating", 4.3) + .put("tags", ImmutableList.of("family", "history", "fantasy")) + .put("awards", ImmutableMap.of("nobel", true, "nebula", false)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 10.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book4", + ImmutableMap.builder() + .put("title", "The Lord of the Rings") + .put("author", "J.R.R. Tolkien") + .put("genre", "Fantasy") + .put("published", 1954) + .put("rating", 4.7) + .put("tags", ImmutableList.of("adventure", "magic", "epic")) + .put("awards", ImmutableMap.of("hugo", false, "nebula", false)) + .put("cost", Double.NaN) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book5", + ImmutableMap.builder() + .put("title", "The Handmaid's Tale") + .put("author", "Margaret Atwood") + .put("genre", "Dystopian") + .put("published", 1985) + .put("rating", 4.1) + .put("tags", ImmutableList.of("feminism", "totalitarianism", "resistance")) + .put("awards", ImmutableMap.of("arthur c. clarke", true, "booker prize", false)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book6", + ImmutableMap.builder() + .put("title", "Crime and Punishment") + .put("author", "Fyodor Dostoevsky") + .put("genre", "Psychological Thriller") + .put("published", 1866) + .put("rating", 4.3) + .put("tags", ImmutableList.of("philosophy", "crime", "redemption")) + .put("awards", ImmutableMap.of("none", true)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book7", + ImmutableMap.builder() + .put("title", "To Kill a Mockingbird") + .put("author", "Harper Lee") + .put("genre", "Southern Gothic") + .put("published", 1960) + .put("rating", 4.2) + .put("tags", ImmutableList.of("racism", "injustice", "coming-of-age")) + .put("awards", ImmutableMap.of("pulitzer", true)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0, 1.0})) + .build()) + .put( + "book8", + ImmutableMap.builder() + .put("title", "1984") + .put("author", "George Orwell") + .put("genre", "Dystopian") + .put("published", 1949) + .put("rating", 4.2) + .put("tags", ImmutableList.of("surveillance", "totalitarianism", "propaganda")) + .put("awards", ImmutableMap.of("prometheus", true)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 1.0, 1.0})) + .build()) + .put( + "book9", + ImmutableMap.builder() + .put("title", "The Great Gatsby") + .put("author", "F. Scott Fitzgerald") + .put("genre", "Modernist") + .put("published", 1925) + .put("rating", 4.0) + .put("tags", ImmutableList.of("wealth", "american dream", "love")) + .put("awards", ImmutableMap.of("none", true)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0, 1.0})) + .build()) + .put( + "book10", + ImmutableMap.builder() + .put("title", "Dune") + .put("author", "Frank Herbert") + .put("genre", "Science Fiction") + .put("published", 1965) + .put("rating", 4.6) + .put("tags", ImmutableList.of("politics", "desert", "ecology")) + .put("awards", ImmutableMap.of("hugo", true, "nebula", true)) + .put( + "embedding", + vector(new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 10.0})) + .build()) + .put( + "book11", + ImmutableMap.builder() + .put("title", "Timestamp Book") + .put("author", "Timestamp Author") + .put("timestamp", new Date()) + .build()) + .build(); + collection = testCollectionWithDocs(bookDocs); + } + + @Test + public void testAllDataTypes() throws Exception { + Date refDate = new Date(); + Timestamp refTimestamp = Timestamp.now(); + GeoPoint refGeoPoint = new GeoPoint(1, 2); + byte[] refBytes = new byte[] {1, 2, 3}; + double[] refVector = new double[] {1.0, 2.0, 3.0}; + + Map refMap = + map( + "number", + 1, + "string", + "a string", + "boolean", + true, + "null", + null, + "geoPoint", + refGeoPoint, + "timestamp", + refTimestamp, + "date", + Timestamp.of(refDate), + "bytes", + com.google.cloud.firestore.Blob.fromBytes(refBytes), + "vector", + vector(refVector)); + + List refArray = + Lists.newArrayList( + 1, + "a string", + true, + null, + refTimestamp, + refGeoPoint, + Timestamp.of(refDate), + com.google.cloud.firestore.Blob.fromBytes(refBytes), + vector(refVector)); + + Pipeline pipeline = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .select( + constant(1L).as("number"), + constant("a string").as("string"), + constant(true).as("boolean"), + nullValue().as("null"), + constant(refTimestamp).as("timestamp"), + constant(refDate).as("date"), + constant(refGeoPoint).as("geoPoint"), + constant(com.google.cloud.firestore.Blob.fromBytes(refBytes)).as("bytes"), + constant(vector(refVector)).as("vector"), + Expression.map(refMap).as("map"), + array(refArray).as("array")); + + List results = pipeline.execute().get().getResults(); + assertThat(results).hasSize(1); + Map data = results.get(0).getData(); + + assertThat(data.get("number")).isEqualTo(1L); + assertThat(data.get("string")).isEqualTo("a string"); + assertThat(data.get("boolean")).isEqualTo(true); + assertThat(data.get("null")).isNull(); + assertThat(data.get("geoPoint")).isEqualTo(refGeoPoint); + assertThat(data.get("timestamp")).isEqualTo(refTimestamp); + assertThat(data.get("date")).isEqualTo(Timestamp.of(refDate)); + assertThat(data.get("bytes")).isEqualTo(com.google.cloud.firestore.Blob.fromBytes(refBytes)); + assertThat(data.get("vector")).isEqualTo(vector(refVector)); + assertThat(stringOfOrderedKeyValues((Map) data.get("map"))) + .isEqualTo(stringOfOrderedKeyValues(refMap)); + assertThat(data.get("array").toString()).isEqualTo(refArray.toString()); + } + + private String stringOfOrderedKeyValues(Map map) { + return map.entrySet().stream() + .sorted(Map.Entry.comparingByKey()) + .map(e -> e.getKey() + "=" + e.getValue()) + .collect(Collectors.joining(", ")); + } + + @Test + public void testResultMetadata() throws Exception { + Pipeline pipeline = firestore.pipeline().collection(collection.getPath()); + Pipeline.Snapshot snapshot = pipeline.execute().get(); + assertThat(snapshot.getExecutionTime()).isNotNull(); + + for (PipelineResult result : snapshot.getResults()) { + assertThat(result.getCreateTime()).isAtMost(result.getUpdateTime()); + assertThat(result.getUpdateTime()).isLessThan(result.getExecutionTime()); + } + + collection.document("book1").update("rating", 5.0).get(); + snapshot = + pipeline.where(equal("title", "The Hitchhiker's Guide to the Galaxy")).execute().get(); + for (PipelineResult result : snapshot.getResults()) { + assertThat(result.getCreateTime()).isLessThan(result.getUpdateTime()); + } + } + + @Test + public void testResultIsEqual() throws Exception { + Pipeline pipeline = + firestore.pipeline().collection(collection.getPath()).sort(field("title").ascending()); + Pipeline.Snapshot snapshot1 = pipeline.limit(1).execute().get(); + Pipeline.Snapshot snapshot2 = pipeline.limit(1).execute().get(); + Pipeline.Snapshot snapshot3 = pipeline.offset(1).limit(1).execute().get(); + + assertThat(snapshot1.getResults()).hasSize(1); + assertThat(snapshot2.getResults()).hasSize(1); + assertThat(snapshot3.getResults()).hasSize(1); + assertThat(snapshot1.getResults().get(0)).isEqualTo(snapshot2.getResults().get(0)); + assertThat(snapshot1.getResults().get(0)).isNotEqualTo(snapshot3.getResults().get(0)); + } + + @Test + public void testEmptyResultMetadata() throws Exception { + Pipeline pipeline = firestore.pipeline().collection(collection.getPath()).limit(0); + Pipeline.Snapshot snapshot = pipeline.execute().get(); + assertThat(snapshot.getResults()).isEmpty(); + assertThat(snapshot.getExecutionTime()).isNotNull(); + // Ensure execution time is recent, within a tolerance. + long now = Timestamp.now().toDate().getTime(); + long executionTime = snapshot.getExecutionTime().toDate().getTime(); + assertThat(now - executionTime).isLessThan(3000); // 3 seconds tolerance + } + + @Test + public void testAggregateResultMetadata() throws Exception { + Pipeline pipeline = + firestore.pipeline().collection(collection.getPath()).aggregate(countAll().as("count")); + Pipeline.Snapshot snapshot = pipeline.execute().get(); + assertThat(snapshot.getResults()).hasSize(1); + assertThat(snapshot.getExecutionTime()).isNotNull(); + + PipelineResult aggregateResult = snapshot.getResults().get(0); + assertThat(aggregateResult.getCreateTime()).isNull(); + assertThat(aggregateResult.getUpdateTime()).isNull(); + + // Ensure execution time is recent, within a tolerance. + long now = Timestamp.now().toDate().getTime(); + long executionTime = snapshot.getExecutionTime().toDate().getTime(); + assertThat(now - executionTime).isLessThan(3000); // 3 seconds tolerance + } + + @Test + public void testAggregates() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .aggregate(countAll().as("count")) + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("count", 11L))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("genre", "Science Fiction")) + .aggregate( + countAll().as("count"), + AggregateFunction.average("rating").as("avg_rating"), + field("rating").maximum().as("max_rating")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("count", 2L, "avg_rating", 4.4, "max_rating", 4.6))); + } + + @Test + public void testMoreAggregates() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .aggregate( + sum("rating").as("sum_rating"), + count("rating").as("count_rating"), + countDistinct("genre").as("distinct_genres")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat((Double) result.get("sum_rating")).isWithin(0.00001).of(43.1); + assertThat(result.get("count_rating")).isEqualTo(10L); + assertThat(result.get("distinct_genres")).isEqualTo(8L); + } + + @Test + public void testCountIfAggregate() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .aggregate(countIf(Expression.greaterThan(field("rating"), 4.3)).as("count")) + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("count", 3L))); + } + + @Test + public void testGroupBysWithoutAccumulators() throws Exception { + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .createFrom(collection) + .where(lessThan("published", 1900)) + .aggregate(Aggregate.withAccumulators().withGroups("genre")); + }); + } + + @Test + public void testDistinct() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(lessThan("published", 1900)) + .distinct(field("genre").toLower().as("lower_genre")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("lower_genre", "romance"), map("lower_genre", "psychological thriller")); + } + + @Test + public void testGroupBysAndAggregate() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(lessThan("published", 1984)) + .aggregate( + Aggregate.withAccumulators(AggregateFunction.average("rating").as("avg_rating")) + .withGroups("genre")) + .where(greaterThan("avg_rating", 4.3)) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("avg_rating", 4.7, "genre", "Fantasy"), + map("avg_rating", 4.5, "genre", "Romance"), + map("avg_rating", 4.4, "genre", "Science Fiction")); + } + + @Test + public void testMinMax() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .aggregate( + countAll().as("count"), + field("rating").maximum().as("max_rating"), + field("published").minimum().as("min_published")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "count", 11L, + "max_rating", 4.7, + "min_published", 1813L))); + } + + @Test + public void testFirstAndLastAccumulators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .sort(field("published").ascending()) + .aggregate( + first("rating").as("firstBookRating"), + first("title").as("firstBookTitle"), + last("rating").as("lastBookRating"), + last("title").as("lastBookTitle")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat(result.get("firstBookRating")).isEqualTo(4.5); + assertThat(result.get("firstBookTitle")).isEqualTo("Pride and Prejudice"); + assertThat(result.get("lastBookRating")).isEqualTo(4.1); + assertThat(result.get("lastBookTitle")).isEqualTo("The Handmaid's Tale"); + } + + @Test + public void testFirstAndLastAccumulatorsWithInstanceMethod() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .sort(field("published").ascending()) + .aggregate( + field("rating").first().as("firstBookRating"), + field("title").first().as("firstBookTitle"), + field("rating").last().as("lastBookRating"), + field("title").last().as("lastBookTitle")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat(result.get("firstBookRating")).isEqualTo(4.5); + assertThat(result.get("firstBookTitle")).isEqualTo("Pride and Prejudice"); + assertThat(result.get("lastBookRating")).isEqualTo(4.1); + assertThat(result.get("lastBookTitle")).isEqualTo("The Handmaid's Tale"); + } + + @Test + public void testArrayAggAccumulators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .sort(field("published").ascending()) + .aggregate(arrayAgg("rating").as("allRatings")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat((List) result.get("allRatings")) + .containsExactly(4.5, 4.3, 4.0, 4.2, 4.7, 4.2, 4.6, 4.3, 4.2, 4.1) + .inOrder(); + } + + @Test + public void testArrayAggAccumulatorsWithInstanceMethod() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .sort(field("published").ascending()) + .aggregate(field("rating").arrayAgg().as("allRatings")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat((List) result.get("allRatings")) + .containsExactly(4.5, 4.3, 4.0, 4.2, 4.7, 4.2, 4.6, 4.3, 4.2, 4.1) + .inOrder(); + } + + @Test + public void testArrayAggDistinctAccumulators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .aggregate(arrayAggDistinct("rating").as("allDistinctRatings")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + List distinctRatings = (List) result.get("allDistinctRatings"); + List sortedRatings = + distinctRatings.stream().map(o -> (Double) o).sorted().collect(Collectors.toList()); + + assertThat(sortedRatings).containsExactly(4.0, 4.1, 4.2, 4.3, 4.5, 4.6, 4.7).inOrder(); + } + + @Test + public void testArrayAggDistinctAccumulatorsWithInstanceMethod() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("published").greaterThan(0)) + .aggregate(field("rating").arrayAggDistinct().as("allDistinctRatings")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + List distinctRatings = (List) result.get("allDistinctRatings"); + List sortedRatings = + distinctRatings.stream().map(o -> (Double) o).sorted().collect(Collectors.toList()); + + assertThat(sortedRatings).containsExactly(4.0, 4.1, 4.2, 4.3, 4.5, 4.6, 4.7).inOrder(); + } + + @Test + public void selectSpecificFields() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .select("title", "author") + .sort(field("author").ascending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy", "author", "Douglas Adams"), + map("title", "The Great Gatsby", "author", "F. Scott Fitzgerald"), + map("title", "Dune", "author", "Frank Herbert"), + map("title", "Crime and Punishment", "author", "Fyodor Dostoevsky"), + map("title", "One Hundred Years of Solitude", "author", "Gabriel García Márquez"), + map("title", "1984", "author", "George Orwell"), + map("title", "To Kill a Mockingbird", "author", "Harper Lee"), + map("title", "The Lord of the Rings", "author", "J.R.R. Tolkien"), + map("title", "Pride and Prejudice", "author", "Jane Austen"), + map("title", "The Handmaid's Tale", "author", "Margaret Atwood"), + map("title", "Timestamp Book", "author", "Timestamp Author"))); + } + + @Test + public void addAndRemoveFields() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(field("author").notEqual("Timestamp Author")) + .addFields( + Expression.stringConcat(field("author"), "_", field("title")).as("author_title"), + Expression.stringConcat(field("title"), "_", field("author")).as("title_author")) + .removeFields("title_author", "tags", "awards", "rating", "title", "embedding", "cost") + .removeFields(field("published"), field("genre"), field("nestedField")) + .sort(field("author_title").ascending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "author_title", + "Douglas Adams_The Hitchhiker's Guide to the Galaxy", + "author", + "Douglas Adams"), + map( + "author_title", + "F. Scott Fitzgerald_The Great Gatsby", + "author", + "F. Scott Fitzgerald"), + map("author_title", "Frank Herbert_Dune", "author", "Frank Herbert"), + map( + "author_title", + "Fyodor Dostoevsky_Crime and Punishment", + "author", + "Fyodor Dostoevsky"), + map( + "author_title", + "Gabriel García Márquez_One Hundred Years of Solitude", + "author", + "Gabriel García Márquez"), + map("author_title", "George Orwell_1984", "author", "George Orwell"), + map("author_title", "Harper Lee_To Kill a Mockingbird", "author", "Harper Lee"), + map( + "author_title", + "J.R.R. Tolkien_The Lord of the Rings", + "author", + "J.R.R. Tolkien"), + map("author_title", "Jane Austen_Pride and Prejudice", "author", "Jane Austen"), + map( + "author_title", + "Margaret Atwood_The Handmaid's Tale", + "author", + "Margaret Atwood"))); + } + + @Test + public void whereByMultipleConditions() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(and(greaterThan("rating", 4.5), equal("genre", "Science Fiction"))) + .execute() + .get() + .getResults(); + + // It's Dune + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(collection.document("book10").get().get().getData())); + assertThat(results.get(0).getReference()).isEqualTo(collection.document("book10")); + } + + @Test + public void whereByOrCondition() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(or(equal("genre", "Romance"), equal("genre", "Dystopian"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "Pride and Prejudice"), + map("title", "The Handmaid's Tale"), + map("title", "1984"))); + } + + @Test + public void testPipelineWithOffsetAndLimit() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .sort(field("author").ascending()) + .offset(5) + .limit(3) + .select("title", "author") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "1984", "author", "George Orwell"), + map("title", "To Kill a Mockingbird", "author", "Harper Lee"), + map("title", "The Lord of the Rings", "author", "J.R.R. Tolkien"))); + } + + @Test + public void testArrayContains() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayContains("tags", "comedy")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + // The Hitchhiker's Guide to the Galaxy + .isEqualTo(Lists.newArrayList(collection.document("book1").get().get().getData())); + } + + @Test + public void testArrayContainsAny() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayContainsAny("tags", Lists.newArrayList("comedy", "classic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy"), + map("title", "Pride and Prejudice"))); + } + + @Test + public void testArrayContainsAll() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayContainsAll("tags", Lists.newArrayList("adventure", "magic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + } + + @Test + public void testArrayLength() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("tags").arrayLength().as("tagsCount")) + .where(equal("tagsCount", 3)) + .execute() + .get() + .getResults(); + + // All documents have 3 tags in the test dataset + assertThat(data(results)).hasSize(10); + } + + @Test + public void testArrayFirst() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayFirst("tags").equal("adventure")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("tags").arrayFirst().equal("adventure")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent arrays + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("empty", emptyList(), "nullval", Expression.nullValue()))) + .select( + arrayFirst("empty").as("emptyResult"), + arrayFirst("nullval").as("nullResult"), + arrayFirst("nonExistent").as("absentResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + // no emptyResult as arrayFirst returns UNSET for empty arrays + map("nullResult", null, "absentResult", null))); + } + + @Test + public void testArrayFirstN() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayFirstN("tags", 2).equal(Lists.newArrayList("adventure", "magic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where( + field("tags") + .arrayFirstN(4) + .equal(Lists.newArrayList("adventure", "magic", "epic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent arrays + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("empty", emptyList(), "nullval", Expression.nullValue()))) + .select( + arrayFirstN("empty", 2).as("emptyResult"), + arrayFirstN("nullval", 2).as("nullResult"), + arrayFirstN("nonExistent", 2).as("absentResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("emptyResult", emptyList(), "nullResult", null, "absentResult", null))); + } + + @Test + public void testArrayLast() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayLast("tags").equal("epic")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("tags").arrayLast().equal("epic")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent arrays + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("empty", emptyList(), "nullval", Expression.nullValue()))) + .select( + arrayLast("empty").as("emptyResult"), + arrayLast("nullval").as("nullResult"), + arrayLast("nonExistent").as("absentResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + // no emptyResult as arrayLast returns UNSET for empty arrays + map("nullResult", null, "absentResult", null))); + } + + @Test + public void testArrayLastN() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayLastN("tags", 2).equal(Lists.newArrayList("magic", "epic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where( + field("tags").arrayLastN(4).equal(Lists.newArrayList("adventure", "magic", "epic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent arrays + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("empty", emptyList(), "nullval", Expression.nullValue()))) + .select( + arrayLastN("empty", 2).as("emptyResult"), + arrayLastN("nullval", 2).as("nullResult"), + arrayLastN("nonExistent", 2).as("absentResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("emptyResult", emptyList(), "nullResult", null, "absentResult", null))); + } + + @Test + public void testArrayMinimum() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayMinimum("tags").equal("adventure")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy"), + map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("tags").arrayMinimum().equal("adventure")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy"), + map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent arrays + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map( + map( + "empty", + emptyList(), + "nullval", + Expression.nullValue(), + "mixed", + Lists.newArrayList(1, "2", 3, "10")))) + .select( + arrayMinimum("empty").as("emptyResult"), + arrayMinimum("nullval").as("nullResult"), + arrayMinimum("nonExistent").as("absentResult"), + arrayMinimum("mixed").as("mixedResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "emptyResult", + null, + "nullResult", + null, + "absentResult", + null, + "mixedResult", + 1L))); + } + + @Test + public void testArrayMinimumN() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayMinimumN("tags", 2).equal(Lists.newArrayList("adventure", "epic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where( + field("tags") + .arrayMinimumN(4) + .equal(Lists.newArrayList("adventure", "epic", "magic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + } + + @Test + public void testArrayMaximum() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayMaximum("tags").equal("magic")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("tags").arrayMaximum().equal("magic")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + // Test with empty/null/non-existent and mixed types + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map( + map( + "empty", + emptyList(), + "nullval", + Expression.nullValue(), + "mixed", + Lists.newArrayList(1, "2", 3, "10")))) + .select( + arrayMaximum("empty").as("emptyResult"), + arrayMaximum("nullval").as("nullResult"), + arrayMaximum("nonExistent").as("absentResult"), + arrayMaximum("mixed").as("mixedResult")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "emptyResult", + null, + "nullResult", + null, + "absentResult", + null, + "mixedResult", + "2"))); + } + + @Test + public void testArrayMaximumN() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(arrayMaximumN("tags", 2).equal(Lists.newArrayList("magic", "epic"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where( + field("tags") + .arrayMaximumN(4) + .equal(Lists.newArrayList("magic", "epic", "adventure"))) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("title", "The Lord of the Rings"))); + } + + @Test + public void testArrayIndexOf() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .select( + arrayIndexOf("tags", "adventure").as("indexFirst"), + arrayIndexOf(field("tags"), "magic").as("indexSecond"), + field("tags").arrayIndexOf("epic").as("indexLast"), + arrayIndexOf("tags", "nonexistent").as("indexNone"), + arrayIndexOf("empty", "anything").as("indexEmpty")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "indexFirst", + 0L, + "indexSecond", + 1L, + "indexLast", + 2L, + "indexNone", + -1L, + "indexEmpty", + null))); + + // Test with duplicate values + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith(Expression.map(map("arr", Lists.newArrayList(1, 2, 3, 2, 1)))) + .select(arrayIndexOf("arr", 2).as("firstIndex")) + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("firstIndex", 1L))); + + // Test with null value + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("arr", Lists.newArrayList(1, null, 3, 2, 1), "nullArr", null))) + .select( + arrayIndexOf("arr", null).as("nullIndex"), + arrayIndexOf("nullArr", null).as("nullIndexNull")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("nullIndex", 1L, "nullIndexNull", null))); + } + + @Test + public void testArrayLastIndexOf() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .select( + arrayLastIndexOf("tags", "adventure").as("lastIndexFirst"), + arrayLastIndexOf(field("tags"), "magic").as("lastIndexSecond"), + field("tags").arrayLastIndexOf("epic").as("lastIndexLast"), + arrayLastIndexOf("tags", "nonexistent").as("lastIndexNone"), + arrayLastIndexOf("empty", "anything").as("lastIndexEmpty")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "lastIndexFirst", + 0L, + "lastIndexSecond", + 1L, + "lastIndexLast", + 2L, + "lastIndexNone", + -1L, + "lastIndexEmpty", + null))); + + // Test with duplicate values + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith(Expression.map(map("arr", Lists.newArrayList(1, 2, 3, 2, 1)))) + .select(arrayLastIndexOf("arr", 2).as("lastIndex")) + .execute() + .get() + .getResults(); + + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("lastIndex", 3L))); + + // Test with null value + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map(map("arr", Lists.newArrayList(1, null, 3, 2, 1), "nullArr", null))) + .select( + arrayLastIndexOf("arr", null).as("nullIndex"), + arrayLastIndexOf("nullArr", null).as("nullIndexNull")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("nullIndex", 1L, "nullIndexNull", null))); + } + + @Test + public void testArrayIndexOfAll() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .select( + arrayIndexOfAll("tags", "adventure").as("indicesFirst"), + arrayIndexOfAll(field("tags"), "magic").as("indicesSecond"), + field("tags").arrayIndexOfAll("epic").as("indicesLast"), + arrayIndexOfAll("tags", "nonexistent").as("indicesNone")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "indicesFirst", + Lists.newArrayList(0L), + "indicesSecond", + Lists.newArrayList(1L), + "indicesLast", + Lists.newArrayList(2L), + "indicesNone", + Lists.newArrayList()))); + + // Test with duplicate values + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith(Expression.map(map("arr", Lists.newArrayList(1, 2, 3, 2, 1)))) + .select(arrayIndexOfAll("arr", 2).as("indices")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("indices", Lists.newArrayList(1L, 3L)))); + + // Test with null values + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .replaceWith( + Expression.map( + map("arr", Lists.newArrayList(1, null, 3, null, 1), "nullArr", null))) + .select( + arrayIndexOfAll("arr", null).as("indices"), + arrayIndexOfAll("nullArr", null).as("indicesNull"), + arrayIndexOfAll("nonExistentArray", null).as("indicesNonExistent")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "indices", + Lists.newArrayList(1L, 3L), + "indicesNull", + null, + "indicesNonExistent", + null))); + } + + @Test + public void testArrayConcat() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("tags").arrayConcat(array("newTag1", "newTag2")).as("modifiedTags")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "modifiedTags", + Lists.newArrayList("comedy", "space", "adventure", "newTag1", "newTag2")))); + } + + @Test + public void testStrConcat() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(Expression.stringConcat(field("author"), " - ", field("title")).as("bookInfo")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("bookInfo", "Douglas Adams - The Hitchhiker's Guide to the Galaxy"))); + } + + @Test + public void testStartsWith() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(startsWith("title", "The")) + .select("title") + .sort(field("title").ascending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Great Gatsby"), + map("title", "The Handmaid's Tale"), + map("title", "The Hitchhiker's Guide to the Galaxy"), + map("title", "The Lord of the Rings"))); + } + + @Test + public void testEndsWith() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(endsWith(field("title"), constant("y"))) + .select("title") + .sort(field("title").descending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy"), + map("title", "The Great Gatsby"))); + } + + @Test + public void testLength() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("title").charLength().as("titleLength"), field("title")) + .where(greaterThan("titleLength", 21)) + .sort(field("titleLength").descending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("titleLength", 36L, "title", "The Hitchhiker's Guide to the Galaxy"), + map("titleLength", 29L, "title", "One Hundred Years of Solitude"))); + } + + @Test + public void testStringFunctions() throws Exception { + List results; + + // Reverse + results = + firestore + .pipeline() + .collection(collection.getPath()) + .select(field("title").reverse().as("reversed_title"), field("author")) + .where(field("author").equal("Douglas Adams")) + .execute() + .get() + .getResults(); + assertThat(data(results).get(0).get("reversed_title")) + .isEqualTo("yxalaG eht ot ediuG s'rekihhctiH ehT"); + + // CharLength + results = + firestore + .pipeline() + .createFrom(collection) + .select(field("title").charLength().as("title_length"), field("author")) + .where(field("author").equal("Douglas Adams")) + .execute() + .get() + .getResults(); + assertThat(data(results).get(0).get("title_length")).isEqualTo(36L); + + // ByteLength + results = + firestore + .pipeline() + .createFrom(collection) + .select( + field("author"), + field("title").stringConcat("_银河系漫游指南").byteLength().as("title_byte_length")) + .where(field("author").equal("Douglas Adams")) + .execute() + .get() + .getResults(); + assertThat(data(results).get(0).get("title_byte_length")).isEqualTo(58L); + } + + @Test + public void testToLowercase() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("title").toLower().as("lowercaseTitle")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList(map("lowercaseTitle", "the hitchhiker's guide to the galaxy"))); + } + + @Test + public void testToUppercase() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("author").toUpper().as("uppercaseAuthor")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("uppercaseAuthor", "DOUGLAS ADAMS"))); + } + + @Test + public void testTrim() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .addFields(stringConcat(constant(" "), field("title"), constant(" ")).as("spacedTitle")) + .select(field("spacedTitle").trim().as("trimmedTitle"), field("spacedTitle")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "spacedTitle", " The Hitchhiker's Guide to the Galaxy ", + "trimmedTitle", "The Hitchhiker's Guide to the Galaxy"))); + } + + @Test + public void testTrimWithCharacters() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .addFields(concat(constant("_-"), field("title"), constant("-_")).as("paddedTitle")) + .select(field("paddedTitle").trimValue("_-").as("trimmedTitle"), field("paddedTitle")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "paddedTitle", + "_-The Hitchhiker's Guide to the Galaxy-_", + "trimmedTitle", + "The Hitchhiker's Guide to the Galaxy"))); + } + + @Test + public void testLike() throws Exception { + assumeFalse( + "LIKE is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("title").like("%Guide%")) + .select("title") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo(Lists.newArrayList(map("title", "The Hitchhiker's Guide to the Galaxy"))); + } + + @Test + public void testRegexContains() throws Exception { + assumeFalse( + "LIKE is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + // Find titles that contain either "the" or "of" (case-insensitive) + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("title").regexContains("(?i)(the|of)")) + .execute() + .get() + .getResults(); + + assertThat(data(results)).hasSize(5); + } + + @Test + public void testRegexFind() throws Exception { + assumeFalse( + "Regexes are not supported against the emulator", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("title").regexFind("^\\w+").as("firstWordInTitle")) + .sort(field("firstWordInTitle").ascending()) + .limit(3) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("firstWordInTitle", "1984"), + map("firstWordInTitle", "Crime"), + map("firstWordInTitle", "Dune"))); + } + + @Test + public void testRegexFindAll() throws Exception { + assumeFalse( + "Regexes are not supported against the emulator", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("title").regexFindAll("\\w+").as("wordsInTitle")) + .sort(field("wordsInTitle").ascending()) + .limit(3) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("wordsInTitle", Lists.newArrayList("1984")), + map("wordsInTitle", Lists.newArrayList("Crime", "and", "Punishment")), + map("wordsInTitle", Lists.newArrayList("Dune")))); + } + + @Test + public void testRegexMatches() throws Exception { + assumeFalse( + "LIKE is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + // Find titles that contain either "the" or "of" (case-insensitive) + List results = + firestore + .pipeline() + .createFrom(collection) + .where(regexMatch("title", ".*(?i)(the|of).*")) + .execute() + .get() + .getResults(); + + assertThat(data(results)).hasSize(5); + } + + @Test + public void testArithmeticOperations() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select( + add(field("rating"), 1).as("ratingPlusOne"), + subtract(field("published"), 1900).as("yearsSince1900"), + field("rating").multiply(10).as("ratingTimesTen"), + field("rating").divide(2).as("ratingDividedByTwo")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "ratingPlusOne", + 5.2, + "yearsSince1900", + 79L, + "ratingTimesTen", + 42.0, + "ratingDividedByTwo", + 2.1))); + } + + @Test + public void testComparisonOperators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where( + and( + greaterThan("rating", 4.2), + field("rating").lessThanOrEqual(4.5), + notEqual("genre", "Science Fiction"))) + .select("rating", "title") + .sort(field("title").ascending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("rating", 4.3, "title", "Crime and Punishment"), + map("rating", 4.3, "title", "One Hundred Years of Solitude"), + map("rating", 4.5, "title", "Pride and Prejudice"))); + } + + @Test + public void testLogicalAndComparisonOperators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where( + xor( + equal("genre", "Romance"), + equal("genre", "Dystopian"), + equal("genre", "Fantasy"), + equal("published", 1949))) + .select("title") + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("title", "Pride and Prejudice"), + map("title", "The Lord of the Rings"), + map("title", "The Handmaid's Tale")); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(Expression.equalAny("genre", Lists.newArrayList("Romance", "Dystopian"))) + .select("title") + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("title", "Pride and Prejudice"), + map("title", "The Handmaid's Tale"), + map("title", "1984")); + + results = + firestore + .pipeline() + .createFrom(collection) + .where( + Expression.notEqualAny( + "genre", Lists.newArrayList("Science Fiction", "Romance", "Dystopian", null))) + .select("genre") + .distinct("genre") + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + // This is somewhat surprising because the pipeline did ask specifically for genre not + // equal to null, + // however at the later distinct stage, UNSET is grouped as null and thus null appears + // in the result. + map("genre", null), + map("genre", "Magical Realism"), + map("genre", "Fantasy"), + map("genre", "Psychological Thriller"), + map("genre", "Southern Gothic"), + map("genre", "Modernist")); + } + + @Test + public void testCondExpression() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("title").notEqual("Timestamp Book")) + .select( + conditional(Expression.greaterThan(field("published"), 1980), "Modern", "Classic") + .as("era"), + field("title"), + field("published")) + .sort(field("published").ascending()) + .limit(2) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("era", "Classic", "title", "Pride and Prejudice", "published", 1813L), + map("era", "Classic", "title", "Crime and Punishment", "published", 1866L))); + } + + @Test + public void testLogicalOperators() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where( + or( + and(greaterThan("rating", 4.5), equal("genre", "Science Fiction")), + lessThan("published", 1900))) + .select("title") + .sort(field("title").ascending()) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "Crime and Punishment"), + map("title", "Dune"), + map("title", "Pride and Prejudice"))); + } + + @Test + public void testChecks() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .sort(field("rating").descending()) + .limit(1) + .select( + field("rating").equal(nullValue()).as("ratingIsNull"), + field("rating").equal(Double.NaN).as("ratingIsNaN"), + // arrayGet("title", 0) evaluates to UNSET so it is not an error + arrayGet("title", 0).isError().as("isError"), + arrayGet("title", 0).ifError(constant("was error")).as("ifError"), + field("foo").isAbsent().as("isAbsent"), + field("title").notEqual(nullValue()).as("titleIsNotNull"), + field("cost").notEqual(Double.NaN).as("costIsNotNan"), + field("fooBarBaz").exists().as("fooBarBazExists"), + field("title").exists().as("titleExists")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "ratingIsNull", + false, + "ratingIsNaN", + false, + "isError", + false, + "isAbsent", + true, + "titleIsNotNull", + true, + "costIsNotNan", + false, + "fooBarBazExists", + false, + "titleExists", + true))); + } + + @Test + public void testLogicalMinMax() throws Exception { + List results; + + // logicalMax + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("author").equal("Douglas Adams")) + .select( + field("rating").logicalMaximum(4.5).as("max_rating"), + logicalMaximum(field("published"), 1900).as("max_published")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("max_rating", 4.5, "max_published", 1979L)); + + // logicalMin + results = + firestore + .pipeline() + .createFrom(collection) + .where(field("author").equal("Douglas Adams")) + .select( + field("rating").logicalMinimum(4.5).as("min_rating"), + logicalMinimum(field("published"), 1900).as("min_published")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("min_rating", 4.2, "min_published", 1900L)); + } + + @Test + public void testMapGet() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .select(field("awards").mapGet("hugo").as("hugoAward"), field("title")) + .where(equal("hugoAward", true)) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("hugoAward", true, "title", "The Hitchhiker's Guide to the Galaxy"), + map("hugoAward", true, "title", "Dune"))); + } + + @Test + public void testDataManipulationExpressions() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "Timestamp Book")) + .select( + timestampAdd(field("timestamp"), "day", 1).as("timestamp_plus_day"), + Expression.timestampSubtract(field("timestamp"), "hour", 1) + .as("timestamp_minus_hour")) + .execute() + .get() + .getResults(); + assertThat(results).hasSize(1); + Date originalTimestamp = (Date) bookDocs.get("book11").get("timestamp"); + Timestamp timestampPlusDay = (Timestamp) results.get(0).getData().get("timestamp_plus_day"); + Timestamp timestampMinusHour = (Timestamp) results.get(0).getData().get("timestamp_minus_hour"); + assertThat(timestampPlusDay.toDate().getTime() - originalTimestamp.getTime()) + .isEqualTo(24 * 60 * 60 * 1000); + assertThat(originalTimestamp.getTime() - timestampMinusHour.toDate().getTime()) + .isEqualTo(60 * 60 * 1000); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + arrayGet("tags", 1).as("second_tag"), + mapMerge(field("awards"), Expression.map(map("new_award", true))) + .as("merged_awards")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "second_tag", + "space", + "merged_awards", + map("hugo", true, "nebula", false, "new_award", true)))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + arrayReverse("tags").as("reversed_tags"), + mapRemove(field("awards"), "nebula").as("removed_awards")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "reversed_tags", + Lists.newArrayList("adventure", "space", "comedy"), + "removed_awards", + map("hugo", true)))); + } + + @Test + public void testTimestampTrunc() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "Timestamp Book")) + .select( + Expression.timestampTruncate(field("timestamp"), "year").as("trunc_year"), + Expression.timestampTruncate(field("timestamp"), "month").as("trunc_month"), + Expression.timestampTruncate(field("timestamp"), "day").as("trunc_day"), + Expression.timestampTruncate(field("timestamp"), "hour").as("trunc_hour"), + Expression.timestampTruncate(field("timestamp"), "minute").as("trunc_minute"), + Expression.timestampTruncate(field("timestamp"), "second").as("trunc_second")) + .execute() + .get() + .getResults(); + assertThat(results).hasSize(1); + Map data = results.get(0).getData(); + Date originalDate = (Date) bookDocs.get("book11").get("timestamp"); + java.util.Calendar cal = java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC")); + cal.setTime(originalDate); + + cal.set(java.util.Calendar.MONTH, java.util.Calendar.JANUARY); + cal.set(java.util.Calendar.DAY_OF_MONTH, 1); + cal.set(java.util.Calendar.HOUR_OF_DAY, 0); + cal.set(java.util.Calendar.MINUTE, 0); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_year")).isEqualTo(Timestamp.of(cal.getTime())); + + cal.setTime(originalDate); + cal.set(java.util.Calendar.DAY_OF_MONTH, 1); + cal.set(java.util.Calendar.HOUR_OF_DAY, 0); + cal.set(java.util.Calendar.MINUTE, 0); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_month")).isEqualTo(Timestamp.of(cal.getTime())); + + cal.setTime(originalDate); + cal.set(java.util.Calendar.HOUR_OF_DAY, 0); + cal.set(java.util.Calendar.MINUTE, 0); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_day")).isEqualTo(Timestamp.of(cal.getTime())); + + cal.setTime(originalDate); + cal.set(java.util.Calendar.MINUTE, 0); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_hour")).isEqualTo(Timestamp.of(cal.getTime())); + + cal.setTime(originalDate); + cal.set(java.util.Calendar.SECOND, 0); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_minute")).isEqualTo(Timestamp.of(cal.getTime())); + + cal.setTime(originalDate); + cal.set(java.util.Calendar.MILLISECOND, 0); + assertThat(data.get("trunc_second")).isEqualTo(Timestamp.of(cal.getTime())); + } + + @Test + public void testMathExpressions() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + ceil(field("rating")).as("ceil_rating"), + floor(field("rating")).as("floor_rating"), + pow(field("rating"), 2).as("pow_rating"), + round(field("rating")).as("round_rating"), + sqrt(field("rating")).as("sqrt_rating"), + field("published").mod(10).as("mod_published")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat((Double) result.get("ceil_rating")).isEqualTo(5.0); + assertThat((Double) result.get("floor_rating")).isEqualTo(4.0); + assertThat((Double) result.get("pow_rating")).isWithin(0.00001).of(17.64); + assertThat((Double) result.get("round_rating")).isEqualTo(4.0); + assertThat((Double) result.get("sqrt_rating")).isWithin(0.00001).of(2.04939); + assertThat((Long) result.get("mod_published")).isEqualTo(9L); + } + + @Test + public void testAdvancedMathExpressions() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .select( + exp(field("rating")).as("exp_rating"), + ln(field("rating")).as("ln_rating"), + log(field("rating"), 10).as("log_rating"), + field("rating").log10().as("log10_rating")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat((Double) result.get("exp_rating")).isWithin(0.00001).of(109.94717); + assertThat((Double) result.get("ln_rating")).isWithin(0.00001).of(1.54756); + assertThat((Double) result.get("log_rating")).isWithin(0.00001).of(0.67209); + assertThat((Double) result.get("log10_rating")).isWithin(0.00001).of(0.67209); + } + + @Test + public void testRand() throws Exception { + assumeFalse( + "Rand is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .select(rand().as("randomNumber")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(results).hasSize(1); + Object randomNumber = results.get(0).getData().get("randomNumber"); + assertThat(randomNumber).isInstanceOf(Double.class); + assertThat((Double) randomNumber).isAtLeast(0.0); + assertThat((Double) randomNumber).isLessThan(1.0); + } + + @Test + public void testTrunc() throws Exception { + assumeFalse( + "Trunc is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("title").equal("Pride and Prejudice")) + .limit(1) + .select(trunc("rating").as("truncatedRating")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat(result.get("truncatedRating")).isEqualTo(4.0); + } + + @Test + public void testTruncWithInstanceMethod() throws Exception { + assumeFalse( + "Trunc is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .where(field("title").equal("Pride and Prejudice")) + .limit(1) + .select(field("rating").trunc().as("truncatedRating")) + .execute() + .get() + .getResults(); + + Map result = data(results).get(0); + assertThat(result.get("truncatedRating")).isEqualTo(4.0); + } + + @Test + public void testTruncToPrecision() throws Exception { + assumeFalse( + "Trunc is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .limit(1) + .select( + truncToPrecision(constant(4.123456), 0).as("p0"), + truncToPrecision(constant(4.123456), 1).as("p1"), + truncToPrecision(constant(4.123456), 2).as("p2"), + truncToPrecision(constant(4.123456), 4).as("p4")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "p0", 4.0, + "p1", 4.1, + "p2", 4.12, + "p4", 4.1234))); + } + + @Test + public void testTruncToPrecisionWithInstanceMethod() throws Exception { + assumeFalse( + "Trunc is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + + List results = + firestore + .pipeline() + .createFrom(collection) + .limit(1) + .select( + constant(4.123456).truncToPrecision(0).as("p0"), + constant(4.123456).truncToPrecision(1).as("p1"), + constant(4.123456).truncToPrecision(constant(2)).as("p2"), + constant(4.123456).truncToPrecision(4).as("p4")) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "p0", 4.0, + "p1", 4.1, + "p2", 4.12, + "p4", 4.1234))); + } + + @Test + public void testConcat() throws Exception { + // String concat + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("author"), " ", field("title")).as("author_title")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat(result.get("author_title")) + .isEqualTo("Douglas Adams The Hitchhiker's Guide to the Galaxy"); + + // Array concat + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("tags"), ImmutableList.of("newTag")).as("new_tags")) + .execute() + .get() + .getResults(); + result = data(results).get(0); + assertThat((List) result.get("new_tags")) + .containsExactly("comedy", "space", "adventure", "newTag"); + + // Blob concat + byte[] bytes1 = new byte[] {1, 2}; + byte[] bytes2 = new byte[] {3, 4}; + byte[] expected = new byte[] {1, 2, 3, 4}; + results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .select( + concat( + constant(com.google.cloud.firestore.Blob.fromBytes(bytes1)), + com.google.cloud.firestore.Blob.fromBytes(bytes2)) + .as("concatenated_blob")) + .execute() + .get() + .getResults(); + result = data(results).get(0); + assertThat(((com.google.cloud.firestore.Blob) result.get("concatenated_blob")).toBytes()) + .isEqualTo(expected); + + // Mismatched types should just fail. + assertThrows( + ExecutionException.class, + () -> + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("title"), field("tags")).as("mismatched")) + .execute() + .get() + .getResults()); + } + + @Test + public void testCurrentTimestamp() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .select(Expression.currentTimestamp().as("now")) + .execute() + .get() + .getResults(); + assertThat(results).hasSize(1); + Object nowValue = results.get(0).getData().get("now"); + assertThat(nowValue).isInstanceOf(Timestamp.class); + Timestamp nowTimestamp = (Timestamp) nowValue; + // Check that the timestamp is recent (e.g., within the last 5 seconds) + long diff = new Date().getTime() - nowTimestamp.toDate().getTime(); + assertThat(diff).isAtMost(5000L); + } + + @Test + public void testIfAbsent() throws Exception { + // Case 1: Field is present, should return the field value. + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("rating").ifAbsent(0.0).as("rating_or_default")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("rating_or_default", 4.2)); + + // Case 2: Field is absent, should return the default value. + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + Expression.ifAbsent(field("non_existent_field"), "default").as("field_or_default")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("field_or_default", "default")); + + // Case 3: Field is present and null, should return null. + collection + .document("bookWithNull") + .set(map("title", "Book With Null", "optional_field", null)) + .get(); + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "Book With Null")) + .select(Expression.ifAbsent(field("optional_field"), "default").as("field_or_default")) + .execute() + .get() + .getResults(); + assertThat(results.get(0).get("field_or_default")).isNull(); + collection.document("bookWithNull").delete().get(); + + // Case 4: Test different overloads. + // ifAbsent(String, Any) + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent("non_existent_field", "default_string").as("res")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("res", "default_string")); + + // ifAbsent(String, Expression) + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent("non_existent_field", field("author")).as("res")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("res", "Frank Herbert")); + + // ifAbsent(Expression, Expression) + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent(field("non_existent_field"), field("author")).as("res")) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("res", "Frank Herbert")); + } + + @Test + public void testJoin() throws Exception { + // Test join with a constant delimiter + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.join("tags", ", ").as("joined_tags")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat(result.get("joined_tags")).isEqualTo("comedy, space, adventure"); + + // Test join with an expression delimiter + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.join(field("tags"), constant(" | ")).as("joined_tags")) + .execute() + .get() + .getResults(); + result = data(results).get(0); + assertThat(result.get("joined_tags")).isEqualTo("comedy | space | adventure"); + + // Test extension method + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("tags").join(" - ").as("joined_tags")) + .execute() + .get() + .getResults(); + result = data(results).get(0); + assertThat(result.get("joined_tags")).isEqualTo("comedy - space - adventure"); + } + + @Test + public void testArraySum() throws Exception { + collection.document("book4").update("sales", ImmutableList.of(100, 200, 50)).get(); + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Lord of the Rings")) + .select(Expression.arraySum("sales").as("totalSales")) + .limit(1) + .execute() + .get() + .getResults(); + assertThat(data(results)).containsExactly(map("totalSales", 350L)); + } + + @Test + public void testTimestampConversions() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .select( + unixSecondsToTimestamp(constant(1741380235L)).as("unixSecondsToTimestamp"), + unixMillisToTimestamp(constant(1741380235123L)).as("unixMillisToTimestamp"), + unixMicrosToTimestamp(constant(1741380235123456L)).as("unixMicrosToTimestamp"), + timestampToUnixSeconds( + constant(Timestamp.ofTimeSecondsAndNanos(1741380235L, 123456789))) + .as("timestampToUnixSeconds"), + timestampToUnixMicros( + constant(Timestamp.ofTimeSecondsAndNanos(1741380235L, 123456789))) + .as("timestampToUnixMicros"), + timestampToUnixMillis( + constant(Timestamp.ofTimeSecondsAndNanos(1741380235L, 123456789))) + .as("timestampToUnixMillis")) + .execute() + .get() + .getResults(); + Map result = data(results).get(0); + assertThat(result.get("unixSecondsToTimestamp")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(1741380235L, 0)); + assertThat(result.get("unixMillisToTimestamp")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(1741380235L, 123000000)); + assertThat(result.get("unixMicrosToTimestamp")) + .isEqualTo(Timestamp.ofTimeSecondsAndNanos(1741380235L, 123456000)); + assertThat(result.get("timestampToUnixSeconds")).isEqualTo(1741380235L); + assertThat(result.get("timestampToUnixMicros")).isEqualTo(1741380235123456L); + assertThat(result.get("timestampToUnixMillis")).isEqualTo(1741380235123L); + } + + @Test + public void testVectorLength() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .select(vectorLength(constant(vector(new double[] {1.0, 2.0, 3.0}))).as("vectorLength")) + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("vectorLength", 3L))); + } + + @Test + public void testStrContains() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(Expression.stringContains(field("title"), "'s")) + .select("title") + .sort(field("title").ascending()) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("title", "The Handmaid's Tale"), + map("title", "The Hitchhiker's Guide to the Galaxy")); + } + + @Test + public void testSubstring() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Lord of the Rings")) + .select( + Expression.substring(field("title"), constant(9), constant(2)).as("of"), + substring("title", 16, 5).as("Rings")) + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("of", "of", "Rings", "Rings"))); + } + + @Test + public void testSplitStringByStringDelimiter() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.split(field("title"), " ").as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("title").split(" ").as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + } + + @Test + public void testSplitStringByExpressionDelimiter() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.split(field("title"), constant(" ")).as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + + results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("title").split(constant(" ")).as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + } + + @Test + public void testSplitBlobByByteArrayDelimiter() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .addFields( + constant(Blob.fromBytes(new byte[] {0x01, 0x02, 0x03, 0x04, 0x01, 0x05})) + .as("data")) + .select( + Expression.split(field("data"), constant(Blob.fromBytes(new byte[] {0x01}))) + .as("split_data")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_data", + ImmutableList.of( + Blob.fromBytes(new byte[] {}), + Blob.fromBytes(new byte[] {0x02, 0x03, 0x04}), + Blob.fromBytes(new byte[] {0x05})))); + + results = + firestore + .pipeline() + .collection(collection.getPath()) + .limit(1) + .addFields( + constant(Blob.fromBytes(new byte[] {0x01, 0x02, 0x03, 0x04, 0x01, 0x05})) + .as("data")) + .select( + field("data").split(constant(Blob.fromBytes(new byte[] {0x01}))).as("split_data")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_data", + ImmutableList.of( + Blob.fromBytes(new byte[] {}), + Blob.fromBytes(new byte[] {0x02, 0x03, 0x04}), + Blob.fromBytes(new byte[] {0x05})))); + } + + @Test + public void testSplitStringFieldByStringDelimiter() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.split("title", " ").as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + } + + @Test + public void testSplitStringFieldByExpressionDelimiter() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(Expression.split("title", constant(" ")).as("split_title")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "split_title", + ImmutableList.of("The", "Hitchhiker's", "Guide", "to", "the", "Galaxy"))); + } + + @Test + public void testSplitWithMismatchedTypesShouldFail() { + ExecutionException exception = + assertThrows( + ExecutionException.class, + () -> + firestore + .pipeline() + .collection(collection.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + Expression.split( + field("title"), constant(Blob.fromBytes(new byte[] {0x01}))) + .as("mismatched_split")) + .execute() + .get()); + assertThat(exception.getCause()).isInstanceOf(ApiException.class); + ApiException apiException = (ApiException) exception.getCause(); + assertThat(apiException.getStatusCode().getCode()).isEqualTo(StatusCode.Code.INVALID_ARGUMENT); + } + + @Test + public void testDistanceFunctions() throws Exception { + double[] sourceVector = {0.1, 0.1}; + double[] targetVector = {0.5, 0.8}; + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .select( + cosineDistance(constant(vector(sourceVector)), targetVector).as("cosineDistance"), + dotProduct(constant(vector(sourceVector)), targetVector).as("dotProductDistance"), + euclideanDistance(constant(vector(sourceVector)), targetVector) + .as("euclideanDistance")) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "cosineDistance", 0.02560880430538015, + "dotProductDistance", 0.13, + "euclideanDistance", 0.806225774829855))); + } + + @Test + public void testNestedFields() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("awards.hugo", true)) + .select("title", "awards.hugo") + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy", "awards.hugo", true), + map("title", "Dune", "awards.hugo", true))); + } + + @Test + public void testPipelineInTransactions() throws Exception { + assumeFalse( + "Transactions are not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + Pipeline pipeline = + firestore + .pipeline() + .createFrom(collection) + .where(equal("awards.hugo", true)) + .select("title", "awards.hugo", Field.DOCUMENT_ID); + + firestore + .runTransaction( + transaction -> { + List results = transaction.execute(pipeline).get().getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy", "awards.hugo", true), + map("title", "Dune", "awards.hugo", true))); + + transaction.update(collection.document("book1"), map("foo", "bar")); + + return "done"; + }) + .get(); + + List result = + firestore + .pipeline() + .createFrom(collection) + .where(equal("foo", "bar")) + .select("title") + .execute() + .get() + .getResults(); + assertThat(data(result)) + .isEqualTo(Lists.newArrayList(map("title", "The Hitchhiker's Guide to the Galaxy"))); + } + + @Test + public void testPipelineInTransactionsWithOptions() throws Exception { + assumeFalse( + "Transactions are not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + Pipeline pipeline = firestore.pipeline().createFrom(collection).limit(1); + + firestore + .runTransaction( + transaction -> { + PipelineExecuteOptions options = new PipelineExecuteOptions().with("foo", "bar"); + List results = + transaction.execute(pipeline, options).get().getResults(); + assertThat(results).hasSize(1); + return "done"; + }) + .get(); + } + + @Test + public void testRawStage() throws Exception { + // can select fields + List results = + firestore + .pipeline() + .collection(collection.getPath()) + // .select(field("title"), Expression.map(map("author", + // field("author"))).as("metadata")) + .rawStage( + RawStage.ofName("select") + .withArguments( + map( + "title", + field("title"), + "metadata", + Expression.map(map("author", field("author")))))) + .sort(field("metadata.author").ascending()) + .limit(1) + .execute() + .get() + .getResults(); + + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "title", + "The Hitchhiker's Guide to the Galaxy", + "metadata", + map("author", "Douglas Adams")))); + + // can add fields + results = + firestore + .pipeline() + .collection(collection.getPath()) + .sort(field("author").ascending()) + .limit(1) + .select("title", "author") + .rawStage( + RawStage.ofName("add_fields") + .withArguments( + map( + "display", + Expression.stringConcat(field("title"), " - ", field("author"))))) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map( + "title", + "The Hitchhiker's Guide to the Galaxy", + "author", + "Douglas Adams", + "display", + "The Hitchhiker's Guide to the Galaxy - Douglas Adams"))); + + // can filter with where + results = + firestore + .pipeline() + .collection(collection.getPath()) + .select("title", "author") + .rawStage(RawStage.ofName("where").withArguments(equal("author", "Douglas Adams"))) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("title", "The Hitchhiker's Guide to the Galaxy", "author", "Douglas Adams"))); + + // can limit, offset, and sort + results = + firestore + .pipeline() + .collection(collection.getPath()) + .select("title", "author") + .rawStage( + RawStage.ofName("sort") + .withArguments(map("direction", "ascending", "expression", field("author")))) + .rawStage(RawStage.ofName("offset").withArguments(3)) + .rawStage(RawStage.ofName("limit").withArguments(1)) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("author", "Fyodor Dostoevsky", "title", "Crime and Punishment"))); + + // can perform aggregate query + results = + firestore + .pipeline() + .collection(collection.getPath()) + .select("title", "author", "rating") + .rawStage( + RawStage.ofName("aggregate") + .withArguments( + map("averageRating", AggregateFunction.average("rating")), map())) + .execute() + .get() + .getResults(); + Map aggregateResult = data(results).get(0); + assertThat((Double) aggregateResult.get("averageRating")).isWithin(0.00001).of(4.31); + + // can perform distinct query + results = + firestore + .pipeline() + .collection(collection.getPath()) + .select("title", "author", "rating") + .rawStage(RawStage.ofName("distinct").withArguments(map("rating", field("rating")))) + .sort(field("rating").descending()) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map("rating", 4.7), + map("rating", 4.6), + map("rating", 4.5), + map("rating", 4.3), + map("rating", 4.2), + map("rating", 4.1), + map("rating", 4.0), + map("rating", null)); + + // can perform FindNearest query + results = + firestore + .pipeline() + .collection(collection.getPath()) + .rawStage( + RawStage.ofName("find_nearest") + .withArguments( + field("embedding"), + constant( + vector( + new double[] {10.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0})), + "euclidean") + .withOptions( + new RawOptions() + .with("distance_field", field("computedDistance")) + .with("limit", 2))) + .select("title", "computedDistance") + .execute() + .get() + .getResults(); + assertThat(results.size()).isEqualTo(2); + assertThat(results.get(0).getData().get("title")) + .isEqualTo("The Hitchhiker's Guide to the Galaxy"); + assertThat((Double) results.get(0).getData().get("computedDistance")).isWithin(0.00001).of(1.0); + assertThat(results.get(1).getData().get("title")).isEqualTo("One Hundred Years of Solitude"); + assertThat((Double) results.get(1).getData().get("computedDistance")) + .isWithin(0.00001) + .of(12.041594578792296); + } + + @Test + public void testReplaceWith() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .replaceWith("awards") + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("hugo", true, "nebula", false))); + + results = + firestore + .pipeline() + .createFrom(collection) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .replaceWith( + Expression.map( + map("foo", "bar", "baz", Expression.map(map("title", field("title")))))) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("foo", "bar", "baz", map("title", "The Hitchhiker's Guide to the Galaxy")))); + } + + @Test + public void testSampleLimit() throws Exception { + List results = + firestore.pipeline().createFrom(collection).sample(3).execute().get().getResults(); + + assertThat(results).hasSize(3); + } + + @Test + public void testSamplePercentage() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .sample(Sample.withPercentage(0.6)) + .execute() + .get() + .getResults(); + + assertThat(results).isNotEmpty(); + } + + @Test + public void testUnion() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .union(firestore.pipeline().createFrom(collection)) + .execute() + .get() + .getResults(); + + assertThat(results).hasSize(22); + } + + @Test + public void testUnnest() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(Expression.equal(field("title"), "The Hitchhiker's Guide to the Galaxy")) + .unnest("tags", "tag") + .execute() + .get() + .getResults(); + + assertThat(results).hasSize(3); + } + + @Test + public void testUnnestWithIndexField() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(Expression.equal(field("title"), "The Hitchhiker's Guide to the Galaxy")) + .unnest("tags", "tag", new UnnestOptions().withIndexField("tagsIndex")) + .execute() + .get() + .getResults(); + + assertThat(results).hasSize(3); + for (int i = 0; i < results.size(); i++) { + assertThat(results.get(i).getData().get("tagsIndex")).isEqualTo((long) i); + } + } + + @Test + public void testUnnestWithExpr() throws Exception { + List results = + firestore + .pipeline() + .createFrom(collection) + .where(Expression.equal(field("title"), "The Hitchhiker's Guide to the Galaxy")) + .unnest(array(1L, 2L, 3L).as("copy")) + .execute() + .get() + .getResults(); + + assertThat(results).hasSize(3); + for (int i = 0; i < results.size(); i++) { + assertThat(results.get(i).getData().get("copy")).isEqualTo((long) i + 1); + } + } + + @Test + public void testPaginationWithStartAfter() throws Exception { + CollectionReference paginationCollection = + testCollectionWithDocs( + ImmutableMap.>builder() + .put("doc1", map("order", 1)) + .put("doc2", map("order", 2)) + .put("doc3", map("order", 3)) + .put("doc4", map("order", 4)) + .build()); + + Pipeline pipeline = + firestore.pipeline().createFrom(paginationCollection.orderBy("order").limit(2)); + + Pipeline.Snapshot snapshot = pipeline.execute().get(); + assertThat(data(snapshot.getResults())).containsExactly(map("order", 1L), map("order", 2L)); + + PipelineResult lastResult = snapshot.getResults().get(snapshot.getResults().size() - 1); + snapshot = + firestore + .pipeline() + .createFrom(paginationCollection.orderBy("order").startAfter(lastResult.get("order"))) + .execute() + .get(); + assertThat(data(snapshot.getResults())).containsExactly(map("order", 3L), map("order", 4L)); + } + + @Test + public void testDocumentsAsSource() throws Exception { + List results = + firestore + .pipeline() + .documents( + collection.document("book1"), + collection.document("book2"), + collection.document("book3")) + .execute() + .get() + .getResults(); + assertThat(results).hasSize(3); + } + + @Test + public void testCollectionGroupAsSource() throws Exception { + String subcollectionId = LocalFirestoreHelper.autoId(); + collection.document("book1").collection(subcollectionId).add(map("order", 1)).get(); + collection.document("book2").collection(subcollectionId).add(map("order", 2)).get(); + List results = + firestore + .pipeline() + .collectionGroup(subcollectionId) + .sort(field("order").ascending()) + .execute() + .get() + .getResults(); + assertThat(data(results)).isEqualTo(Lists.newArrayList(map("order", 1L), map("order", 2L))); + } + + @Test + public void testDatabaseAsSource() throws Exception { + String randomId = LocalFirestoreHelper.autoId(); + collection.document("book1").collection("sub").add(map("order", 1, "randomId", randomId)).get(); + collection.document("book2").collection("sub").add(map("order", 2, "randomId", randomId)).get(); + List results = + firestore + .pipeline() + .database() + .where(equal("randomId", randomId)) + .sort(field("order").ascending()) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .isEqualTo( + Lists.newArrayList( + map("order", 1L, "randomId", randomId), map("order", 2L, "randomId", randomId))); + } + + @Test + public void testFindNearest() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .findNearest( + "embedding", + new double[] {10.0, 1.0, 2.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0}, + FindNearest.DistanceMeasure.EUCLIDEAN, + new FindNearestOptions().withLimit(2).withDistanceField("computedDistance")) + .select("title", "computedDistance") + .execute() + .get() + .getResults(); + assertThat(results.size()).isEqualTo(2); + assertThat(results.get(0).getData().get("title")) + .isEqualTo("The Hitchhiker's Guide to the Galaxy"); + assertThat((Double) results.get(0).getData().get("computedDistance")).isWithin(0.00001).of(1.0); + assertThat(results.get(1).getData().get("title")).isEqualTo("One Hundred Years of Solitude"); + assertThat((Double) results.get(1).getData().get("computedDistance")) + .isWithin(0.00001) + .of(12.041594578792296); + } + + @Test + public void testExplain() throws Exception { + assumeFalse( + "Explain is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + Pipeline pipeline = + firestore.pipeline().createFrom(collection).sort(field("__name__").ascending()); + Pipeline.Snapshot snapshot = + pipeline + .execute( + new PipelineExecuteOptions() + .withExplainOptions( + new ExplainOptions() + .withExecutionMode(ExplainOptions.ExecutionMode.ANALYZE))) + .get(); + assertThat(snapshot.getResults()).isNotEmpty(); + assertThat(snapshot.getExplainStats().getText()).isNotEmpty(); + + snapshot = + pipeline + .execute(new PipelineExecuteOptions().withExplainOptions(new ExplainOptions())) + .get(); + assertThat(snapshot.getResults()).isNotEmpty(); + assertThat(snapshot.getExplainStats()).isNull(); + } + + @Test + public void testOptions() throws ExecutionException, InterruptedException { + assumeFalse( + "Certain options are not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + PipelineExecuteOptions opts = + new PipelineExecuteOptions() + .withIndexMode("recommended") + .withExplainOptions( + new ExplainOptions().withExecutionMode(ExplainOptions.ExecutionMode.ANALYZE)); + + double[] vector = {1.0, 2.0, 3.0}; + + Pipeline pipeline = + firestore + .pipeline() + .collection( + "/k", + new CollectionOptions().withHints(new CollectionHints().withForceIndex("title"))) + .findNearest( + "topicVectors", + vector, + FindNearest.DistanceMeasure.COSINE, + new FindNearestOptions().withLimit(10).withDistanceField("distance")) + .aggregate( + Aggregate.withAccumulators(AggregateFunction.average("rating").as("avg_rating")) + .withGroups("genre"), + new AggregateOptions() + .withHints(new AggregateHints().with("test_option", "test_value"))); + + assertThrows(ExecutionException.class, () -> pipeline.execute(opts).get()); + } + + @Test + public void testErrorHandling() { + assumeFalse( + "Error handling is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + ExecutionException exception = + assertThrows( + ExecutionException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .rawStage(RawStage.ofName("invalidStage")) + .execute() + .get(); + }); + assertThat(exception.getCause()).isInstanceOf(ApiException.class); + ApiException apiException = (ApiException) exception.getCause(); + assertThat(apiException.getStatusCode().getCode()).isEqualTo(StatusCode.Code.INVALID_ARGUMENT); + } + + @Test + public void testType() throws Exception { + List results = + firestore + .pipeline() + .collection(collection.getPath()) + .where(field("author").equal("Douglas Adams")) + .limit(1) + .select( + Expression.type("title").as("string_type"), + Expression.type("published").as("number_type"), + Expression.type(field("awards").mapGet("hugo")).as("boolean_type"), + Expression.type(nullValue()).as("null_type"), + Expression.type("embedding").as("vector_type")) + .execute() + .get() + .getResults(); + assertThat(data(results)) + .containsExactly( + map( + "string_type", + "string", + "number_type", + "int64", + "boolean_type", + "boolean", + "null_type", + "null", + "vector_type", + "vector")); + } + + @Test + public void testExplainWithError() { + assumeFalse( + "Explain with error is not supported against the emulator.", + isRunningAgainstFirestoreEmulator(firestore)); + Pipeline pipeline = + firestore.pipeline().createFrom(collection).sort(field("rating").ascending()); + ExecutionException exception = + assertThrows( + ExecutionException.class, + () -> { + pipeline + .execute( + new PipelineExecuteOptions() + .withExplainOptions( + new ExplainOptions() + .withExecutionMode(ExplainOptions.ExecutionMode.ANALYZE)) + .with("memory_limit", 1)) + .get(); + }); + assertThat(exception.getCause()).isInstanceOf(ApiException.class); + ApiException apiException = (ApiException) exception.getCause(); + assertThat(apiException.getStatusCode().getCode()) + .isEqualTo(StatusCode.Code.RESOURCE_EXHAUSTED); + } + + @Test + public void testCrossDatabaseRejection() throws Exception { + FirestoreOptions firestoreOptions = + FirestoreOptions.newBuilder().setProjectId("test-project-2").build(); + try (Firestore firestore2 = firestoreOptions.getService()) { + CollectionReference collection2 = firestore2.collection("test-collection"); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore.pipeline().collection(collection2); + }); + assertThat(exception.getMessage()).contains("Invalid CollectionReference"); + } + } + + @Test + public void disallowDuplicateAliasesInAggregate() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .aggregate(countAll().as("dup"), AggregateFunction.average("rating").as("dup")); + }); + assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); + } + + @Test + public void disallowDuplicateAliasesInSelect() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .select(field("title").as("dup"), field("author").as("dup")); + }); + assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); + } + + @Test + public void disallowDuplicateAliasesInAddFields() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .addFields(field("title").as("dup"), field("author").as("dup")); + }); + assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); + } + + @Test + public void disallowDuplicateAliasesInDistinct() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .distinct(field("genre").as("dup"), field("author").as("dup")); + }); + assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); + } + + @Test + public void disallowDuplicateAliasesAcrossStages() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> { + firestore + .pipeline() + .collection(collection.getPath()) + .select(field("title").as("title_dup")) + .addFields(field("author").as("author_dup")) + .distinct(field("genre").as("genre_dup")) + .select(field("title_dup").as("final_dup"), field("author_dup").as("final_dup")); + }); + assertThat(exception).hasMessageThat().contains("Duplicate alias or field name"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryAggregationsTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryAggregationsTest.java new file mode 100644 index 000000000000..19e3b4488101 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryAggregationsTest.java @@ -0,0 +1,1229 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.AggregateField.average; +import static com.google.cloud.firestore.AggregateField.sum; +import static com.google.cloud.firestore.LocalFirestoreHelper.autoId; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.it.TestHelper.await; +import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Arrays.asList; +import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.*; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITQueryAggregationsTest extends ITBaseTest { + private CollectionReference testCollection() { + String collectionPath = "java-" + autoId(); + return firestore.collection(collectionPath); + } + + private CollectionReference testCollection(String name) { + return firestore.collection("java-" + name + "-" + autoId()); + } + + private CollectionReference testCollectionWithDocs(Map> docs) + throws InterruptedException { + CollectionReference collection = testCollection(); + CollectionReference writer = firestore.collection(collection.getId()); + writeAllDocs(writer, docs); + return collection; + } + + public static AggregateQuerySnapshot verifyPipelineReturnsSameResult(AggregateQuery query) + throws ExecutionException, InterruptedException { + + AggregateQuerySnapshot snapshot = query.get().get(); + + if (getFirestoreEdition() != FirestoreEdition.ENTERPRISE) { + return snapshot; + } + + List pipelineResults = + query.getQuery().getFirestore().pipeline().createFrom(query).execute().get().getResults(); + assertThat(pipelineResults).hasSize(1); + assertThat(pipelineResults.get(0).getData()) + .isEqualTo(TestUtil.getAggregateSnapshotData(snapshot)); + + return snapshot; + } + + public static void writeAllDocs( + CollectionReference collection, Map> docs) + throws InterruptedException { + for (Map.Entry> doc : docs.entrySet()) { + await(collection.document(doc.getKey()).set(doc.getValue())); + } + } + + private static Map> testDocs1 = + map( + "a", + map("author", "authorA", "title", "titleA", "pages", 100, "foo", 1, "bar", 2, "baz", 3), + "b", + map("author", "authorB", "title", "titleB", "pages", 50, "foo", 1, "bar", 2, "baz", 3)); + + @Test + public void canRunCountUsingAggregationMethod() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(AggregateField.count())); + assertThat(snapshot.getCount()).isEqualTo(2); + } + + @Test + public void allowsAliasesForLongestFieldNames() throws Exception { + assumeFalse( + "Skip this test when running against the Firestore emulator or enterprise backend because" + + " they do not support long field names.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + // The longest field name allowed is 1499 characters long. + // Ensure that sum(longestField) and average(longestField) work. + StringBuilder builder = new StringBuilder(1500); + for (int i = 0; i < 1499; i++) { + builder.append("k"); + } + String longestField = builder.toString(); + Map> testDocs = + map("a", map(longestField, 2), "b", map(longestField, 4)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(AggregateField.sum(longestField))); + assertThat(snapshot.get(AggregateField.sum(longestField))).isEqualTo(6); + AggregateQuerySnapshot snapshot2 = + verifyPipelineReturnsSameResult(collection.aggregate(AggregateField.average(longestField))); + assertThat(snapshot2.get(AggregateField.average(longestField))).isEqualTo(3.0); + } + + @Test + public void canGetDuplicateAggregations() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + collection + .aggregate(AggregateField.count(), AggregateField.count(), sum("pages"), sum("pages")) + .get() + .get(); + assertThat(snapshot.getCount()).isEqualTo(2); + assertThat(snapshot.get(sum("pages"))).isEqualTo(150); + } + + @Test + public void aggregateErrorMessageIfIndexIsMissing() throws Exception { + assumeFalse( + "Skip this test when running against emulator or Enterprise because they do not require" + + " composite index creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuery aggregateQuery = + collection + .whereEqualTo("key1", 42) + .whereLessThan("key2", 42) + .aggregate(AggregateField.count()); + ExecutionException executionException = + assertThrows(ExecutionException.class, () -> aggregateQuery.get().get()); + assertThat(executionException) + .hasCauseThat() + .hasMessageThat() + .containsMatch("FAILED_PRECONDITION:.*index.*"); + } + + @Test + public void canRunSumQuery() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("pages"))); + assertThat(snapshot.get(sum("pages"))).isEqualTo(150); + } + + @Test + public void canRunAverageQuery() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("pages"))); + assertThat(snapshot.get(average("pages"))).isEqualTo(75.0); + } + + @Test + public void canGetMultipleAggregationsInTheSameQuery() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate(sum("pages"), average("pages"), AggregateField.count())); + assertThat(snapshot.get(sum("pages"))).isEqualTo(150); + assertThat(snapshot.get(average("pages"))).isEqualTo(75.0); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + } + + @Test + public void getCorrectTypeForSumLong() throws Exception { + Map> testDocs = map("a", map("foo", 100), "b", map("foo", 100)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("foo"))); + Object sum = snapshot.get(sum("foo")); + assertThat(sum instanceof Long).isTrue(); + } + + @Test + public void getCorrectTypeForSumDouble() throws Exception { + Map> testDocs = map("a", map("foo", 100.5), "b", map("foo", 100)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("foo"))); + Object sum = snapshot.get(sum("foo")); + assertThat(sum instanceof Double).isTrue(); + } + + @Test + public void getCorrectTypeForSumNaN() throws Exception { + Map> testDocs = + map("a", map("foo", 100.5), "b", map("foo", Double.NaN)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("foo"))); + Object sum = snapshot.get(sum("foo")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum.equals(Double.NaN)); + } + + @Test + public void getCorrectTypeForAverageDouble() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("pages"))); + Object average = snapshot.get((AggregateField) average("pages")); + assertThat(average instanceof Double).isTrue(); + } + + @Test + public void getCorrectTypeForAverageNaN() throws Exception { + Map> testDocs = + map("a", map("foo", 100.5), "b", map("foo", Double.NaN)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("foo"))); + Object sum = snapshot.get(average("foo")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum.equals(Double.NaN)); + } + + @Test + public void getCorrectTypeForAverageNull() throws Exception { + CollectionReference collection = testCollection(); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("bar"))); + Object sum = snapshot.get(average("bar")); + assertThat(sum == null).isTrue(); + } + + @Test + public void canPerformMaxAggregations() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateField f1 = sum("pages"); + AggregateField f2 = average("pages"); + AggregateField f3 = AggregateField.count(); + AggregateField f4 = sum("foo"); + AggregateField f5 = sum("bar"); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(f1, f2, f3, f4, f5)); + assertThat(snapshot.get(f1)).isEqualTo(150); + assertThat(snapshot.get(f2)).isEqualTo(75.0); + assertThat(snapshot.get(f3)).isEqualTo(2); + assertThat(snapshot.get(f4)).isEqualTo(2); + assertThat(snapshot.get(f5)).isEqualTo(4); + } + + @Test + public void cannotPerformMoreThanMaxAggregations() throws Exception { + // TODO: Update this test once aggregate de-duplication is implemented and more aggregation + // types are available. + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateField f1 = sum("pages"); + AggregateField f2 = average("pages"); + AggregateField f3 = AggregateField.count(); + AggregateField f4 = sum("foo"); + AggregateField f5 = sum("bar"); + AggregateField f6 = sum("baz"); + Exception exception = null; + try { + collection.aggregate(f1, f2, f3, f4, f5, f6).get().get(); + } catch (Exception e) { + exception = e; + } + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertThat(exception).isNotNull(); + if (!isRunningAgainstFirestoreEmulator(firestore)) { + assertThat(exception.getMessage()).contains("maximum number of aggregations"); + } + } else { + assertThat(exception).isNull(); + } + } + + @Test + public void aggregateQueriesSupportCollectionGroups() throws Exception { + assumeTrue( + "Skip this test when running against prod because it requires composite index creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + String collectionGroupId = "myColGroupId" + autoId(); + Map data = map("x", 2); + // Setting documents at the following paths: + // `${collectionGroupId}/cg-doc1`, + // `abc/123/${collectionGroupId}/cg-doc2`, + // `zzz${collectionGroupId}/cg-doc3`, + // `abc/123/zzz${collectionGroupId}/cg-doc4`, + // `abc/123/zzz/${collectionGroupId}` + await(firestore.collection(collectionGroupId).document("cg-doc1").set(data)); + await( + firestore + .collection("abc") + .document("123") + .collection(collectionGroupId) + .document("cg-doc2") + .set(data)); + await(firestore.collection("zzz" + collectionGroupId).document("cg-doc3").set(data)); + await( + firestore + .collection("abc") + .document("123") + .collection("zzz" + collectionGroupId) + .document("cg-doc4") + .set(data)); + await( + firestore + .collection("abc") + .document("123") + .collection("zzz") + .document(collectionGroupId) + .set(data)); + CollectionGroup collectionGroup = firestore.collectionGroup(collectionGroupId); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collectionGroup.aggregate(AggregateField.count(), sum("x"), average("x"))); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + assertThat(snapshot.get(sum("x"))).isEqualTo(4); + assertThat(snapshot.get(average("x"))).isEqualTo(2); + } + + @Test + public void performsAggregationsOnDocumentsWithAllAggregatedFields() throws Exception { + assumeTrue( + "Skip if we are running against standard in prod", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + Map> testDocs = + map( + "a", + map("author", "authorA", "title", "titleA", "pages", 100, "year", 1980), + "b", + map("author", "authorB", "title", "titleB", "pages", 50, "year", 2020), + "c", + map("author", "authorC", "title", "titleC", "pages", 150, "year", 2021), + "d", + map("author", "authorD", "title", "titleD", "pages", 50)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate( + sum("pages"), average("pages"), average("year"), AggregateField.count())); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertThat(snapshot.get(sum("pages"))).isEqualTo(300); + assertThat(snapshot.get(average("pages"))).isEqualTo(100); + assertThat(snapshot.get(average("year"))).isEqualTo(2007); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(3); + } else { + assertThat(snapshot.get(sum("pages"))).isEqualTo(350); + assertThat(snapshot.get(average("pages"))).isEqualTo(87.5); + assertThat(snapshot.get(average("year"))).isEqualTo(2007); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(4); + } + } + + @Test + public void performsAggregationsWhenNaNExistsForSomeFieldValues() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + Map> testDocs = + map( + "a", + map( + "author", "authorA", "title", "titleA", "pages", 100, "year", 1980, "rating", + 5), + "b", + map("author", "authorB", "title", "titleB", "pages", 50, "year", 2020, "rating", 4), + "c", + map( + "author", + "authorC", + "title", + "titleC", + "pages", + 100, + "year", + 1980, + "rating", + Double.NaN), + "d", + map( + "author", "authorD", "title", "titleD", "pages", 50, "year", 2020, "rating", + 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate(sum("rating"), sum("pages"), average("year"))); + assertThat(snapshot.get(sum("rating"))).isEqualTo(Double.NaN); + assertThat(snapshot.get(sum("pages"))).isEqualTo(300); + assertThat(snapshot.get(average("year"))).isEqualTo(2000); + } + + @Test + public void throwsAnErrorWhenGettingTheResultOfAnUnrequestedAggregation() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("pages"))); + Exception exception = null; + try { + snapshot.get(average("pages")); + } catch (Exception e) { + exception = e; + } + assertThat(exception).isNotNull(); + assertThat(exception.getMessage()) + .isEqualTo("'average(pages)' was not requested in the aggregation query."); + exception = null; + try { + snapshot.get(sum("foo")); + } catch (RuntimeException e) { + exception = e; + } + assertThat(exception).isNotNull(); + assertThat(exception.getMessage()) + .isEqualTo("'sum(foo)' was not requested in the aggregation query."); + } + + @Test + public void performsAggregationWhenUsingInOperator() throws Exception { + assumeTrue( + "Skip this test when running against prod because it requires composite index creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + Map> testDocs = + map( + "a", + map( + "author", "authorA", "title", "titleA", "pages", 100, "year", 1980, "rating", + 5), + "b", + map("author", "authorB", "title", "titleB", "pages", 50, "year", 2020, "rating", 4), + "c", + map( + "author", "authorC", "title", "titleC", "pages", 100, "year", 1980, "rating", + 3), + "d", + map( + "author", "authorD", "title", "titleD", "pages", 50, "year", 2020, "rating", + 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection + .whereIn("rating", asList(5, 3)) + .aggregate( + sum("rating"), + average("rating"), + sum("pages"), + average("pages"), + AggregateField.count())); + assertThat(snapshot.get(sum("rating"))).isEqualTo(8); + assertThat(snapshot.get(average("rating"))).isEqualTo(4); + assertThat(snapshot.get(sum("pages"))).isEqualTo(200); + assertThat(snapshot.get(average("pages"))).isEqualTo(100); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + } + + @Test + public void performsAggregationWhenUsingArrayContainsAnyOperator() throws Exception { + assumeTrue( + "Skip this test when running against prod because it requires composite index creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + Map> testDocs = + map( + "a", + map( + "author", + "authorA", + "title", + "titleA", + "pages", + 100, + "year", + 1980, + "rating", + asList(5, 1000)), + "b", + map( + "author", "authorB", "title", "titleB", "pages", 50, "year", 2020, "rating", + asList(4)), + "c", + map( + "author", + "authorC", + "title", + "titleC", + "pages", + 100, + "year", + 1980, + "rating", + asList(2222, 3)), + "d", + map( + "author", "authorD", "title", "titleD", "pages", 50, "year", 2020, "rating", + asList(0))); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection + .whereArrayContainsAny("rating", asList(5, 3)) + .aggregate( + sum("rating"), + average("rating"), + sum("pages"), + average("pages"), + AggregateField.count())); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertThat(snapshot.get(sum("rating"))).isEqualTo(0); + assertThat(snapshot.get(average("rating"))).isEqualTo(null); + assertThat(snapshot.get(sum("pages"))).isEqualTo(200); + assertThat(snapshot.get(average("pages"))).isEqualTo(100); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + } else { + assertThat(snapshot.get(sum("rating"))).isNull(); + assertThat(snapshot.get(average("rating"))).isNull(); + assertThat(snapshot.get(sum("pages"))).isEqualTo(200); + assertThat(snapshot.get(average("pages"))).isEqualTo(100); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + } + } + + @Test + public void performsAggregationsOnNestedMapValues() throws Exception { + Map> testDocs = + map( + "a", + map( + "author", + "authorA", + "title", + "titleA", + "metadata", + map("pages", 100, "rating", map("critic", 2, "user", 5))), + "b", + map( + "author", + "authorB", + "title", + "titleB", + "metadata", + map("pages", 50, "rating", map("critic", 4, "user", 4)))); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate( + sum("metadata.pages"), average("metadata.pages"), AggregateField.count())); + assertThat(snapshot.get(sum("metadata.pages"))).isEqualTo(150); + assertThat(snapshot.get(average("metadata.pages"))).isEqualTo(75); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(2); + } + + @Test + public void performsSumThatResultsInFloat() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5), + "b", map("author", "authorB", "title", "titleB", "rating", 4.5), + "c", map("author", "authorC", "title", "titleC", "rating", 3)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isEqualTo(12.5); + } + + @Test + public void performsSumOfIntsAndFloatsThatResultsInInt() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5), + "b", map("author", "authorB", "title", "titleB", "rating", 4.5), + "c", map("author", "authorC", "title", "titleC", "rating", 3.5)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isEqualTo(13.0); + } + + @Test + public void performsSumThatOverflowsMaxLong() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Long.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", Long.MAX_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + AggregateQuerySnapshot snapshot = collection.aggregate(sum("rating")).get().get(); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isEqualTo((double) Long.MAX_VALUE + (double) Long.MAX_VALUE); + } else { + // enterprise will fail the operation + assertThrows(ExecutionException.class, () -> collection.aggregate(sum("rating")).get().get()); + } + } + + @Test + public void performsSumThatCanOverflowIntegerValuesDuringAccumulation() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Long.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", 1), + "c", map("author", "authorC", "title", "titleC", "rating", -101)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = collection.aggregate(sum("rating")).get().get(); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Long).isTrue(); + assertThat(sum).isEqualTo(Long.MAX_VALUE - 100); + } + + @Test + public void performsSumThatIsNegative() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Long.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", -Long.MAX_VALUE), + "c", map("author", "authorC", "title", "titleC", "rating", -101), + "d", map("author", "authorD", "title", "titleD", "rating", -10000)); + CollectionReference collection = testCollectionWithDocs(testDocs); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + assertThat(snapshot.get(sum("rating"))).isEqualTo(-10101); + } else { + // enterprise will fail the operation + assertThrows(ExecutionException.class, () -> collection.aggregate(sum("rating")).get().get()); + } + } + + @Test + public void performsSumThatIsPositiveInfinity() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Double.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", Double.MAX_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isEqualTo(Double.POSITIVE_INFINITY); + assertThat(snapshot.getDouble(sum("rating"))).isEqualTo(Double.POSITIVE_INFINITY); + assertThat(snapshot.getLong(sum("rating"))).isEqualTo(Long.MAX_VALUE); + } + + @Test + public void performsSumThatIsNegativeInfinity() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", -Double.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", -Double.MAX_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isEqualTo(Double.NEGATIVE_INFINITY); + assertThat(snapshot.getDouble(sum("rating"))).isEqualTo(Double.NEGATIVE_INFINITY); + assertThat(snapshot.getLong(sum("rating"))).isEqualTo(Long.MIN_VALUE); + } + + @Test + public void performsSumThatIsValidButCouldOverflowDuringAggregation() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Double.MAX_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", Double.MAX_VALUE), + "c", map("author", "authorC", "title", "titleC", "rating", -Double.MAX_VALUE), + "d", map("author", "authorD", "title", "titleD", "rating", -Double.MAX_VALUE), + "e", map("author", "authorE", "title", "titleE", "rating", Double.MAX_VALUE), + "f", map("author", "authorF", "title", "titleF", "rating", -Double.MAX_VALUE), + "g", map("author", "authorG", "title", "titleG", "rating", -Double.MAX_VALUE), + "h", map("author", "authorH", "title", "titleH", "rating", Double.MAX_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = collection.aggregate(sum("rating")).get().get(); + Object sum = snapshot.get(sum("rating")); + assertThat(sum instanceof Double).isTrue(); + assertThat(sum).isAnyOf(0, 0.0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); + } + + @Test + public void performsSumThatIncludesNaN() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5), + "b", map("author", "authorB", "title", "titleB", "rating", 4), + "c", map("author", "authorC", "title", "titleC", "rating", Double.NaN), + "d", map("author", "authorD", "title", "titleD", "rating", 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + assertThat(snapshot.get(sum("rating"))).isEqualTo(Double.NaN); + } + + @Test + public void performsSumOverResultSetOfZeroDocuments() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.whereGreaterThan("pages", 200).aggregate(sum("pages"))); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertThat(snapshot.get(sum("pages"))).isEqualTo(0); + } else { + assertThat(snapshot.get(sum("pages"))).isNull(); + } + } + + @Test + public void performsSumOnlyOnNumericFields() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5), + "b", map("author", "authorB", "title", "titleB", "rating", 4), + "c", map("author", "authorC", "title", "titleC", "rating", "3"), + "d", map("author", "authorD", "title", "titleD", "rating", 1)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate(sum("rating"), AggregateField.count())); + assertThat(snapshot.get(sum("rating"))).isEqualTo(10); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(4); + } + + @Test + public void performsSumOfMinIEEE754() throws Exception { + Map> testDocs = + map("a", map("author", "authorA", "title", "titleA", "rating", Double.MIN_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(sum("rating"))); + assertThat(snapshot.get(sum("rating"))).isEqualTo(Double.MIN_VALUE); + } + + @Test + public void performsAverageOfIntsThatResultsInAnInt() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 10), + "b", map("author", "authorB", "title", "titleB", "rating", 5), + "c", map("author", "authorC", "title", "titleC", "rating", 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(5); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(5L); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(5.0); + } + + @Test + public void performsAverageOfFloatsThatResultsInAnInt() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 10.5), + "b", map("author", "authorB", "title", "titleB", "rating", 9.5)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating")) instanceof Double).isTrue(); + assertThat(snapshot.get(average("rating"))).isEqualTo(10); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(10L); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(10.0); + } + + @Test + public void performsAverageOfFloatsAndIntsThatResultsInAnInt() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 10), + "b", map("author", "authorB", "title", "titleB", "rating", 9.5), + "c", map("author", "authorC", "title", "titleC", "rating", 10.5)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(10); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(10L); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(10.0); + } + + @Test + public void performsAverageOfFloatsThatResultsInAFloat() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5.5), + "b", map("author", "authorB", "title", "titleB", "rating", 4.5), + "c", map("author", "authorC", "title", "titleC", "rating", 3.5)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(4.5); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(4.5); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(4L); + } + + @Test + public void performsAverageOfFloatsAndIntsThatResultsInAFloat() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 8.6), + "b", map("author", "authorB", "title", "titleB", "rating", 9), + "c", map("author", "authorC", "title", "titleC", "rating", 10)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(27.6 / 3); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(27.6 / 3); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(9L); + } + + @Test + public void performsAverageOfIntsThatResultsInAFloat() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 10), + "b", map("author", "authorB", "title", "titleB", "rating", 9)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(9.5); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(9.5d); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(9L); + } + + @Test + public void performsAverageCausingUnderflow() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", Double.MIN_VALUE), + "b", map("author", "authorB", "title", "titleB", "rating", 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(0); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(0.0d); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(0L); + } + + @Test + public void performsAverageOfMinIEEE754() throws Exception { + Map> testDocs = + map("a", map("author", "authorA", "title", "titleA", "rating", Double.MIN_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(Double.MIN_VALUE); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(Double.MIN_VALUE); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(0); + } + + @Test + public void performsAverageThatCouldOverflowIEEE754DuringAccumulation() throws Exception { + Map> testDocs = + map( + "a", + map("author", "authorA", "title", "titleA", "rating", Double.MAX_VALUE), + "b", + map("author", "authorB", "title", "titleB", "rating", Double.MAX_VALUE)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(Double.POSITIVE_INFINITY); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(Double.POSITIVE_INFINITY); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(Long.MAX_VALUE); + } + + @Test + public void performsAverageThatIncludesNaN() throws Exception { + Map> testDocs = + map( + "a", + map("author", "authorA", "title", "titleA", "rating", 5), + "b", + map("author", "authorB", "title", "titleB", "rating", 4), + "c", + map("author", "authorC", "title", "titleC", "rating", Double.NaN), + "d", + map("author", "authorD", "title", "titleD", "rating", 0)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult(collection.aggregate(average("rating"))); + assertThat(snapshot.get(average("rating"))).isEqualTo(Double.NaN); + assertThat(snapshot.getDouble(average("rating"))).isEqualTo(Double.NaN); + assertThat(snapshot.getLong(average("rating"))).isEqualTo(0L); + } + + @Test + public void performsAverageOverResultSetOfZeroDocuments() throws Exception { + CollectionReference collection = testCollectionWithDocs(testDocs1); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.whereGreaterThan("pages", 200).aggregate(average("pages"))); + assertThat(snapshot.get(average("pages"))).isEqualTo(null); + assertThat(snapshot.getDouble(average("pages"))).isEqualTo(null); + assertThat(snapshot.getLong(average("pages"))).isEqualTo(null); + } + + @Test + public void performsAverageOnlyOnNumericFields() throws Exception { + Map> testDocs = + map( + "a", map("author", "authorA", "title", "titleA", "rating", 5), + "b", map("author", "authorB", "title", "titleB", "rating", 4), + "c", map("author", "authorC", "title", "titleC", "rating", "3"), + "d", map("author", "authorD", "title", "titleD", "rating", 6)); + CollectionReference collection = testCollectionWithDocs(testDocs); + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection.aggregate(average("rating"), AggregateField.count())); + assertThat(snapshot.get(average("rating"))).isEqualTo(5); + assertThat(snapshot.get(AggregateField.count())).isEqualTo(4); + } + + @Test + public void aggregatesWithDocumentReferenceCursors() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + Map> testDocs = + map( + "a", map("num", 1), + "b", map("num", 2), + "c", map("num", 3), + "d", map("num", 4), + "e", map("num", 5)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + AggregateQuerySnapshot snapshot = + verifyPipelineReturnsSameResult( + collection + .orderBy(FieldPath.documentId()) + .startAfter(collection.document("c")) + .aggregate(sum("num"))); + assertThat(snapshot.get(sum("num"))).isEqualTo(9); + + snapshot = + verifyPipelineReturnsSameResult( + collection + .orderBy(FieldPath.documentId()) + .startAt(collection.document("c")) + .aggregate(sum("num"))); + assertThat(snapshot.get(sum("num"))).isEqualTo(12); + + snapshot = + verifyPipelineReturnsSameResult( + collection + .orderBy(FieldPath.documentId()) + .endBefore(collection.document("c")) + .aggregate(sum("num"))); + assertThat(snapshot.get(sum("num"))).isEqualTo(3); + + snapshot = + verifyPipelineReturnsSameResult( + collection + .orderBy(FieldPath.documentId()) + .endAt(collection.document("c")) + .aggregate(sum("num"))); + assertThat(snapshot.get(sum("num"))).isEqualTo(6); + } + + CollectionReference addTwoDocsForCursorTesting() throws InterruptedException { + Map> testDocs = + map( + "a", map("num", 5, "foo", 1), + "b", map("num", 7, "foo", 2)); + return testCollectionWithDocs(testDocs); + } + + @Test + public void aggregateWithNoFilterNoOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(12); + } + + @Test + public void aggregateWithEqualityFilterNoOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.whereEqualTo("num", 5).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(5); + } + + @Test + public void aggregateWithInequalityFilterNoOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.whereGreaterThan("num", 5).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateWithNoFilterExplicitOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.orderBy("num").aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(12); + } + + @Test + public void aggregateWithEqualityFilterExplicitOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.whereEqualTo("num", 5).orderBy("num").aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(5); + } + + @Test + public void aggregateWithInequalityFilterExplicitOrderByNoCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection.whereGreaterThan("num", 5).orderBy("num").aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateNoFilterExplicitOrderByFieldValueCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.orderBy("num").startAfter(5).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateNoFilterExplicitOrderByDocumentReferenceCursor() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection + .orderBy(FieldPath.documentId()) + .startAfter(collection.document("a")) + .aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateNoFilterNoOrderByDocumentReferenceCursor() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = collection.startAfter(collection.document("a")).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateNoFilterExplicitOrderByDocumentSnapshotCursor() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + DocumentSnapshot docSnapshot = collection.document("a").get().get(); + AggregateQuery query = collection.orderBy("foo").startAfter(docSnapshot).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + // This just happens to work because the orderBy field matches the aggregation field. + @Test + public void aggregateNoFilterExplicitOrderByDocumentSnapshotCursor2() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + DocumentSnapshot docSnapshot = collection.document("a").get().get(); + AggregateQuery query = collection.orderBy("num").startAfter(docSnapshot).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateEqualityFilterExplicitOrderByFieldValueCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection.whereEqualTo("num", 5).orderBy("num").startAt(5).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(5); + } + + @Test + public void aggregateInequalityFilterExplicitOrderByFieldValueCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection.whereGreaterThan("num", 5).orderBy("num").startAt(6).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateEqualityFilterExplicitOrderByDocumentReferenceCursor() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection + .whereEqualTo("num", 7) + .orderBy(FieldPath.documentId()) + .startAfter(collection.document("a")) + .aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + // Full orderBy is provided. + @Test + public void aggregateInequalityFilterExplicitOrderByDocumentReferenceCursor() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + AggregateQuery query = + collection + .whereGreaterThan("num", 0) + .orderBy("num") + .orderBy(FieldPath.documentId()) + .startAfter(5, collection.document("a")) + .aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateEqualityFilterNoOrderByDocumentSnapshotReference() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + DocumentSnapshot docSnapshot = collection.document("a").get().get(); + AggregateQuery query = + collection.whereEqualTo("num", 7).startAfter(docSnapshot).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + // This just happens to work because the orderBy field matches the aggregation field. + @Test + public void aggregateInequalityFilterNoOrderByDocumentSnapshotReference() throws Exception { + CollectionReference collection = addTwoDocsForCursorTesting(); + DocumentSnapshot docSnapshot = collection.document("a").get().get(); + AggregateQuery query = + collection.whereGreaterThan("num", 0).startAfter(docSnapshot).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateInequalityFilterNoOrderByDocumentSnapshotReference2() throws Exception { + assumeTrue( + "Skip this test when running against standard prod because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = addTwoDocsForCursorTesting(); + DocumentSnapshot docSnapshot = collection.document("a").get().get(); + AggregateQuery query = + collection.whereGreaterThan("foo", 0).startAfter(docSnapshot).aggregate(sum("num")); + AggregateQuerySnapshot snapshot = verifyPipelineReturnsSameResult(query); + assertThat(snapshot.get(sum("num"))).isEqualTo(7); + } + + @Test + public void aggregateQueryShouldFailWithMessageWithConsoleLinkIfMissingIndex() { + assumeFalse( + "Only run this test when running against the standard backend", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = testCollection(); + Query compositeIndexQuery = collection.whereEqualTo("field1", 42).whereLessThan("field2", 99); + AggregateQuery compositeIndexAggregateQuery = + compositeIndexQuery.aggregate( + AggregateField.count(), AggregateField.sum("pages"), AggregateField.average("pages")); + ApiFuture future = compositeIndexAggregateQuery.get(); + + ExecutionException executionException = assertThrows(ExecutionException.class, future::get); + + Throwable throwable = executionException.getCause(); + assertThat(throwable).hasMessageThat().ignoringCase().contains("index"); + // TODO(b/316359394) Remove this check for the default databases once cl/582465034 is rolled out + // to production. + if (collection.getFirestore().getOptions().getDatabaseId().equals("(default)")) { + assertThat(throwable).hasMessageThat().contains("https://console.firebase.google.com"); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryCountTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryCountTest.java new file mode 100644 index 000000000000..5ded283ac011 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryCountTest.java @@ -0,0 +1,508 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.LocalFirestoreHelper.autoId; +import static com.google.cloud.firestore.it.TestHelper.await; +import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Collections.singletonMap; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + +import com.google.api.core.ApiFuture; +import com.google.auto.value.AutoValue; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.AggregateField; +import com.google.cloud.firestore.AggregateQuery; +import com.google.cloud.firestore.AggregateQuerySnapshot; +import com.google.cloud.firestore.CollectionGroup; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.TransactionOptions; +import com.google.cloud.firestore.WriteBatch; +import com.google.cloud.firestore.WriteResult; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITQueryCountTest extends ITBaseTest { + + @Rule public TestName testName = new TestName(); + + @Test + public void countShouldReturnZeroForEmptyCollection() throws Exception { + CollectionReference collection = createEmptyCollection(); + AggregateQuerySnapshot snapshot = collection.count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(0); + } + + @Test + public void countShouldReturnNumDocumentsInNonEmptyCollection() throws Exception { + CollectionReference collection = createCollectionWithDocuments(5).collection(); + AggregateQuerySnapshot snapshot = collection.count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(5); + } + + @Test + public void countShouldReturnNumMatchingDocuments() throws Exception { + CollectionReference collection = createEmptyCollection(); + createDocumentsWithKeyValuePair(collection, 3, "key", 42); + createDocumentsWithKeyValuePair(collection, 5, "key", 24); + AggregateQuerySnapshot snapshot = collection.whereEqualTo("key", 42).count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(3); + } + + @Test + public void countShouldRespectLimit() throws Exception { + CollectionReference collection = createCollectionWithDocuments(5).collection(); + AggregateQuerySnapshot snapshot = collection.limit(2).count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(2); + } + + @Test + public void countShouldRespectOffset() throws Exception { + CollectionReference collection = createCollectionWithDocuments(5).collection(); + AggregateQuerySnapshot snapshot = collection.offset(2).count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(3); + } + + @Test + public void countShouldRespectOrderBy() throws Exception { + CollectionReference collection = createEmptyCollection(); + createDocumentsWithKeyValuePair(collection, 3, "key1", 42); + createDocumentsWithKeyValuePair(collection, 5, "key2", 24); + createDocumentsWithKeyValuePair(collection, 4, "key1", 99); + AggregateQuerySnapshot snapshot = collection.orderBy("key1").count().get().get(); + // Note: A subtle side effect of order-by is that it filters out documents that do not have the + // order-by field. + assertThat(snapshot.getCount()).isEqualTo(7); + } + + @Test + public void countShouldRespectStartAtAndEndAtWithDocumentSnapshotCursor() throws Exception { + // TODO(pipeline): Enable this test against production when adding implicitOrderBy. + assumeTrue( + "Skip this test when running against enterprise prod because it does not work yet.", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = createCollectionWithDocuments(10).collection(); + List documentSnapshots = collection.get().get().getDocuments(); + AggregateQuerySnapshot snapshot = + collection + .startAt(documentSnapshots.get(2)) + .endAt(documentSnapshots.get(7)) + .count() + .get() + .get(); + assertThat(snapshot.getCount()).isEqualTo(6); + } + + @Test + public void countShouldRespectStartAtAndEndAtWithDocumentReferenceCursor() throws Exception { + // TODO: Enable this test against production when adding implicitOrderBy. + assumeTrue( + "Skip this test when running against enterprise prod because it does not work yet.", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = createCollectionWithDocuments(10).collection(); + List documentSnapshots = collection.get().get().getDocuments(); + AggregateQuerySnapshot snapshot = + collection + .orderBy(FieldPath.documentId()) + .startAt(documentSnapshots.get(2).getReference()) + .endAt(documentSnapshots.get(7).getReference()) + .count() + .get() + .get(); + assertThat(snapshot.getCount()).isEqualTo(6); + } + + @Test + public void countShouldRespectStartAfterAndEndBeforeWithDocumentSnapshotCursor() + throws Exception { + // TODO(pipeline): Enable this test against production when adding implicitOrderBy. + assumeTrue( + "Skip this test when running against enterprise prod because it does not work yet.", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = createCollectionWithDocuments(10).collection(); + List documentSnapshots = collection.get().get().getDocuments(); + AggregateQuerySnapshot snapshot = + collection + .startAfter(documentSnapshots.get(2)) + .endBefore(documentSnapshots.get(7)) + .count() + .get() + .get(); + assertThat(snapshot.getCount()).isEqualTo(4); + } + + @Test + public void countShouldRespectStartAfterAndEndBeforeWithDocumentReferenceCursor() + throws Exception { + // TODO: Enable this test against production when adding implicitOrderBy. + assumeTrue( + "Skip this test when running against enterprise prod because it does not work yet.", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = createCollectionWithDocuments(10).collection(); + List documentSnapshots = collection.get().get().getDocuments(); + AggregateQuerySnapshot snapshot = + collection + .orderBy(FieldPath.documentId()) + .startAfter(documentSnapshots.get(2).getReference()) + .endBefore(documentSnapshots.get(7).getReference()) + .count() + .get() + .get(); + assertThat(snapshot.getCount()).isEqualTo(4); + } + + @Test + public void countQueriesShouldFailIfCollectionNameIsInvalid() { + CollectionReference collection = createEmptyCollection().document().collection("__invalid__"); + ApiFuture future = collection.count().get(); + ExecutionException executionException = assertThrows(ExecutionException.class, future::get); + assertThat(executionException).hasCauseThat().hasMessageThat().contains("__invalid__"); + assertThat(executionException).hasCauseThat().hasMessageThat().contains("INVALID_ARGUMENT"); + } + + @Test + public void countShouldReturnNumberOfDocumentsForCollectionGroups() throws Exception { + CollectionGroup collectionGroup = createCollectionGroupWithDocuments(13); + AggregateQuerySnapshot snapshot = collectionGroup.count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(13); + } + + @Test + public void aggregateQuerySupportsCollectionGroups() throws Exception { + CollectionGroup collectionGroup = createCollectionGroupWithDocuments(13); + AggregateQuerySnapshot snapshot = collectionGroup.aggregate(AggregateField.count()).get().get(); + assertThat(snapshot.getCount()).isEqualTo(13); + } + + @Test + public void countShouldReturnNumberOfDocumentsForPartitionQuery() throws Exception { + CollectionReference collection = createCollectionWithDocuments(3).collection(); + Query query = collection.select("abc"); + AggregateQuerySnapshot snapshot = query.count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(3); + } + + @Test + public void inFlightCountQueriesShouldCompleteSuccessfullyWhenFirestoreIsClosed() + throws Exception { + CollectionReference collection = createCollectionWithDocuments(20).collection(); + ApiFuture task = collection.count().get(); + collection.getFirestore().close(); + assertThat(task.get().getCount()).isEqualTo(20); + } + + @Test + public void inFlightAggregateQueriesShouldCompleteSuccessfullyWhenFirestoreIsClosed() + throws Exception { + CollectionReference collection = createCollectionWithDocuments(20).collection(); + ApiFuture task = collection.aggregate(AggregateField.count()).get(); + collection.getFirestore().close(); + assertThat(task.get().getCount()).isEqualTo(20); + } + + @Test + public void inFlightCountQueriesShouldCompleteSuccessfullyWhenFirestoreIsShutDownGracefully() + throws Exception { + CollectionReference collection = createCollectionWithDocuments(20).collection(); + ApiFuture task = collection.count().get(); + collection.getFirestore().shutdown(); + assertThat(task.get().getCount()).isEqualTo(20); + } + + @Test + public void + inFlightAggregationQueriesShouldCompleteSuccessfullyWhenFirestoreIsShutDownGracefully() + throws Exception { + CollectionReference collection = createCollectionWithDocuments(20).collection(); + ApiFuture task = collection.aggregate(AggregateField.count()).get(); + collection.getFirestore().shutdown(); + assertThat(task.get().getCount()).isEqualTo(20); + } + + @Test + public void inFlightAggregateQueriesShouldRunToCompletionWhenFirestoreIsShutDownForcefully() + throws Exception { + CollectionReference collection = createCollectionWithDocuments(20).collection(); + ApiFuture task = collection.aggregate(AggregateField.count()).get(); + collection.getFirestore().shutdownNow(); + await(task); + } + + @Test + public void countQueriesShouldFailIfStartedOnAClosedFirestoreInstance() throws Exception { + CollectionReference collection = createEmptyCollection(); + AggregateQuery aggregateQuery = collection.count(); + collection.getFirestore().close(); + assertThrows(IllegalStateException.class, aggregateQuery::get); + } + + @Test + public void aggregateQueriesShouldFailIfStartedOnAClosedFirestoreInstance() throws Exception { + CollectionReference collection = createEmptyCollection(); + AggregateQuery aggregateQuery = collection.aggregate(AggregateField.count()); + collection.getFirestore().close(); + assertThrows(IllegalStateException.class, aggregateQuery::get); + } + + @Test + public void countQueriesShouldFailIfStartedOnAShutDownFirestoreInstance() throws Exception { + CollectionReference collection = createEmptyCollection(); + AggregateQuery aggregateQuery = collection.count(); + collection.getFirestore().shutdown(); + assertThrows(IllegalStateException.class, aggregateQuery::get); + } + + @Test + public void aggregateSnapshotShouldHaveReasonableReadTime() throws Exception { + CollectionReference collection = createCollectionWithDocuments(5).collection(); + AggregateQuerySnapshot snapshot1 = collection.count().get().get(); + AggregateQuerySnapshot snapshot2 = collection.count().get().get(); + long readTimeMs1 = msFromTimestamp(snapshot1.getReadTime()); + long readTimeMs2 = msFromTimestamp(snapshot2.getReadTime()); + assertThat(readTimeMs1).isLessThan(readTimeMs2); + } + + @Test + public void aggregateSnapshotShouldHaveCorrectQuery() throws Exception { + CollectionReference collection = createCollectionWithDocuments(5).collection(); + AggregateQuery aggregateQuery = collection.count(); + AggregateQuerySnapshot snapshot1 = aggregateQuery.get().get(); + AggregateQuerySnapshot snapshot2 = aggregateQuery.get().get(); + assertThat(snapshot1.getQuery()).isSameInstanceAs(aggregateQuery); + assertThat(snapshot2.getQuery()).isSameInstanceAs(aggregateQuery); + } + + @Test + public void aggregateQueryShouldHaveCorrectQuery() { + CollectionReference collection = firestore.collection("abc"); + AggregateQuery aggregateQuery = collection.count(); + assertThat(aggregateQuery.getQuery()).isSameInstanceAs(collection); + } + + @Test + public void aggregateQueryShouldWorkInATransaction() throws Exception { + CollectionReference collection = createCollectionWithDocuments(7).collection(); + ApiFuture transactionFuture = + collection.getFirestore().runTransaction(t -> t.get(collection.count()).get()); + AggregateQuerySnapshot snapshot = transactionFuture.get(); + assertThat(snapshot.getCount()).isEqualTo(7); + } + + @Test + public void aggregateQueryInATransactionShouldLockTheCountedDocuments() throws Exception { + assumeTrue( + "Skip this test when running against production because " + + "it appears that production is failing to lock the counted documents b/248152832", + isRunningAgainstFirestoreEmulator(firestore)); + + CollectionReference collection = createEmptyCollection(); + DocumentReference document = createDocumentInCollection(collection); + CountDownLatch aggregateQueryExecutedSignal = new CountDownLatch(1); + CountDownLatch transactionContinueSignal = new CountDownLatch(1); + + ApiFuture transactionFuture = + collection + .getFirestore() + .runTransaction( + t -> { + t.get(collection.count()).get(); + aggregateQueryExecutedSignal.countDown(); + transactionContinueSignal.await(); + return null; + }); + + ExecutionException executionException; + try { + aggregateQueryExecutedSignal.await(); + ApiFuture documentSetTask = document.set(singletonMap("abc", "def")); + executionException = assertThrows(ExecutionException.class, documentSetTask::get); + } finally { + transactionContinueSignal.countDown(); + } + + assertThat(executionException) + .hasCauseThat() + .hasMessageThat() + .ignoringCase() + .contains("transaction lock timeout"); + + // Wait for the transaction to finish. + transactionFuture.get(); + } + + @Test + public void aggregateQueryInATransactionShouldRespectReadTime() throws Exception { + CreatedCollectionInfo createdCollectionInfo = createCollectionWithDocuments(5); + CollectionReference collection = createdCollectionInfo.collection(); + List documents = createdCollectionInfo.documents(); + + // Get a snapshot of the query to get its read time. + AggregateQuerySnapshot snapshot = collection.count().get().get(); + assertThat(snapshot.getCount()).isEqualTo(5); + + // Delete one of the documents from the result set so that, below, we can verify that specifying + // the read time before this deletion will count the documents at the old read time. + documents.get(0).delete().get(); + + ApiFuture transactionFuture = + collection + .getFirestore() + .runTransaction( + t -> t.get(collection.count()).get().getCount(), + TransactionOptions.createReadOnlyOptionsBuilder() + .setReadTime(snapshot.getReadTime().toProto()) + .build()); + + Long transactionCount = transactionFuture.get(); + assertThat(transactionCount).isEqualTo(5); + } + + @Test + public void countQueryShouldFailWithMessageWithConsoleLinkIfMissingIndex() { + assumeFalse( + "Skip this test when running against the Firestore emulator or enterprise because they " + + "do not use indexes and never fails with a 'missing index' error", + isRunningAgainstFirestoreEmulator(firestore) + || getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = createEmptyCollection(); + Query compositeIndexQuery = collection.whereEqualTo("field1", 42).whereLessThan("field2", 99); + AggregateQuery compositeIndexCountQuery = compositeIndexQuery.count(); + ApiFuture future = compositeIndexCountQuery.get(); + + ExecutionException executionException = assertThrows(ExecutionException.class, future::get); + + Throwable throwable = executionException.getCause(); + assertThat(throwable).hasMessageThat().ignoringCase().contains("index"); + // TODO(b/316359394) Remove this check for the default databases once cl/582465034 is rolled out + // to production. + if (collection.getFirestore().getOptions().getDatabaseId().equals("(default)")) { + assertThat(throwable).hasMessageThat().contains("https://console.firebase.google.com"); + } + } + + private CollectionReference createEmptyCollection() { + String collectionPath = "java-" + testName.getMethodName() + "-" + autoId(); + return firestore.collection(collectionPath); + } + + private CreatedCollectionInfo createCollectionWithDocuments(int numDocuments) + throws ExecutionException, InterruptedException { + CollectionReference collection = createEmptyCollection(); + List createdDocuments = + createDocumentsWithKeyValuePair(collection, numDocuments, "key", 42); + return CreatedCollectionInfo.create(collection, createdDocuments); + } + + private List createDocumentsWithKeyValuePair( + CollectionReference collection, int numDocumentsToCreate, String key, int value) + throws ExecutionException, InterruptedException { + WriteBatch writeBatch = firestore.batch(); + ArrayList createdDocuments = new ArrayList<>(); + for (int i = 0; i < numDocumentsToCreate; i++) { + DocumentReference doc = collection.document(); + createdDocuments.add(doc); + writeBatch.create(doc, singletonMap(key, value)); + } + writeBatch.commit().get(); + return createdDocuments; + } + + private List createDocumentsInCollection( + CollectionReference collection, int numDocumentsToCreate) + throws ExecutionException, InterruptedException { + return createDocumentsWithKeyValuePair(collection, numDocumentsToCreate, "meaning", 42); + } + + private DocumentReference createDocumentInCollection(CollectionReference collection) + throws ExecutionException, InterruptedException { + WriteBatch writeBatch = collection.getFirestore().batch(); + DocumentReference createdDocument = + createDocumentInCollection(writeBatch, collection, "age", 42); + writeBatch.commit(); + return createdDocument; + } + + private void createDocumentInCollection(WriteBatch writeBatch, CollectionReference collection) + throws ExecutionException, InterruptedException { + createDocumentInCollection(writeBatch, collection, "age", 42); + } + + private DocumentReference createDocumentInCollection( + WriteBatch writeBatch, CollectionReference collection, String key, int value) + throws ExecutionException, InterruptedException { + DocumentReference doc = collection.document(); + writeBatch.create(doc, singletonMap(key, value)); + return doc; + } + + private CollectionGroup createCollectionGroupWithDocuments(int numDocumentsToCreate) + throws ExecutionException, InterruptedException { + String collectionId = autoId(); + + // Create some collections to participate in the group. + ArrayList collections = new ArrayList<>(); + for (int i = 0; i <= numDocumentsToCreate / 3; i++) { + collections.add(createEmptyCollection().document().collection(collectionId)); + } + + // Populate the collections with documents. + WriteBatch writeBatch = firestore.batch(); + for (int i = 0; i < numDocumentsToCreate; i++) { + CollectionReference collection = collections.get(i % collections.size()); + createDocumentInCollection(writeBatch, collection); + } + + writeBatch.commit().get(); + + return firestore.collectionGroup(collectionId); + } + + /** Converts a {@link Timestamp} to the equivalent number of milliseconds. */ + private static long msFromTimestamp(Timestamp timestamp) { + return (timestamp.getSeconds() * 1_000) + (timestamp.getNanos() / 1_000_000); + } + + @AutoValue + abstract static class CreatedCollectionInfo { + + abstract CollectionReference collection(); + + abstract List documents(); + + static CreatedCollectionInfo create( + CollectionReference collection, List documents) { + return new AutoValue_ITQueryCountTest_CreatedCollectionInfo(collection, documents); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryFindNearestTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryFindNearestTest.java new file mode 100644 index 000000000000..0d40fbd7710b --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryFindNearestTest.java @@ -0,0 +1,940 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.LocalFirestoreHelper.autoId; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.it.TestHelper.await; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.*; +import static org.junit.Assume.assumeTrue; + +import com.google.cloud.firestore.*; +import java.time.Duration; +import java.util.Arrays; +import java.util.Map; +import javax.annotation.Nullable; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITQueryFindNearestTest extends ITBaseTest { + static String testId = autoId(); + + @Rule public TestName testName = new TestName(); + + private String getUniqueTestId() { + return testId + "-" + testName.getMethodName(); + } + + private CollectionReference testCollection() { + String collectionPath = "index-test-collection"; + return firestore.collection(collectionPath); + } + + private CollectionReference testCollectionWithDocs(Map> docs) + throws InterruptedException { + CollectionReference collection = testCollection(); + CollectionReference writer = firestore.collection(collection.getId()); + writeAllDocs(writer, docs); + return collection; + } + + private String getUniqueDocId(String docId) { + return testId + docId; + } + + public void writeAllDocs(CollectionReference collection, Map> docs) + throws InterruptedException { + for (Map.Entry> doc : docs.entrySet()) { + Map data = doc.getValue(); + data.put("testId", getUniqueTestId()); + data.put("docId", getUniqueDocId(doc.getKey())); + await(collection.add(data)); + } + } + + @Test + public void findNearestWithEuclideanDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", map("foo", "bar"), + "b", map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10})), + "c", map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "d", map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0})), + "e", map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0})), + "f", map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("d")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("c")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("e")); + } + + @Test + public void findNearestWithEuclideanDistanceFirestoreTypeOverride() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", map("foo", "bar"), + "b", map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10})), + "c", map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "d", map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0})), + "e", map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0})), + "f", map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + FieldPath.of("embedding"), + FieldValue.vector(new double[] {10, 10}), + 3, + VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("d")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("c")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("e")); + } + + @Test + public void findNearestWithCosineDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", "bar"), + "b", + map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10})), + "c", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "d", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0})), + "e", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0})), + "f", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest("embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.COSINE); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertTrue( + Arrays.asList(getUniqueDocId("f"), getUniqueDocId("c")) + .contains(snapshot.getDocuments().get(0).get("docId"))); + assertTrue( + Arrays.asList(getUniqueDocId("f"), getUniqueDocId("c")) + .contains(snapshot.getDocuments().get(1).get("docId"))); + assertTrue( + Arrays.asList(getUniqueDocId("d"), getUniqueDocId("e")) + .contains(snapshot.getDocuments().get(2).get("docId"))); + } + + @Test + public void findNearestWithDotProductDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", "bar"), + "b", + map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10})), + "c", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "d", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0})), + "e", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0})), + "f", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.DOT_PRODUCT); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("f")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("e")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("d")); + } + + @Test + public void findNearestSkipsFieldsOfWrongTypes() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", "bar"), + "b", + map("foo", "bar", "embedding", Arrays.asList(10.0, 10.0)), + "c", + map("foo", "bar", "embedding", "not actually a vector"), + "d", + map("foo", "bar", "embedding", null), + "e", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {9, 9})), + "f", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {50, 50})), + "g", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 100, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("e")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("f")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("g")); + } + + @Test + public void findNearestIgnoresMismatchingDimensions() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", "bar"), + "b", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {10})), + "c", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {9, 9})), + "d", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {50, 50})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("c")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("d")); + } + + @Test + public void findNearestOnNonExistentField() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", "bar"), + "b", + map("foo", "bar", "otherField", Arrays.asList(10.0, 10.0)), + "c", + map("foo", "bar", "otherField", "not actually a vector"), + "d", + map("foo", "bar", "otherField", null))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(0); + } + + @Test + public void findNearestOnVectorNestedInAMap() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("nested", map("foo", "bar")), + "b", + map( + "nested", + map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10}))), + "c", + map( + "nested", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1}))), + "d", + map( + "nested", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0}))), + "e", + map( + "nested", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0}))), + "f", + map( + "nested", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100}))))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "nested.embedding", + new double[] {10, 10}, + 3, + VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("b")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("d")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("c")); + } + + @Test + public void findNearestWithSelectToExcludeVectorDataInResponse() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", + map("foo", 1), + "b", + map("foo", 2, "embedding", FieldValue.vector(new double[] {10, 10})), + "c", + map("foo", 3, "embedding", FieldValue.vector(new double[] {1, 1})), + "d", + map("foo", 4, "embedding", FieldValue.vector(new double[] {10, 0})), + "e", + map("foo", 5, "embedding", FieldValue.vector(new double[] {20, 0})), + "f", + map("foo", 6, "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereIn("foo", Arrays.asList(1, 2, 3, 4, 5, 6)) + .whereEqualTo("testId", getUniqueTestId()) + .select("foo", "docId") + .findNearest( + "embedding", new double[] {10, 10}, 10, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(5); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("b")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("d")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("c")); + assertThat(snapshot.getDocuments().get(3).get("docId")).isEqualTo(getUniqueDocId("e")); + assertThat(snapshot.getDocuments().get(4).get("docId")).isEqualTo(getUniqueDocId("f")); + + for (QueryDocumentSnapshot doc : snapshot.getDocuments()) { + assertThat(doc.get("embedding")).isNull(); + } + } + + @Test + public void findNearestLimits() throws Exception { + double[] embeddingVector = new double[2048]; + double[] queryVector = new double[2048]; + for (int i = 0; i < 2048; i++) { + embeddingVector[i] = i + 1; + queryVector[i] = i - 1; + } + + CollectionReference collection = + testCollectionWithDocs(map("a", map("embedding", FieldValue.vector(embeddingVector)))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest("embedding", queryVector, 1000, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(1); + + assertThat(((VectorValue) snapshot.getDocuments().get(0).get("embedding")).toArray()) + .isEqualTo(embeddingVector); + } + + @Test + public void requestingComputedCosineDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0, 1})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0, -0.1})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-1, 0})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.COSINE, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(4); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(0).getDouble("distance")).isEqualTo(0); + + assertThat(snapshot.getDocuments().get(1).getDouble("distance")).isEqualTo(1); + assertThat(snapshot.getDocuments().get(2).getDouble("distance")).isEqualTo(1); + + assertThat(snapshot.getDocuments().get(3).get("docId")).isEqualTo(getUniqueDocId("5")); + assertThat(snapshot.getDocuments().get(3).getDouble("distance")).isEqualTo(2); + } + + @Test + public void requestingComputedEuclideanDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, -0.1})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {4, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(4); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("4")); + assertThat(snapshot.getDocuments().get(0).getDouble("distance")).isEqualTo(0.1); + + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(1).getDouble("distance")).isEqualTo(1); + + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("5")); + assertThat(snapshot.getDocuments().get(2).getDouble("distance")).isEqualTo(5); + + assertThat(snapshot.getDocuments().get(3).get("docId")).isEqualTo(getUniqueDocId("3")); + assertThat(snapshot.getDocuments().get(3).getDouble("distance")).isEqualTo(100); + } + + @Test + public void requestingComputedDotProductDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.DOT_PRODUCT, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(4); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(0).getDouble("distance")).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + assertThat(snapshot.getDocuments().get(1).getDouble("distance")).isEqualTo(1); + + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("5")); + assertThat(snapshot.getDocuments().get(2).getDouble("distance")).isEqualTo(0.1); + + assertThat(snapshot.getDocuments().get(3).get("docId")).isEqualTo(getUniqueDocId("4")); + assertThat(snapshot.getDocuments().get(3).getDouble("distance")).isEqualTo(-20); + } + + @Test + public void overwritesDistanceResultFieldOnConflict() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map( + "foo", + "bar", + "embedding", + FieldValue.vector(new double[] {0, 1}), + "distance", + "100 miles"))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.COSINE, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(1); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("1")); + assertThat(snapshot.getDocuments().get(0).getDouble("distance")).isEqualTo(1); + } + + @Test + public void requestingComputedDistanceInSelectQueries() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0, 1})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0, -0.1})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-1, 0})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .select("embedding", "distance", "docId") + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.COSINE, + VectorQueryOptions.newBuilder().setDistanceResultField("distance").build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(4); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(0).getDouble("distance")).isEqualTo(0); + + assertThat(snapshot.getDocuments().get(1).getDouble("distance")).isEqualTo(1); + assertThat(snapshot.getDocuments().get(2).getDouble("distance")).isEqualTo(1); + + assertThat(snapshot.getDocuments().get(3).get("docId")).isEqualTo(getUniqueDocId("5")); + assertThat(snapshot.getDocuments().get(3).getDouble("distance")).isEqualTo(2); + } + + @Test + public void queryingWithDistanceThresholdUsingCosineDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0, -0.1})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-1, 0})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.COSINE, + VectorQueryOptions.newBuilder().setDistanceThreshold(1.0).build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("4")); + } + + @Test + public void queryingWithDistanceThresholdUsingEuclideanDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, -0.1})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {4, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.EUCLIDEAN, + VectorQueryOptions.newBuilder().setDistanceThreshold(5.0).build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(3); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("4")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(2).get("docId")).isEqualTo(getUniqueDocId("5")); + } + + @Test + public void queryingWithDistanceThresholdUsingDotProductDistance() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.DOT_PRODUCT, + VectorQueryOptions.newBuilder().setDistanceThreshold(1.0).build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + } + + @Test + public void queryWithDistanceResultFieldAndDistanceThreshold() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 5, + VectorQuery.DistanceMeasure.DOT_PRODUCT, + VectorQueryOptions.newBuilder() + .setDistanceThreshold(0.11) + .setDistanceResultField("foo") + .build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(0).getDouble("foo")).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + assertThat(snapshot.getDocuments().get(1).getDouble("foo")).isEqualTo(1); + } + + @Test + public void queryWithDistanceResultFieldAndDistanceThresholdWithFirestoreTypes() + throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + FieldPath.of("embedding"), + FieldValue.vector(new double[] {1, 0}), + 5, + VectorQuery.DistanceMeasure.DOT_PRODUCT, + VectorQueryOptions.newBuilder() + .setDistanceThreshold(0.11) + .setDistanceResultField("foo") + .build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(0).getDouble("foo")).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + assertThat(snapshot.getDocuments().get(1).getDouble("foo")).isEqualTo(1); + } + + @Test + public void willNotExceedLimitEvenIfThereAreMoreResultsMoreSimilarThanDistanceThreshold() + throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", + new double[] {1, 0}, + 2, // limit set to 2 + VectorQuery.DistanceMeasure.DOT_PRODUCT, + VectorQueryOptions.newBuilder().setDistanceThreshold(0.0).build()); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertThat(snapshot.size()).isEqualTo(2); + + assertThat(snapshot.getDocuments().get(0).get("docId")).isEqualTo(getUniqueDocId("2")); + assertThat(snapshot.getDocuments().get(1).get("docId")).isEqualTo(getUniqueDocId("3")); + } + + @Test + public void testVectorQueryPlan() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support explain yet", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {1, 0}, 5, VectorQuery.DistanceMeasure.DOT_PRODUCT); + + ExplainResults explainResults = + vectorQuery.explain(ExplainOptions.builder().setAnalyze(false).build()).get(); + + @Nullable VectorQuerySnapshot snapshot = explainResults.getSnapshot(); + assertThat(snapshot).isNull(); + + ExplainMetrics metrics = explainResults.getMetrics(); + assertThat(metrics).isNotNull(); + + PlanSummary planSummary = metrics.getPlanSummary(); + assertThat(planSummary).isNotNull(); + assertThat(planSummary.getIndexesUsed()).isNotEmpty(); + + ExecutionStats stats = metrics.getExecutionStats(); + assertThat(stats).isNull(); + } + + @Test + public void testVectorQueryProfile() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support explain yet", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + CollectionReference collection = + testCollectionWithDocs( + map( + "1", + map("foo", "bar"), + "2", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {2, 0})), + "3", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 100})), + "4", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {-20, 0})), + "5", + map("foo", "bar", "embedding", FieldValue.vector(new double[] {0.1, 4})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {1, 0}, 5, VectorQuery.DistanceMeasure.DOT_PRODUCT); + + ExplainResults explainResults = + vectorQuery.explain(ExplainOptions.builder().setAnalyze(true).build()).get(); + + @Nullable VectorQuerySnapshot snapshot = explainResults.getSnapshot(); + assertThat(snapshot).isNotNull(); + assertThat(snapshot.size()).isEqualTo(4); + + ExplainMetrics metrics = explainResults.getMetrics(); + assertThat(metrics).isNotNull(); + + PlanSummary planSummary = metrics.getPlanSummary(); + assertThat(planSummary).isNotNull(); + assertThat(planSummary.getIndexesUsed()).isNotEmpty(); + + ExecutionStats stats = metrics.getExecutionStats(); + assertThat(stats).isNotNull(); + assertThat(stats.getDebugStats()).isNotEmpty(); + assertThat(stats.getReadOperations()).isEqualTo(5); + assertThat(stats.getResultsReturned()).isEqualTo(4); + assertThat(stats.getExecutionDuration()).isGreaterThan(Duration.ZERO); + } + + @Test + public void vectorQuerySnapshotReturnsVectorQuery() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "a", map("foo", "bar"), + "b", map("foo", "xxx", "embedding", FieldValue.vector(new double[] {10, 10})), + "c", map("foo", "bar", "embedding", FieldValue.vector(new double[] {1, 1})), + "d", map("foo", "bar", "embedding", FieldValue.vector(new double[] {10, 0})), + "e", map("foo", "bar", "embedding", FieldValue.vector(new double[] {20, 0})), + "f", map("foo", "bar", "embedding", FieldValue.vector(new double[] {100, 100})))); + + VectorQuery vectorQuery = + collection + .whereEqualTo("foo", "bar") + .whereEqualTo("testId", getUniqueTestId()) + .findNearest( + "embedding", new double[] {10, 10}, 3, VectorQuery.DistanceMeasure.EUCLIDEAN); + + VectorQuerySnapshot snapshot = vectorQuery.get().get(); + + assertTrue(snapshot.getQuery() == vectorQuery); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java new file mode 100644 index 000000000000..0335983bf184 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryTest.java @@ -0,0 +1,1238 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; +import static com.google.common.primitives.Ints.asList; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeTrue; + +import com.google.cloud.firestore.*; +import com.google.cloud.firestore.Query.Direction; +import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITQueryTest extends ITBaseTest { + + @Rule public TestName testName = new TestName(); + + private CollectionReference createEmptyCollection() { + String collectionPath = + "java-" + testName.getMethodName() + "-" + LocalFirestoreHelper.autoId(); + return firestore.collection(collectionPath); + } + + public static Map map(Object... entries) { + Map res = new LinkedHashMap<>(); + for (int i = 0; i < entries.length; i += 2) { + res.put((String) entries[i], (T) entries[i + 1]); + } + return res; + } + + public CollectionReference testCollectionWithDocs(Map> docs) + throws ExecutionException, InterruptedException, TimeoutException { + CollectionReference collection = firestore.collection(LocalFirestoreHelper.autoId()); + for (Map.Entry> doc : docs.entrySet()) { + collection.document(doc.getKey()).set(doc.getValue()).get(5, TimeUnit.SECONDS); + } + return collection; + } + + public static void checkResultContainsDocumentsInOrder(Query query, String... docs) + throws ExecutionException, InterruptedException { + checkResultContainsDocumentsInOrder(query, getFirestoreEdition(), docs); + } + + public static void checkResultContainsDocumentsInOrder( + Query query, FirestoreEdition edition, String... docs) + throws ExecutionException, InterruptedException { + switch (edition) { + case STANDARD: + { + QuerySnapshot snapshot = query.get().get(); + List result = + snapshot.getDocuments().stream() + .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + .collect(Collectors.toList()); + assertThat(result).isEqualTo(Arrays.asList(docs)); + + break; + } + case ENTERPRISE: + { + QuerySnapshot snapshot = query.get().get(); + List result = + snapshot.getDocuments().stream() + .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + .collect(Collectors.toList()); + // Implicit orderby is not enforced with enterprise + assertThat(result).containsExactlyElementsIn(Arrays.asList(docs)); + + List pipelineResults = + query.getFirestore().pipeline().createFrom(query).execute().get().getResults(); + result = + pipelineResults.stream() + .map( + pipelineResult -> + Objects.requireNonNull(pipelineResult.getReference()).getId()) + .collect(Collectors.toList()); + assertThat(result).containsExactlyElementsIn(Arrays.asList(docs)); + + break; + } + } + } + + public static void checkResultContainsDocuments(Query query, String... docs) + throws ExecutionException, InterruptedException { + checkResultContainsDocuments(query, getFirestoreEdition(), docs); + } + + public static void checkResultContainsDocuments( + Query query, FirestoreEdition edition, String... docs) + throws ExecutionException, InterruptedException { + QuerySnapshot snapshot = query.get().get(); + Set result = + snapshot.getDocuments().stream() + .map(queryDocumentSnapshot -> queryDocumentSnapshot.getReference().getId()) + .collect(Collectors.toSet()); + assertThat(result).isEqualTo(Sets.newHashSet(docs)); + + if (edition == FirestoreEdition.ENTERPRISE) { + List pipelineResults = + query.getFirestore().pipeline().createFrom(query).execute().get().getResults(); + result = + pipelineResults.stream() + .map(pipelineResult -> Objects.requireNonNull(pipelineResult.getReference()).getId()) + .collect(Collectors.toSet()); + assertThat(result).isEqualTo(Sets.newHashSet(docs)); + } + } + + @Test + public void orQueries() throws Exception { + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("a", 2, "b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1, "b", 1)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + + // Two equalities: a==1 || b==1. + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))), + "doc1", + "doc2", + "doc4", + "doc5"); + + // (a==1 && b==0) || (a==3 && b==2) + checkResultContainsDocumentsInOrder( + collection.where( + Filter.or( + Filter.and(Filter.equalTo("a", 1), Filter.equalTo("b", 0)), + Filter.and(Filter.equalTo("a", 3), Filter.equalTo("b", 2)))), + "doc1", + "doc3"); + + // a==1 && (b==0 || b==3). + checkResultContainsDocumentsInOrder( + collection.where( + Filter.and( + Filter.equalTo("a", 1), Filter.or(Filter.equalTo("b", 0), Filter.equalTo("b", 3)))), + "doc1", + "doc4"); + + // (a==2 || b==2) && (a==3 || b==3) + checkResultContainsDocumentsInOrder( + collection.where( + Filter.and( + Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 2)), + Filter.or(Filter.equalTo("a", 3), Filter.equalTo("b", 3)))), + "doc3"); + + // Test with limits without orderBy (the __name__ ordering is the tiebreaker). + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))).limit(1), + "doc2"); + } + + @Test + public void orQueriesWithCompositeIndexes() throws Exception { + assumeTrue( + "Skip this test when running against production because these queries require a composite" + + " index.", + isRunningAgainstFirestoreEmulator(firestore)); + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("a", 2, "b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1, "b", 1)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + + // with one inequality: a>2 || b==1. + checkResultContainsDocuments( + collection.where(Filter.or(Filter.greaterThan("a", 2), Filter.equalTo("b", 1))), + "doc5", + "doc2", + "doc3"); + + // Test with limits (implicit order by ASC): (a==1) || (b > 0) LIMIT 2 + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))).limit(2), + "doc1", + "doc2"); + + // Test with limits (explicit order by): (a==1) || (b > 0) LIMIT_TO_LAST 2 + // Note: The public query API does not allow implicit ordering when limitToLast is used. + checkResultContainsDocumentsInOrder( + collection + .where(Filter.or(Filter.equalTo("a", 1), Filter.greaterThan("b", 0))) + .limitToLast(2) + .orderBy("b"), + "doc3", + "doc4"); + + // Test with limits (explicit order by ASC): (a==2) || (b == 1) ORDER BY a LIMIT 1 + checkResultContainsDocumentsInOrder( + collection + .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) + .limit(1) + .orderBy("a"), + "doc5"); + + // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a LIMIT_TO_LAST 1 + checkResultContainsDocumentsInOrder( + collection + .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) + .limitToLast(1) + .orderBy("a"), + "doc2"); + + // Test with limits (explicit order by DESC): (a==2) || (b == 1) ORDER BY a DESC LIMIT 1 + checkResultContainsDocumentsInOrder( + collection + .where(Filter.or(Filter.equalTo("a", 2), Filter.equalTo("b", 1))) + .limit(1) + .orderBy("a", Direction.DESCENDING), + "doc2"); + } + + @Test + public void orQueryDoesNotIncludeDocumentsWithMissingFields() throws Exception { + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1), + "doc6", map("a", 2)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + + // Query: a==1 || b==1 + // There's no explicit nor implicit orderBy. Documents with missing 'a' or missing 'b' should be + // allowed if the document matches at least one disjunction term. + Query query = collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))); + checkResultContainsDocumentsInOrder(query, "doc1", "doc2", "doc4", "doc5"); + } + + @Test + public void orQueryDoesNotIncludeDocumentsWithMissingFields2() throws Exception { + assumeTrue( + "Skip this test when running against production because these queries require a composite" + + " index.", + isRunningAgainstFirestoreEmulator(firestore)); + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1), + "doc6", map("a", 2)); + + CollectionReference collection = testCollectionWithDocs(testDocs); + + // Query: a==1 || b==1 order by a. + // doc2 should not be included because it's missing the field 'a', and we have "orderBy a". + Query query1 = + collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("a"); + checkResultContainsDocumentsInOrder(query1, "doc1", "doc4", "doc5"); + + // Query: a==1 || b==1 order by b. + // doc5 should not be included because it's missing the field 'b', and we have "orderBy b". + Query query2 = + collection.where(Filter.or(Filter.equalTo("a", 1), Filter.equalTo("b", 1))).orderBy("b"); + checkResultContainsDocumentsInOrder(query2, "doc1", "doc2", "doc4"); + + // Query: a>2 || b==1. + // This query has an implicit 'order by a'. + // doc2 should not be included because it's missing the field 'a'. + Query query3 = collection.where(Filter.or(Filter.greaterThan("a", 2), Filter.equalTo("b", 1))); + checkResultContainsDocumentsInOrder(query3, "doc3"); + + // Query: a>1 || b==1 order by a order by b. + // doc6 should not be included because it's missing the field 'b'. + // doc2 should not be included because it's missing the field 'a'. + Query query4 = + collection + .where(Filter.or(Filter.greaterThan("a", 1), Filter.equalTo("b", 1))) + .orderBy("a") + .orderBy("b"); + checkResultContainsDocumentsInOrder(query4, "doc3"); + } + + @Test + public void orQueriesWithIn() throws ExecutionException, InterruptedException, TimeoutException { + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1), + "doc6", map("a", 2)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + // a==2 || b in [2,3] + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 2), Filter.inArray("b", asList(2, 3)))), + "doc3", + "doc4", + "doc6"); + } + + @Test + public void orQueriesWithNotIn() + throws ExecutionException, InterruptedException, TimeoutException { + assumeTrue( + "Skip this test when running against production because it requires composite index" + + " creation.", + isRunningAgainstFirestoreEmulator(firestore)); + Map> testDocs = + map( + "doc1", map("a", 1, "b", 0), + "doc2", map("b", 1), + "doc3", map("a", 3, "b", 2), + "doc4", map("a", 1, "b", 3), + "doc5", map("a", 1), + "doc6", map("a", 2)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + // a==2 || b not-in [2,3] + // Has implicit orderBy b. + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 2), Filter.notInArray("b", asList(2, 3)))), + "doc1", + "doc2"); + } + + @Test + public void orQueriesWithArrayMembership() + throws ExecutionException, InterruptedException, TimeoutException { + Map> testDocs = + map( + "doc1", map("a", 1, "b", asList(0)), + "doc2", map("b", asList(1)), + "doc3", map("a", 3, "b", asList(2, 7)), + "doc4", map("a", 1, "b", asList(3, 7)), + "doc5", map("a", 1), + "doc6", map("a", 2)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + // a==2 || b array-contains 7 + checkResultContainsDocumentsInOrder( + collection.where(Filter.or(Filter.equalTo("a", 2), Filter.arrayContains("b", 7))), + "doc3", + "doc4", + "doc6"); + + // a==2 || b array-contains-any [0, 3] + checkResultContainsDocumentsInOrder( + collection.where( + Filter.or(Filter.equalTo("a", 2), Filter.arrayContainsAny("b", asList(0, 3)))), + "doc1", + "doc4", + "doc6"); + } + + @Test + public void testUsingInWithArrayContains() + throws ExecutionException, InterruptedException, TimeoutException { + Map> testDocs = + map( + "doc1", map("a", 1, "b", asList(0)), + "doc2", map("b", asList(1)), + "doc3", map("a", 3, "b", asList(2, 7)), + "doc4", map("a", 1, "b", asList(3, 7)), + "doc5", map("a", 1), + "doc6", map("a", 2)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + Query query1 = + collection.where( + Filter.or(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 3))); + checkResultContainsDocumentsInOrder(query1, "doc3", "doc4", "doc6"); + + Query query2 = + collection.where( + Filter.and(Filter.inArray("a", asList(2, 3)), Filter.arrayContains("b", 7))); + checkResultContainsDocumentsInOrder(query2, "doc3"); + + Query query3 = + collection.where( + Filter.or( + Filter.inArray("a", asList(2, 3)), + Filter.and(Filter.arrayContains("b", 3), Filter.equalTo("a", 1)))); + checkResultContainsDocumentsInOrder(query3, "doc3", "doc4", "doc6"); + + Query query4 = + collection.where( + Filter.and( + Filter.inArray("a", asList(2, 3)), + Filter.or(Filter.arrayContains("b", 7), Filter.equalTo("a", 1)))); + checkResultContainsDocumentsInOrder(query4, "doc3"); + } + + @Test + public void testOrderByEquality() + throws ExecutionException, InterruptedException, TimeoutException { + Map> testDocs = + map( + "doc1", map("a", 1, "b", asList(0)), + "doc2", map("b", asList(1)), + "doc3", map("a", 3, "b", asList(2, 7), "c", 10), + "doc4", map("a", 1, "b", asList(3, 7)), + "doc5", map("a", 1), + "doc6", map("a", 2, "c", 20)); + CollectionReference collection = testCollectionWithDocs(testDocs); + + Query query1 = collection.where(Filter.equalTo("a", 1)).orderBy("a"); + checkResultContainsDocumentsInOrder(query1, "doc1", "doc4", "doc5"); + + Query query2 = collection.where(Filter.inArray("a", asList(2, 3))).orderBy("a"); + checkResultContainsDocumentsInOrder(query2, "doc6", "doc3"); + } + + /** Multiple Inequality */ + @Test + public void multipleInequalityOnDifferentFields() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", map("key", "a", "sort", 0, "v", 0), + "doc2", map("key", "b", "sort", 3, "v", 1), + "doc3", map("key", "c", "sort", 1, "v", 3), + "doc4", map("key", "d", "sort", 2, "v", 2))); + + Query query1 = + collection + .whereNotEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .whereGreaterThan("v", 2); + checkResultContainsDocumentsInOrder(query1, "doc3"); + + // Duplicate inequality fields + Query query2 = + collection + .whereNotEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .whereGreaterThan("sort", 1); + checkResultContainsDocumentsInOrder(query2, "doc4"); + + // With multiple IN + Query query3 = + collection + .whereGreaterThanOrEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .whereIn("v", asList(2, 3, 4)) + .whereIn("sort", asList(2, 3)); + checkResultContainsDocumentsInOrder(query3, "doc4"); + + // With NOT-IN + Query query4 = + collection + .whereGreaterThanOrEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .whereNotIn("v", asList(2, 4, 5)); + checkResultContainsDocumentsInOrder(query4, "doc1", "doc3"); + + // With orderby + Query query5 = + collection + .whereGreaterThanOrEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .orderBy("v", Direction.DESCENDING); + checkResultContainsDocumentsInOrder(query5, "doc3", "doc4", "doc1"); + + // With limit + Query query6 = + collection + .whereGreaterThanOrEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .orderBy("v", Direction.DESCENDING) + .limit(2); + checkResultContainsDocumentsInOrder(query6, "doc3", "doc4"); + + // With limitToLast + Query query7 = + collection + .whereGreaterThanOrEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .orderBy("v", Direction.DESCENDING) + .limitToLast(2); + checkResultContainsDocumentsInOrder(query7, "doc4", "doc1"); + } + + @Test + public void multipleInequalityOnSpecialValues() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", map("key", "a", "sort", 0, "v", 0), + "doc2", map("key", "b", "sort", Double.NaN, "v", 1), + "doc3", map("key", "c", "sort", null, "v", 3), + "doc4", map("key", "d", "v", 2), + "doc5", map("key", "e", "sort", 0), + "doc6", map("key", "f", "sort", 1, "v", 1))); + + Query query1 = collection.whereNotEqualTo("key", "a").whereLessThanOrEqualTo("sort", 2); + checkResultContainsDocumentsInOrder(query1, "doc5", "doc6"); + + Query query2 = + collection + .whereNotEqualTo("key", "a") + .whereLessThanOrEqualTo("sort", 2) + .whereLessThanOrEqualTo("v", 1); + checkResultContainsDocumentsInOrder(query2, "doc6"); + } + + @Test + public void multipleInequalityWithArrayMembership() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 0, "v", asList(0)), + "doc2", + map("key", "b", "sort", 1, "v", asList(0, 1, 3)), + "doc3", + map("key", "c", "sort", 1, "v", asList()), + "doc4", + map("key", "d", "sort", 2, "v", asList(1)), + "doc5", + map("key", "e", "sort", 3, "v", asList(2, 4)), + "doc6", + map("key", "f", "sort", 4, "v", Arrays.asList(Double.NaN)), + "doc7", + map("key", "g", "sort", 4, "v", Collections.singletonList(null)))); + + Query query1 = + collection + .whereNotEqualTo("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .whereArrayContains("v", 0); + checkResultContainsDocumentsInOrder(query1, "doc2"); + + Query query2 = + collection + .whereNotEqualTo("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .whereArrayContainsAny("v", asList(0, 1)); + checkResultContainsDocumentsInOrder(query2, "doc2", "doc4"); + } + + private static Map nestedObject(int number) { + return map( + "name", + String.format("room %d", number), + "metadata", + map("createdAt", number), + "field", + String.format("field %d", number), + "field.dot", + number, + "field\\slash", + number); + } + + // Use cursor in following test cases to add implicit order by fields in the sdk and compare the + // result with the query fields normalized in the server. + @Test + public void multipleInequalityWithNestedField() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", nestedObject(400), + "doc2", nestedObject(200), + "doc3", nestedObject(100), + "doc4", nestedObject(300))); + + // ordered by: name asc, metadata.createdAt asc, __name__ asc + Query query1 = + collection + .whereLessThanOrEqualTo("metadata.createdAt", 500) + .whereGreaterThan("metadata.createdAt", 100) + .whereNotEqualTo("name", "room 200") + .orderBy("name"); + DocumentSnapshot docSnap = collection.document("doc4").get().get(); + Query query1WithCursor = query1.startAt(docSnap); + checkResultContainsDocumentsInOrder(query1, "doc4", "doc1"); + checkResultContainsDocumentsInOrder(query1WithCursor, "doc4", "doc1"); + + // ordered by: name desc, field desc, field.dot desc, field\\slash desc, __name__ desc + Query query2 = + collection + .whereGreaterThanOrEqualTo("field", "field 100") + .whereNotEqualTo(FieldPath.of("field.dot"), 300) + .whereLessThan("field\\slash", 400) + .orderBy("name", Direction.DESCENDING); + docSnap = collection.document("doc2").get().get(); + Query query2WithCursor = query2.startAt(docSnap); + checkResultContainsDocumentsInOrder(query2, "doc2", "doc3"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc2", "doc3"); + } + + @Test + public void multipleInequalityWithCompositeFilters() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 0, "v", 5), + "doc2", + map("key", "aa", "sort", 4, "v", 4), + "doc3", + map("key", "c", "sort", 3, "v", 3), + "doc4", + map("key", "b", "sort", 2, "v", 2), + "doc5", + map("key", "b", "sort", 2, "v", 1), + "doc6", + map("key", "b", "sort", 0, "v", 0))); + + // Implicitly ordered by: 'key' asc, 'sort' asc, 'v' asc, __name__ asc + Query query1 = + collection.where( + Filter.or( + Filter.and(Filter.equalTo("key", "b"), Filter.lessThanOrEqualTo("sort", 2)), + Filter.and(Filter.notEqualTo("key", "b"), Filter.greaterThan("v", 4)))); + DocumentSnapshot docSnap = collection.document("doc1").get().get(); + Query query1WithCursor = query1.startAt(docSnap); + checkResultContainsDocumentsInOrder(query1, "doc1", "doc6", "doc5", "doc4"); + checkResultContainsDocumentsInOrder(query1WithCursor, "doc1", "doc6", "doc5", "doc4"); + + // Ordered by: 'sort' desc, 'key' asc, 'v' asc, __name__ asc + Query query2 = + collection + .where( + Filter.or( + Filter.and(Filter.equalTo("key", "b"), Filter.lessThanOrEqualTo("sort", 2)), + Filter.and(Filter.notEqualTo("key", "b"), Filter.greaterThan("v", 4)))) + .orderBy("sort", Direction.DESCENDING) + .orderBy("key"); + docSnap = collection.document("doc5").get().get(); + Query query2WithCursor = query2.startAt(docSnap); + checkResultContainsDocumentsInOrder(query2, "doc5", "doc4", "doc1", "doc6"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc5", "doc4", "doc1", "doc6"); + + // Implicitly ordered by: 'key' asc, 'sort' asc, 'v' asc, __name__ asc + Query query3 = + collection.where( + Filter.and( + Filter.or( + Filter.and(Filter.equalTo("key", "b"), Filter.lessThanOrEqualTo("sort", 4)), + Filter.and(Filter.notEqualTo("key", "b"), Filter.greaterThanOrEqualTo("v", 4))), + Filter.or( + Filter.and( + Filter.greaterThan("key", "b"), Filter.greaterThanOrEqualTo("sort", 1)), + Filter.and(Filter.lessThan("key", "b"), Filter.greaterThan("v", 0))))); + docSnap = collection.document("doc1").get().get(); + Query query3WithCursor = query3.startAt(docSnap); + checkResultContainsDocumentsInOrder(query3, "doc1", "doc2"); + checkResultContainsDocumentsInOrder(query3WithCursor, "doc1", "doc2"); + } + + @Test + public void multipleInequalityFieldsWillBeImplicitlyOrderedLexicographicallyByServer() + throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 0, "v", 5), + "doc2", + map("key", "aa", "sort", 4, "v", 4), + "doc3", + map("key", "b", "sort", 3, "v", 3), + "doc4", + map("key", "b", "sort", 2, "v", 2), + "doc5", + map("key", "b", "sort", 2, "v", 1), + "doc6", + map("key", "b", "sort", 0, "v", 0))); + + DocumentSnapshot docSnap = collection.document("doc2").get().get(); + + // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc + Query query1 = + collection + .whereNotEqualTo("key", "a") + .whereGreaterThan("sort", 1) + .whereIn("v", asList(1, 2, 3, 4)); + Query query1WithCursor = query1.startAt(docSnap); + checkResultContainsDocumentsInOrder(query1, "doc2", "doc4", "doc5", "doc3"); + checkResultContainsDocumentsInOrder(query1WithCursor, "doc2", "doc4", "doc5", "doc3"); + + // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc + Query query2 = + collection + .whereGreaterThan("sort", 1) + .whereNotEqualTo("key", "a") + .whereIn("v", asList(1, 2, 3, 4)); + Query query2WithCursor = query2.startAt(docSnap); + checkResultContainsDocumentsInOrder(query2, "doc2", "doc4", "doc5", "doc3"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc2", "doc4", "doc5", "doc3"); + } + + @Test + public void multipleInequalityWithMultipleExplicitOrderBy() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 5, "v", 0), + "doc2", + map("key", "aa", "sort", 4, "v", 0), + "doc3", + map("key", "b", "sort", 3, "v", 1), + "doc4", + map("key", "b", "sort", 2, "v", 1), + "doc5", + map("key", "bb", "sort", 1, "v", 1), + "doc6", + map("key", "c", "sort", 0, "v", 2))); + + DocumentSnapshot docSnap = collection.document("doc2").get().get(); + + // Ordered by: 'v' asc, 'key' asc, 'sort' asc, __name__ asc + Query query1 = + collection.whereGreaterThan("key", "a").whereGreaterThanOrEqualTo("sort", 1).orderBy("v"); + Query query1WithCursor = query1.startAt(docSnap); + checkResultContainsDocumentsInOrder(query1, "doc2", "doc4", "doc3", "doc5"); + checkResultContainsDocumentsInOrder(query1WithCursor, "doc2", "doc4", "doc3", "doc5"); + + // Ordered by: 'v asc, 'sort' asc, 'key' asc, __name__ asc + Query query2 = + collection + .whereGreaterThan("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .orderBy("v") + .orderBy("sort"); + Query query2WithCursor = query2.startAt(docSnap); + checkResultContainsDocumentsInOrder(query2, "doc2", "doc5", "doc4", "doc3"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc2", "doc5", "doc4", "doc3"); + + docSnap = collection.document("doc5").get().get(); + + // Implicit order by matches the direction of last explicit order by. + // Ordered by: 'v' desc, 'key' desc, 'sort' desc, __name__ desc + Query query3 = + collection + .whereGreaterThan("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .orderBy("v", Direction.DESCENDING); + Query query3WithCursor = query3.startAt(docSnap); + checkResultContainsDocumentsInOrder(query3, "doc5", "doc3", "doc4", "doc2"); + checkResultContainsDocumentsInOrder(query3WithCursor, "doc5", "doc3", "doc4", "doc2"); + + // Ordered by: 'v desc, 'sort' asc, 'key' asc, __name__ asc + Query query4 = + collection + .whereGreaterThan("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .orderBy("v", Direction.DESCENDING) + .orderBy("sort"); + Query query4WithCursor = query4.startAt(docSnap); + checkResultContainsDocumentsInOrder(query4, "doc5", "doc4", "doc3", "doc2"); + checkResultContainsDocumentsInOrder(query4WithCursor, "doc5", "doc4", "doc3", "doc2"); + } + + @Test + public void multipleInequalityFieldsInAggregateQuery() throws Exception { + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 5, "v", 0), + "doc2", + map("key", "aa", "sort", 4, "v", 0), + "doc3", + map("key", "b", "sort", 3, "v", 1), + "doc4", + map("key", "b", "sort", 2, "v", 1), + "doc5", + map("key", "bb", "sort", 1, "v", 1))); + + AggregateQuery query = + collection + .whereGreaterThan("key", "a") + .whereGreaterThanOrEqualTo("sort", 1) + .orderBy("v") + .count(); + if (isRunningAgainstFirestoreEmulator(firestore)) { + assertThat(query.get().get().getCount()).isEqualTo(4); + } + + if (getFirestoreEdition() == FirestoreEdition.ENTERPRISE) { + assertThat( + query + .getQuery() + .getFirestore() + .pipeline() + .createFrom(query) + .execute() + .get() + .getResults()) + .isNotEmpty(); + } + // TODO(MIEQ): Add sum and average when they are public. + } + + @Test + public void multipleInequalityFieldsWithDocumentKey() throws Exception { + assumeTrue( + "Standard edition requires index setup, but this is a dynamic collection", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + CollectionReference collection = + testCollectionWithDocs( + map( + "doc1", + map("key", "a", "sort", 5), + "doc2", + map("key", "aa", "sort", 4), + "doc3", + map("key", "b", "sort", 3), + "doc4", + map("key", "b", "sort", 2), + "doc5", + map("key", "bb", "sort", 1))); + + DocumentSnapshot docSnap = collection.document("doc2").get().get(); + + // Document Key in inequality field will implicitly ordered to the last. + // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc + Query query1 = + collection + .whereGreaterThan("sort", 1) + .whereNotEqualTo("key", "a") + .whereLessThan(FieldPath.documentId(), "doc5"); + Query query1WithCursor = query1.startAt(docSnap); + checkResultContainsDocumentsInOrder(query1, "doc2", "doc4", "doc3"); + checkResultContainsDocumentsInOrder(query1WithCursor, "doc2", "doc4", "doc3"); + + // Changing filters order will not affect implicit order. + // Implicitly ordered by: 'key' asc, 'sort' asc, __name__ asc + Query query2 = + collection + .whereLessThan(FieldPath.documentId(), "doc5") + .whereGreaterThan("sort", 1) + .whereNotEqualTo("key", "a"); + Query query2WithCursor = query2.startAt(docSnap); + checkResultContainsDocumentsInOrder(query2, "doc2", "doc4", "doc3"); + checkResultContainsDocumentsInOrder(query2WithCursor, "doc2", "doc4", "doc3"); + + // Ordered by: 'sort' desc, 'key' desc, __name__ desc + Query query3 = + collection + .whereLessThan(FieldPath.documentId(), "doc5") + .whereGreaterThan("sort", 1) + .whereNotEqualTo("key", "a") + .orderBy("sort", Direction.DESCENDING); + Query query3WithCursor = query3.startAt(docSnap); + checkResultContainsDocumentsInOrder(query3, "doc2", "doc3", "doc4"); + checkResultContainsDocumentsInOrder(query3WithCursor, "doc2", "doc3", "doc4"); + } + + @Test + public void snapshotListenerSortsNumbersSameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + firestore + .batch() + .set(col.document("intMin"), map("value", Long.MIN_VALUE)) + .set(col.document("doubleMin"), map("value", ((double) Long.MIN_VALUE) - 100)) + .set(col.document("intMax"), map("value", Long.MAX_VALUE)) + .set(col.document("doubleMax"), map("value", ((double) Long.MAX_VALUE) + 100)) + .set(col.document("NaN"), map("value", Double.NaN)) + .set(col.document("integerMax"), map("value", (long) Integer.MAX_VALUE)) + .set(col.document("integerMin"), map("value", (long) Integer.MIN_VALUE)) + .set(col.document("negativeInfinity"), map("value", Double.NEGATIVE_INFINITY)) + .set(col.document("positiveInfinity"), map("value", Double.POSITIVE_INFINITY)) + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals(queryOrder, listenerOrder); // Assert order in the SDK + } + + @Test + public void snapshotListenerSortsUnicodeStringsSameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + firestore + .batch() + .set(col.document("a"), map("value", "Łukasiewicz")) + .set(col.document("b"), map("value", "Sierpiński")) + .set(col.document("c"), map("value", "岩澤")) + .set(col.document("d"), map("value", "🄟")) + .set(col.document("e"), map("value", "P")) + .set(col.document("f"), map("value", "︒")) + .set(col.document("g"), map("value", "🐵")) + .set(col.document("h"), map("value", "你好")) + .set(col.document("i"), map("value", "你顥")) + .set(col.document("j"), map("value", "😁")) + .set(col.document("k"), map("value", "😀")) + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals(queryOrder, Arrays.asList("b", "a", "h", "i", "c", "f", "e", "d", "g", "k", "j")); + assertEquals(queryOrder, listenerOrder); + } + + @Test + public void snapshotListenerSortsUnicodeStringsInArraySameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + firestore + .batch() + .set(col.document("a"), map("value", Arrays.asList("Łukasiewicz"))) + .set(col.document("b"), map("value", Arrays.asList("Sierpiński"))) + .set(col.document("c"), map("value", Arrays.asList("岩澤"))) + .set(col.document("d"), map("value", Arrays.asList("🄟"))) + .set(col.document("e"), map("value", Arrays.asList("P"))) + .set(col.document("f"), map("value", Arrays.asList("︒"))) + .set(col.document("g"), map("value", Arrays.asList("🐵"))) + .set(col.document("h"), map("value", Arrays.asList("你好"))) + .set(col.document("i"), map("value", Arrays.asList("你顥"))) + .set(col.document("j"), map("value", Arrays.asList("😁"))) + .set(col.document("k"), map("value", Arrays.asList("😀"))) + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals(queryOrder, Arrays.asList("b", "a", "h", "i", "c", "f", "e", "d", "g", "k", "j")); + assertEquals(queryOrder, listenerOrder); + } + + @Test + public void snapshotListenerSortsUnicodeStringsInMapSameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + firestore + .batch() + .set(col.document("a"), map("value", map("foo", "Łukasiewicz"))) + .set(col.document("b"), map("value", map("foo", "Sierpiński"))) + .set(col.document("c"), map("value", map("foo", "岩澤"))) + .set(col.document("d"), map("value", map("foo", "🄟"))) + .set(col.document("e"), map("value", map("foo", "P"))) + .set(col.document("f"), map("value", map("foo", "︒"))) + .set(col.document("g"), map("value", map("foo", "🐵"))) + .set(col.document("h"), map("value", map("foo", "你好"))) + .set(col.document("i"), map("value", map("foo", "你顥"))) + .set(col.document("j"), map("value", map("foo", "😁"))) + .set(col.document("k"), map("value", map("foo", "😀"))) + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals(queryOrder, Arrays.asList("b", "a", "h", "i", "c", "f", "e", "d", "g", "k", "j")); + assertEquals(queryOrder, listenerOrder); + } + + @Test + public void snapshotListenerSortsUnicodeStringsInMapKeySameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + firestore + .batch() + .set(col.document("a"), map("value", map("Łukasiewicz", "foo"))) + .set(col.document("b"), map("value", map("Sierpiński", "foo"))) + .set(col.document("c"), map("value", map("岩澤", "foo"))) + .set(col.document("d"), map("value", map("🄟", "foo"))) + .set(col.document("e"), map("value", map("P", "foo"))) + .set(col.document("f"), map("value", map("︒", "foo"))) + .set(col.document("g"), map("value", map("🐵", "foo"))) + .set(col.document("h"), map("value", map("你好", "foo"))) + .set(col.document("i"), map("value", map("你顥", "foo"))) + .set(col.document("j"), map("value", map("😁", "foo"))) + .set(col.document("k"), map("value", map("😀", "foo"))) + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals(queryOrder, Arrays.asList("b", "a", "h", "i", "c", "f", "e", "d", "g", "k", "j")); + assertEquals(queryOrder, listenerOrder); + } + + @Test + public void snapshotListenerSortsUnicodeStringsInDocumentKeySameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + firestore + .batch() + .set(col.document("Łukasiewicz"), map("value", "foo")) + .set(col.document("Sierpiński"), map("value", "foo")) + .set(col.document("岩澤"), map("value", "foo")) + .set(col.document("🄟"), map("value", "foo")) + .set(col.document("P"), map("value", "foo")) + .set(col.document("︒"), map("value", "foo")) + .set(col.document("🐵"), map("value", "foo")) + .set(col.document("你好"), map("value", "你好")) + .set(col.document("你顥"), map("value", "你顥")) + .set(col.document("😁"), map("value", "😁")) + .set(col.document("😀"), map("value", "😀")) + .commit() + .get(); + + Query query = col.orderBy(FieldPath.documentId()); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + assertEquals( + queryOrder, + Arrays.asList( + "Sierpiński", "Łukasiewicz", "你好", "你顥", "岩澤", "︒", "P", "🄟", "🐵", "😀", "😁")); + assertEquals(queryOrder, listenerOrder); + } + + @Test + public void snapshotListenerSortsInvalidUnicodeStringsSameWayAsServer() throws Exception { + CollectionReference col = createEmptyCollection(); + + // Note: Protocol Buffer converts any invalid surrogates to "?". + firestore + .batch() + .set(col.document("a"), map("value", "Z")) + .set(col.document("b"), map("value", "你好")) + .set(col.document("c"), map("value", "😀")) + .set(col.document("d"), map("value", "ab\uD800")) // Lone high surrogate + .set(col.document("e"), map("value", "ab\uDC00")) // Lone low surrogate + .set(col.document("f"), map("value", "ab\uD800\uD800")) // Unpaired high surrogate + .set(col.document("g"), map("value", "ab\uDC00\uDC00")) // Unpaired low surrogate + .commit() + .get(); + + Query query = col.orderBy("value", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + latch.countDown(); + }); + latch.await(); + registration.remove(); + + switch (getFirestoreEdition()) { + case STANDARD: + assertEquals(queryOrder, Arrays.asList("a", "d", "e", "f", "g", "b", "c")); + assertEquals(queryOrder, listenerOrder); + break; + case ENTERPRISE: + assertThat(queryOrder) + .containsExactlyElementsIn(Arrays.asList("a", "d", "e", "f", "g", "c", "b")); + assertEquals(listenerOrder, Arrays.asList("a", "d", "e", "f", "g", "b", "c")); + break; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryToPipelineTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryToPipelineTest.java new file mode 100644 index 000000000000..e35677d9d8ae --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryToPipelineTest.java @@ -0,0 +1,695 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.it.ITQueryTest.map; +import static org.junit.Assert.assertEquals; +import static org.junit.Assume.assumeTrue; + +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.Filter; +import com.google.cloud.firestore.LocalFirestoreHelper; +import com.google.cloud.firestore.PipelineResult; +import com.google.cloud.firestore.Query; +import com.google.common.collect.ImmutableMap; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITQueryToPipelineTest extends ITBaseTest { + + public CollectionReference testCollectionWithDocs(Map> docs) + throws ExecutionException, InterruptedException, TimeoutException { + CollectionReference collection = firestore.collection(LocalFirestoreHelper.autoId()); + for (Map.Entry> doc : docs.entrySet()) { + collection.document(doc.getKey()).set(doc.getValue()).get(5, TimeUnit.SECONDS); + } + return collection; + } + + List> data(List results) { + return results.stream().map(PipelineResult::getData).collect(Collectors.toList()); + } + + @Before + public void setup() throws Exception { + assumeTrue( + "This test suite only runs against the Enterprise edition.", + getFirestoreEdition().equals(FirestoreEdition.ENTERPRISE)); + } + + private Object normalizeNumbers(Object value) { + if (value instanceof Number) { + if (value instanceof Double || value instanceof Float) { + return ((Number) value).doubleValue(); + } + return ((Number) value).longValue(); + } + if (value instanceof List) { + return ((List) value).stream().map(this::normalizeNumbers).collect(Collectors.toList()); + } + if (value instanceof Map) { + Map newMap = new HashMap<>(); + ((Map) value).forEach((k, v) -> newMap.put((String) k, normalizeNumbers(v))); + return newMap; + } + return value; + } + + private Map normalizeMap(Map map) { + Map newMap = new HashMap<>(); + map.forEach((key, value) -> newMap.put(key, normalizeNumbers(value))); + return newMap; + } + + private void verifyResults(List actual, Map... expected) { + List> actualData = data(actual); + assertEquals(expected.length, actualData.size()); + for (int i = 0; i < expected.length; ++i) { + Map expectedMap = normalizeMap(expected[i]); + Map actualMap = normalizeMap(actualData.get(i)); + assertEquals(expectedMap, actualMap); + } + } + + @Test + public void supportsDefaultQuery() throws Exception { + CollectionReference collRef = testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L))); + List snapshot = + firestore.pipeline().createFrom(collRef).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsFilteredQuery() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.whereEqualTo("foo", 1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsFilteredQueryWithFieldPath() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.whereEqualTo(FieldPath.of("foo"), 1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsOrderedQueryWithDefaultOrder() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L), map("foo", 2L)); + } + + @Test + public void supportsOrderedQueryWithAsc() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo", Query.Direction.ASCENDING); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L), map("foo", 2L)); + } + + @Test + public void supportsOrderedQueryWithDesc() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo", Query.Direction.DESCENDING); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L), map("foo", 1L)); + } + + @Test + public void supportsLimitQuery() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").limit(1); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsLimitToLastQuery() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L), "3", map("foo", 3L))); + Query query1 = collRef.orderBy("foo").limitToLast(2); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L), map("foo", 3L)); + } + + @Test + public void supportsStartAt() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").startAt(2L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void supportsStartAtWithLimitToLast() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L), + "2", map("foo", 2L), + "3", map("foo", 3L), + "4", map("foo", 4L), + "5", map("foo", 5L))); + Query query1 = collRef.orderBy("foo").startAt(3L).limitToLast(4); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 3L), map("foo", 4L), map("foo", 5L)); + } + + @Test + public void supportsEndAtWithLimitToLast() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L), + "2", map("foo", 2L), + "3", map("foo", 3L), + "4", map("foo", 4L), + "5", map("foo", 5L))); + Query query1 = collRef.orderBy("foo").endAt(3L).limitToLast(2); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L), map("foo", 3L)); + } + + @Test + public void supportsStartAfterWithDocumentSnapshot() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.>builder() + .put("1", map("id", 1L, "foo", 1L, "bar", 1L, "baz", 1L)) + .put("2", map("id", 2L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("3", map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("4", map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L)) + .put("5", map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("6", map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("7", map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L)) + .put("8", map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("9", map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("10", map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)) + .put("11", map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L)) + .put("12", map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)) + .build()); + DocumentSnapshot docRef = collRef.document("2").get().get(); + Query query1 = collRef.orderBy("foo").orderBy("bar").orderBy("baz").startAfter(docRef); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults( + snapshot, + map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L), + map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L), + map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L), + map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L), + map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L), + map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)); + } + + @Test + public void supportsStartAtWithDocumentSnapshot() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.>builder() + .put("1", map("id", 1L, "foo", 1L, "bar", 1L, "baz", 1L)) + .put("2", map("id", 2L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("3", map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("4", map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L)) + .put("5", map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("6", map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("7", map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L)) + .put("8", map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("9", map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("10", map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)) + .put("11", map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L)) + .put("12", map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)) + .build()); + DocumentSnapshot docRef = collRef.document("2").get().get(); + Query query1 = collRef.orderBy("foo").orderBy("bar").orderBy("baz").startAt(docRef); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults( + snapshot, + map("id", 2L, "foo", 1L, "bar", 1L, "baz", 2L), + map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L), + map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L), + map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L), + map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L), + map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L), + map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)); + } + + @Test + public void supportsStartAfter() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").startAfter(1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void supportsEndAt() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").endAt(1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsEndBefore() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").endBefore(2L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsPagination() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").limit(1); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + + Query query2 = query1.startAfter(snapshot.get(0).get("foo")); + snapshot = firestore.pipeline().createFrom(query2).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void supportsPaginationOnDocumentIds() throws Exception { + CollectionReference collRef = + testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L), "2", map("foo", 2L))); + Query query1 = collRef.orderBy("foo").orderBy(FieldPath.documentId()).limit(1); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L)); + + Query query2 = + query1.startAfter(snapshot.get(0).get("foo"), snapshot.get(0).getReference().getId()); + snapshot = firestore.pipeline().createFrom(query2).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void supportsCollectionGroups() throws Exception { + CollectionReference collRef = testCollectionWithDocs(ImmutableMap.of()); + String collectionGroupId = collRef.getId() + "group"; + + firestore + .document(collRef.getId() + "/foo/" + collectionGroupId + "/doc1") + .set(map("foo", 1L)) + .get(); + firestore + .document(collRef.getId() + "/bar/baz/boo/" + collectionGroupId + "/doc2") + .set(map("bar", 1L)) + .get(); + + Query query1 = firestore.collectionGroup(collectionGroupId).orderBy(FieldPath.documentId()); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + + verifyResults(snapshot, map("bar", 1L), map("foo", 1L)); + } + + @Test + public void supportsQueryOverCollectionPathWithSpecialCharacters() throws Exception { + CollectionReference collRef = testCollectionWithDocs(ImmutableMap.of()); + CollectionReference collectionWithSpecials = + collRef.document("so!@#$%^&*()_+special").collection("so!@#$%^&*()_+special"); + collectionWithSpecials.add(map("foo", 1L)).get(); + collectionWithSpecials.add(map("foo", 2L)).get(); + + Query query = collectionWithSpecials.orderBy("foo", Query.Direction.ASCENDING); + List snapshot = + firestore.pipeline().createFrom(query).execute().get().getResults(); + + verifyResults(snapshot, map("foo", 1L), map("foo", 2L)); + } + + @Test + public void supportsMultipleInequalityOnSameField() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.>builder() + .put("01", map("id", 1L, "foo", 1L, "bar", 1L, "baz", 1L)) + .put("02", map("id", 2L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("03", map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("04", map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L)) + .put("05", map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("06", map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("07", map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L)) + .put("08", map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("09", map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("10", map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)) + .put("11", map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L)) + .put("12", map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)) + .build()); + Query query1 = + collRef.where( + Filter.and(Filter.greaterThan("id", 2L), Filter.lessThanOrEqualTo("id", 10L))); + List snapshot = + firestore.pipeline().createFrom(query1.orderBy("id")).execute().get().getResults(); + verifyResults( + snapshot, + map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L), + map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L), + map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L), + map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L), + map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L), + map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)); + } + + @Test + public void supportsMultipleInequalityOnDifferentFields() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.>builder() + .put("01", map("id", 1L, "foo", 1L, "bar", 1L, "baz", 1L)) + .put("02", map("id", 2L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("03", map("id", 3L, "foo", 1L, "bar", 1L, "baz", 2L)) + .put("04", map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L)) + .put("05", map("id", 5L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("06", map("id", 6L, "foo", 1L, "bar", 2L, "baz", 2L)) + .put("07", map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L)) + .put("08", map("id", 8L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("09", map("id", 9L, "foo", 2L, "bar", 1L, "baz", 2L)) + .put("10", map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)) + .put("11", map("id", 11L, "foo", 2L, "bar", 2L, "baz", 2L)) + .put("12", map("id", 12L, "foo", 2L, "bar", 2L, "baz", 2L)) + .build()); + Query query1 = + collRef.where( + Filter.and(Filter.greaterThanOrEqualTo("id", 2L), Filter.lessThan("baz", 2L))); + List snapshot = + firestore.pipeline().createFrom(query1.orderBy("id")).execute().get().getResults(); + verifyResults( + snapshot, + map("id", 4L, "foo", 1L, "bar", 2L, "baz", 1L), + map("id", 7L, "foo", 2L, "bar", 1L, "baz", 1L), + map("id", 10L, "foo", 2L, "bar", 2L, "baz", 1L)); + } + + @Test + public void supportsCollectionGroupQuery() throws Exception { + CollectionReference collRef = testCollectionWithDocs(ImmutableMap.of("1", map("foo", 1L))); + List snapshot = + firestore + .pipeline() + .createFrom(firestore.collectionGroup(collRef.getId())) + .execute() + .get() + .getResults(); + verifyResults(snapshot, map("foo", 1L)); + } + + @Test + public void supportsEqNan() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", Double.NaN), + "2", map("foo", 2L, "bar", 1L), + "3", map("foo", 3L, "bar", "bar"))); + Query query1 = collRef.whereEqualTo("bar", Double.NaN); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", Double.NaN)); + } + + @Test + public void supportsNeqNan() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", Double.NaN), + "2", map("foo", 2L, "bar", 1L), + "3", map("foo", 3L, "bar", "bar"))); + Query query1 = collRef.whereNotEqualTo("bar", Double.NaN).orderBy("foo"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L, "bar", 1L), map("foo", 3L, "bar", "bar")); + } + + @Test + public void supportsEqNull() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of("1", map("foo", 1L, "bar", null), "2", map("foo", 2L, "bar", 1L))); + Query query1 = collRef.whereEqualTo("bar", null); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", null)); + } + + @Test + public void supportsNeqNull() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of("1", map("foo", 1L, "bar", null), "2", map("foo", 2L, "bar", 1L))); + Query query1 = collRef.whereNotEqualTo("bar", null); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L, "bar", 1L)); + } + + @Test + public void supportsNeq() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of("1", map("foo", 1L, "bar", 0L), "2", map("foo", 2L, "bar", 1L))); + Query query1 = collRef.whereNotEqualTo("bar", 0L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 2L, "bar", 1L)); + } + + @Test + public void supportsArrayContains() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", Arrays.asList(0L, 2L, 4L, 6L)), + "2", map("foo", 2L, "bar", Arrays.asList(1L, 3L, 5L, 7L)))); + Query query1 = collRef.whereArrayContains("bar", 4L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", Arrays.asList(0L, 2L, 4L, 6L))); + } + + @Test + public void supportsArrayContainsAny() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", Arrays.asList(0L, 2L, 4L, 6L)), + "2", map("foo", 2L, "bar", Arrays.asList(1L, 3L, 5L, 7L)), + "3", map("foo", 3L, "bar", Arrays.asList(10L, 20L, 30L, 40L)))); + Query query1 = collRef.whereArrayContainsAny("bar", Arrays.asList(4L, 5L)); + List snapshot = + firestore.pipeline().createFrom(query1.orderBy("foo")).execute().get().getResults(); + verifyResults( + snapshot, + map("foo", 1L, "bar", Arrays.asList(0L, 2L, 4L, 6L)), + map("foo", 2L, "bar", Arrays.asList(1L, 3L, 5L, 7L))); + } + + @Test + public void supportsIn() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 2L), + "2", map("foo", 2L), + "3", map("foo", 3L, "bar", 10L))); + Query query1 = collRef.whereIn("bar", Arrays.asList(0L, 10L, 20L)); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 3L, "bar", 10L)); + } + + @Test + public void supportsInWith1() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 2L), + "2", map("foo", 2L), + "3", map("foo", 3L, "bar", 10L))); + Query query1 = collRef.whereIn("bar", Arrays.asList(2L)); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", 2L)); + } + + @Test + public void supportsNotIn() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 2L), + "2", map("foo", 2L, "bar", 1L), + "3", map("foo", 3L, "bar", 10L))); + Query query1 = collRef.whereNotIn("bar", Arrays.asList(0L, 10L, 20L)).orderBy("foo"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", 2L), map("foo", 2L, "bar", 1L)); + } + + @Test + public void supportsNotInWith1() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 2L), + "2", map("foo", 2L), + "3", map("foo", 3L, "bar", 10L))); + Query query1 = collRef.whereNotIn("bar", Arrays.asList(2L)).orderBy("foo"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + if (getFirestoreEdition() == FirestoreEdition.ENTERPRISE) { + verifyResults(snapshot, map("foo", 2L), map("foo", 3L, "bar", 10L)); + } else { + verifyResults(snapshot, map("foo", 3L, "bar", 10L)); + } + } + + @Test + public void supportsOrOperator() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 2L), + "2", map("foo", 2L, "bar", 0L), + "3", map("foo", 3L, "bar", 10L))); + Query query1 = + collRef + .where(Filter.or(Filter.equalTo("bar", 2L), Filter.equalTo("foo", 3L))) + .orderBy("foo"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + verifyResults(snapshot, map("foo", 1L, "bar", 2L), map("foo", 3L, "bar", 10L)); + } + + @Test + public void testNotEqualIncludesMissingField() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 1L), + "2", map("foo", 2L) // Missing "bar" + )); + Query query1 = collRef.whereNotEqualTo("bar", 1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + // document "2" should be included because "bar" is missing, which is not equal to 1. + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void testNotInIncludesMissingField() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 1L), + "2", map("foo", 2L) // Missing "bar" + )); + Query query1 = collRef.whereNotIn("bar", Arrays.asList(1L)); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + // document "2" should be included because "bar" is missing, which is not in [1]. + verifyResults(snapshot, map("foo", 2L)); + } + + @Test + public void testInequalityMaintainsExistenceFilter() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 0L), + "2", map("foo", 2L) // Missing "bar" + )); + Query query1 = collRef.whereLessThan("bar", 1L); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + // document "2" should be excluded because "bar" is missing. + verifyResults(snapshot, map("foo", 1L, "bar", 0L)); + } + + @Test + public void testExplicitOrderMaintainsExistenceFilter() throws Exception { + CollectionReference collRef = + testCollectionWithDocs( + ImmutableMap.of( + "1", map("foo", 1L, "bar", 1L), + "2", map("foo", 2L) // Missing "bar" + )); + Query query1 = collRef.orderBy("bar"); + List snapshot = + firestore.pipeline().createFrom(query1).execute().get().getResults(); + // document "2" should be excluded because "bar" is missing and we have explicit order. + verifyResults(snapshot, map("foo", 1L, "bar", 1L)); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryWatchTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryWatchTest.java new file mode 100644 index 000000000000..447dfa4d7e07 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITQueryWatchTest.java @@ -0,0 +1,1178 @@ +/* + * Copyright 2020 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.common.collect.ImmutableList.toImmutableList; +import static com.google.common.truth.Truth.assertThat; +import static com.google.common.truth.Truth.assertWithMessage; +import static java.util.Arrays.asList; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; + +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentChange; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.EventListener; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.FirestoreException; +import com.google.cloud.firestore.ListenerRegistration; +import com.google.cloud.firestore.LocalFirestoreHelper; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.Query.Direction; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.it.ITQueryWatchTest.QuerySnapshotEventListener.ListenerAssertions; +import com.google.common.base.Joiner; +import com.google.common.base.Joiner.MapJoiner; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; +import com.google.common.collect.Range; +import com.google.common.truth.Truth; +import com.google.firestore.v1.ExistenceFilter; +import com.google.firestore.v1.ListenResponse; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.stream.Collectors; +import javax.annotation.Nullable; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public final class ITQueryWatchTest extends ITBaseTest { + @Rule public TestName testName = new TestName(); + + private CollectionReference randomColl; + + @Before + public void before() throws Exception { + super.before(); + useFirestoreSpy(); + String autoId = LocalFirestoreHelper.autoId(); + String collPath = String.format("java-%s-%s", testName.getMethodName(), autoId); + randomColl = firestore.collection(collPath); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with empty results. + *
  2. Verify the listener receives an empty event. + *
+ */ + @Test + public void emptyResults() throws InterruptedException { + final Query query = randomColl.whereEqualTo("foo", "bar"); + // register the snapshot listener for the query + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(1, 1)); + listenerAssertions.addedIdsIsEmpty(); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsEmpty(); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with non-empty results. + *
  2. Verify the listener receives an event including the expected document. + *
+ */ + @Test + public void nonEmptyResults() throws Exception { + // create a document in our collection that will match the query + setDocument("doc", map("foo", "bar")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(1, 1)); + listenerAssertions.addedIdsIsAnyOf("doc"); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsEmpty(); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with empty results. + *
  2. Create a new document that matches the query. + *
  3. Verify newly created document results in an ADDED event. + *
+ */ + @Test + public void emptyResults_newDocument_ADDED() + throws InterruptedException, TimeoutException, ExecutionException { + + final Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).setAddedEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + randomColl.document("doc").set(map("foo", "bar")).get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.ADDED); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(2, 2)); + listenerAssertions.addedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsEmpty(); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with empty results. + *
  2. Modify an existing document so that it matches the query. + *
  3. Verify newly created document results in an ADDED event. + *
+ */ + @Test + public void emptyResults_modifiedDocument_ADDED() throws Exception { + // create our "existing non-matching document" + DocumentReference testDoc = setDocument("doc", map("baz", "baz")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).setAddedEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + testDoc.update("foo", "bar").get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.ADDED); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(2, 2)); + listenerAssertions.addedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsEmpty(); + + ListenerEvent event = listener.lastListenerEvent(); + //noinspection ConstantConditions guarded by "assertNoError" above + QueryDocumentSnapshot doc = event.value.getDocumentChanges().get(0).getDocument(); + assertThat(doc.get("foo")).isEqualTo("bar"); + assertThat(doc.get("baz")).isEqualTo("baz"); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with non-empty results. + *
  2. Modify an existing document that is part of the results. + *
  3. Verify modified document results in a MODIFIED event. + *
+ */ + @Test + public void nonEmptyResults_modifiedDocument_MODIFIED() throws Exception { + DocumentReference testDoc = setDocument("doc", map("foo", "bar")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + // register the snapshot listener for the query + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder() + .setInitialEventCount(1) + .setModifiedEventCount(1) + .build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + testDoc.update("baz", "baz").get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.MODIFIED); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(2, 2)); + listenerAssertions.addedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.modifiedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.removedIdsIsEmpty(); + + ListenerEvent event = listener.lastListenerEvent(); + //noinspection ConstantConditions guarded by "assertNoError" above + QueryDocumentSnapshot doc = event.value.getDocumentChanges().get(0).getDocument(); + assertThat(doc.get("foo")).isEqualTo("bar"); + assertThat(doc.get("baz")).isEqualTo("baz"); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with non-empty results. + *
  2. Delete an existing document that is part of the results. + *
  3. Verify deleted document results in a REMOVED event. + *
+ */ + @Test + public void nonEmptyResults_deletedDocument_REMOVED() throws Exception { + DocumentReference testDoc = setDocument("doc", map("foo", "bar")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + // register the snapshot listener for the query + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder() + .setInitialEventCount(1) + .setRemovedEventCount(1) + .build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + testDoc.delete().get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.REMOVED); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(2, 2)); + listenerAssertions.addedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsAnyOf(emptyList(), singletonList("doc")); + + ListenerEvent event = listener.lastListenerEvent(); + //noinspection ConstantConditions guarded by "assertNoError" above + QueryDocumentSnapshot doc = event.value.getDocumentChanges().get(0).getDocument(); + assertThat(doc.get("foo")).isEqualTo("bar"); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with non-empty results. + *
  2. Modify an existing document that is part of the results to no longer match the query. + *
  3. Verify modified document results in a REMOVED event. + *
+ */ + @Test + public void nonEmptyResults_modifiedDocument_REMOVED() throws Exception { + DocumentReference testDoc = setDocument("doc", map("foo", "bar")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + // register the snapshot listener for the query + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder() + .setInitialEventCount(1) + .setRemovedEventCount(1) + .build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + testDoc.set(map("bar", "foo")).get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.REMOVED); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.closed(2, 2)); + listenerAssertions.addedIdsIsAnyOf(emptyList(), singletonList("doc")); + listenerAssertions.modifiedIdsIsEmpty(); + listenerAssertions.removedIdsIsAnyOf(emptyList(), singletonList("doc")); + + ListenerEvent event = listener.lastListenerEvent(); + //noinspection ConstantConditions guarded by "assertNoError" above + QueryDocumentSnapshot doc = event.value.getDocumentChanges().get(0).getDocument(); + assertThat(doc.get("foo")).isEqualTo("bar"); + } + + /** + * + * + *
    + *
  1. Attach a listener to a query with non-empty results. + *
  2. Trigger existence filter mismatch, thereby invoking retry behavior. + *
  3. Add and remove documents. + *
  4. Verify expected snapshots are raised. + *
+ */ + @Test + public void restartAfterFailedFilter() throws Exception { + // create a document in our collection that will match the query + DocumentReference testDoc1 = setDocument("doc1", map("foo", "bar")); + DocumentReference testDoc2 = setDocument("doc2", map("foo", "bar")); + + final Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder() + .setInitialEventCount(1) + .setAddedEventCount(3) + .setRemovedEventCount(1) + .build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + listener + .assertionsForLastEvent() + .noError() + .addedIdsIsAnyOf("doc1", "doc2") + .modifiedIdsIsEmpty() + .removedIdsIsEmpty(); + listener.lastDocumentIdsIsAnyOf("doc1", "doc2"); + + // Trigger existence filter mismatch, thereby invoking retry behavior. + // Prompting Firestore to send filter mismatch is difficult, so we hack + // in the response. All we are concerned about is invoking retry. + firestoreSpy.streamRequestBidiStreamObserver.onResponse(filter(0)); + + // A race condition will sometimes throw an error if the SuppressibleBidiStream does not + // silence the old stream. This can be caused by `Preconditions.checkState(stream == null)` + // in Watch class. + + setDocument("doc3", map("foo", "bar")); + listener.eventsCountDownLatch.await(DocumentChange.Type.ADDED); + listener + .assertionsForLastEvent() + .noError() + .addedIdsIsAnyOf("doc3") + .modifiedIdsIsEmpty() + .removedIdsIsEmpty(); + listener.lastDocumentIdsIsAnyOf("doc1", "doc2", "doc3"); + + testDoc1.set(map("bar", "foo")).get(5, TimeUnit.SECONDS); + listener.eventsCountDownLatch.await(DocumentChange.Type.REMOVED); + listener + .assertionsForLastEvent() + .noError() + .addedIdsIsEmpty() + .modifiedIdsIsEmpty() + .removedIdsIsAnyOf("doc1"); + listener.lastDocumentIdsIsAnyOf("doc2", "doc3"); + + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.eventCountIsAnyOf(Range.singleton(3)); + } + + /** Verifies that QuerySnapshot for limitToLast() queries are ordered correctly. */ + @Test + public void limitToLast() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + final Query query = randomColl.orderBy("counter").limitToLast(2); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + listenerAssertions.addedIdsIsAnyOf(emptyList(), asList("doc2", "doc3")); + } + + /** Verifies that the SDK orders vector fields the same way as the backend. */ + @Test + public void vectorFieldOrder() throws Exception { + // We validate that the SDK orders the vector field the same way as the backend + // by comparing the sort order of vector fields from a Query.get() and + // Query.addSnapshotListener(). Query.addSnapshotListener() will return sort order + // of the SDK, and Query.get() will return sort order of the backend. + + // Test data in the order that we expect the backend to sort it. + List> docsInOrder = + Arrays.asList( + map("embedding", Arrays.asList(1, 2, 3, 4, 5, 6)), + map("embedding", Arrays.asList(100)), + map("embedding", FieldValue.vector(new double[] {Double.NEGATIVE_INFINITY})), + map("embedding", FieldValue.vector(new double[] {-100})), + map("embedding", FieldValue.vector(new double[] {100})), + map("embedding", FieldValue.vector(new double[] {Double.POSITIVE_INFINITY})), + map("embedding", FieldValue.vector(new double[] {1, 2})), + map("embedding", FieldValue.vector(new double[] {2, 2})), + map("embedding", FieldValue.vector(new double[] {1, 2, 3})), + map("embedding", FieldValue.vector(new double[] {1, 2, 3, 4})), + map("embedding", FieldValue.vector(new double[] {1, 2, 3, 4, 5})), + map("embedding", FieldValue.vector(new double[] {1, 2, 100, 4, 4})), + map("embedding", FieldValue.vector(new double[] {100, 2, 3, 4, 5})), + map("embedding", map()), + map("embedding", map("HELLO", "WORLD")), + map("embedding", map("hello", "world"))); + + // Add docs and store doc IDs + List docIds = new ArrayList(); + for (int i = 0; i < docsInOrder.size(); i++) { + DocumentReference docRef = randomColl.add(docsInOrder.get(i)).get(); + docIds.add(docRef.getId()); + } + + // Test query + Query orderedQuery = randomColl.orderBy("embedding"); + + // Run query with snapshot listener + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).build(); + ListenerRegistration registration = orderedQuery.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + } finally { + registration.remove(); + } + + // Get doc IDs from snapshot listener + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + List listenerIds = listenerAssertions.addedIds; + + // Run query with get() and get doc IDs + QuerySnapshot querySnapshot = orderedQuery.get().get(); + List getIds = + querySnapshot.getDocuments().stream().map(ds -> ds.getId()).collect(Collectors.toList()); + + // Assert that get and snapshot listener requests sort docs in the same, expected order + assertArrayEquals(docIds.toArray(new String[0]), getIds.toArray(new String[0])); + assertArrayEquals(docIds.toArray(new String[0]), listenerIds.toArray(new String[0])); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with startAt when the full limit is + * used in the result set. + */ + @Test + public void limitToLastWithStartAtFullLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAt(5).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc7", "doc8", "doc9"); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with startAt when the partial limit + * is used in the result set. + */ + @Test + public void limitToLastWithStartAtPartialLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAt(8).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc8", "doc9"); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with startAfter when the full limit + * is used in the result set. + */ + @Test + public void limitToLastWithStartAfterFullLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAfter(5).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc7", "doc8", "doc9"); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with startAfter when the partial + * limit is used in the result set. + */ + @Test + public void limitToLastWithStartAfterPartialLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAfter(7).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc8", "doc9"); + } + + /** Verifies that QuerySnapshot for limitToLast() queries work with endAt. */ + @Test + public void limitToLastWithEndAt() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").endAt(5).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc3", "doc4", "doc5"); + } + + /** Verifies that QuerySnapshot for limitToLast() queries work with endBefore. */ + @Test + public void limitToLastWithEndBefore() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").endBefore(5).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc2", "doc3", "doc4"); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with both startAt and endAt when the + * full limit is used in the result set. + */ + @Test + public void limitToLastWithStartAtAndEndAtFullLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAt(3).endAt(6).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc4", "doc5", "doc6"); + } + + /** + * Verifies that QuerySnapshot for limitToLast() queries work with both startAt and endAt when the + * partial limit is used in the result set. + */ + @Test + public void limitToLastWithStartAtAndEndAtPartialLimit() throws Exception { + for (int i = 0; i < 10; i++) { + setDocument("doc" + i, Collections.singletonMap("counter", i)); + } + Query query = randomColl.orderBy("counter").startAt(5).endAt(6).limitToLast(3); + assertQueryResultContainsDocsInOrder(query, "doc5", "doc6"); + } + + private static void assertQueryResultContainsDocsInOrder(Query query, String... docIds) + throws ExecutionException, InterruptedException { + QuerySnapshot snapshot = query.get().get(); + ImmutableList actualDocIds = + snapshot.getDocuments().stream().map(DocumentSnapshot::getId).collect(toImmutableList()); + assertThat(actualDocIds).containsExactlyElementsIn(docIds).inOrder(); + } + + @Test + public void shutdownNowTerminatesActiveListener() throws Exception { + Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setExpectError().build(); + + query.addSnapshotListener(listener); + firestore.shutdownNow(); + + listener.eventsCountDownLatch.awaitError(); + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.hasError(); + } + + @Test + public void shutdownNowPreventsAddingNewListener() throws Exception { + Query query = randomColl.whereEqualTo("foo", "bar"); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setExpectError().build(); + + firestore.shutdownNow(); + query.addSnapshotListener(listener); + + listener.eventsCountDownLatch.awaitError(); + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.hasError(); + } + + @Test + public void snapshotListenerSortsQueryByDocumentIdInTheSameOrderAsServer() throws Exception { + CollectionReference col = randomColl; + + firestore + .batch() + .set(col.document("A"), Collections.singletonMap("a", 1)) + .set(col.document("a"), Collections.singletonMap("a", 1)) + .set(col.document("Aa"), Collections.singletonMap("a", 1)) + .set(col.document("7"), Collections.singletonMap("a", 1)) + .set(col.document("12"), Collections.singletonMap("a", 1)) + .set(col.document("__id7__"), Collections.singletonMap("a", 1)) + .set(col.document("__id12__"), Collections.singletonMap("a", 1)) + .set(col.document("__id-2__"), Collections.singletonMap("a", 1)) + .set(col.document("_id1__"), Collections.singletonMap("a", 1)) + .set(col.document("__id1_"), Collections.singletonMap("a", 1)) + .set(col.document("__id"), Collections.singletonMap("a", 1)) + .commit() + .get(); + + Query query = col.orderBy("__name__", Direction.ASCENDING); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + List expectedOrder = + Arrays.asList( + "__id-2__", + "__id7__", + "__id12__", + "12", + "7", + "A", + "Aa", + "__id", + "__id1_", + "_id1__", + "a"); + assertThat(queryOrder) + .containsExactlyElementsIn(expectedOrder) + .inOrder(); // standard backend order + } else { + List expectedOrder = + Arrays.asList( + "12", + "7", + "A", + "Aa", + "__id", + "__id-2__", + "__id12__", + "__id1_", + "__id7__", + "_id1__", + "a"); + + assertThat(queryOrder) + .containsExactlyElementsIn(expectedOrder) + .inOrder(); // enterprise backend order + } + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + + latch.countDown(); + }); + + latch.await(); + registration.remove(); + + List expectedOrder = + Arrays.asList( + "__id-2__", + "__id7__", + "__id12__", + "12", + "7", + "A", + "Aa", + "__id", + "__id1_", + "_id1__", + "a"); + // TODO: SDK now implements stardard backend order. We need to change it to Enterprise order + assertEquals(expectedOrder, listenerOrder); // Assert order in the SDK + } + + @Test + public void snapshotListenerSortsFilteredQueryByDocumentIdInTheSameOrderAsServer() + throws Exception { + CollectionReference col = randomColl; + + firestore + .batch() + .set(col.document("A"), Collections.singletonMap("a", 1)) + .set(col.document("a"), Collections.singletonMap("a", 1)) + .set(col.document("Aa"), Collections.singletonMap("a", 1)) + .set(col.document("7"), Collections.singletonMap("a", 1)) + .set(col.document("12"), Collections.singletonMap("a", 1)) + .set(col.document("__id7__"), Collections.singletonMap("a", 1)) + .set(col.document("__id12__"), Collections.singletonMap("a", 1)) + .set(col.document("__id-2__"), Collections.singletonMap("a", 1)) + .set(col.document("_id1__"), Collections.singletonMap("a", 1)) + .set(col.document("__id1_"), Collections.singletonMap("a", 1)) + .set(col.document("__id"), Collections.singletonMap("a", 1)) + .commit() + .get(); + + Query query = + col.whereGreaterThan(FieldPath.documentId(), "__id7__") + .whereLessThanOrEqualTo(FieldPath.documentId(), "A") + .orderBy("__name__", Direction.ASCENDING); + List expectedOrder = Arrays.asList("__id12__", "12", "7", "A"); + + QuerySnapshot snapshot = query.get().get(); + List queryOrder = + snapshot.getDocuments().stream().map(doc -> doc.getId()).collect(Collectors.toList()); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(expectedOrder, queryOrder); // Assert order from backend + } else { + assertThat(queryOrder).isEmpty(); + } + + CountDownLatch latch = new CountDownLatch(1); + List listenerOrder = new ArrayList<>(); + + ListenerRegistration registration = + query.addSnapshotListener( + (value, error) -> { + listenerOrder.addAll( + value.getDocuments().stream() + .map(doc -> doc.getId()) + .collect(Collectors.toList())); + + latch.countDown(); + }); + + latch.await(); + registration.remove(); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(expectedOrder, listenerOrder); // Assert order in the SDK + } else { + assertThat(listenerOrder).isEmpty(); + } + } + + /** + * A tuple class used by {@code #queryWatch}. This class represents an event delivered to the + * registered query listener. + */ + private static final class ListenerEvent { + + @Nullable private final QuerySnapshot value; + @Nullable private final FirestoreException error; + + ListenerEvent(@Nullable QuerySnapshot value, @Nullable FirestoreException error) { + this.value = value; + this.error = error; + } + } + + private static final class EventsCountDownLatch { + private final CountDownLatch initialEventsCountDownLatch; + private final int initialEventCount; + private final CountDownLatch errorCountDownLatch; + private final EnumMap eventsCounts; + private final EnumMap eventsCountDownLatches; + + EventsCountDownLatch( + int initialEventCount, + int addedInitialCount, + int modifiedInitialCount, + int removedInitialCount, + int errorCount) { + initialEventsCountDownLatch = new CountDownLatch(initialEventCount); + this.initialEventCount = initialEventCount; + this.errorCountDownLatch = new CountDownLatch(errorCount); + eventsCounts = new EnumMap<>(DocumentChange.Type.class); + eventsCounts.put(DocumentChange.Type.ADDED, addedInitialCount); + eventsCounts.put(DocumentChange.Type.MODIFIED, modifiedInitialCount); + eventsCounts.put(DocumentChange.Type.REMOVED, removedInitialCount); + eventsCountDownLatches = new EnumMap<>(DocumentChange.Type.class); + eventsCountDownLatches.put(DocumentChange.Type.ADDED, new CountDownLatch(addedInitialCount)); + eventsCountDownLatches.put( + DocumentChange.Type.MODIFIED, new CountDownLatch(modifiedInitialCount)); + eventsCountDownLatches.put( + DocumentChange.Type.REMOVED, new CountDownLatch(removedInitialCount)); + } + + void countDown() { + initialEventsCountDownLatch.countDown(); + } + + void countDown(DocumentChange.Type type) { + eventsCountDownLatches.get(type).countDown(); + } + + void countError() { + errorCountDownLatch.countDown(); + } + + void awaitInitialEvents() throws InterruptedException { + initialEventsCountDownLatch.await(5 * initialEventCount, TimeUnit.SECONDS); + } + + void awaitError() throws InterruptedException { + errorCountDownLatch.await(5, TimeUnit.SECONDS); + } + + void await(DocumentChange.Type type) throws InterruptedException { + int count = eventsCounts.get(type); + eventsCountDownLatches.get(type).await(5 * count, TimeUnit.SECONDS); + } + } + + static class QuerySnapshotEventListener implements EventListener { + final List receivedEvents; + final EventsCountDownLatch eventsCountDownLatch; + + private QuerySnapshotEventListener( + int initialCount, + int addedEventCount, + int modifiedEventCount, + int removedEventCount, + int errorCount) { + this.receivedEvents = Collections.synchronizedList(new ArrayList<>()); + this.eventsCountDownLatch = + new EventsCountDownLatch( + initialCount, addedEventCount, modifiedEventCount, removedEventCount, errorCount); + } + + @Override + public void onEvent(@Nullable QuerySnapshot value, @Nullable FirestoreException error) { + receivedEvents.add(new ListenerEvent(value, error)); + if (value != null) { + List documentChanges = value.getDocumentChanges(); + for (DocumentChange docChange : documentChanges) { + eventsCountDownLatch.countDown(docChange.getType()); + } + } + if (error != null) { + eventsCountDownLatch.countError(); + } + eventsCountDownLatch.countDown(); + } + + ListenerAssertions assertions() { + return new ListenerAssertions(receivedEvents); + } + + ListenerAssertions assertionsForLastEvent() { + return new ListenerAssertions(singletonList(lastListenerEvent())); + } + + ListenerEvent lastListenerEvent() { + return receivedEvents.get(receivedEvents.size() - 1); + } + + void lastDocumentIdsIsAnyOf(String... s) { + List ids = + Lists.transform(lastListenerEvent().value.getDocuments(), DocumentSnapshot::getId); + Truth.assertThat(ids).containsExactlyElementsIn(s); + } + + static Builder builder() { + return new Builder(); + } + + @SuppressWarnings("SameParameterValue") + static final class Builder { + private int initialEventCount = 0; + private int addedEventCount = 0; + private int modifiedEventCount = 0; + private int removedEventCount = 0; + private int errorCount = 0; + + private Builder() {} + + Builder setInitialEventCount(int initialEventCount) { + this.initialEventCount = initialEventCount; + return this; + } + + Builder setAddedEventCount(int addedEventCount) { + this.addedEventCount = addedEventCount; + return this; + } + + Builder setModifiedEventCount(int modifiedEventCount) { + this.modifiedEventCount = modifiedEventCount; + return this; + } + + Builder setRemovedEventCount(int removedEventCount) { + this.removedEventCount = removedEventCount; + return this; + } + + Builder setExpectError() { + this.errorCount = 1; + return this; + } + + public QuerySnapshotEventListener build() { + return new QuerySnapshotEventListener( + initialEventCount, addedEventCount, modifiedEventCount, removedEventCount, errorCount); + } + } + + static final class ListenerAssertions { + private static final MapJoiner MAP_JOINER = Joiner.on(",").withKeyValueSeparator("="); + private final List addedIds; + private final List modifiedIds; + private final List removedIds; + private final List receivedEvents; + + ListenerAssertions(List receivedEvents) { + this.receivedEvents = receivedEvents; + List querySnapshots = getQuerySnapshots(receivedEvents); + addedIds = getIds(querySnapshots, DocumentChange.Type.ADDED); + modifiedIds = getIds(querySnapshots, DocumentChange.Type.MODIFIED); + removedIds = getIds(querySnapshots, DocumentChange.Type.REMOVED); + } + + private ListenerAssertions noError() { + final Optional anyError = + receivedEvents.stream().filter(input -> input.error != null).findFirst(); + if (anyError.isPresent()) { + throw new Error("snapshotListener received an error", anyError.get().error); + } + return this; + } + + private ListenerAssertions hasError() { + final Optional anyError = + receivedEvents.stream().filter(input -> input.error != null).findFirst(); + assertWithMessage("snapshotListener did not receive an expected error") + .that(anyError.isPresent()) + .isTrue(); + return this; + } + + private static List getQuerySnapshots(List events) { + return events.stream() + .filter(input -> input.value != null) + .map(input -> input.value) + .collect(Collectors.toList()); + } + + private static List getIds( + List querySnapshots, DocumentChange.Type type) { + final List documentIds = new ArrayList<>(); + for (QuerySnapshot querySnapshot : querySnapshots) { + final List changes = querySnapshot.getDocumentChanges(); + for (DocumentChange change : changes) { + if (change.getType() == type) { + documentIds.add(change.getDocument().getId()); + } + } + } + return documentIds; + } + + ListenerAssertions addedIdsIsEmpty() { + Truth.assertWithMessage(debugMessage()).that(addedIds).isEmpty(); + return this; + } + + ListenerAssertions addedIdsIsAnyOf(String... s) { + Truth.assertWithMessage(debugMessage()).that(addedIds).containsExactlyElementsIn(s); + return this; + } + + ListenerAssertions addedIdsIsAnyOf(List s1, List s2) { + Truth.assertWithMessage(debugMessage()).that(addedIds).isAnyOf(s1, s2); + return this; + } + + ListenerAssertions modifiedIdsIsEmpty() { + Truth.assertWithMessage(debugMessage()).that(modifiedIds).isEmpty(); + return this; + } + + ListenerAssertions modifiedIdsIsAnyOf(String... s) { + Truth.assertWithMessage(debugMessage()).that(modifiedIds).containsExactlyElementsIn(s); + return this; + } + + ListenerAssertions modifiedIdsIsAnyOf(List s1, List s2) { + Truth.assertWithMessage(debugMessage()).that(modifiedIds).isAnyOf(s1, s2); + return this; + } + + ListenerAssertions removedIdsIsEmpty() { + Truth.assertWithMessage(debugMessage()).that(removedIds).isEmpty(); + return this; + } + + ListenerAssertions removedIdsIsAnyOf(String... s) { + Truth.assertWithMessage(debugMessage()).that(removedIds).containsExactlyElementsIn(s); + return this; + } + + ListenerAssertions removedIdsIsAnyOf(List s1, List s2) { + Truth.assertWithMessage(debugMessage()).that(removedIds).isAnyOf(s1, s2); + return this; + } + + ListenerAssertions eventCountIsAnyOf(Range range) { + Truth.assertWithMessage(debugMessage()).that((int) receivedEvents.size()).isIn(range); + return this; + } + + private String debugMessage() { + final StringBuilder builder = new StringBuilder(); + builder.append("events[\n"); + for (ListenerEvent receivedEvent : receivedEvents) { + builder.append("event{"); + builder.append("error=").append(receivedEvent.error); + builder.append(","); + builder.append("value="); + debugMessage(builder, receivedEvent.value); + builder.append("},\n"); + } + builder.append("]"); + return builder.toString(); + } + + private static void debugMessage(StringBuilder builder, QuerySnapshot qs) { + if (qs == null) { + builder.append("null"); + } else { + builder.append("{"); + List documents = qs.getDocuments(); + builder.append("documents["); + for (QueryDocumentSnapshot document : documents) { + debugMessage(builder, document); + } + builder.append("],"); + List changes = qs.getDocumentChanges(); + builder.append("documentChanges["); + for (DocumentChange change : changes) { + debugMessage(builder, change.getDocument()); + } + builder.append("]"); + builder.append("}"); + } + } + + private static void debugMessage( + StringBuilder builder, QueryDocumentSnapshot queryDocumentSnapshot) { + if (queryDocumentSnapshot == null) { + builder.append("null"); + } else { + builder.append("{"); + builder.append("path=").append(queryDocumentSnapshot.getReference().getPath()); + builder.append(","); + builder.append("data="); + debugMessage(builder, queryDocumentSnapshot.getData()); + builder.append("}"); + } + } + + private static void debugMessage(StringBuilder builder, Map data) { + builder.append("{"); + MAP_JOINER.appendTo(builder, data); + builder.append("}"); + } + } + } + + private DocumentReference setDocument(String documentId, Map fields) throws Exception { + DocumentReference documentReference = randomColl.document(documentId); + documentReference.set(fields).get(); + return documentReference; + } + + private ListenResponse filter(int documentCount) { + ListenResponse.Builder response = ListenResponse.newBuilder(); + response.setFilter(ExistenceFilter.newBuilder().setCount(documentCount).build()); + return response.build(); + } + + @Test + public void testInequalityIncludesAndSortsMissingFields() throws Exception { + setDocument("doc1", map("key", 1)); + setDocument("doc2", map("key", 2)); + setDocument("doc3", map("other", 1)); // missing "key" + setDocument("doc4", map("key", null)); + + final Query query = randomColl.whereNotEqualTo("key", 1); + QuerySnapshotEventListener listener = + QuerySnapshotEventListener.builder().setInitialEventCount(1).build(); + ListenerRegistration registration = query.addSnapshotListener(listener); + + try { + listener.eventsCountDownLatch.awaitInitialEvents(); + } finally { + registration.remove(); + } + + ListenerAssertions listenerAssertions = listener.assertions(); + listenerAssertions.noError(); + + if (getFirestoreEdition() == FirestoreEdition.ENTERPRISE) { + // Expect doc2, doc3, doc4. doc1 excluded. + // Order: Missing/Null (which are equal in sort) < Number. + // Missing/Null sorted by __name__. + // doc3 < doc4. + // So: doc3, doc4, doc2. + // TODO: Watch still applies orderby normalization for now + List expectedOrder = Arrays.asList("doc2", "doc4"); + assertEquals(expectedOrder, listenerAssertions.addedIds); + } else { + List expectedOrder = singletonList("doc2"); + assertEquals(expectedOrder, listenerAssertions.addedIds); + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITShutdownTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITShutdownTest.java new file mode 100644 index 000000000000..f6ca62e9dd1f --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITShutdownTest.java @@ -0,0 +1,119 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeFalse; + +import com.google.api.core.SettableApiFuture; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.ListenerRegistration; +import com.google.cloud.firestore.LocalFirestoreHelper; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.rules.Timeout; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITShutdownTest extends ITBaseTest { + @Rule public final Timeout timeout = new Timeout(5, TimeUnit.SECONDS); + @Rule public TestName testName = new TestName(); + + @Test + public void closeSuccess_withListenerRemove() throws Exception { + Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + ListenerRegistration listener = attachListener(fs); + listener.remove(); + fs.close(); + } + + @Test + public void closeFailure_withoutListenerRemove() throws Exception { + // TODO(pipeline): This test fails against emulator, suggesting the test setup probably depends + // on timing. + // We should fix it. + assumeFalse( + "Skip this test when running against the emulator because it depends on timing.", + TestHelper.isRunningAgainstFirestoreEmulator(firestore)); + + final Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + attachListener(fs); + + ExecutorService testExecutorService = Executors.newSingleThreadExecutor(); + final SettableApiFuture result = SettableApiFuture.create(); + testExecutorService.submit( + () -> { + try { + fs.close(); + result.set(null); + } catch (Throwable throwable) { + result.setException(throwable); + } + }); + + try { + result.get(1, TimeUnit.SECONDS); + fail(); + } catch (TimeoutException e) { + // Expected + } finally { + testExecutorService.shutdown(); + } + } + + @Test + public void shutdownNowSuccess_withoutListenerRemove() throws Exception { + Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + attachListener(fs); + fs.shutdownNow(); + } + + @Test + public void shutdownSuccess_withoutListenerRemove() throws Exception { + Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + attachListener(fs); + fs.shutdown(); + } + + @Test + public void closeAndShutdown() throws Exception { + Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + attachListener(fs); + fs.shutdown(); + fs.shutdownNow(); + fs.close(); + } + + private ListenerRegistration attachListener(Firestore fs) throws InterruptedException { + final CountDownLatch cdl = new CountDownLatch(1); + ListenerRegistration listenerRegistration = + fs.collection( + String.format( + "java-%s-%s", testName.getMethodName(), LocalFirestoreHelper.autoId())) + .addSnapshotListener((value, error) -> cdl.countDown()); + cdl.await(); + return listenerRegistration; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java new file mode 100644 index 000000000000..1712046be9a6 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java @@ -0,0 +1,2457 @@ +/* + * Copyright 2017 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.FirestoreBundleTest.toBundleElements; +import static com.google.cloud.firestore.FirestoreBundleTest.verifyDocumentAndMeta; +import static com.google.cloud.firestore.FirestoreBundleTest.verifyMetadata; +import static com.google.cloud.firestore.FirestoreBundleTest.verifyNamedQuery; +import static com.google.cloud.firestore.LocalFirestoreHelper.FOO_LIST; +import static com.google.cloud.firestore.LocalFirestoreHelper.FOO_MAP; +import static com.google.cloud.firestore.LocalFirestoreHelper.UPDATE_SINGLE_FIELD_OBJECT; +import static com.google.cloud.firestore.LocalFirestoreHelper.fullPath; +import static com.google.cloud.firestore.LocalFirestoreHelper.map; +import static com.google.cloud.firestore.it.TestHelper.isRunningAgainstFirestoreEmulator; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Arrays.asList; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.api.core.SettableApiFuture; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.cloud.Timestamp; +import com.google.cloud.firestore.BulkWriter; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.FieldMask; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreBundle; +import com.google.cloud.firestore.FirestoreException; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.ListenerRegistration; +import com.google.cloud.firestore.LocalFirestoreHelper; +import com.google.cloud.firestore.LocalFirestoreHelper.AllSupportedTypes; +import com.google.cloud.firestore.LocalFirestoreHelper.SingleField; +import com.google.cloud.firestore.Precondition; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.Query.Direction; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QueryPartition; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.SetOptions; +import com.google.cloud.firestore.Transaction; +import com.google.cloud.firestore.Transaction.Function; +import com.google.cloud.firestore.TransactionOptions; +import com.google.cloud.firestore.VectorValue; +import com.google.cloud.firestore.WriteBatch; +import com.google.cloud.firestore.WriteResult; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.google.firestore.bundle.BundleElement; +import com.google.firestore.bundle.BundledDocumentMetadata; +import com.google.firestore.bundle.BundledQuery.LimitType; +import com.google.firestore.bundle.NamedQuery; +import com.google.firestore.v1.RunQueryRequest; +import io.grpc.Status; +import io.grpc.Status.Code; +import io.grpc.StatusRuntimeException; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITSystemTest extends ITBaseTest { + + private static final double DOUBLE_EPSILON = 0.000001; + + private final Map SINGLE_FIELD_MAP = LocalFirestoreHelper.SINGLE_FIELD_MAP; + private final Map ALL_SUPPORTED_TYPES_MAP = + LocalFirestoreHelper.ALL_SUPPORTED_TYPES_MAP; + private final SingleField SINGLE_FIELD_OBJECT = LocalFirestoreHelper.SINGLE_FIELD_OBJECT; + private final AllSupportedTypes ALL_SUPPORTED_TYPES_OBJECT = + LocalFirestoreHelper.ALL_SUPPORTED_TYPES_OBJECT; + private final Map SINGLE_FILED_MAP_WITH_DOT = + LocalFirestoreHelper.SINGLE_FILED_MAP_WITH_DOT; + + @Rule public TestName testName = new TestName(); + + private CollectionReference randomColl; + private DocumentReference randomDoc; + + @Before + public void before() throws Exception { + super.before(); + + randomColl = + firestore.collection( + String.format("java-%s-%s", testName.getMethodName(), LocalFirestoreHelper.autoId())); + randomDoc = randomColl.document(); + } + + private DocumentReference setDocument(String documentId, Map fields) throws Exception { + DocumentReference documentReference = randomColl.document(documentId); + documentReference.set(fields).get(); + return documentReference; + } + + private DocumentReference addDocument(String key, Object value, Object... fields) + throws Exception { + DocumentReference documentReference = randomColl.document(); + documentReference.update(Precondition.NONE, key, value, fields).get(); + return documentReference; + } + + private List querySnapshotToIds(QuerySnapshot querySnapshot) { + List documentIds = new ArrayList<>(); + for (QueryDocumentSnapshot snapshot : querySnapshot.getDocuments()) { + documentIds.add(snapshot.getId()); + } + return documentIds; + } + + @Test + public void getAll() throws Exception { + DocumentReference ref1 = randomColl.document("doc1"); + DocumentReference ref2 = randomColl.document("doc2"); + + ApiFutures.allAsList(ImmutableList.of(ref1.set(SINGLE_FIELD_MAP), ref2.set(SINGLE_FIELD_MAP))) + .get(); + + List documentSnapshots = firestore.getAll(ref1, ref2).get(); + assertEquals(2, documentSnapshots.size()); + assertEquals("doc1", documentSnapshots.get(0).getId()); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshots.get(0).toObject(SingleField.class)); + assertEquals("doc2", documentSnapshots.get(1).getId()); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshots.get(1).toObject(SingleField.class)); + } + + @Test + public void getAllWithFieldMask() throws Exception { + DocumentReference ref = randomColl.document("doc1"); + ref.set(ALL_SUPPORTED_TYPES_MAP).get(); + List documentSnapshots = + firestore.getAll(new DocumentReference[] {ref}, FieldMask.of("foo")).get(); + assertEquals(map("foo", "bar"), documentSnapshots.get(0).getData()); + } + + @Test + public void getFieldMaskWithDocumentReference() throws Exception { + DocumentReference ref = randomColl.document("doc1"); + ref.set(ALL_SUPPORTED_TYPES_MAP).get(); + DocumentSnapshot documentSnapshots = ref.get(FieldMask.of("foo", "foobar")).get(); + assertEquals("bar", documentSnapshots.get("foo")); + assertNull(documentSnapshots.get("foobar")); + } + + @Test + public void addDocument() throws Exception { + DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get(); + assertEquals(20, documentReference.getId().length()); + DocumentSnapshot documentSnapshot = documentReference.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void createDocument() throws Exception { + assertEquals(20, randomDoc.getId().length()); + randomDoc.create(SINGLE_FIELD_MAP).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void createDocumentWithValue() throws Exception { + assertEquals(20, randomDoc.getId().length()); + randomDoc.create(LocalFirestoreHelper.SINGLE_FIELD_PROTO).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void createDocumentWithFloat() throws Exception { + assertEquals(20, randomDoc.getId().length()); + randomDoc.create(LocalFirestoreHelper.SINGLE_FLOAT_PROTO).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void setDocument() throws Exception { + Map nanNullMap = new HashMap<>(); + nanNullMap.put("nan", Double.NaN); + nanNullMap.put("null", null); + randomDoc.set(nanNullMap).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals((Double) Double.NaN, documentSnapshot.getDouble("nan")); + assertEquals(null, documentSnapshot.get("null")); + } + + @Test + public void setDocumentWithValue() throws Exception { + assertEquals(20, randomDoc.getId().length()); + randomDoc.set(LocalFirestoreHelper.SINGLE_FIELD_PROTO).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void setDocumentWithFloat() throws Exception { + assertEquals(20, randomDoc.getId().length()); + randomDoc.set(LocalFirestoreHelper.SINGLE_FLOAT_PROTO).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(SINGLE_FIELD_OBJECT, documentSnapshot.toObject(SingleField.class)); + } + + @Test + public void setDocumentWithMerge() throws Exception { + Map originalMap = LocalFirestoreHelper.map("a.b", "c", "nested", map("d", "e")); + Map updateMap = LocalFirestoreHelper.map("f.g", "h", "nested", map("i", "j")); + Map resultMap = + LocalFirestoreHelper.map("a.b", "c", "f.g", "h", "nested", map("d", "e", "i", "j")); + randomDoc.set(originalMap).get(); + randomDoc.set(updateMap, SetOptions.merge()).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(resultMap, documentSnapshot.getData()); + } + + @Test + public void setWithIncrementAndMerge() throws ExecutionException, InterruptedException { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("sum", 1L)).get(); + docRef.set(Collections.singletonMap("sum", FieldValue.increment(2)), SetOptions.merge()).get(); + DocumentSnapshot docSnap = docRef.get().get(); + assertEquals(3L, docSnap.get("sum")); + } + + @Test + public void mergeDocumentWithServerTimestamp() throws Exception { + Map originalMap = LocalFirestoreHelper.map("a", "b"); + Map updateMap = map("c", FieldValue.serverTimestamp()); + randomDoc.set(originalMap).get(); + randomDoc.set(updateMap, SetOptions.merge()).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals("b", documentSnapshot.getString("a")); + assertNotNull(documentSnapshot.getDate("c")); + } + + @Test + public void updateDocument() throws Exception { + AllSupportedTypes expectedResult = new AllSupportedTypes(); + WriteResult writeResult = randomDoc.set(ALL_SUPPORTED_TYPES_MAP).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals(expectedResult, documentSnapshot.toObject(AllSupportedTypes.class)); + randomDoc.update(Precondition.updatedAt(writeResult.getUpdateTime()), "foo", "updated").get(); + documentSnapshot = randomDoc.get().get(); + expectedResult.foo = "updated"; + assertEquals(expectedResult, documentSnapshot.toObject(AllSupportedTypes.class)); + expectedResult.model = ImmutableMap.of("foo", UPDATE_SINGLE_FIELD_OBJECT.foo); + randomDoc.update("model", UPDATE_SINGLE_FIELD_OBJECT).get(); + documentSnapshot = randomDoc.get().get(); + assertEquals(expectedResult, documentSnapshot.toObject(AllSupportedTypes.class)); + } + + @Test(expected = ExecutionException.class) + public void updateDocumentExists() throws Exception { + randomDoc.update(SINGLE_FIELD_MAP).get(); + } + + @Test + public void serverTimestamp() throws Exception { + randomDoc.set(map("time", FieldValue.serverTimestamp())).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertTrue(documentSnapshot.getDate("time").getTime() > 0); + } + + @Test + public void timestampDoesntGetTruncatedDuringUpdate() throws Exception { + DocumentReference documentReference = + addDocument("time", Timestamp.ofTimeSecondsAndNanos(0, 123000)); + DocumentSnapshot documentSnapshot = documentReference.get().get(); + + Timestamp timestamp = documentSnapshot.getTimestamp("time"); + documentReference.update("time", timestamp); + + documentSnapshot = documentReference.get().get(); + timestamp = documentSnapshot.getTimestamp("time"); + assertEquals(123000, timestamp.getNanos()); + } + + @Test + public void fieldDelete() throws Exception { + Map fields = new HashMap<>(); + fields.put("foo1", "bar1"); + fields.put("foo2", "bar2"); + randomDoc.set(fields).get(); + + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertEquals("bar1", documentSnapshot.getString("foo1")); + assertEquals("bar2", documentSnapshot.getString("foo2")); + randomDoc.update("foo1", "bar3", "foo2", FieldValue.delete()).get(); + documentSnapshot = randomDoc.get().get(); + assertEquals("bar3", documentSnapshot.getString("foo1")); + assertNull(documentSnapshot.getString("foo2")); + } + + @Test + public void deleteDocument() throws Exception { + randomDoc.delete().get(); + WriteResult writeResult = randomDoc.set(ALL_SUPPORTED_TYPES_MAP).get(); + try { + randomDoc.delete(Precondition.updatedAt(Timestamp.ofTimeSecondsAndNanos(1, 0))).get(); + fail(); + } catch (ExecutionException e) { + assertTrue(e.getMessage().contains("FAILED_PRECONDITION")); + } + writeResult = randomDoc.delete(Precondition.updatedAt(writeResult.getUpdateTime())).get(); + DocumentSnapshot documentSnapshot = randomDoc.get().get(); + assertFalse(documentSnapshot.exists()); + assertTrue(writeResult.getUpdateTime().getSeconds() > 0); + } + + @Test + public void defaultQuery() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + QuerySnapshot querySnapshot = randomColl.get().get(); + assertEquals(2, querySnapshot.size()); + + Iterator documents = querySnapshot.iterator(); + assertEquals("bar", documents.next().get("foo")); + assertEquals("bar", documents.next().get("foo")); + } + + @Test + public void defaultQueryStream() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("bar", "bar").iterator(); + randomColl.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.get("foo")); + } + + @Override + public void onError(Throwable throwable) {} + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iterator.hasNext()); + } + + @Test + public void largeQuery() throws Exception { + int count = 100; + while (count-- > 0) { + addDocument("foo", "bar"); + } + + QuerySnapshot querySnapshot = randomColl.get().get(); + assertEquals(100, querySnapshot.size()); + } + + @Test + public void largeQueryStream() throws Exception { + int count = 100; + while (count-- > 0) { + addDocument("foo", "bar"); + } + + final Semaphore semaphore = new Semaphore(0); + final int[] docCount = {0}; + randomColl.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + docCount[0]++; + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertEquals(100, docCount[0]); + } + + @Test + public void noResults() throws Exception { + QuerySnapshot querySnapshot = randomColl.get().get(); + assertTrue(querySnapshot.isEmpty()); + assertNotNull(querySnapshot.getReadTime()); + } + + @Test + public void noResultsStream() throws Exception { + final Semaphore semaphore = new Semaphore(0); + final int[] docCount = {0}; + randomColl.stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + docCount[0]++; + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertEquals(0, docCount[0]); + } + + @Test + public void queryWithMicrosecondPrecision() throws Exception { + Timestamp microsecondTimestamp = Timestamp.ofTimeSecondsAndNanos(0, 123000); + + DocumentReference documentReference = addDocument("time", microsecondTimestamp); + DocumentSnapshot documentSnapshot = documentReference.get().get(); + + Query query = randomColl.whereEqualTo("time", microsecondTimestamp); + QuerySnapshot querySnapshot = query.get().get(); + assertEquals(1, querySnapshot.size()); + + // Using `.toDate()` truncates to millseconds, and hence the query doesn't match. + query = randomColl.whereEqualTo("time", microsecondTimestamp.toDate()); + querySnapshot = query.get().get(); + assertEquals(0, querySnapshot.size()); + } + + @Test + public void nestedQuery() throws Exception { + randomColl = randomColl.document("foo").collection("bar"); + addDocument("foo", "bar"); + + QuerySnapshot querySnapshot = randomColl.get().get(); + DocumentSnapshot documentSnapshot = querySnapshot.getDocuments().get(0); + assertTrue(documentSnapshot.getReference().getPath().contains("/foo/bar")); + } + + @Test + public void limitQuery() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + QuerySnapshot querySnapshot = randomColl.orderBy("counter").limit(2).get().get(); + assertEquals(asList("doc1", "doc2"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void limitQueryStream() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2").iterator(); + randomColl.orderBy("counter").limit(2).stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iterator.hasNext()); + } + + @Test + public void limitToLastQuery() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + QuerySnapshot querySnapshot = randomColl.orderBy("counter").limitToLast(2).get().get(); + assertEquals(asList("doc2", "doc3"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void largerLimitQuery() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + QuerySnapshot querySnapshot = randomColl.orderBy("counter").limit(4).get().get(); + assertEquals(asList("doc1", "doc2", "doc3"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void largerLimitQueryStream() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + setDocument("doc3", Collections.singletonMap("counter", 3)); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Arrays.asList("doc1", "doc2", "doc3").iterator(); + randomColl.orderBy("counter").limit(4).stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.getId()); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iterator.hasNext()); + } + + @Test + public void offsetQuery() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + QuerySnapshot querySnapshot = randomColl.offset(1).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals("bar", querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void offsetQueryStream() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iterator = Collections.singletonList("bar").iterator(); + randomColl.offset(1).stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iterator.next(), documentSnapshot.get("foo")); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iterator.hasNext()); + } + + @Test + public void largerOffsetQuery() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + QuerySnapshot querySnapshot = randomColl.offset(3).get().get(); + assertEquals(0, querySnapshot.size()); + } + + @Test + public void largerOffsetQueryStream() throws Exception { + addDocument("foo", "bar"); + addDocument("foo", "bar"); + + final Semaphore semaphore = new Semaphore(0); + final int[] docCount = {0}; + randomColl.offset(3).stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + docCount[0]++; + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertEquals(0, docCount[0]); + } + + @Test + public void orderByQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.orderBy("foo").get().get(); + Iterator documents = querySnapshot.iterator(); + assertEquals(1L, documents.next().get("foo")); + assertEquals(2L, documents.next().get("foo")); + + querySnapshot = randomColl.orderBy("foo", Query.Direction.DESCENDING).get().get(); + documents = querySnapshot.iterator(); + assertEquals(2L, documents.next().get("foo")); + assertEquals(1L, documents.next().get("foo")); + } + + @Test + public void orderByQueryStream() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + final Semaphore semaphore = new Semaphore(0); + final Iterator iteratorAscending = Arrays.asList(1L, 2L).iterator(); + randomColl.orderBy("foo").stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iteratorAscending.next(), documentSnapshot.get("foo")); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iteratorAscending.hasNext()); + + final Iterator iteratorDescending = Arrays.asList(2L, 1L).iterator(); + randomColl.orderBy("foo", Query.Direction.DESCENDING).stream( + new ApiStreamObserver() { + @Override + public void onNext(DocumentSnapshot documentSnapshot) { + assertEquals(iteratorDescending.next(), documentSnapshot.get("foo")); + } + + @Override + public void onError(Throwable throwable) { + fail(); + } + + @Override + public void onCompleted() { + semaphore.release(); + } + }); + + semaphore.acquire(); + // Verify the number of response + assertFalse(iteratorDescending.hasNext()); + } + + @Test + public void selectQuery() throws Exception { + addDocument("foo", 1, "bar", 2); + + QuerySnapshot querySnapshot = randomColl.select("foo").get().get(); + assertEquals(1, querySnapshot.size()); + DocumentSnapshot documentSnapshot = querySnapshot.getDocuments().get(0); + assertEquals(1L, documentSnapshot.get("foo")); + assertNull(documentSnapshot.get("bar")); + } + + @Test + public void equalsQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.whereEqualTo("foo", 1).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(1L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void greaterThanQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.whereGreaterThan("foo", 1).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(2L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void multipleInequalityQueryOnSamePropertiesShouldBeSupported() throws Exception { + addDocument("foo", 1); + + QuerySnapshot querySnapshot = + randomColl.whereGreaterThan("foo", 0).whereLessThanOrEqualTo("foo", 2).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(1L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void multipleInequalityQueryOnDifferentPropertiesShouldBeSupported() throws Exception { + // TODO(MIEQ): Enable this test against production when possible. + assumeTrue( + "Skip this test if running against production because multiple inequality is " + + "not supported yet.", + isRunningAgainstFirestoreEmulator(firestore)); + + addDocument("foo", 1, "bar", 2); + + QuerySnapshot querySnapshot = + randomColl.whereGreaterThan("foo", 0).whereLessThanOrEqualTo("bar", 2).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(1L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void greaterThanOrEqualQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.whereGreaterThanOrEqualTo("foo", 1).get().get(); + assertEquals(2, querySnapshot.size()); + } + + @Test + public void lessThanQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.whereLessThan("foo", 2).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(1L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void lessThanOrEqualQuery() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.whereLessThanOrEqualTo("foo", 2).get().get(); + assertEquals(2, querySnapshot.size()); + } + + @Test + public void unaryQuery() throws Exception { + addDocument("foo", 1, "bar", Double.NaN); + addDocument("foo", 2, "bar", null); + + QuerySnapshot querySnapshot = randomColl.whereEqualTo("bar", Double.NaN).get().get(); + assertEquals(1, querySnapshot.size()); + DocumentSnapshot documentSnapshot = querySnapshot.getDocuments().get(0); + assertEquals(1L, documentSnapshot.get("foo")); + assertEquals(Double.NaN, documentSnapshot.get("bar")); + + querySnapshot = randomColl.whereEqualTo("bar", null).get().get(); + assertEquals(1, querySnapshot.size()); + documentSnapshot = querySnapshot.getDocuments().get(0); + assertEquals(2L, documentSnapshot.get("foo")); + assertNull(documentSnapshot.get("bar")); + } + + @Test + public void startAt() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.orderBy("foo").startAt(1).get().get(); + assertEquals(2, querySnapshot.size()); + Iterator documents = querySnapshot.iterator(); + assertEquals(1L, documents.next().get("foo")); + assertEquals(2L, documents.next().get("foo")); + } + + @Test + public void startAfter() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.orderBy("foo").startAfter(1).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(2L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void startAfterAddsAnImplicitOrderByForDocumentReferences() throws Exception { + DocumentReference doc1 = randomColl.document("doc1"); + DocumentReference doc2 = randomColl.document("doc2"); + + doc1.set(map("foo", 1)).get(); + doc2.set(map("foo", 1)).get(); + + QuerySnapshot querySnapshot = randomColl.startAfter(doc1).get().get(); + assertEquals(1, querySnapshot.size()); + Iterator documents = querySnapshot.iterator(); + assertEquals(doc2, documents.next().getReference()); + } + + @Test + public void endAt() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.orderBy("foo").endAt(2).get().get(); + assertEquals(2, querySnapshot.size()); + Iterator documents = querySnapshot.iterator(); + assertEquals(1L, documents.next().get("foo")); + assertEquals(2L, documents.next().get("foo")); + } + + @Test + public void endBefore() throws Exception { + addDocument("foo", 1); + addDocument("foo", 2); + + QuerySnapshot querySnapshot = randomColl.orderBy("foo").endBefore(2).get().get(); + assertEquals(1, querySnapshot.size()); + assertEquals(1L, querySnapshot.getDocuments().get(0).get("foo")); + } + + @Test + public void partitionedQuery() throws Exception { + assumeFalse( + "Partitioned query is not supported with enterprise yet", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + // Partitioned queries are not supported in the emulator. + assumeFalse( + "Skip this test when running against the Firestore emulator because it does not support" + + " partitioned queries.", + isRunningAgainstFirestoreEmulator(firestore)); + + int documentCount = 2 * 128 + 127; // Minimum partition size is 128. + + WriteBatch batch = firestore.batch(); + for (int i = 0; i < documentCount; ++i) { + batch.create(randomColl.document(), map("foo", i)); + } + batch.commit().get(); + + StreamConsumer consumer = new StreamConsumer<>(); + firestore.collectionGroup(randomColl.getId()).getPartitions(3, consumer); + final List partitions = consumer.consume().get(); + + assertNull(partitions.get(0).getStartAt()); + for (int i = 0; i < partitions.size() - 1; ++i) { + assertArrayEquals(partitions.get(i).getEndBefore(), partitions.get(i + 1).getStartAt()); + } + assertNull(partitions.get(partitions.size() - 1).getEndBefore()); + + // Validate that we can use the partitions to read the original documents. + int resultCount = 0; + for (QueryPartition partition : partitions) { + resultCount += partition.createQuery().get().get().size(); + } + assertEquals(documentCount, resultCount); + } + + @Test + public void partitionedQuery_future() throws Exception { + assumeFalse( + "Partitioned query is not supported with enterprise yet", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + // Partitioned queries are not supported in the emulator. + assumeFalse( + "Skip this test when running against the Firestore emulator because it does not support" + + " partitioned queries.", + isRunningAgainstFirestoreEmulator(firestore)); + + int documentCount = 2 * 128 + 127; // Minimum partition size is 128. + + WriteBatch batch = firestore.batch(); + for (int i = 0; i < documentCount; ++i) { + batch.create(randomColl.document(), map("foo", i)); + } + batch.commit().get(); + + ApiFuture> future = + firestore.collectionGroup(randomColl.getId()).getPartitions(3); + final List partitions = future.get(); + + assertNull(partitions.get(0).getStartAt()); + for (int i = 0; i < partitions.size() - 1; ++i) { + assertArrayEquals(partitions.get(i).getEndBefore(), partitions.get(i + 1).getStartAt()); + } + assertNull(partitions.get(partitions.size() - 1).getEndBefore()); + + // Validate that we can use the partitions to read the original documents. + int resultCount = 0; + for (QueryPartition partition : partitions) { + resultCount += partition.createQuery().get().get().size(); + } + assertEquals(documentCount, resultCount); + } + + @Test + public void emptyPartitionedQuery() throws Exception { + assumeFalse( + "Partitioned query is not supported with enterprise yet", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + // Partitioned queries are not supported in the emulator. + assumeFalse( + "Skip this test when running against the Firestore emulator because it does not support" + + " partitioned queries.", + isRunningAgainstFirestoreEmulator(firestore)); + + StreamConsumer consumer = new StreamConsumer<>(); + firestore.collectionGroup(randomColl.getId()).getPartitions(3, consumer); + final List partitions = consumer.consume().get(); + + assertEquals(1, partitions.size()); + assertNull(partitions.get(0).getStartAt()); + assertNull(partitions.get(0).getEndBefore()); + } + + @Test + public void validatesPartitionCount() { + StreamConsumer consumer = new StreamConsumer<>(); + try { + firestore.collectionGroup(randomColl.getId()).getPartitions(0, consumer); + fail(); + } catch (IllegalArgumentException e) { + assertEquals("Desired partition count must be one or greater", e.getMessage()); + } + } + + @Test + public void failedTransaction() { + try { + firestore + .runTransaction( + (Function) + transaction -> { + throw new RuntimeException("User exception"); + }) + .get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("User exception")); + } + } + + @Test + public void asyncTxFailsWithUserError() throws Exception { + try { + firestore + .runAsyncTransaction( + (Transaction.AsyncFunction) + transaction -> { + throw new RuntimeException("User exception"); + }) + .get(); + fail(); + } catch (Exception e) { + assertTrue(e.getMessage().endsWith("User exception")); + } + } + + @Test + public void doesNotRetryTransactionsWithFailedPreconditions() { + final DocumentReference documentReference = randomColl.document(); + + final AtomicInteger attempts = new AtomicInteger(); + + ApiFuture firstTransaction = + firestore.runTransaction( + transaction -> { + attempts.incrementAndGet(); + transaction.update(documentReference, "foo", "bar"); + return null; + }); + + try { + firstTransaction.get(); + fail("ApiFuture should fail with ExecutionException"); + } catch (InterruptedException e) { + fail("ApiFuture should fail with ExecutionException"); + } catch (ExecutionException e) { + assertEquals(1, attempts.intValue()); + assertEquals(404, ((FirestoreException) e.getCause()).getCode()); + } + } + + @Test + public void successfulTransactionWithContention() throws Exception { + final DocumentReference documentReference = addDocument("counter", 1); + + final CountDownLatch latch = new CountDownLatch(2); + final AtomicInteger attempts = new AtomicInteger(); + + // One of these transaction fails and has to be retried since they both acquire locks on the + // same document, which they then modify. + ApiFuture firstTransaction = + firestore.runTransaction( + transaction -> { + attempts.incrementAndGet(); + DocumentSnapshot documentSnapshot = transaction.get(documentReference).get(); + latch.countDown(); + latch.await(); + transaction.update( + documentReference, "counter", documentSnapshot.getLong("counter") + 1); + return "foo"; + }); + + ApiFuture secondTransaction = + firestore.runTransaction( + transaction -> { + attempts.incrementAndGet(); + List documentSnapshots = + transaction.getAll(documentReference).get(); + latch.countDown(); + latch.await(); + transaction.update( + documentReference, "counter", documentSnapshots.get(0).getLong("counter") + 1); + return "bar"; + }); + + assertEquals("foo", firstTransaction.get()); + assertEquals("bar", secondTransaction.get()); + assertThat(attempts.intValue()).isAtLeast(3); + assertEquals(3, (long) documentReference.get().get().getLong("counter")); + } + + @Test + public void writeBatch() throws Exception { + DocumentReference createDocument = randomColl.document(); + DocumentReference setDocument = randomColl.document(); + DocumentReference updateDocument = addDocument("foo", "bar"); + DocumentReference deleteDocument = addDocument("foo", "bar"); + + WriteBatch batch = firestore.batch(); + + batch.create(createDocument, SINGLE_FIELD_OBJECT); + batch.set(setDocument, ALL_SUPPORTED_TYPES_OBJECT); + batch.update(updateDocument, "foo", "foobar"); + batch.delete(deleteDocument); + + batch.commit().get(); + + List documentSnapshots = + firestore.getAll(createDocument, setDocument, updateDocument, deleteDocument).get(); + + Iterator iterator = documentSnapshots.iterator(); + assertEquals(SINGLE_FIELD_OBJECT, iterator.next().toObject(SingleField.class)); + assertEquals(ALL_SUPPORTED_TYPES_OBJECT, iterator.next().toObject(AllSupportedTypes.class)); + assertEquals("foobar", iterator.next().get("foo")); + assertFalse(iterator.next().exists()); + } + + @Test + public void omitWriteResultForDocumentTransforms() + throws ExecutionException, InterruptedException { + WriteBatch batch = firestore.batch(); + batch.set(randomColl.document(), SINGLE_FIELD_MAP); + batch.set(randomColl.document(), map("time", FieldValue.serverTimestamp())); + List writeResults = batch.commit().get(); + assertEquals(2, writeResults.size()); + } + + @Test + public void listCollections() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support" + + " listCollections", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + + // We test with 21 collections since 20 collections are by default returned in a single paged + // response. + String[] collections = + new String[] { + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", + "17", "18", "19", "20", "21" + }; + Arrays.sort(collections); // Sort in alphabetical (non-numeric) order. + + WriteBatch batch = firestore.batch(); + for (String collection : collections) { + batch.create(randomDoc.collection(collection).document("doc"), SINGLE_FIELD_OBJECT); + } + batch.commit().get(); + + Iterable collectionRefs = randomDoc.listCollections(); + + int count = 0; + for (CollectionReference collectionRef : collectionRefs) { + assertEquals(collections[count++], collectionRef.getId()); + } + assertEquals(collections.length, count); + } + + @Test + public void listDocuments() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support listDocuments", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + // We test with 21 documents since 20 documents are by default returned in a single paged + // response. + String[] documents = + new String[] { + "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", + "17", "18", "19", "20", "21" + }; + Arrays.sort(documents); // Sort in alphabetical (non-numeric) order. + + WriteBatch batch = firestore.batch(); + for (String document : documents) { + batch.create(randomColl.document(document), SINGLE_FIELD_OBJECT); + } + batch.commit().get(); + + Iterable collectionRefs = randomColl.listDocuments(); + + int count = 0; + for (DocumentReference documentRef : collectionRefs) { + assertEquals(documents[count++], documentRef.getId()); + } + assertEquals(documents.length, count); + } + + @Test + public void listDocumentsListsMissingDocument() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support" + + " missing documents.", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + randomColl.document("missing/foo/bar").set(SINGLE_FIELD_MAP).get(); + Iterable collectionRefs = randomColl.listDocuments(); + assertEquals(randomColl.document("missing"), collectionRefs.iterator().next()); + } + + @Test + public void addAndRemoveFields() throws ExecutionException, InterruptedException { + Map expected = new HashMap<>(); + + randomDoc.create(Collections.emptyMap()).get(); + assertEquals(expected, getData()); + + randomDoc.delete().get(); + assertFalse(randomDoc.get().get().exists()); + + randomDoc.create(map("a", map("b", "c"))).get(); + expected.put("a", map("b", "c")); + assertEquals(expected, getData()); + + randomDoc.set(Collections.emptyMap()).get(); + expected = map(); + assertEquals(expected, getData()); + + randomDoc.set(map("a", map("b", "c"))).get(); + expected.put("a", map("b", "c")); + assertEquals(expected, getData()); + + randomDoc.set(map("a", map("d", "e")), SetOptions.merge()).get(); + getNestedMap(expected, "a").put("d", "e"); + assertEquals(expected, getData()); + + randomDoc + .set(LocalFirestoreHelper.map("a", map("d", FieldValue.delete())), SetOptions.merge()) + .get(); + getNestedMap(expected, "a").remove("d"); + assertEquals(expected, getData()); + + randomDoc + .set(LocalFirestoreHelper.map("a", map("b", FieldValue.delete())), SetOptions.merge()) + .get(); + getNestedMap(expected, "a").remove("b"); + assertEquals(expected, getData()); + + randomDoc.set(LocalFirestoreHelper.map("a", map("e", "foo")), SetOptions.merge()).get(); + getNestedMap(expected, "a").put("e", "foo"); + assertEquals(expected, getData()); + + randomDoc.set(map("f", "foo"), SetOptions.merge()).get(); + expected.put("f", "foo"); + assertEquals(expected, getData()); + + randomDoc.set(LocalFirestoreHelper.map("f", map("g", "foo")), SetOptions.merge()).get(); + expected.put("f", map("g", "foo")); + assertEquals(expected, getData()); + + randomDoc.update("f.h", "foo").get(); + getNestedMap(expected, "f").put("h", "foo"); + assertEquals(expected, getData()); + + randomDoc.update("f.g", FieldValue.delete()).get(); + getNestedMap(expected, "f").remove("g"); + assertEquals(expected, getData()); + + randomDoc.update("f.h", FieldValue.delete()).get(); + getNestedMap(expected, "f").remove("h"); + assertEquals(expected, getData()); + + randomDoc.update("f", FieldValue.delete()).get(); + expected.remove("f"); + assertEquals(expected, getData()); + + randomDoc.update("i.j", map()).get(); + expected.put("i", map("j", map())); + assertEquals(expected, getData()); + + randomDoc.update("i.j", map("k", "foo")).get(); + getNestedMap(expected, "i").put("j", map("k", "foo")); + assertEquals(expected, getData()); + + randomDoc.update("i.j", LocalFirestoreHelper.map("l", map("k", "foo"))).get(); + getNestedMap(expected, "i").put("j", map("l", map("k", "foo"))); + assertEquals(expected, getData()); + + randomDoc.update("i.j", LocalFirestoreHelper.map("l", map())).get(); + getNestedMap(expected, "i").put("j", map("l", map())); + assertEquals(expected, getData()); + + randomDoc.update("i", FieldValue.delete()).get(); + expected.remove("i"); + assertEquals(expected, getData()); + + randomDoc.update("a", FieldValue.delete()).get(); + expected.remove("a"); + assertEquals(expected, getData()); + } + + @Test + public void addAndRemoveServerTimestamps() throws ExecutionException, InterruptedException { + Map expected = new HashMap<>(); + + randomDoc + .create( + map("time", FieldValue.serverTimestamp(), "a", map("b", FieldValue.serverTimestamp()))) + .get(); + Timestamp time = (Timestamp) getData().get("time"); + expected.put("time", time); + expected.put("a", map("b", time)); + assertEquals(expected, getData()); + + randomDoc + .set(map("time", FieldValue.serverTimestamp(), "a", map("c", FieldValue.serverTimestamp()))) + .get(); + time = updateTime(expected); + expected.put("a", map("c", time)); + assertEquals(expected, getData()); + + randomDoc + .set( + map("time", FieldValue.serverTimestamp(), "e", FieldValue.serverTimestamp()), + SetOptions.merge()) + .get(); + time = updateTime(expected); + expected.put("e", time); + assertEquals(expected, getData()); + + randomDoc + .set( + map("time", FieldValue.serverTimestamp(), "e", map("f", FieldValue.serverTimestamp())), + SetOptions.merge()) + .get(); + time = updateTime(expected); + expected.put("e", map("f", time)); + assertEquals(expected, getData()); + + randomDoc + .update("time", FieldValue.serverTimestamp(), "g.h", FieldValue.serverTimestamp()) + .get(); + time = updateTime(expected); + expected.put("g", map("h", time)); + assertEquals(expected, getData()); + + randomDoc + .update("time", FieldValue.serverTimestamp(), "g.j", map("k", FieldValue.serverTimestamp())) + .get(); + time = updateTime(expected); + getNestedMap(expected, "g").put("j", map("k", time)); + assertEquals(expected, getData()); + } + + private Timestamp updateTime(Map dataWithTime) + throws ExecutionException, InterruptedException { + Timestamp time = (Timestamp) getData().get("time"); + dataWithTime.put("time", time); + return time; + } + + private Map getNestedMap(Map map, String key) { + return (Map) map.get(key); + } + + private Map getData() throws ExecutionException, InterruptedException { + return randomDoc.get().get().getData(); + } + + @Test + public void writeAndReadVectorEmbeddings() throws ExecutionException, InterruptedException { + Map expected = new HashMap<>(); + + randomDoc + .create( + map( + "vector0", + FieldValue.vector(new double[] {0.0}), + "vector1", + FieldValue.vector(new double[] {1, 2, 3.99}))) + .get(); + randomDoc + .set( + map( + "vector0", + FieldValue.vector(new double[] {0.0}), + "vector1", + FieldValue.vector(new double[] {1, 2, 3.99}), + "vector2", + FieldValue.vector(new double[] {0, 0, 0}))) + .get(); + randomDoc.update(map("vector3", FieldValue.vector(new double[] {-1, -200, -9999}))).get(); + + expected.put("vector0", FieldValue.vector(new double[] {0.0})); + expected.put("vector1", FieldValue.vector(new double[] {1, 2, 3.99})); + expected.put("vector2", FieldValue.vector(new double[] {0, 0, 0})); + expected.put("vector3", FieldValue.vector(new double[] {-1, -200, -9999})); + + DocumentSnapshot actual = randomDoc.get().get(); + + assertTrue(actual.get("vector0") instanceof VectorValue); + assertTrue(actual.get("vector1") instanceof VectorValue); + assertTrue(actual.get("vector2") instanceof VectorValue); + assertTrue(actual.get("vector3") instanceof VectorValue); + + assertArrayEquals( + expected.get("vector0").toArray(), + actual.get("vector0", VectorValue.class).toArray(), + DOUBLE_EPSILON); + assertArrayEquals( + expected.get("vector1").toArray(), + actual.get("vector1", VectorValue.class).toArray(), + DOUBLE_EPSILON); + assertArrayEquals( + expected.get("vector2").toArray(), + actual.get("vector2", VectorValue.class).toArray(), + DOUBLE_EPSILON); + assertArrayEquals( + expected.get("vector3").toArray(), + actual.get("vector3", VectorValue.class).toArray(), + DOUBLE_EPSILON); + } + + @Test + public void listenToDocumentsWithVectors() throws Throwable { + CompletableFuture listen = new CompletableFuture<>(); + ListenerRegistration registration = null; + DocumentReference ref = randomColl.document(); + AtomicInteger snapshotCount = new AtomicInteger(); + + try { + registration = + randomColl + .whereEqualTo("purpose", "vector tests") + .addSnapshotListener( + (value, error) -> { + try { + DocumentSnapshot docSnap = + value.isEmpty() ? null : value.getDocuments().get(0); + + switch (snapshotCount.getAndIncrement()) { + case 0: + assertNull(docSnap); + ref.create( + map( + "purpose", "vector tests", + "vector0", FieldValue.vector(new double[] {0.0}), + "vector1", FieldValue.vector(new double[] {1, 2, 3.99}))) + .get(); + break; + case 1: + assertNotNull(docSnap); + + assertEquals( + docSnap.getVectorValue("vector0"), + FieldValue.vector(new double[] {0.0})); + assertEquals( + docSnap.getVectorValue("vector1"), + FieldValue.vector(new double[] {1, 2, 3.99})); + + ref.set( + map( + "purpose", + "vector tests", + "vector0", + FieldValue.vector(new double[] {0.0}), + "vector1", + FieldValue.vector(new double[] {1, 2, 3.99}), + "vector2", + FieldValue.vector(new double[] {0, 0, 0}))) + .get(); + break; + case 2: + assertNotNull(docSnap); + + assertEquals( + docSnap.getVectorValue("vector0"), + FieldValue.vector(new double[] {0.0})); + assertEquals( + docSnap.getVectorValue("vector1"), + FieldValue.vector(new double[] {1, 2, 3.99})); + assertEquals( + docSnap.getVectorValue("vector2"), + FieldValue.vector(new double[] {0, 0, 0})); + + ref.update( + map("vector3", FieldValue.vector(new double[] {-1, -200, -999}))) + .get(); + break; + case 3: + assertNotNull(docSnap); + + assertEquals( + docSnap.getVectorValue("vector0"), + FieldValue.vector(new double[] {0.0})); + assertEquals( + docSnap.getVectorValue("vector1"), + FieldValue.vector(new double[] {1, 2, 3.99})); + assertEquals( + docSnap.getVectorValue("vector2"), + FieldValue.vector(new double[] {0, 0, 0})); + assertEquals( + docSnap.getVectorValue("vector3"), + FieldValue.vector(new double[] {-1, -200, -999})); + + ref.delete().get(); + break; + case 4: + assertNull(docSnap); + listen.complete(null); + break; + } + } catch (Throwable t) { + listen.completeExceptionally(t); + } + }); + + listen.get(); + } finally { + if (registration != null) { + registration.remove(); + } + } + } + + @Test + public void documentWatch() throws Exception { + CompletableFuture listen = new CompletableFuture<>(); + DocumentReference documentReference = randomColl.document(); + ListenerRegistration registration = null; + AtomicInteger snapshotCount = new AtomicInteger(); + + try { + registration = + documentReference.addSnapshotListener( + (value, error) -> { + try { + switch (snapshotCount.getAndIncrement()) { + case 0: + assertFalse(value.exists()); + documentReference.set(map("foo", "foo")); + break; + case 1: + assertTrue(value.exists()); + DocumentSnapshot documentSnapshot = documentReference.get().get(); + assertEquals("foo", documentSnapshot.getString("foo")); + documentReference.set(map("foo", "bar")); + break; + case 2: + assertTrue(value.exists()); + documentSnapshot = documentReference.get().get(); + assertEquals("bar", documentSnapshot.getString("foo")); + documentReference.delete(); + break; + case 3: + assertFalse(value.exists()); + listen.complete(null); + break; + } + } catch (Exception e) { + listen.completeExceptionally(e); + } + }); + listen.get(); + } finally { + if (registration != null) { + registration.remove(); + } + } + } + + private int paginateResults(Query query, List results) + throws ExecutionException, InterruptedException { + if (!results.isEmpty()) { + query = query.startAfter(results.get(results.size() - 1)); + } + + QuerySnapshot querySnapshot = query.get().get(); + + if (querySnapshot.isEmpty()) { + return 0; + } else { + results.addAll(querySnapshot.getDocuments()); + return 1 + paginateResults(query, results); + } + } + + @Test + public void queryPaginationWithOrderByClause() throws ExecutionException, InterruptedException { + WriteBatch batch = firestore.batch(); + + for (int i = 0; i < 10; ++i) { + batch.set(randomColl.document(), map("val", i)); + } + + batch.commit().get(); + + Query query = randomColl.orderBy("val").limit(3); + + List results = new ArrayList<>(); + int pageCount = paginateResults(query, results); + assertEquals(4, pageCount); + assertEquals(10, results.size()); + } + + @Test + public void queryPaginationWithWhereClause() throws ExecutionException, InterruptedException { + // TODO(pipeline): Enable this test against production when adding implicitOrderBy. + assumeTrue( + "Skip this test when running against enterprise because it does not work yet.", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + WriteBatch batch = firestore.batch(); + + for (int i = 0; i < 10; ++i) { + batch.set(randomColl.document(), map("val", i)); + } + + batch.commit().get(); + + Query query = randomColl.whereGreaterThanOrEqualTo("val", 1).limit(3); + + List results = new ArrayList<>(); + int pageCount = paginateResults(query, results); + assertEquals(3, pageCount); + assertEquals(9, results.size()); + } + + @Test + public void arrayOperators() throws ExecutionException, InterruptedException { + Query containsQuery = randomColl.whereArrayContains("foo", "bar"); + + assertTrue(containsQuery.get().get().isEmpty()); + + DocumentReference doc1 = randomColl.document(); + DocumentReference doc2 = randomColl.document(); + doc1.set(Collections.singletonMap("foo", FieldValue.arrayUnion("bar"))).get(); + doc2.set(Collections.singletonMap("foo", FieldValue.arrayUnion("baz"))).get(); + + assertEquals(1, containsQuery.get().get().size()); + + doc1.set(Collections.singletonMap("foo", FieldValue.arrayRemove("bar"))).get(); + doc2.set(Collections.singletonMap("foo", FieldValue.arrayRemove("baz"))).get(); + + assertTrue(containsQuery.get().get().isEmpty()); + } + + @Test + public void testCollectionGroupQueries() throws ExecutionException, InterruptedException { + // Use `randomColl` to get a random collection group name to use but ensure it starts with 'b' + // for predictable ordering. + String collectionGroup = "b" + randomColl.getId(); + + String[] docPaths = + new String[] { + "abc/123/${collectionGroup}/cg-doc1", + "abc/123/${collectionGroup}/cg-doc2", + "${collectionGroup}/cg-doc3", + "${collectionGroup}/cg-doc4", + "def/456/${collectionGroup}/cg-doc5", + "${collectionGroup}/virtual-doc/nested-coll/not-cg-doc", + "x${collectionGroup}/not-cg-doc", + "${collectionGroup}x/not-cg-doc", + "abc/123/${collectionGroup}x/not-cg-doc", + "abc/123/x${collectionGroup}/not-cg-doc", + "abc/${collectionGroup}" + }; + WriteBatch batch = firestore.batch(); + for (String path : docPaths) { + batch.set( + firestore.document(path.replace("${collectionGroup}", collectionGroup)), map("x", 1)); + } + batch.commit().get(); + + QuerySnapshot querySnapshot = firestore.collectionGroup(collectionGroup).get().get(); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals( + asList("cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5"), + querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5")); + } + } + + @Test + public void collectionGroupQueriesWithStartAtEndAtWithArbitraryDocumentIds() + throws ExecutionException, InterruptedException { + // Use `randomColl` to get a random collection group name to use but ensure it starts with 'b' + // for predictable ordering. + String collectionGroup = "b" + randomColl.getId(); + + String[] docPaths = + new String[] { + "a/a/${collectionGroup}/cg-doc1", + "a/b/a/b/${collectionGroup}/cg-doc2", + "a/b/${collectionGroup}/cg-doc3", + "a/b/c/d/${collectionGroup}/cg-doc4", + "a/c/${collectionGroup}/cg-doc5", + "${collectionGroup}/cg-doc6", + "a/b/nope/nope" + }; + WriteBatch batch = firestore.batch(); + for (String path : docPaths) { + batch.set( + firestore.document(path.replace("${collectionGroup}", collectionGroup)), map("x", 1)); + } + batch.commit().get(); + + QuerySnapshot querySnapshot = + firestore + .collectionGroup(collectionGroup) + .orderBy(FieldPath.documentId()) + .startAt("a/b") + .endAt("a/b0") + .get() + .get(); + assertEquals(asList("cg-doc2", "cg-doc3", "cg-doc4"), querySnapshotToIds(querySnapshot)); + + querySnapshot = + firestore + .collectionGroup(collectionGroup) + .orderBy(FieldPath.documentId()) + .startAfter("a/b") + .endBefore("a/b/" + collectionGroup + "/cg-doc3") + .get() + .get(); + assertEquals(asList("cg-doc2"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void collectionGroupQueriesWithWhereFiltersOnArbitraryDocumentIds() + throws ExecutionException, InterruptedException { + // Use `randomColl` to get a random collection group name to use but ensure it starts with 'b' + // for predictable ordering. + String collectionGroup = "b" + randomColl.getId(); + + String[] docPaths = + new String[] { + "a/a/${collectionGroup}/cg-doc1", + "a/b/a/b/${collectionGroup}/cg-doc2", + "a/b/${collectionGroup}/cg-doc3", + "a/b/c/d/${collectionGroup}/cg-doc4", + "a/c/${collectionGroup}/cg-doc5", + "${collectionGroup}/cg-doc6", + "a/b/nope/nope" + }; + + WriteBatch batch = firestore.batch(); + for (String path : docPaths) { + batch.set( + firestore.document(path.replace("${collectionGroup}", collectionGroup)), map("x", 1)); + } + batch.commit().get(); + + QuerySnapshot querySnapshot = + firestore + .collectionGroup(collectionGroup) + .whereGreaterThanOrEqualTo(FieldPath.documentId(), "a/b") + .whereLessThanOrEqualTo(FieldPath.documentId(), "a/b0") + .get() + .get(); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("cg-doc2", "cg-doc3", "cg-doc4"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("cg-doc2", "cg-doc3", "cg-doc4")); + } + + querySnapshot = + firestore + .collectionGroup(collectionGroup) + .whereGreaterThan(FieldPath.documentId(), "a/b") + .whereLessThan(FieldPath.documentId(), "a/b/" + collectionGroup + "/cg-doc3") + .get() + .get(); + assertEquals(asList("cg-doc2"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void inQueries() throws Exception { + setDocument("a", map("zip", 98101)); + setDocument("b", map("zip", 91102)); + setDocument("c", map("zip", 98103)); + setDocument("d", map("zip", asList(98101))); + setDocument("e", map("zip", asList("98101", map("zip", 98101)))); + setDocument("f", map("zip", map("code", 500))); + + QuerySnapshot querySnapshot = + randomColl.whereIn("zip", Arrays.asList(98101, 98103)).get().get(); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("a", "c"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)).containsExactlyElementsIn(asList("a", "c")); + } + } + + @Test + public void notEqualQueries() throws Exception { + setDocument("a", map("zip", Double.NaN)); + setDocument("b", map("zip", 91102)); + setDocument("c", map("zip", 98101)); + setDocument("d", map("zip", 98103)); + setDocument("e", map("zip", asList(98101))); + setDocument("f", map("zip", asList("98101", map("zip", 98101)))); + setDocument("g", map("zip", map("zip", 98101))); + setDocument("h", map("zip", null)); + + QuerySnapshot querySnapshot = randomColl.whereNotEqualTo("zip", 98101).get().get(); + switch (getFirestoreEdition()) { + case STANDARD: + assertEquals(asList("a", "b", "d", "e", "f", "g"), querySnapshotToIds(querySnapshot)); + break; + case ENTERPRISE: + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("a", "b", "d", "e", "f", "g", "h")); + break; + } + + querySnapshot = randomColl.whereNotEqualTo("zip", Double.NaN).get().get(); + switch (getFirestoreEdition()) { + case STANDARD: + assertEquals(asList("b", "c", "d", "e", "f", "g"), querySnapshotToIds(querySnapshot)); + break; + case ENTERPRISE: + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("b", "c", "d", "e", "f", "g", "h")); + break; + } + + querySnapshot = randomColl.whereNotEqualTo("zip", null).get().get(); + switch (getFirestoreEdition()) { + case STANDARD: + assertEquals(asList("a", "b", "c", "d", "e", "f", "g"), querySnapshotToIds(querySnapshot)); + break; + case ENTERPRISE: + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("a", "b", "c", "d", "e", "f", "g")); + break; + } + } + + @Test + public void notEqualQueriesWithDocumentId() throws Exception { + DocumentReference doc1 = setDocument("a", map("count", 1)); + DocumentReference doc2 = setDocument("b", map("count", 2)); + setDocument("c", map("count", 3)); + + QuerySnapshot querySnapshot = + randomColl.whereNotEqualTo(FieldPath.documentId(), doc1.getId()).get().get(); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("b", "c"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)).containsExactlyElementsIn(asList("b", "c")); + } + } + + @Test + public void inQueriesWithDocumentId() throws Exception { + DocumentReference doc1 = setDocument("a", map("count", 1)); + DocumentReference doc2 = setDocument("b", map("count", 2)); + setDocument("c", map("count", 3)); + + QuerySnapshot querySnapshot = + randomColl.whereIn(FieldPath.documentId(), Arrays.asList(doc1.getId(), doc2)).get().get(); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("a", "b"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)).containsExactlyElementsIn(asList("a", "b")); + } + } + + @Test + public void notInQueries() throws Exception { + setDocument("a", map("zip", 98101)); + setDocument("b", map("zip", 91102)); + setDocument("c", map("zip", 98103)); + setDocument("d", map("zip", asList(98101))); + setDocument("e", map("zip", asList("98101", map("zip", 98101)))); + setDocument("f", map("zip", map("code", 500))); + + QuerySnapshot querySnapshot = + randomColl.whereNotIn("zip", Arrays.asList(98101, 98103)).get().get(); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("b", "d", "e", "f"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("b", "d", "e", "f")); + } + + querySnapshot = randomColl.whereNotIn("zip", Arrays.asList(Double.NaN)).get().get(); + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("b", "a", "c", "d", "e", "f"), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("b", "a", "c", "d", "e", "f")); + } + + List nullArray = new ArrayList<>(); + nullArray.add(null); + querySnapshot = randomColl.whereNotIn("zip", nullArray).get().get(); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(new ArrayList<>(), querySnapshotToIds(querySnapshot)); + } else { + assertThat(querySnapshotToIds(querySnapshot)) + .containsExactlyElementsIn(asList("a", "b", "c", "d", "e", "f")); + } + } + + @Test + public void notInQueriesWithDocumentId() throws Exception { + DocumentReference doc1 = setDocument("a", map("count", 1)); + DocumentReference doc2 = setDocument("b", map("count", 2)); + setDocument("c", map("count", 3)); + + QuerySnapshot querySnapshot = + randomColl + .whereNotIn(FieldPath.documentId(), Arrays.asList(doc1.getId(), doc2)) + .get() + .get(); + + assertEquals(asList("c"), querySnapshotToIds(querySnapshot)); + } + + @Test + public void arrayContainsAnyQueries() throws Exception { + setDocument("a", map("array", asList(42))); + setDocument("b", map("array", asList("a", 42, "c"))); + setDocument("c", map("array", asList(41.999, "42", map("a", 42)))); + setDocument("d", map("array", asList(42), "array2", "sigh")); + setDocument("e", map("array", asList(43))); + setDocument("f", map("array", asList(map("a", 42)))); + setDocument("g", map("array", 42)); + + Query query = randomColl.whereArrayContainsAny("array", Arrays.asList(42, 43)); + + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(asList("a", "b", "d", "e"), querySnapshotToIds(query.get().get())); + } else { + assertThat(querySnapshotToIds(query.get().get())) + .containsExactlyElementsIn(asList("a", "b", "d", "e")); + } + } + + @Test + public void integerIncrement() throws ExecutionException, InterruptedException { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("sum", 1L)).get(); + docRef.update("sum", FieldValue.increment(2)).get(); + DocumentSnapshot docSnap = docRef.get().get(); + assertEquals(3L, docSnap.get("sum")); + } + + @Test + public void floatIncrement() throws ExecutionException, InterruptedException { + DocumentReference docRef = randomColl.document(); + docRef.set(Collections.singletonMap("sum", 1.1)).get(); + docRef.update("sum", FieldValue.increment(2.2)).get(); + DocumentSnapshot docSnap = docRef.get().get(); + assertEquals(3.3, (Double) docSnap.get("sum"), DOUBLE_EPSILON); + } + + @Test + public void getAllWithObserver() throws Exception { + DocumentReference ref1 = randomColl.document("doc1"); + ref1.set(ALL_SUPPORTED_TYPES_MAP).get(); + + DocumentReference ref2 = randomColl.document("doc2"); + ref2.set(ALL_SUPPORTED_TYPES_MAP).get(); + + DocumentReference ref3 = randomColl.document("doc3"); + + final DocumentReference[] documentReferences = {ref1, ref2, ref3}; + + StreamConsumer consumer = new StreamConsumer<>(); + firestore.getAll(documentReferences, FieldMask.of("foo"), consumer); + + final List documentSnapshots = consumer.consume().get(); + + assertEquals( + ALL_SUPPORTED_TYPES_OBJECT, documentSnapshots.get(0).toObject(AllSupportedTypes.class)); + assertEquals( + ALL_SUPPORTED_TYPES_OBJECT, documentSnapshots.get(1).toObject(AllSupportedTypes.class)); + assertNotEquals( + ALL_SUPPORTED_TYPES_OBJECT, documentSnapshots.get(2).toObject(AllSupportedTypes.class)); + + assertEquals(3, documentSnapshots.size()); + // Only standard edition returns the documents in the order of the request. + if (getFirestoreEdition() == FirestoreEdition.STANDARD) { + assertEquals(ref1.getId(), documentSnapshots.get(0).getId()); + assertEquals(ref2.getId(), documentSnapshots.get(1).getId()); + assertEquals(ref3.getId(), documentSnapshots.get(2).getId()); + } + } + + @Test + public void testInstanceReturnedByGetServiceCanBeUsedToDeserializeAQuery() throws Exception { + Firestore fs = FirestoreOptions.getDefaultInstance().getService(); + RunQueryRequest proto = fs.collection("coll").whereEqualTo("bob", "alice").toProto(); + fs.close(); + Query.fromProto(fs, proto); + } + + @Test + public void deleteNestedFieldUsingFieldPath() throws Exception { + DocumentReference documentReference = randomColl.document("doc1"); + documentReference.set(map("a.b", SINGLE_FILED_MAP_WITH_DOT)).get(); + DocumentSnapshot documentSnapshots = documentReference.get().get(); + assertEquals(SINGLE_FILED_MAP_WITH_DOT, documentSnapshots.getData().get("a.b")); + + FieldPath path = FieldPath.of("a.b", "c.d"); + documentReference.update(path, FieldValue.delete()).get(); + documentSnapshots = documentReference.get().get(); + assertNull(documentSnapshots.getData().get("c.d")); + } + + @Test + public void readOnlyTransaction_successfulGet() + throws ExecutionException, InterruptedException, TimeoutException { + final DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get(); + + final AtomicReference ref = new AtomicReference<>(); + + final ApiFuture runTransaction = + firestore.runTransaction( + transaction -> { + final DocumentSnapshot snapshot = + transaction.get(documentReference).get(5, TimeUnit.SECONDS); + ref.compareAndSet(null, snapshot); + return null; + }, + TransactionOptions.createReadOnlyOptionsBuilder().build()); + + runTransaction.get(10, TimeUnit.SECONDS); + assertEquals("bar", ref.get().get("foo")); + } + + @Test + public void readOnlyTransaction_failureWhenAttemptingWrite() + throws InterruptedException, TimeoutException { + + final DocumentReference documentReference = randomColl.document("tx/ro/writeShouldFail"); + final ApiFuture runTransaction = + firestore.runTransaction( + transaction -> { + transaction.set(documentReference, SINGLE_FIELD_MAP); + return null; + }, + TransactionOptions.createReadOnlyOptionsBuilder().build()); + + ExecutionException e = + assertThrows( + ExecutionException.class, + () -> { + runTransaction.get(10, TimeUnit.SECONDS); + }); + final Throwable cause = e.getCause(); + assertThat(cause).isInstanceOf(FirestoreException.class); + final Throwable rootCause = ExceptionUtils.getRootCause(cause); + assertThat(rootCause).isInstanceOf(StatusRuntimeException.class); + final StatusRuntimeException invalidArgument = (StatusRuntimeException) rootCause; + final Status status = invalidArgument.getStatus(); + assertThat(status.getCode()).isEqualTo(Code.INVALID_ARGUMENT); + assertThat(status.getDescription()).contains("read-only"); + } + + @Test + public void readOnlyTransaction_successfulRead() throws Exception { + DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get(); + + Timestamp firstWriteTime = + documentReference.set(Collections.singletonMap("counter", 1)).get().getUpdateTime(); + documentReference.set(Collections.singletonMap("counter", 2)).get(); + + final TransactionOptions options = + TransactionOptions.createReadOnlyOptionsBuilder() + .setReadTime( + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(firstWriteTime.getSeconds()) + .setNanos(firstWriteTime.getNanos())) + .build(); + + final ApiFuture runTransaction = + firestore.runTransaction( + transaction -> { + final DocumentSnapshot snapshot = + transaction.get(documentReference).get(5, TimeUnit.SECONDS); + return snapshot.getLong("counter"); + }, + options); + + assertEquals(1, runTransaction.get(10, TimeUnit.SECONDS).longValue()); + + DocumentSnapshot documentSnapshot = documentReference.get().get(); + assertEquals(2, (long) documentSnapshot.getData().get("counter")); + } + + @Test + public void readOnlyTransaction_failureWhenAttemptReadOlderThan60Seconds() + throws ExecutionException, InterruptedException, TimeoutException { + // Skip this test because emulator does not have this behavior. + assumeFalse( + "Skip this test when running against the emulator because it does not have this behavior.", + TestHelper.isRunningAgainstFirestoreEmulator(firestore)); + + final DocumentReference documentReference = randomColl.add(SINGLE_FIELD_MAP).get(); + + // Exception isn't thrown until 60 minutes. + // To ensure we exceed this, we use 120 minutes. + // If this test fails, we should likely be update documentation to reflect new value. See all + // usages of "Read Time" on proto, and within SDK. + // + // If Point-in-Time Recovery is enabled, can additionally be a whole minute timestamp within the + // past 7 days. For that reason `twoHours` is calculated to whole minute to more accurately + // catch this situation. + final long twoHours = (System.currentTimeMillis() / 60_000 - 120) * 60; + final TransactionOptions options = + TransactionOptions.createReadOnlyOptionsBuilder() + .setReadTime( + com.google.protobuf.Timestamp.newBuilder().setSeconds(twoHours).setNanos(0)) + .build(); + + final ApiFuture runTransaction = + firestore.runTransaction( + transaction -> { + transaction.get(documentReference).get(5, TimeUnit.SECONDS); + return null; + }, + options); + + ExecutionException e = + assertThrows(ExecutionException.class, () -> runTransaction.get(10, TimeUnit.SECONDS)); + final Throwable rootCause = ExceptionUtils.getRootCause(e); + assertThat(rootCause).isInstanceOf(StatusRuntimeException.class); + final StatusRuntimeException invalidArgument = (StatusRuntimeException) rootCause; + final Status status = invalidArgument.getStatus(); + assertThat(status.getCode()).isEqualTo(Code.FAILED_PRECONDITION); + } + + @Test + public void deserializeCustomList() throws Exception { + LocalFirestoreHelper.CustomList customList = new LocalFirestoreHelper.CustomList(); + customList.fooList = FOO_LIST; + DocumentReference documentReference = randomColl.document("doc1"); + documentReference.set(customList).get(); + DocumentSnapshot documentSnapshots = documentReference.get().get(); + LocalFirestoreHelper.CustomList targetCustomList = + documentSnapshots.toObject(LocalFirestoreHelper.CustomList.class); + + assertEquals(FOO_LIST, targetCustomList.fooList); + assertEquals(SINGLE_FIELD_OBJECT, targetCustomList.fooList.get(0)); + } + + @Test + public void deserializeCustomMap() throws Exception { + LocalFirestoreHelper.CustomMap customMap = new LocalFirestoreHelper.CustomMap(); + customMap.fooMap = FOO_MAP; + DocumentReference documentReference = randomColl.document("doc1"); + documentReference.set(customMap).get(); + DocumentSnapshot documentSnapshots = documentReference.get().get(); + LocalFirestoreHelper.CustomMap targetCustomMap = + documentSnapshots.toObject(LocalFirestoreHelper.CustomMap.class); + + assertEquals(FOO_MAP, targetCustomMap.fooMap); + assertEquals(SINGLE_FIELD_OBJECT, targetCustomMap.fooMap.get("customMap")); + } + + /** Wrapper around ApiStreamObserver that returns the results in a list. */ + private static class StreamConsumer implements ApiStreamObserver { + SettableApiFuture> done = SettableApiFuture.create(); + List results = Collections.synchronizedList(new ArrayList<>()); + + @Override + public void onNext(T element) { + results.add(element); + } + + @Override + public void onError(Throwable throwable) { + done.setException(throwable); + } + + @Override + public void onCompleted() { + done.set(results); + } + + public ApiFuture> consume() { + return done; + } + } + + @Test + public void testBuildingBundleWhenDocumentDoesNotExist() throws Exception { + FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle"); + DocumentSnapshot snapshot = randomDoc.get().get(); + bundleBuilder.add(snapshot); + + // Expected bundle elements are [bundleMetadata, documentMetadata] + List elements = toBundleElements(bundleBuilder.build().toByteBuffer()); + assertEquals(2, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), + snapshot.getReadTime().toProto(), + /*totalDocuments*/ 1, + /*expectEmptyContent*/ false); + assertEquals( + BundledDocumentMetadata.newBuilder() + .setExists(false) + .setName(fullPath(randomDoc, firestore.getOptions())) + .setReadTime(snapshot.getReadTime().toProto()) + .build(), + elements.get(1).getDocumentMetadata()); + } + + @Test + public void testBuildingBundleWithLimitQuery() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + + Query limitQuery = randomColl.orderBy("counter", Direction.DESCENDING).limit(1); + QuerySnapshot limitQuerySnap = limitQuery.get().get(); + FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle"); + bundleBuilder.add("limit", limitQuerySnap); + + // Expected bundle elements are [bundleMetadata, limitQuery, + // documentMetadata, document] + List elements = toBundleElements(bundleBuilder.build().toByteBuffer()); + assertEquals(4, elements.size()); + + verifyMetadata(elements.get(0).getMetadata(), limitQuerySnap.getReadTime().toProto(), 1, false); + + NamedQuery namedLimitQuery = elements.get(1).getNamedQuery(); + + verifyNamedQuery( + namedLimitQuery, + "limit", + limitQuerySnap.getReadTime().toProto(), + limitQuery, + LimitType.FIRST); + + verifyDocumentAndMeta( + elements.get(2).getDocumentMetadata(), + elements.get(3).getDocument(), + fullPath(randomColl.document("doc2"), firestore.getOptions()), + Lists.newArrayList("limit"), + randomColl.document("doc2").get().get(), + limitQuerySnap.getReadTime().toProto()); + } + + @Test + public void testBuildingBundleWithLimitToLastQuery() throws Exception { + setDocument("doc1", Collections.singletonMap("counter", 1)); + setDocument("doc2", Collections.singletonMap("counter", 2)); + + Query limitToLastQuery = randomColl.orderBy("counter").limitToLast(1); + QuerySnapshot limitToLastQuerySnap = limitToLastQuery.get().get(); + FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle"); + bundleBuilder.add("limitToLast", limitToLastQuerySnap); + + // Expected bundle elements are [bundleMetadata, limitToLastQuery, + // documentMetadata, document] + List elements = toBundleElements(bundleBuilder.build().toByteBuffer()); + assertEquals(4, elements.size()); + + verifyMetadata( + elements.get(0).getMetadata(), limitToLastQuerySnap.getReadTime().toProto(), 1, false); + + NamedQuery namedLimitToLastQuery = elements.get(1).getNamedQuery(); + + verifyNamedQuery( + namedLimitToLastQuery, + "limitToLast", + limitToLastQuerySnap.getReadTime().toProto(), + randomColl.orderBy("counter").limit(1), + LimitType.LAST); + + verifyDocumentAndMeta( + elements.get(2).getDocumentMetadata(), + elements.get(3).getDocument(), + fullPath(randomColl.document("doc2"), firestore.getOptions()), + Lists.newArrayList("limitToLast"), + randomColl.document("doc2").get().get(), + limitToLastQuerySnap.getReadTime().toProto()); + } + + private int countDocumentChildren(DocumentReference reference) { + int count = 0; + Iterable collections = reference.listCollections(); + for (CollectionReference collectionReference : collections) { + count += countCollectionChildren(collectionReference); + } + return count; + } + + private int countCollectionChildren(CollectionReference reference) { + int count = 0; + Iterable documents = reference.listDocuments(); + for (DocumentReference documentReference : documents) { + count += countDocumentChildren(documentReference) + 1; + } + return count; + } + + private void setupRecursiveDeleteTest() throws Exception { + // ROOT-DB + // └── randomCol + // ├── anna + // └── bob + // └── parentsCol + // ├── charlie + // └── daniel + // └── childCol + // ├── ernie + // └── francis + WriteBatch batch = firestore.batch(); + batch.set(randomColl.document("anna"), map("name", "anna")); + batch.set(randomColl.document("bob"), map("name", "bob")); + batch.set(randomColl.document("bob/parentsCol/charlie"), map("name", "charlie")); + batch.set(randomColl.document("bob/parentsCol/daniel"), map("name", "daniel")); + batch.set(randomColl.document("bob/parentsCol/daniel/childCol/ernie"), map("name", "ernie")); + batch.set( + randomColl.document("bob/parentsCol/daniel/childCol/francis"), map("name", "francis")); + batch.commit().get(); + } + + @Test + public void testRecursiveDeleteTopLevelCollection() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support showMissing", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + setupRecursiveDeleteTest(); + firestore.recursiveDelete(randomColl).get(); + assertEquals(0, countCollectionChildren(randomColl)); + } + + @Test + public void testRecursiveDeleteNestedCollection() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support showMissing", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + setupRecursiveDeleteTest(); + firestore.recursiveDelete(randomColl.document("bob").collection("parentsCol")).get(); + assertEquals(2, countCollectionChildren(randomColl)); + } + + @Test + public void testRecursiveDeleteNestedDocument() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support showMissing", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + setupRecursiveDeleteTest(); + DocumentReference document = randomColl.document("bob/parentsCol/daniel"); + firestore.recursiveDelete(document).get(); + DocumentSnapshot snap = document.get().get(); + assertFalse(snap.exists()); + assertEquals(1, countDocumentChildren(randomColl.document("bob"))); + assertEquals(3, countCollectionChildren(randomColl)); + } + + @Test + public void testRecursiveDeleteLeafDocument() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support showMissing", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + setupRecursiveDeleteTest(); + DocumentReference document = randomColl.document("bob/parentsCol/daniel/childCol/ernie"); + firestore.recursiveDelete(document).get(); + DocumentSnapshot snap = document.get().get(); + assertFalse(snap.exists()); + assertEquals(5, countCollectionChildren(randomColl)); + } + + @Ignore("Flaky with graalvm-native-a") + @Test + public void testRecursiveDeleteDoesNotAffectOtherCollections() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support showMissing", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + setupRecursiveDeleteTest(); + + // Add another nested collection that shouldn't be deleted. + CollectionReference collectionB = firestore.collection("doggos"); + collectionB.document("doggo").set(map("name", "goodboi")).get(); + + firestore.recursiveDelete(collectionB).get(); + assertEquals(6, countCollectionChildren(randomColl)); + assertEquals(0, countCollectionChildren(collectionB)); + } + + @Test + public void testRecursiveDeleteWithCustomBulkWriterInstance() throws Exception { + assumeFalse( + "Skip this test when running against enterprise because it does not support" + + " bulk writer.", + getFirestoreEdition() == FirestoreEdition.ENTERPRISE); + + setupRecursiveDeleteTest(); + + BulkWriter bulkWriter = firestore.bulkWriter(); + final int[] callbackCount = {0}; + bulkWriter.addWriteResultListener((documentReference, result) -> callbackCount[0]++); + + firestore.recursiveDelete(randomColl, bulkWriter).get(); + assertEquals(0, countCollectionChildren(randomColl)); + assertEquals(6, callbackCount[0]); + } + + @Test + public void testEnforcesTimeouts() { + FirestoreOptions firestoreOptions = + FirestoreOptions.newBuilder() + .setRetrySettings( + RetrySettings.newBuilder() + .setMaxRpcTimeoutDuration(Duration.ofMillis(1)) + .setTotalTimeoutDuration(Duration.ofMillis(1)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(1)) + .build()) + .build(); + firestore = firestoreOptions.getService(); + CollectionReference collection = firestore.collection("timeout"); + + // RunQuery + assertThrows(ExecutionException.class, () -> collection.get().get()); + // CommitRequest + assertThrows(ExecutionException.class, () -> collection.add(map()).get()); + // BulkCommit + assertThrows( + ExecutionException.class, + () -> { + BulkWriter bulkWriter = firestore.bulkWriter(); + ApiFuture op = bulkWriter.set(collection.document(), map()); + bulkWriter.close(); + op.get(); + }); + // BatchGetDocuments + assertThrows(ExecutionException.class, () -> collection.document().get().get()); + // ListDocuments + assertThrows(FirestoreException.class, () -> collection.listDocuments().iterator().hasNext()); + // ListCollections + assertThrows( + FirestoreException.class, + () -> collection.document().listCollections().iterator().hasNext()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTest.java new file mode 100644 index 000000000000..be4ef4485dd1 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTest.java @@ -0,0 +1,840 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import static com.google.cloud.firestore.it.ITBaseTest.getFirestoreEdition; +import static com.google.cloud.firestore.telemetry.TelemetryConstants.*; +import static com.google.cloud.firestore.telemetry.TraceUtil.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; +import static org.junit.Assume.assumeTrue; + +import com.google.cloud.firestore.BulkWriter; +import com.google.cloud.firestore.BulkWriterOptions; +import com.google.cloud.firestore.CollectionGroup; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.FieldMask; +import com.google.cloud.firestore.FieldPath; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOpenTelemetryOptions; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.Precondition; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.SetOptions; +import com.google.cloud.firestore.WriteBatch; +import com.google.cloud.firestore.it.ITBaseTest.FirestoreEdition; +import com.google.common.base.Preconditions; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; +import io.opentelemetry.api.trace.StatusCode; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import io.opentelemetry.sdk.OpenTelemetrySdkBuilder; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.resources.Resource; +import io.opentelemetry.sdk.testing.exporter.InMemorySpanExporter; +import io.opentelemetry.sdk.trace.SdkTracerProvider; +import io.opentelemetry.sdk.trace.SpanProcessor; +import io.opentelemetry.sdk.trace.data.EventData; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import io.opentelemetry.sdk.trace.samplers.Sampler; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nullable; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public abstract class ITTracingTest { + protected abstract boolean isUsingGlobalOpenTelemetrySDK(); + + private static final Logger logger = + Logger.getLogger(com.google.cloud.firestore.it.ITTracingTest.class.getName()); + + private static final int TRACE_FORCE_FLUSH_MILLIS = 1000; + private static final int TRACE_PROVIDER_SHUTDOWN_MILLIS = 1000; + private static final int IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS = 50; + private static final String SERVICE = "google.firestore.v1.Firestore/"; + private static final String BATCH_GET_DOCUMENTS_RPC_NAME = "BatchGetDocuments"; + private static final String COMMIT_RPC_NAME = "Commit"; + private static final String LIST_DOCUMENTS_RPC_NAME = "ListDocuments"; + private static final String LIST_COLLECTIONS_RPC_NAME = "ListCollectionIds"; + private static final String BATCH_WRITE_RPC_NAME = "BatchWrite"; + private static final String RUN_QUERY_RPC_NAME = "RunQuery"; + private static final String RUN_AGGREGATION_QUERY_RPC_NAME = "RunAggregationQuery"; + private static final String BEGIN_TRANSACTION_RPC_NAME = "BeginTransaction"; + private static final String ROLLBACK_RPC_NAME = "Rollback"; + + private static OpenTelemetrySdk openTelemetrySdk; + + // We use an InMemorySpanExporter for testing which keeps all generated trace spans + // in memory so that we can check their correctness. + protected InMemorySpanExporter inMemorySpanExporter; + + protected Firestore firestore; + + Map spanNameToSpanId = new HashMap<>(); + Map spanIdToParentSpanId = new HashMap<>(); + Map spanNameToSpanData = new HashMap<>(); + + @Rule public TestName testName = new TestName(); + + @Before + public void before() { + inMemorySpanExporter = InMemorySpanExporter.create(); + + Resource resource = Resource.getDefault(); + SpanProcessor inMemorySpanProcessor = SimpleSpanProcessor.create(inMemorySpanExporter); + FirestoreOptions.Builder optionsBuilder = FirestoreOptions.newBuilder(); + FirestoreOpenTelemetryOptions.Builder otelOptionsBuilder = + FirestoreOpenTelemetryOptions.newBuilder(); + OpenTelemetrySdkBuilder openTelemetrySdkBuilder = + OpenTelemetrySdk.builder() + .setTracerProvider( + SdkTracerProvider.builder() + .setResource(resource) + .addSpanProcessor(inMemorySpanProcessor) + .setSampler(Sampler.alwaysOn()) + .build()); + + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + openTelemetrySdk = openTelemetrySdkBuilder.buildAndRegisterGlobal(); + optionsBuilder.setOpenTelemetryOptions(otelOptionsBuilder.build()); + } else { + openTelemetrySdk = openTelemetrySdkBuilder.build(); + optionsBuilder.setOpenTelemetryOptions( + otelOptionsBuilder.setOpenTelemetry(openTelemetrySdk).build()); + } + + String namedDb = System.getProperty("FIRESTORE_NAMED_DATABASE"); + if (namedDb != null) { + logger.log( + Level.INFO, + String.format( + "Integration test using named database %s for test %s", + namedDb, testName.getMethodName())); + optionsBuilder = optionsBuilder.setDatabaseId(namedDb); + } else { + logger.log( + Level.INFO, + String.format( + "Integration test using default database for test %s", testName.getMethodName())); + } + firestore = optionsBuilder.build().getService(); + + assumeFalse( + "ITTracingTest is not supported against the emulator.", + "EMULATOR".equals(ITBaseTest.getTargetBackend())); + + // Clean up existing maps. + spanNameToSpanId.clear(); + spanIdToParentSpanId.clear(); + spanNameToSpanData.clear(); + } + + @After + public void after() throws Exception { + Preconditions.checkNotNull( + firestore, + "Error instantiating Firestore. Check that the service account credentials were properly" + + " set."); + firestore.shutdown(); + inMemorySpanExporter.reset(); + } + + @AfterClass + public static void teardown() { + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().shutdown(); + completableResultCode.join(TRACE_PROVIDER_SHUTDOWN_MILLIS, TimeUnit.MILLISECONDS); + } + + void waitForTracesToComplete() throws Exception { + // We need to call `firestore.close()` because that will also close the + // gRPC channel and hence force the gRPC instrumentation library to flush + // its spans. + firestore.close(); + + // The same way that querying the Cloud Trace backend may not give us the + // full trace on the first try, querying the in-memory traces may not result + // in the full trace immediately. Note that performing the `flush` is not + // enough. This doesn't pose an issue in practice, but can make tests flaky. + // Therefore, we're adding a delay to make sure we avoid any flakiness. + inMemorySpanExporter.flush().join(IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS, TimeUnit.MILLISECONDS); + TimeUnit.MILLISECONDS.sleep(IN_MEMORY_SPAN_EXPORTER_DELAY_MILLIS); + + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().forceFlush(); + completableResultCode.join(TRACE_FORCE_FLUSH_MILLIS, TimeUnit.MILLISECONDS); + } + + // Prepares all the spans in memory for inspection. + List prepareSpans() throws Exception { + waitForTracesToComplete(); + List spans = inMemorySpanExporter.getFinishedSpanItems(); + buildSpanMaps(spans); + printSpans(); + return spans; + } + + void buildSpanMaps(List spans) { + for (SpanData spanData : spans) { + spanNameToSpanData.put(spanData.getName(), spanData); + spanNameToSpanId.put(spanData.getName(), spanData.getSpanId()); + spanIdToParentSpanId.put(spanData.getSpanId(), spanData.getParentSpanId()); + } + } + + // Returns the SpanData object for the span with the given name. + // Returns null if no span with the given name exists. + @Nullable + SpanData getSpanByName(String spanName) { + return spanNameToSpanData.get(spanName); + } + + // Returns the SpanData object for the gRPC span with the given RPC name. + // Returns null if no such span exists. + @Nullable + SpanData getGrpcSpanByName(String rpcName) { + return getSpanByName(SERVICE + rpcName); + } + + String grpcSpanName(String rpcName) { + return SERVICE + rpcName; + } + + void assertSameTrace(SpanData... spans) { + if (spans.length > 1) { + String traceId = spans[0].getTraceId(); + for (SpanData spanData : spans) { + assertEquals(traceId, spanData.getTraceId()); + } + } + } + + // Helper to see the spans in standard output while developing tests + void printSpans() { + for (SpanData spanData : spanNameToSpanData.values()) { + logger.log( + Level.FINE, + String.format( + "SPAN ID:%s, ParentID:%s, KIND:%s, TRACE ID:%s, NAME:%s, ATTRIBUTES:%s, EVENTS:%s\n", + spanData.getSpanId(), + spanData.getParentSpanId(), + spanData.getKind(), + spanData.getTraceId(), + spanData.getName(), + spanData.getAttributes().toString(), + spanData.getEvents().toString())); + } + } + + // Asserts that the span hierarchy exists for the given span names. The hierarchy starts with the + // root span, followed + // by the child span, grandchild span, and so on. It also asserts that all the given spans belong + // to the same trace, + // and that Firestore-generated spans contain the expected Firestore attributes. + void assertSpanHierarchy(String... spanNamesHierarchy) { + List spanNames = Arrays.asList(spanNamesHierarchy); + + for (int i = 0; i + 1 < spanNames.size(); ++i) { + String parentSpanName = spanNames.get(i); + String childSpanName = spanNames.get(i + 1); + SpanData parentSpan = getSpanByName(parentSpanName); + SpanData childSpan = getSpanByName(childSpanName); + assertNotNull(parentSpan); + assertNotNull(childSpan); + assertEquals(childSpan.getParentSpanId(), parentSpan.getSpanId()); + assertSameTrace(childSpan, parentSpan); + // gRPC spans do not have Firestore attributes. + if (!parentSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(parentSpan); + } + if (!childSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(childSpan); + } + } + } + + void assertHasExpectedAttributes(SpanData spanData, String... additionalExpectedAttributes) { + // All Firestore-generated spans have the settings attributes. + List expectedAttributes = + Arrays.asList( + "gcp.resource.name", + "gcp.firestore.memory_utilization", + "gcp.firestore.settings.host", + "gcp.firestore.settings.project_id", + "gcp.firestore.settings.database_id", + "gcp.firestore.settings.channel.needs_credentials", + "gcp.firestore.settings.channel.needs_endpoint", + "gcp.firestore.settings.channel.needs_headers", + "gcp.firestore.settings.channel.should_auto_close", + "gcp.firestore.settings.channel.transport_name", + "gcp.firestore.settings.retry_settings.max_rpc_timeout", + "gcp.firestore.settings.retry_settings.retry_delay_multiplier", + "gcp.firestore.settings.retry_settings.initial_retry_delay", + "gcp.firestore.settings.credentials.authentication_type", + "gcp.firestore.settings.retry_settings.max_attempts", + "gcp.firestore.settings.retry_settings.max_retry_delay", + "gcp.firestore.settings.retry_settings.rpc_timeout_multiplier", + "gcp.firestore.settings.retry_settings.total_timeout", + "gcp.firestore.settings.retry_settings.initial_rpc_timeout"); + + expectedAttributes.addAll(Arrays.asList(additionalExpectedAttributes)); + + Attributes spanAttributes = spanData.getAttributes(); + for (String expectedAttribute : expectedAttributes) { + assertNotNull(spanAttributes.get(AttributeKey.stringKey(expectedAttribute))); + } + } + + // Returns true if and only if the given span data contains an event with the given name and the + // given expected + // attributes. + boolean hasEvent(SpanData spanData, String eventName, @Nullable Attributes expectedAttributes) { + if (spanData == null) { + return false; + } + + logger.log( + Level.INFO, + String.format( + "Checking if span named '%s' (ID='%s') contains an event named '%s'", + spanData.getName(), spanData.getSpanId(), eventName)); + + List events = spanData.getEvents(); + for (EventData event : events) { + if (event.getName().equals(eventName)) { + if (expectedAttributes == null) { + return true; + } + + // Make sure attributes also match. + Attributes eventAttributes = event.getAttributes(); + return expectedAttributes.equals(eventAttributes); + } + } + return false; + } + + // This is a POJO used for testing APIs that take a POJO. + public static class Pojo { + public int bar; + + public Pojo() { + bar = 0; + } + + public Pojo(int bar) { + this.bar = bar; + } + + public int getBar() { + return bar; + } + + public void setBar(int bar) { + this.bar = bar; + } + } + + @Test + public void aggregateQueryGet() throws Exception { + firestore.collection("col").count().get().get(); + waitForTracesToComplete(); + List spans = inMemorySpanExporter.getFinishedSpanItems(); + buildSpanMaps(spans); + assertEquals(2, spans.size()); + SpanData getSpan = getSpanByName(METHOD_NAME_AGGREGATION_QUERY_GET); + SpanData grpcSpan = getGrpcSpanByName(METHOD_NAME_RUN_AGGREGATION_QUERY); + assertNotNull(getSpan); + assertNotNull(grpcSpan); + assertEquals(grpcSpan.getParentSpanId(), getSpan.getSpanId()); + assertSameTrace(getSpan, grpcSpan); + assertHasExpectedAttributes(getSpan); + List events = getSpan.getEvents(); + assertTrue(events.size() > 0); + assertTrue(events.get(0).getAttributes().size() > 0); + assertEquals(events.get(0).getName(), "RunAggregationQuery Stream started."); + assertEquals( + events.get(0).getAttributes().get(AttributeKey.longKey(ATTRIBUTE_KEY_ATTEMPT)).longValue(), + 0); + } + + @Test + public void bulkWriterCommit() throws Exception { + ScheduledExecutorService bulkWriterExecutor = Executors.newSingleThreadScheduledExecutor(); + BulkWriter bulkWriter = + firestore.bulkWriter(BulkWriterOptions.builder().setExecutor(bulkWriterExecutor).build()); + bulkWriter.set( + firestore.collection("col").document("foo"), + Collections.singletonMap("bulk-foo", "bulk-bar")); + bulkWriter.close(); + bulkWriterExecutor.awaitTermination(100, TimeUnit.MILLISECONDS); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_BULK_WRITER_COMMIT, grpcSpanName(BATCH_WRITE_RPC_NAME)); + } + + @Test + public void partitionQuery() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support partition" + + " query", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + + CollectionGroup collectionGroup = firestore.collectionGroup("col"); + collectionGroup.getPartitions(3).get(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_PARTITION_QUERY, grpcSpanName(METHOD_NAME_PARTITION_QUERY)); + } + + @Test + public void collectionListDocuments() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support listDocuments", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + + firestore.collection("col").listDocuments(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_COL_REF_LIST_DOCUMENTS, grpcSpanName(LIST_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docRefCreate() throws Exception { + firestore.collection("col").document().create(Collections.singletonMap("foo", "bar")).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_CREATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefCreate2() throws Exception { + firestore.collection("col").document().create(new Pojo(1)).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_CREATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet() throws Exception { + firestore.collection("col").document("foo").set(Collections.singletonMap("foo", "bar")).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_SET, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet2() throws Exception { + firestore + .collection("col") + .document("foo") + .set(Collections.singletonMap("foo", "bar"), SetOptions.merge()) + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_SET, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet3() throws Exception { + firestore.collection("col").document("foo").set(new Pojo(1)).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_SET, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefSet4() throws Exception { + firestore.collection("col").document("foo").set(new Pojo(1), SetOptions.merge()).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_SET, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate() throws Exception { + firestore + .collection("col") + .document("foo") + .update(Collections.singletonMap("foo", "bar")) + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate2() throws Exception { + firestore + .collection("col") + .document("foo") + .update(Collections.singletonMap("foo", "bar"), Precondition.NONE) + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate3() throws Exception { + firestore.collection("col").document("foo").update("key", "value", "key2", "value2").get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate4() throws Exception { + firestore + .collection("col") + .document("foo") + .update(FieldPath.of("key"), "value", FieldPath.of("key2"), "value2") + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate5() throws Exception { + firestore + .collection("col") + .document("foo") + .update(Precondition.NONE, "key", "value", "key2", "value2") + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefUpdate6() throws Exception { + firestore + .collection("col") + .document("foo") + .update(Precondition.NONE, FieldPath.of("key"), "value", FieldPath.of("key2"), "value2") + .get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_UPDATE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefDelete() throws Exception { + firestore.collection("col").document("doc0").delete().get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_DELETE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefDelete2() throws Exception { + firestore.collection("col").document("doc0").delete(Precondition.NONE).get(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_DELETE, METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + } + + @Test + public void docRefGet() throws Exception { + firestore.collection("col").document("doc0").get().get(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_DOC_REF_GET, grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docRefGet2() throws Exception { + firestore.collection("col").document("doc0").get(FieldMask.of("foo")).get(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_DOC_REF_GET, grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + } + + @Test + public void docListCollections() throws Exception { + assumeTrue( + "Skip this test when running against enterprise because it does not support" + + " listCollections", + getFirestoreEdition() != FirestoreEdition.ENTERPRISE); + + firestore.collection("col").document("doc0").listCollections(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy( + METHOD_NAME_DOC_REF_LIST_COLLECTIONS, grpcSpanName(LIST_COLLECTIONS_RPC_NAME)); + } + + @Test + public void getAll() throws Exception { + DocumentReference docRef0 = firestore.collection("col").document(); + DocumentReference docRef1 = firestore.collection("col").document(); + DocumentReference[] docs = {docRef0, docRef1}; + firestore.getAll(docs).get(); + List spans = prepareSpans(); + assertEquals(1, spans.size()); + SpanData span = getSpanByName(grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + assertTrue(hasEvent(span, "BatchGetDocuments: First response received", null)); + assertTrue( + hasEvent( + span, + "BatchGetDocuments: Completed with 2 responses.", + Attributes.builder().put(ATTRIBUTE_KEY_NUM_RESPONSES, 2).build())); + } + + @Test + public void queryGet() throws Exception { + firestore.collection("col").whereEqualTo("foo", "my_non_existent_value").get().get(); + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_QUERY_GET, grpcSpanName(RUN_QUERY_RPC_NAME)); + SpanData span = getSpanByName(METHOD_NAME_QUERY_GET); + assertTrue( + hasEvent( + span, + "RunQuery", + Attributes.builder() + .put(ATTRIBUTE_KEY_IS_RETRY_WITH_CURSOR, false) + .put(ATTRIBUTE_KEY_IS_TRANSACTIONAL, false) + .build())); + assertTrue( + hasEvent( + span, + "RunQuery: Completed", + Attributes.builder().put(ATTRIBUTE_KEY_DOC_COUNT, 0).build())); + } + + @Test + public void transaction() throws Exception { + firestore + .runTransaction( + transaction -> { + Query q = firestore.collection("col").whereGreaterThan("bla", ""); + DocumentReference d = firestore.collection("col").document("foo"); + DocumentReference[] docList = {d, d}; + // Document Query. + transaction.get(q).get(); + + // Aggregation Query. + transaction.get(q.count()); + + // Get multiple documents. + transaction.getAll(d, d).get(); + + // Commit 2 documents. + transaction.set( + firestore.collection("foo").document("bar"), + Collections.singletonMap("foo", "bar")); + transaction.set( + firestore.collection("foo").document("bar2"), + Collections.singletonMap("foo2", "bar2")); + return 0; + }) + .get(); + + /* + Transaction.Run + |_ Transaction.Begin + |_ Transaction.Get.Query + |_ Transaction.Get.AggregateQuery + |_ Transaction.Get.Documents + |_ Transaction.Get.Documents + |_ Transaction.Get.Commit + */ + List spans = prepareSpans(); + assertEquals(11, spans.size()); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_BEGIN, + grpcSpanName(BEGIN_TRANSACTION_RPC_NAME)); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_QUERY, + grpcSpanName(RUN_QUERY_RPC_NAME)); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_AGGREGATION_QUERY, + grpcSpanName(RUN_AGGREGATION_QUERY_RPC_NAME)); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_GET_DOCUMENTS, + grpcSpanName(BATCH_GET_DOCUMENTS_RPC_NAME)); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, METHOD_NAME_TRANSACTION_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + + Attributes commitAttributes = getSpanByName(METHOD_NAME_TRANSACTION_COMMIT).getAttributes(); + assertEquals( + 2L, + commitAttributes + .get(AttributeKey.longKey("gcp.firestore." + ATTRIBUTE_KEY_DOC_COUNT)) + .longValue()); + + Attributes runTransactionAttributes = + getSpanByName(METHOD_NAME_TRANSACTION_RUN).getAttributes(); + assertEquals( + 5L, + runTransactionAttributes + .get(AttributeKey.longKey("gcp.firestore." + ATTRIBUTE_KEY_ATTEMPTS_ALLOWED)) + .longValue()); + assertEquals( + 5L, + runTransactionAttributes + .get(AttributeKey.longKey("gcp.firestore." + ATTRIBUTE_KEY_ATTEMPTS_REMAINING)) + .longValue()); + assertEquals( + "READ_WRITE", + runTransactionAttributes.get( + AttributeKey.stringKey("gcp.firestore." + ATTRIBUTE_KEY_TRANSACTION_TYPE))); + } + + @Test + public void transactionRollback() throws Exception { + String myErrorMessage = "My error message."; + try { + firestore + .runTransaction( + transaction -> { + if (true) { + throw (new Exception(myErrorMessage)); + } + return 0; + }) + .get(); + } catch (Exception e) { + // Catch and move on. + } + + /* + Transaction.Run + |_ Transaction.Begin + |_ Transaction.Rollback + */ + List spans = prepareSpans(); + assertEquals(5, spans.size()); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_BEGIN, + grpcSpanName(BEGIN_TRANSACTION_RPC_NAME)); + assertSpanHierarchy( + METHOD_NAME_TRANSACTION_RUN, + METHOD_NAME_TRANSACTION_ROLLBACK, + grpcSpanName(ROLLBACK_RPC_NAME)); + + SpanData runTransactionSpanData = getSpanByName(METHOD_NAME_TRANSACTION_RUN); + assertEquals(StatusCode.ERROR, runTransactionSpanData.getStatus().getStatusCode()); + assertEquals(1, runTransactionSpanData.getEvents().size()); + assertEquals( + myErrorMessage, + runTransactionSpanData + .getEvents() + .get(0) + .getAttributes() + .get(AttributeKey.stringKey("exception.message"))); + assertEquals( + "java.lang.Exception", + runTransactionSpanData + .getEvents() + .get(0) + .getAttributes() + .get(AttributeKey.stringKey("exception.type"))); + assertTrue( + runTransactionSpanData + .getEvents() + .get(0) + .getAttributes() + .get(AttributeKey.stringKey("exception.stacktrace")) + .startsWith("java.lang.Exception: My error message.")); + } + + @Test + public void writeBatch() throws Exception { + WriteBatch batch = firestore.batch(); + DocumentReference docRef = firestore.collection("foo").document(); + batch.create(docRef, Collections.singletonMap("foo", "bar")); + batch.update(docRef, Collections.singletonMap("foo", "bar")); + batch.delete(docRef); + batch.commit().get(); + + List spans = prepareSpans(); + assertEquals(2, spans.size()); + assertSpanHierarchy(METHOD_NAME_BATCH_COMMIT, grpcSpanName(COMMIT_RPC_NAME)); + assertEquals( + false, + getSpanByName(METHOD_NAME_BATCH_COMMIT) + .getAttributes() + .get(AttributeKey.booleanKey("gcp.firestore." + ATTRIBUTE_KEY_IS_TRANSACTIONAL)) + .booleanValue()); + assertEquals( + 3L, + getSpanByName(METHOD_NAME_BATCH_COMMIT) + .getAttributes() + .get(AttributeKey.longKey("gcp.firestore." + ATTRIBUTE_KEY_DOC_COUNT)) + .longValue()); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestGlobalOtel.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestGlobalOtel.java new file mode 100644 index 000000000000..89495ed501c9 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestGlobalOtel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.it; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITTracingTestGlobalOtel extends ITTracingTest { + @Override + protected boolean isUsingGlobalOpenTelemetrySDK() { + return true; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestNonGlobalOtel.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestNonGlobalOtel.java new file mode 100644 index 000000000000..490b68b50c56 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITTracingTestNonGlobalOtel.java @@ -0,0 +1,27 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.it; + +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITTracingTestNonGlobalOtel extends ITTracingTest { + @Override + protected boolean isUsingGlobalOpenTelemetrySDK() { + return false; + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/TestHelper.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/TestHelper.java new file mode 100644 index 000000000000..ad851e4be928 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/TestHelper.java @@ -0,0 +1,58 @@ +/* + * Copyright 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.it; + +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.Firestore; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; + +public final class TestHelper { + /** Make constructor private to prevent creating instances. */ + private TestHelper() {} + + /** Returns whether the tests are running against the Firestore emulator. */ + static boolean isRunningAgainstFirestoreEmulator(Firestore firestore) { + return firestore.getOptions().getEmulatorHost() != null; + } + + /** + * Blocks the calling thread until the given future completes. Note that this method does not + * check the success or failure of the future; it returns regardless of its success or failure. + */ + public static void await(ApiFuture future) throws InterruptedException { + AtomicBoolean done = new AtomicBoolean(false); + ExecutorService executor = Executors.newSingleThreadExecutor(); + future.addListener( + () -> { + synchronized (done) { + done.set(true); + done.notifyAll(); + } + }, + executor); + + synchronized (done) { + while (!done.get()) { + done.wait(); + } + } + + executor.shutdown(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpcTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpcTest.java new file mode 100644 index 000000000000..3cf7025d0ffc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/spi/v1/GrpcFirestoreRpcTest.java @@ -0,0 +1,352 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.spi.v1; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.api.gax.retrying.ExponentialRetryAlgorithm; +import com.google.api.gax.retrying.RetryAlgorithm; +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.retrying.ScheduledRetryingExecutor; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.StatusCode.Code; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.v1.FirestoreClient.ListDocumentsPagedResponse; +import com.google.cloud.firestore.v1.FirestoreClient.PartitionQueryPagedResponse; +import com.google.cloud.firestore.v1.stub.FirestoreStubSettings; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.Set; +import org.junit.BeforeClass; +import org.junit.Test; + +public class GrpcFirestoreRpcTest { + + private static FirestoreStubSettings defaultStubSettings; + + private final FirestoreOptions firestoreOptionsWithoutOverride = + FirestoreOptions.newBuilder().setProjectId("test-project").build(); + + @BeforeClass + public static void beforeClass() throws IOException { + defaultStubSettings = FirestoreStubSettings.newBuilder().build(); + } + + static T getViaReflection(Object o, String fieldName) + throws NoSuchFieldException, IllegalAccessException { + return getViaReflection(o.getClass(), fieldName, o); + } + + static T getViaReflection(Class clazz, String fieldName, Object o) + throws NoSuchFieldException, IllegalAccessException { + Field field = clazz.getDeclaredField(fieldName); + field.setAccessible(true); + return (T) field.get(o); + } + + @Test + public void retrySettingsOverride() throws Exception { + RetrySettings retrySettings = RetrySettings.newBuilder().setMaxAttempts(2).build(); + FirestoreOptions firestoreOptions = + FirestoreOptions.newBuilder() + .setProjectId("test-project") + .setRetrySettings(retrySettings) + .build(); + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptions); + + CallableRetryData commit = getRetryData(grpcFirestoreRpc.commitCallable()); + assertThat(commit.retrySettings).isEqualTo(retrySettings); + assertThat(commit.retryableCodes) + .containsExactlyElementsIn(defaultStubSettings.commitSettings().getRetryableCodes()); + + CallableRetryData batchWrite = getRetryData(grpcFirestoreRpc.batchWriteCallable()); + assertThat(batchWrite.retrySettings).isEqualTo(retrySettings); + assertThat(batchWrite.retryableCodes) + .containsExactlyElementsIn(defaultStubSettings.batchWriteSettings().getRetryableCodes()); + + CallableRetryData batchGetDocuments = + getRetryData(grpcFirestoreRpc.batchGetDocumentsCallable()); + assertThat(batchGetDocuments.retrySettings).isEqualTo(retrySettings); + assertThat(batchGetDocuments.retryableCodes) + .containsExactlyElementsIn( + defaultStubSettings.batchGetDocumentsSettings().getRetryableCodes()); + + CallableRetryData runQuery = getRetryData(grpcFirestoreRpc.runQueryCallable()); + assertThat(runQuery.retrySettings).isEqualTo(retrySettings); + assertThat(runQuery.retryableCodes) + .containsExactlyElementsIn(defaultStubSettings.runQuerySettings().getRetryableCodes()); + + CallableRetryData runAggregationQuery = + getRetryData(grpcFirestoreRpc.runAggregationQueryCallable()); + assertThat(runAggregationQuery.retrySettings).isEqualTo(retrySettings); + assertThat(runAggregationQuery.retryableCodes) + .containsExactlyElementsIn( + defaultStubSettings.runAggregationQuerySettings().getRetryableCodes()); + + CallableRetryData beginTransaction = getRetryData(grpcFirestoreRpc.beginTransactionCallable()); + assertThat(beginTransaction.retrySettings).isEqualTo(retrySettings); + assertThat(beginTransaction.retryableCodes) + .containsExactlyElementsIn( + defaultStubSettings.beginTransactionSettings().getRetryableCodes()); + + CallableRetryData rollback = getRetryData(grpcFirestoreRpc.rollbackCallable()); + assertThat(rollback.retrySettings).isEqualTo(retrySettings); + assertThat(rollback.retryableCodes) + .containsExactlyElementsIn(defaultStubSettings.rollbackSettings().getRetryableCodes()); + + CallableRetryData listCollectionIdsPaged = + getRetryData(grpcFirestoreRpc.listCollectionIdsPagedCallable()); + assertThat(listCollectionIdsPaged.retrySettings).isEqualTo(retrySettings); + assertThat(listCollectionIdsPaged.retryableCodes) + .containsExactlyElementsIn( + defaultStubSettings.listCollectionIdsSettings().getRetryableCodes()); + + CallableRetryData partitionQueryPaged = + getRetryData(grpcFirestoreRpc.partitionQueryPagedCallable()); + assertThat(partitionQueryPaged.retrySettings).isEqualTo(retrySettings); + assertThat(partitionQueryPaged.retryableCodes) + .containsExactlyElementsIn( + defaultStubSettings.partitionQuerySettings().getRetryableCodes()); + + CallableRetryData listDocumentsPaged = + getRetryData(grpcFirestoreRpc.listDocumentsPagedCallable()); + assertThat(listDocumentsPaged.retrySettings).isEqualTo(retrySettings); + assertThat(listDocumentsPaged.retryableCodes) + .containsExactlyElementsIn(defaultStubSettings.listDocumentsSettings().getRetryableCodes()); + } + + private static RetrySettings withMaxAttempt5(RetrySettings retrySettings) { + return retrySettings.toBuilder().setMaxAttempts(5).build(); + } + + @Test + public void commitCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.commitCallable()); + UnaryCallSettings expectedSettings = + defaultStubSettings.commitSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void batchWriteCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.batchWriteCallable()); + UnaryCallSettings expectedSettings = + defaultStubSettings.batchWriteSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void batchGetDocumentsCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.batchGetDocumentsCallable()); + ServerStreamingCallSettings + expectedSettings = defaultStubSettings.batchGetDocumentsSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void runQueryCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.runQueryCallable()); + ServerStreamingCallSettings expectedSettings = + defaultStubSettings.runQuerySettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void runAggregationQueryCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.runAggregationQueryCallable()); + ServerStreamingCallSettings + expectedSettings = defaultStubSettings.runAggregationQuerySettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void executePipelineCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.executePipelineCallable()); + ServerStreamingCallSettings expectedSettings = + defaultStubSettings.executePipelineSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void beginTransactionCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.beginTransactionCallable()); + UnaryCallSettings expectedSettings = + defaultStubSettings.beginTransactionSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void rollbackCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.rollbackCallable()); + UnaryCallSettings expectedSettings = + defaultStubSettings.rollbackSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void listCollectionIdsPagedCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.listCollectionIdsPagedCallable()); + PagedCallSettings + expectedSettings = defaultStubSettings.listDocumentsSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void partitionQueryPagedCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.partitionQueryPagedCallable()); + PagedCallSettings + expectedSettings = defaultStubSettings.partitionQuerySettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + @Test + public void listDocumentsPagedCallableFollowsServiceConfig() throws Exception { + GrpcFirestoreRpc grpcFirestoreRpc = new GrpcFirestoreRpc(firestoreOptionsWithoutOverride); + CallableRetryData actual = getRetryData(grpcFirestoreRpc.listDocumentsPagedCallable()); + PagedCallSettings + expectedSettings = defaultStubSettings.listDocumentsSettings(); + assertThat(actual.retrySettings) + .isEqualTo(withMaxAttempt5(expectedSettings.getRetrySettings())); + assertThat(actual.retryableCodes) + .containsExactlyElementsIn(expectedSettings.getRetryableCodes()); + } + + private static CallableRetryData getRetryData(Object callable) throws Exception { + String aClassName = callable.getClass().getName(); + switch (aClassName) { + case "com.google.api.gax.tracing.TracedUnaryCallable": + case "com.google.api.gax.tracing.TracedServerStreamingCallable": + return getRetryData(getViaReflection(callable, "innerCallable")); + case "com.google.api.gax.rpc.UnaryCallable$1": + case "com.google.api.gax.rpc.ServerStreamingCallable$1": + return getRetryData(getViaReflection(callable, "this$0")); + case "com.google.api.gax.rpc.RetryingCallable": + return new CallableRetryData( + getRetrySettings(getViaReflection(callable, "executor")), + getRetryableCodes(getViaReflection(callable, "callable"))); + case "com.google.api.gax.rpc.RetryingServerStreamingCallable": + return new CallableRetryData( + getRetrySettings(getViaReflection(callable, "executor")), + getRetryableCodes(getViaReflection(callable, "innerCallable"))); + case "com.google.api.gax.rpc.PagedCallable": + return getRetryData(getViaReflection(callable, "callable")); + default: + throw new Exception("Unexpected class " + aClassName); + } + } + + private static Set getRetryableCodes(Object o) + throws NoSuchFieldException, IllegalAccessException { + switch (o.getClass().getName()) { + case "com.google.api.gax.rpc.ServerStreamingCallable$1": + return getRetryableCodes(getViaReflection(o, "this$0")); + case "com.google.api.gax.rpc.WatchdogServerStreamingCallable": + return getRetryableCodes(getViaReflection(o, "inner")); + } + Object exceptionFactory = getViaReflection(o, "exceptionFactory"); + return getViaReflection(exceptionFactory, "retryableCodes"); + } + + private static RetrySettings getRetrySettings(Object o) throws Exception { + String aClassName = o.getClass().getName(); + switch (aClassName) { + case "com.google.api.gax.retrying.ScheduledRetryingExecutor": + { + Object retryAlgorithm = + getViaReflection(ScheduledRetryingExecutor.class, "retryAlgorithm", o); + Object exponentialRetryAlgorithm = + getViaReflection(RetryAlgorithm.class, "timedAlgorithmWithContext", retryAlgorithm); + return getViaReflection( + ExponentialRetryAlgorithm.class, "globalSettings", exponentialRetryAlgorithm); + } + default: + throw new Exception("Unexpected class " + aClassName); + } + } + + static class CallableRetryData { + final RetrySettings retrySettings; + final Set retryableCodes; + + CallableRetryData(RetrySettings retrySettings, Set retryableCodes) { + this.retrySettings = retrySettings; + this.retryableCodes = retryableCodes; + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/DisabledTraceUtilTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/DisabledTraceUtilTest.java new file mode 100644 index 000000000000..4e60fc7481bc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/DisabledTraceUtilTest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; + +public class DisabledTraceUtilTest { + @Test + public void disabledTraceUtilDoesNotProvideChannelConfigurator() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getChannelConfigurator()).isNull(); + } + + @Test + public void usesDisabledContext() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.currentContext() instanceof DisabledTraceUtil.Context).isTrue(); + } + + @Test + public void usesDisabledSpan() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.currentSpan() instanceof DisabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") instanceof DisabledTraceUtil.Span).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.currentContext()) + instanceof DisabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesDisabledScope() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.currentContext().makeCurrent() instanceof DisabledTraceUtil.Scope) + .isTrue(); + assertThat(traceUtil.currentSpan().makeCurrent() instanceof DisabledTraceUtil.Scope).isTrue(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java new file mode 100644 index 000000000000..d3fb7e216787 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/EnabledTraceUtilTest.java @@ -0,0 +1,200 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.firestore.FirestoreOpenTelemetryOptions; +import com.google.cloud.firestore.FirestoreOptions; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.trace.TracerProvider; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import java.time.Duration; +import org.junit.Before; +import org.junit.Test; + +public class EnabledTraceUtilTest { + @Before + public void setUp() { + GlobalOpenTelemetry.resetForTest(); + } + + EnabledTraceUtil defaultEnabledTraceUtil() { + return new EnabledTraceUtil(FirestoreOptions.getDefaultInstance()); + } + + FirestoreOptions.Builder getBaseOptions() { + return FirestoreOptions.newBuilder().setProjectId("test-project").setDatabaseId("(default)"); + } + + @Test + public void usesOpenTelemetryFromOptions() { + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + FirestoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + FirestoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getOpenTelemetry()).isSameInstanceAs(myOpenTelemetrySdk); + } + + @Test + public void usesGlobalOpenTelemetryIfOpenTelemetryInstanceNotProvided() { + OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + assertThat(traceUtil.getOpenTelemetry()).isSameInstanceAs(GlobalOpenTelemetry.get()); + } + + @Test + public void usesOpenTelemetryFromOptionsEvenIfGlobalOpenTelemetryExists() { + // Register a GlobalOpenTelemetry. + OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + + // Pass in a *different* OpenTelemetry instance to Firestore to use. + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + FirestoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + FirestoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + + // Assert Firestore uses the custom one, not the global one. + assertThat(traceUtil.getOpenTelemetry()).isSameInstanceAs(myOpenTelemetrySdk); + assertThat(traceUtil.getOpenTelemetry()).isNotSameInstanceAs(GlobalOpenTelemetry.get()); + } + + @Test + public void defaultOptionsDoesNotRegisterGrpcChannelConfigurator() { + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + assertThat(traceUtil.getOpenTelemetry().getTracerProvider()) + .isSameInstanceAs(TracerProvider.noop()); + assertThat(traceUtil.getChannelConfigurator()).isNull(); + } + + @Test + public void globalOpenTelemetryRegistersGrpcChannelConfigurator() { + OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + assertThat(traceUtil.getChannelConfigurator()).isNotNull(); + } + + @Test + public void openTelemetryInstanceRegistersGrpcChannelConfigurator() { + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + FirestoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + FirestoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getChannelConfigurator()).isNotNull(); + } + + @Test + public void usesEnabledContext() { + assertThat(defaultEnabledTraceUtil().currentContext() instanceof EnabledTraceUtil.Context) + .isTrue(); + } + + @Test + public void usesEnabledSpan() { + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + assertThat(traceUtil.currentSpan() instanceof EnabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") instanceof EnabledTraceUtil.Span).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.currentContext()) instanceof EnabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesEnabledScope() { + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + assertThat(traceUtil.currentContext().makeCurrent() instanceof EnabledTraceUtil.Scope).isTrue(); + assertThat(traceUtil.currentSpan().makeCurrent() instanceof EnabledTraceUtil.Scope).isTrue(); + } + + @Test + public void durationString() { + EnabledTraceUtil traceUtil = defaultEnabledTraceUtil(); + Duration duration = Duration.ofSeconds(2, 9); + assertThat(traceUtil.durationString(duration)).isEqualTo("2.000000009s"); + + duration = Duration.ofSeconds(3, 98); + assertThat(traceUtil.durationString(duration)).isEqualTo("3.000000098s"); + + duration = Duration.ofSeconds(4, 987); + assertThat(traceUtil.durationString(duration)).isEqualTo("4.000000987s"); + + duration = Duration.ofSeconds(5, 9876); + assertThat(traceUtil.durationString(duration)).isEqualTo("5.000009876s"); + + duration = Duration.ofSeconds(6, 98765); + assertThat(traceUtil.durationString(duration)).isEqualTo("6.000098765s"); + + duration = Duration.ofSeconds(7, 987654); + assertThat(traceUtil.durationString(duration)).isEqualTo("7.000987654s"); + + duration = Duration.ofSeconds(8, 9876543); + assertThat(traceUtil.durationString(duration)).isEqualTo("8.009876543s"); + + duration = Duration.ofSeconds(9, 98765432); + assertThat(traceUtil.durationString(duration)).isEqualTo("9.098765432s"); + + duration = Duration.ofSeconds(10, 987654321); + assertThat(traceUtil.durationString(duration)).isEqualTo("10.987654321s"); + + duration = Duration.ofSeconds(1, 0); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.0s"); + + duration = Duration.ofSeconds(1, 1); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.000000001s"); + + duration = Duration.ofSeconds(1, 10); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.00000001s"); + + duration = Duration.ofSeconds(1, 100); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.0000001s"); + + duration = Duration.ofSeconds(1, 1_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.000001s"); + + duration = Duration.ofSeconds(1, 10_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.00001s"); + + duration = Duration.ofSeconds(1, 100_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.0001s"); + + duration = Duration.ofSeconds(1, 1_000_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.001s"); + + duration = Duration.ofSeconds(1, 10_000_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.01s"); + + duration = Duration.ofSeconds(1, 100_000_000); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.1s"); + + duration = Duration.ofSeconds(1, 100_000_001); + assertThat(traceUtil.durationString(duration)).isEqualTo("1.100000001s"); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/TraceUtilTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/TraceUtilTest.java new file mode 100644 index 000000000000..e2c20b1dfebf --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/telemetry/TraceUtilTest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.cloud.firestore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.firestore.FirestoreOptions; +import io.opentelemetry.api.trace.TracerProvider; +import org.junit.Test; + +public class TraceUtilTest { + @Test + public void defaultOptionsUseNoopTracer() { + TraceUtil traceUtil = TraceUtil.getInstance(FirestoreOptions.getDefaultInstance()); + assertThat(traceUtil instanceof EnabledTraceUtil).isTrue(); + EnabledTraceUtil enabledTraceUtil = (EnabledTraceUtil) traceUtil; + assertThat( + enabledTraceUtil.getOpenTelemetry().getTracerProvider().equals(TracerProvider.noop())); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java new file mode 100644 index 000000000000..6a37e04faecb --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientHttpJsonTest.java @@ -0,0 +1,747 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import 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.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.firestore.v1.stub.HttpJsonFirestoreStub; +import com.google.common.collect.Lists; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import com.google.firestore.v1.WriteResult; +import com.google.protobuf.ByteString; +import com.google.protobuf.Empty; +import com.google.protobuf.Timestamp; +import com.google.rpc.Status; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreClientHttpJsonTest { + private static MockHttpService mockService; + private static FirestoreClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonFirestoreStub.getMethodDescriptors(), FirestoreSettings.getDefaultEndpoint()); + FirestoreSettings settings = + FirestoreSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + FirestoreSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void getDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .setMask(DocumentMask.newBuilder().build()) + .build(); + + Document actualResponse = client.getDocument(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .setMask(DocumentMask.newBuilder().build()) + .build(); + client.getDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + "projects/project-6440/databases/database-6440/documents/document-6440/document-6440") + .setCollectionId("collectionId-3631") + .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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListDocumentsRequest request = + ListDocumentsRequest.newBuilder() + .setParent( + "projects/project-6440/databases/database-6440/documents/document-6440/document-6440") + .setCollectionId("collectionId-3631") + .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. + } + } + + @Test + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Document document = + Document.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + DocumentMask updateMask = DocumentMask.newBuilder().build(); + + Document actualResponse = client.updateDocument(document, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Document document = + Document.newBuilder() + .setName( + "projects/project-615/databases/database-615/documents/document-615/document-615") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + DocumentMask updateMask = DocumentMask.newBuilder().build(); + client.updateDocument(document, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteDocumentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-615/databases/database-615/documents/document-615/document-615"; + + client.deleteDocument(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-615/databases/database-615/documents/document-615/document-615"; + client.deleteDocument(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchGetDocumentsTest() throws Exception {} + + @Test + public void batchGetDocumentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void beginTransactionTest() throws Exception { + BeginTransactionResponse expectedResponse = + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + + BeginTransactionResponse actualResponse = client.beginTransaction(database); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void beginTransactionExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + client.beginTransaction(database); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + List writes = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(database, writes); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void commitExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + List writes = new ArrayList<>(); + client.commit(database, writes); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void rollbackTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String database = "projects/project-4060/databases/database-4060"; + ByteString transaction = ByteString.EMPTY; + + client.rollback(database, transaction); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void rollbackExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String database = "projects/project-4060/databases/database-4060"; + ByteString transaction = ByteString.EMPTY; + client.rollback(database, transaction); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runQueryTest() throws Exception {} + + @Test + public void runQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void executePipelineTest() throws Exception {} + + @Test + public void executePipelineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void runAggregationQueryTest() throws Exception {} + + @Test + public void runAggregationQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + } + + @Test + public void partitionQueryTest() throws Exception { + Cursor responsesElement = Cursor.newBuilder().build(); + PartitionQueryResponse expectedResponse = + PartitionQueryResponse.newBuilder() + .setNextPageToken("") + .addAllPartitions(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("projects/project-9316/databases/database-9316/documents") + .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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void partitionQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PartitionQueryRequest request = + PartitionQueryRequest.newBuilder() + .setParent("projects/project-9316/databases/database-9316/documents") + .setPartitionCount(-1738969222) + .setPageToken("pageToken873572522") + .setPageSize(883849137) + .build(); + client.partitionQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void writeUnsupportedMethodTest() throws Exception { + // The write() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void listenUnsupportedMethodTest() throws Exception { + // The listen() method is not supported in REST transport. + // This empty test is generated for technical reasons. + } + + @Test + public void listCollectionIdsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListCollectionIdsResponse expectedResponse = + ListCollectionIdsResponse.newBuilder() + .setNextPageToken("") + .addAllCollectionIds(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9316/databases/database-9316/documents"; + + 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 = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listCollectionIdsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9316/databases/database-9316/documents"; + client.listCollectionIds(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void batchWriteTest() throws Exception { + BatchWriteResponse expectedResponse = + BatchWriteResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .addAllStatus(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("projects/project-4060/databases/database-4060") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); + + BatchWriteResponse actualResponse = client.batchWrite(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void batchWriteExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("projects/project-4060/databases/database-4060") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .build(); + client.batchWrite(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("projects/project-2701/databases/database-2701/documents/document-2701") + .setCollectionId("collectionId-3631") + .setDocumentId("documentId-814940266") + .setDocument(Document.newBuilder().build()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + + Document actualResponse = client.createDocument(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createDocumentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateDocumentRequest request = + CreateDocumentRequest.newBuilder() + .setParent("projects/project-2701/databases/database-2701/documents/document-2701") + .setCollectionId("collectionId-3631") + .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. + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java new file mode 100644 index 000000000000..f7008043bd6c --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/FirestoreClientTest.java @@ -0,0 +1,983 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import 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.gax.core.NoCredentialsProvider; +import com.google.api.gax.grpc.GaxGrpcProperties; +import com.google.api.gax.grpc.testing.LocalChannelProvider; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.api.gax.grpc.testing.MockServiceHelper; +import com.google.api.gax.grpc.testing.MockStreamObserver; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.api.gax.rpc.BidiStreamingCallable; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.StatusCode; +import com.google.common.collect.Lists; +import com.google.firestore.v1.AggregationResult; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.Cursor; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.DocumentMask; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.ExplainMetrics; +import com.google.firestore.v1.ExplainOptions; +import com.google.firestore.v1.ExplainStats; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.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 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; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class FirestoreClientTest { + private static MockFirestore mockFirestore; + private static MockLocations mockLocations; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private FirestoreClient client; + + @BeforeClass + public static void startStaticServer() { + mockFirestore = new MockFirestore(); + mockLocations = new MockLocations(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), + Arrays.asList(mockFirestore, mockLocations)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + FirestoreSettings settings = + FirestoreSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = FirestoreClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + 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); + + 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)); + + 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(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getDocumentExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + GetDocumentRequest request = + GetDocumentRequest.newBuilder() + .setName("name3373707") + .setMask(DocumentMask.newBuilder().build()) + .build(); + client.getDocument(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDocumentsTest() throws Exception { + Document responsesElement = Document.newBuilder().build(); + ListDocumentsResponse expectedResponse = + ListDocumentsResponse.newBuilder() + .setNextPageToken("") + .addAllDocuments(Arrays.asList(responsesElement)) + .build(); + mockFirestore.addResponse(expectedResponse); + + ListDocumentsRequest request = + 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(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(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listDocumentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + ListDocumentsRequest request = + 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. + } + } + + @Test + public void updateDocumentTest() throws Exception { + Document expectedResponse = + Document.newBuilder() + .setName("name3373707") + .putAllFields(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + + Document document = Document.newBuilder().build(); + DocumentMask updateMask = DocumentMask.newBuilder().build(); + + Document actualResponse = client.updateDocument(document, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateDocumentRequest actualRequest = ((UpdateDocumentRequest) actualRequests.get(0)); + + Assert.assertEquals(document, actualRequest.getDocument()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateDocumentExceptionTest() throws Exception { + 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. + } + } + + @Test + public void deleteDocumentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestore.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteDocument(name); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteDocumentRequest actualRequest = ((DeleteDocumentRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteDocumentExceptionTest() throws Exception { + 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. + } + } + + @Test + public void batchGetDocumentsTest() throws Exception { + BatchGetDocumentsResponse expectedResponse = + BatchGetDocumentsResponse.newBuilder() + .setTransaction(ByteString.EMPTY) + .setReadTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + BatchGetDocumentsRequest request = + BatchGetDocumentsRequest.newBuilder() + .setDatabase("database1789464955") + .addAllDocuments(new ArrayList()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.batchGetDocumentsCallable(); + callable.serverStreamingCall(request, responseObserver); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void batchGetDocumentsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + BatchGetDocumentsRequest request = + BatchGetDocumentsRequest.newBuilder() + .setDatabase("database1789464955") + .addAllDocuments(new ArrayList()) + .setMask(DocumentMask.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.batchGetDocumentsCallable(); + callable.serverStreamingCall(request, responseObserver); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void beginTransactionTest() throws Exception { + BeginTransactionResponse expectedResponse = + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); + mockFirestore.addResponse(expectedResponse); + + String database = "database1789464955"; + + BeginTransactionResponse actualResponse = client.beginTransaction(database); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BeginTransactionRequest actualRequest = ((BeginTransactionRequest) actualRequests.get(0)); + + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void beginTransactionExceptionTest() throws Exception { + 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. + } + } + + @Test + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + + String database = "database1789464955"; + List writes = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(database, writes); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CommitRequest actualRequest = ((CommitRequest) actualRequests.get(0)); + + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertEquals(writes, actualRequest.getWritesList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void commitExceptionTest() throws Exception { + 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. + } + } + + @Test + public void rollbackTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockFirestore.addResponse(expectedResponse); + + String database = "database1789464955"; + ByteString transaction = ByteString.EMPTY; + + client.rollback(database, transaction); + + List actualRequests = mockFirestore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RollbackRequest actualRequest = ((RollbackRequest) actualRequests.get(0)); + + Assert.assertEquals(database, actualRequest.getDatabase()); + Assert.assertEquals(transaction, actualRequest.getTransaction()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void rollbackExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + String database = "database1789464955"; + ByteString transaction = ByteString.EMPTY; + client.rollback(database, transaction); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runQueryTest() throws Exception { + RunQueryResponse expectedResponse = + RunQueryResponse.newBuilder() + .setTransaction(ByteString.EMPTY) + .setDocument(Document.newBuilder().build()) + .setReadTime(Timestamp.newBuilder().build()) + .setSkippedResults(880286183) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setParent("parent-995424086") + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = client.runQueryCallable(); + callable.serverStreamingCall(request, responseObserver); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void runQueryExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setParent("parent-995424086") + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = client.runQueryCallable(); + callable.serverStreamingCall(request, responseObserver); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void executePipelineTest() throws Exception { + ExecutePipelineResponse expectedResponse = + ExecutePipelineResponse.newBuilder() + .setTransaction(ByteString.EMPTY) + .addAllResults(new ArrayList()) + .setExecutionTime(Timestamp.newBuilder().build()) + .setExplainStats(ExplainStats.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + ExecutePipelineRequest request = + ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.executePipelineCallable(); + callable.serverStreamingCall(request, responseObserver); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void executePipelineExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + ExecutePipelineRequest request = + ExecutePipelineRequest.newBuilder().setDatabase("database1789464955").build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.executePipelineCallable(); + callable.serverStreamingCall(request, responseObserver); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void runAggregationQueryTest() throws Exception { + RunAggregationQueryResponse expectedResponse = + RunAggregationQueryResponse.newBuilder() + .setResult(AggregationResult.newBuilder().build()) + .setTransaction(ByteString.EMPTY) + .setReadTime(Timestamp.newBuilder().build()) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setParent("parent-995424086") + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.runAggregationQueryCallable(); + callable.serverStreamingCall(request, responseObserver); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void runAggregationQueryExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setParent("parent-995424086") + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + ServerStreamingCallable callable = + client.runAggregationQueryCallable(); + callable.serverStreamingCall(request, responseObserver); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + 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.assertEquals(request.getReadTime(), actualRequest.getReadTime()); + 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 { + WriteResponse expectedResponse = + WriteResponse.newBuilder() + .setStreamId("streamId1790933179") + .setStreamToken(ByteString.EMPTY) + .addAllWriteResults(new ArrayList()) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockFirestore.addResponse(expectedResponse); + WriteRequest request = + WriteRequest.newBuilder() + .setDatabase("database1789464955") + .setStreamId("streamId1790933179") + .addAllWrites(new ArrayList()) + .setStreamToken(ByteString.EMPTY) + .putAllLabels(new HashMap()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = client.writeCallable(); + ApiStreamObserver requestObserver = callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + requestObserver.onCompleted(); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void writeExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + WriteRequest request = + WriteRequest.newBuilder() + .setDatabase("database1789464955") + .setStreamId("streamId1790933179") + .addAllWrites(new ArrayList()) + .setStreamToken(ByteString.EMPTY) + .putAllLabels(new HashMap()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = client.writeCallable(); + ApiStreamObserver requestObserver = callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void listenTest() throws Exception { + ListenResponse expectedResponse = ListenResponse.newBuilder().build(); + mockFirestore.addResponse(expectedResponse); + ListenRequest request = + ListenRequest.newBuilder() + .setDatabase("database1789464955") + .putAllLabels(new HashMap()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = client.listenCallable(); + ApiStreamObserver requestObserver = callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + requestObserver.onCompleted(); + + List actualResponses = responseObserver.future().get(); + Assert.assertEquals(1, actualResponses.size()); + Assert.assertEquals(expectedResponse, actualResponses.get(0)); + } + + @Test + public void listenExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + ListenRequest request = + ListenRequest.newBuilder() + .setDatabase("database1789464955") + .putAllLabels(new HashMap()) + .build(); + + MockStreamObserver responseObserver = new MockStreamObserver<>(); + + BidiStreamingCallable callable = client.listenCallable(); + ApiStreamObserver requestObserver = callable.bidiStreamingCall(responseObserver); + + requestObserver.onNext(request); + + try { + List actualResponses = responseObserver.future().get(); + Assert.fail("No exception thrown"); + } catch (ExecutionException e) { + Assert.assertTrue(e.getCause() instanceof InvalidArgumentException); + InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause()); + Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode()); + } + } + + @Test + public void listCollectionIdsTest() throws Exception { + String responsesElement = "responsesElement-318365110"; + ListCollectionIdsResponse expectedResponse = + ListCollectionIdsResponse.newBuilder() + .setNextPageToken("") + .addAllCollectionIds(Arrays.asList(responsesElement)) + .build(); + mockFirestore.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + 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)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listCollectionIdsExceptionTest() throws Exception { + 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. + } + } + + @Test + public void batchWriteTest() throws Exception { + BatchWriteResponse expectedResponse = + BatchWriteResponse.newBuilder() + .addAllWriteResults(new ArrayList()) + .addAllStatus(new ArrayList()) + .build(); + mockFirestore.addResponse(expectedResponse); + + BatchWriteRequest request = + BatchWriteRequest.newBuilder() + .setDatabase("database1789464955") + .addAllWrites(new ArrayList()) + .putAllLabels(new HashMap()) + .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(request.getDatabase(), actualRequest.getDatabase()); + Assert.assertEquals(request.getWritesList(), actualRequest.getWritesList()); + Assert.assertEquals(request.getLabelsMap(), actualRequest.getLabelsMap()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void batchWriteExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockFirestore.addException(exception); + + try { + 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. + } + } + + @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. + } + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java new file mode 100644 index 000000000000..35fd61f69839 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestore.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockFirestore implements MockGrpcService { + private final MockFirestoreImpl serviceImpl; + + public MockFirestore() { + serviceImpl = new MockFirestoreImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java new file mode 100644 index 000000000000..79a77f3b50be --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockFirestoreImpl.java @@ -0,0 +1,478 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.firestore.v1.BatchGetDocumentsRequest; +import com.google.firestore.v1.BatchGetDocumentsResponse; +import com.google.firestore.v1.BatchWriteRequest; +import com.google.firestore.v1.BatchWriteResponse; +import com.google.firestore.v1.BeginTransactionRequest; +import com.google.firestore.v1.BeginTransactionResponse; +import com.google.firestore.v1.CommitRequest; +import com.google.firestore.v1.CommitResponse; +import com.google.firestore.v1.CreateDocumentRequest; +import com.google.firestore.v1.DeleteDocumentRequest; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.ExecutePipelineRequest; +import com.google.firestore.v1.ExecutePipelineResponse; +import com.google.firestore.v1.FirestoreGrpc.FirestoreImplBase; +import com.google.firestore.v1.GetDocumentRequest; +import com.google.firestore.v1.ListCollectionIdsRequest; +import com.google.firestore.v1.ListCollectionIdsResponse; +import com.google.firestore.v1.ListDocumentsRequest; +import com.google.firestore.v1.ListDocumentsResponse; +import com.google.firestore.v1.ListenRequest; +import com.google.firestore.v1.ListenResponse; +import com.google.firestore.v1.PartitionQueryRequest; +import com.google.firestore.v1.PartitionQueryResponse; +import com.google.firestore.v1.RollbackRequest; +import com.google.firestore.v1.RunAggregationQueryRequest; +import com.google.firestore.v1.RunAggregationQueryResponse; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.UpdateDocumentRequest; +import com.google.firestore.v1.WriteRequest; +import com.google.firestore.v1.WriteResponse; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Empty; +import io.grpc.stub.StreamObserver; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockFirestoreImpl extends FirestoreImplBase { + private List requests; + private Queue responses; + + public MockFirestoreImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + @Override + public void getDocument(GetDocumentRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Document) { + requests.add(request); + responseObserver.onNext(((Document) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof ListDocumentsResponse) { + requests.add(request); + responseObserver.onNext(((ListDocumentsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Document) { + requests.add(request); + responseObserver.onNext(((Document) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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()))); + } + } + + @Override + public void batchGetDocuments( + BatchGetDocumentsRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BatchGetDocumentsResponse) { + requests.add(request); + responseObserver.onNext(((BatchGetDocumentsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof BeginTransactionResponse) { + requests.add(request); + responseObserver.onNext(((BeginTransactionResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof CommitResponse) { + requests.add(request); + responseObserver.onNext(((CommitResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof RunQueryResponse) { + requests.add(request); + responseObserver.onNext(((RunQueryResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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 executePipeline( + ExecutePipelineRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ExecutePipelineResponse) { + requests.add(request); + responseObserver.onNext(((ExecutePipelineResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ExecutePipeline, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ExecutePipelineResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void runAggregationQuery( + RunAggregationQueryRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof RunAggregationQueryResponse) { + requests.add(request); + responseObserver.onNext(((RunAggregationQueryResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method RunAggregationQuery, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + RunAggregationQueryResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void partitionQuery( + PartitionQueryRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof PartitionQueryResponse) { + requests.add(request); + responseObserver.onNext(((PartitionQueryResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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()))); + } + } + + @Override + public StreamObserver write(final StreamObserver responseObserver) { + StreamObserver requestObserver = + new StreamObserver() { + @Override + public void onNext(WriteRequest value) { + requests.add(value); + final Object response = responses.remove(); + if (response instanceof WriteResponse) { + responseObserver.onNext(((WriteResponse) response)); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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()))); + } + } + + @Override + public void onError(Throwable t) { + responseObserver.onError(t); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + return requestObserver; + } + + @Override + public StreamObserver listen( + final StreamObserver responseObserver) { + StreamObserver requestObserver = + new StreamObserver() { + @Override + public void onNext(ListenRequest value) { + requests.add(value); + final Object response = responses.remove(); + if (response instanceof ListenResponse) { + responseObserver.onNext(((ListenResponse) response)); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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()))); + } + } + + @Override + public void onError(Throwable t) { + responseObserver.onError(t); + } + + @Override + public void onCompleted() { + responseObserver.onCompleted(); + } + }; + return requestObserver; + } + + @Override + public void listCollectionIds( + ListCollectionIdsRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListCollectionIdsResponse) { + requests.add(request); + responseObserver.onNext(((ListCollectionIdsResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof BatchWriteResponse) { + requests.add(request); + responseObserver.onNext(((BatchWriteResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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.poll(); + if (response instanceof Document) { + requests.add(request); + responseObserver.onNext(((Document) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + 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/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java new file mode 100644 index 000000000000..522dacd36bfc --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocations.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.testing.MockGrpcService; +import com.google.protobuf.AbstractMessage; +import io.grpc.ServerServiceDefinition; +import java.util.List; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocations implements MockGrpcService { + private final MockLocationsImpl serviceImpl; + + public MockLocations() { + serviceImpl = new MockLocationsImpl(); + } + + @Override + public List getRequests() { + return serviceImpl.getRequests(); + } + + @Override + public void addResponse(AbstractMessage response) { + serviceImpl.addResponse(response); + } + + @Override + public void addException(Exception exception) { + serviceImpl.addException(exception); + } + + @Override + public ServerServiceDefinition getServiceDefinition() { + return serviceImpl.bindService(); + } + + @Override + public void reset() { + serviceImpl.reset(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java new file mode 100644 index 000000000000..c99007072820 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/java/com/google/cloud/firestore/v1/MockLocationsImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.firestore.v1; + +import com.google.api.core.BetaApi; +import com.google.cloud.location.LocationsGrpc.LocationsImplBase; +import com.google.protobuf.AbstractMessage; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import javax.annotation.Generated; + +@BetaApi +@Generated("by gapic-generator-java") +public class MockLocationsImpl extends LocationsImplBase { + private List requests; + private Queue responses; + + public MockLocationsImpl() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } + + public List getRequests() { + return requests; + } + + public void addResponse(AbstractMessage response) { + responses.add(response); + } + + public void setResponses(List responses) { + this.responses = new LinkedList(responses); + } + + public void addException(Exception exception) { + responses.add(exception); + } + + public void reset() { + requests = new ArrayList<>(); + responses = new LinkedList<>(); + } +} diff --git a/java-firestore/google-cloud-firestore/src/test/resources/META-INF/native-image/reflect-config.json b/java-firestore/google-cloud-firestore/src/test/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 000000000000..87e033f5c467 --- /dev/null +++ b/java-firestore/google-cloud-firestore/src/test/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,48 @@ +[{ + "name":"com.google.cloud.firestore.LocalFirestoreHelper$AllSupportedTypes", + "allDeclaredFields":true, + "allPublicFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "methods":[{"name":"","parameterTypes":[] }]} +, +{ +"name":"com.google.cloud.firestore.LocalFirestoreHelper$CustomList", +"allDeclaredFields":true, +"allPublicFields":true, +"allDeclaredMethods":true, +"allPublicMethods":true, +"methods":[{"name":"","parameterTypes":[] }]} +, +{ +"name":"com.google.cloud.firestore.LocalFirestoreHelper$CustomMap", +"allDeclaredFields":true, +"allPublicFields":true, +"allDeclaredMethods":true, +"allPublicMethods":true, +"methods":[{"name":"","parameterTypes":[] }]} +, +{ +"name": "com.google.cloud.firestore.it.ITTracingTest$Pojo", +"allDeclaredConstructors": true, +"allPublicConstructors": true, +"allDeclaredMethods": true, +"allPublicMethods": true, +"allDeclaredFields": true, +"allPublicFields": true}, +{ +"name":"com.google.cloud.firestore.LocalFirestoreHelper$FooList", +"methods":[{"name":"","parameterTypes":[] }]} +, +{ +"name":"com.google.cloud.firestore.LocalFirestoreHelper$FooMap", +"methods":[{"name":"","parameterTypes":[] }]} +, +{ +"name":"com.google.cloud.firestore.LocalFirestoreHelper$SingleField", +"allDeclaredFields":true, +"allPublicFields":true, +"allDeclaredMethods":true, +"allPublicMethods":true, +"methods":[{"name":"","parameterTypes":[] }]} +] \ No newline at end of file diff --git a/java-firestore/grpc-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml b/java-firestore/grpc-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..905eab967c44 --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml @@ -0,0 +1,94 @@ + + + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void createBackupSchedule(com.google.firestore.admin.v1.CreateBackupScheduleRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void deleteBackup(com.google.firestore.admin.v1.DeleteBackupRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void deleteBackupSchedule(com.google.firestore.admin.v1.DeleteBackupScheduleRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void getBackup(com.google.firestore.admin.v1.GetBackupRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void getBackupSchedule(com.google.firestore.admin.v1.GetBackupScheduleRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void listBackupSchedules(com.google.firestore.admin.v1.ListBackupSchedulesRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void listBackups(com.google.firestore.admin.v1.ListBackupsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void restoreDatabase(com.google.firestore.admin.v1.RestoreDatabaseRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void updateBackupSchedule(com.google.firestore.admin.v1.UpdateBackupScheduleRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void bulkDeleteDocuments(com.google.firestore.admin.v1.BulkDeleteDocumentsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void createUserCreds(com.google.firestore.admin.v1.CreateUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void deleteUserCreds(com.google.firestore.admin.v1.DeleteUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void disableUserCreds(com.google.firestore.admin.v1.DisableUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void enableUserCreds(com.google.firestore.admin.v1.EnableUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void getUserCreds(com.google.firestore.admin.v1.GetUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void listUserCreds(com.google.firestore.admin.v1.ListUserCredsRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + void resetUserPassword(com.google.firestore.admin.v1.ResetUserPasswordRequest, io.grpc.stub.StreamObserver) + + + 7012 + com/google/firestore/admin/v1/FirestoreAdminGrpc* + * + + diff --git a/java-firestore/grpc-google-cloud-firestore-admin-v1/pom.xml b/java-firestore/grpc-google-cloud-firestore-admin-v1/pom.xml new file mode 100644 index 000000000000..15dc52d1d38a --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-admin-v1/pom.xml @@ -0,0 +1,71 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + grpc-google-cloud-firestore-admin-v1 + GRPC library for grpc-google-cloud-firestore-admin-v1 + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + io.grpc + grpc-stub + compile + + + io.grpc + grpc-protobuf + compile + + + com.google.api.grpc + proto-google-cloud-firestore-admin-v1 + compile + + + com.google.api.grpc + proto-google-common-protos + + + io.grpc + grpc-api + + + com.google.protobuf + protobuf-java + + + com.google.guava + guava + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java b/java-firestore/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java new file mode 100644 index 000000000000..031d4a2e8588 --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminGrpc.java @@ -0,0 +1,4915 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.firestore.admin.v1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * The Cloud Firestore Admin API.
+ * This API provides several administrative services for Cloud Firestore.
+ * Project, Database, Namespace, Collection, Collection Group, and Document are
+ * used as defined in the Google Cloud Firestore API.
+ * Operation: An Operation represents work being performed in the background.
+ * The index service manages Cloud Firestore indexes.
+ * Index creation is performed asynchronously.
+ * An Operation resource is created for each such asynchronous operation.
+ * The state of the operation (including any errors encountered)
+ * may be queried via the Operation resource.
+ * The Operations collection provides a record of actions performed for the
+ * specified Project (including any Operations in progress). Operations are not
+ * created directly but through calls on other collections or resources.
+ * An Operation that is done may be deleted so that it is no longer listed as
+ * part of the Operation collection. Operations are garbage collected after
+ * 30 days. By default, ListOperations will only return in progress and failed
+ * operations. To list completed operation, issue a ListOperations request with
+ * the filter `done: true`.
+ * Operations are created by service `FirestoreAdmin`, but are accessed via
+ * service `google.longrunning.Operations`.
+ * 
+ */ +@io.grpc.stub.annotations.GrpcGenerated +public final class FirestoreAdminGrpc { + + private FirestoreAdminGrpc() {} + + public static final java.lang.String SERVICE_NAME = "google.firestore.admin.v1.FirestoreAdmin"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateIndex", + requestType = com.google.firestore.admin.v1.CreateIndexRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod; + if ((getCreateIndexMethod = FirestoreAdminGrpc.getCreateIndexMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCreateIndexMethod = FirestoreAdminGrpc.getCreateIndexMethod) == null) { + FirestoreAdminGrpc.getCreateIndexMethod = + getCreateIndexMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateIndex")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CreateIndexRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CreateIndex")) + .build(); + } + } + } + return getCreateIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListIndexesRequest, + com.google.firestore.admin.v1.ListIndexesResponse> + getListIndexesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListIndexes", + requestType = com.google.firestore.admin.v1.ListIndexesRequest.class, + responseType = com.google.firestore.admin.v1.ListIndexesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListIndexesRequest, + com.google.firestore.admin.v1.ListIndexesResponse> + getListIndexesMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListIndexesRequest, + com.google.firestore.admin.v1.ListIndexesResponse> + getListIndexesMethod; + if ((getListIndexesMethod = FirestoreAdminGrpc.getListIndexesMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListIndexesMethod = FirestoreAdminGrpc.getListIndexesMethod) == null) { + FirestoreAdminGrpc.getListIndexesMethod = + getListIndexesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListIndexes")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListIndexesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListIndexesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListIndexes")) + .build(); + } + } + } + return getListIndexesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetIndexRequest, com.google.firestore.admin.v1.Index> + getGetIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetIndex", + requestType = com.google.firestore.admin.v1.GetIndexRequest.class, + responseType = com.google.firestore.admin.v1.Index.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetIndexRequest, com.google.firestore.admin.v1.Index> + getGetIndexMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetIndexRequest, com.google.firestore.admin.v1.Index> + getGetIndexMethod; + if ((getGetIndexMethod = FirestoreAdminGrpc.getGetIndexMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetIndexMethod = FirestoreAdminGrpc.getGetIndexMethod) == null) { + FirestoreAdminGrpc.getGetIndexMethod = + getGetIndexMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetIndex")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetIndexRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.Index.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreAdminMethodDescriptorSupplier("GetIndex")) + .build(); + } + } + } + return getGetIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteIndexRequest, com.google.protobuf.Empty> + getDeleteIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteIndex", + requestType = com.google.firestore.admin.v1.DeleteIndexRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteIndexRequest, com.google.protobuf.Empty> + getDeleteIndexMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteIndexRequest, com.google.protobuf.Empty> + getDeleteIndexMethod; + if ((getDeleteIndexMethod = FirestoreAdminGrpc.getDeleteIndexMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteIndexMethod = FirestoreAdminGrpc.getDeleteIndexMethod) == null) { + FirestoreAdminGrpc.getDeleteIndexMethod = + getDeleteIndexMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteIndex")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteIndexRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteIndex")) + .build(); + } + } + } + return getDeleteIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetFieldRequest, com.google.firestore.admin.v1.Field> + getGetFieldMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetField", + requestType = com.google.firestore.admin.v1.GetFieldRequest.class, + responseType = com.google.firestore.admin.v1.Field.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetFieldRequest, com.google.firestore.admin.v1.Field> + getGetFieldMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetFieldRequest, com.google.firestore.admin.v1.Field> + getGetFieldMethod; + if ((getGetFieldMethod = FirestoreAdminGrpc.getGetFieldMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetFieldMethod = FirestoreAdminGrpc.getGetFieldMethod) == null) { + FirestoreAdminGrpc.getGetFieldMethod = + getGetFieldMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetField")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetFieldRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.Field.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreAdminMethodDescriptorSupplier("GetField")) + .build(); + } + } + } + return getGetFieldMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateFieldRequest, com.google.longrunning.Operation> + getUpdateFieldMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateField", + requestType = com.google.firestore.admin.v1.UpdateFieldRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateFieldRequest, com.google.longrunning.Operation> + getUpdateFieldMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateFieldRequest, com.google.longrunning.Operation> + getUpdateFieldMethod; + if ((getUpdateFieldMethod = FirestoreAdminGrpc.getUpdateFieldMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getUpdateFieldMethod = FirestoreAdminGrpc.getUpdateFieldMethod) == null) { + FirestoreAdminGrpc.getUpdateFieldMethod = + getUpdateFieldMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateField")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UpdateFieldRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("UpdateField")) + .build(); + } + } + } + return getUpdateFieldMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListFieldsRequest, + com.google.firestore.admin.v1.ListFieldsResponse> + getListFieldsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListFields", + requestType = com.google.firestore.admin.v1.ListFieldsRequest.class, + responseType = com.google.firestore.admin.v1.ListFieldsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListFieldsRequest, + com.google.firestore.admin.v1.ListFieldsResponse> + getListFieldsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListFieldsRequest, + com.google.firestore.admin.v1.ListFieldsResponse> + getListFieldsMethod; + if ((getListFieldsMethod = FirestoreAdminGrpc.getListFieldsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListFieldsMethod = FirestoreAdminGrpc.getListFieldsMethod) == null) { + FirestoreAdminGrpc.getListFieldsMethod = + getListFieldsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListFields")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListFieldsRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListFieldsResponse + .getDefaultInstance())) + .setSchemaDescriptor(new FirestoreAdminMethodDescriptorSupplier("ListFields")) + .build(); + } + } + } + return getListFieldsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ExportDocumentsRequest, com.google.longrunning.Operation> + getExportDocumentsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ExportDocuments", + requestType = com.google.firestore.admin.v1.ExportDocumentsRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ExportDocumentsRequest, com.google.longrunning.Operation> + getExportDocumentsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ExportDocumentsRequest, com.google.longrunning.Operation> + getExportDocumentsMethod; + if ((getExportDocumentsMethod = FirestoreAdminGrpc.getExportDocumentsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getExportDocumentsMethod = FirestoreAdminGrpc.getExportDocumentsMethod) == null) { + FirestoreAdminGrpc.getExportDocumentsMethod = + getExportDocumentsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExportDocuments")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ExportDocumentsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ExportDocuments")) + .build(); + } + } + } + return getExportDocumentsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ImportDocumentsRequest, com.google.longrunning.Operation> + getImportDocumentsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ImportDocuments", + requestType = com.google.firestore.admin.v1.ImportDocumentsRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ImportDocumentsRequest, com.google.longrunning.Operation> + getImportDocumentsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ImportDocumentsRequest, com.google.longrunning.Operation> + getImportDocumentsMethod; + if ((getImportDocumentsMethod = FirestoreAdminGrpc.getImportDocumentsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getImportDocumentsMethod = FirestoreAdminGrpc.getImportDocumentsMethod) == null) { + FirestoreAdminGrpc.getImportDocumentsMethod = + getImportDocumentsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ImportDocuments")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ImportDocumentsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ImportDocuments")) + .build(); + } + } + } + return getImportDocumentsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest, + com.google.longrunning.Operation> + getBulkDeleteDocumentsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "BulkDeleteDocuments", + requestType = com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest, + com.google.longrunning.Operation> + getBulkDeleteDocumentsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest, + com.google.longrunning.Operation> + getBulkDeleteDocumentsMethod; + if ((getBulkDeleteDocumentsMethod = FirestoreAdminGrpc.getBulkDeleteDocumentsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getBulkDeleteDocumentsMethod = FirestoreAdminGrpc.getBulkDeleteDocumentsMethod) + == null) { + FirestoreAdminGrpc.getBulkDeleteDocumentsMethod = + getBulkDeleteDocumentsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "BulkDeleteDocuments")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("BulkDeleteDocuments")) + .build(); + } + } + } + return getBulkDeleteDocumentsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateDatabaseRequest, com.google.longrunning.Operation> + getCreateDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateDatabase", + requestType = com.google.firestore.admin.v1.CreateDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateDatabaseRequest, com.google.longrunning.Operation> + getCreateDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateDatabaseRequest, com.google.longrunning.Operation> + getCreateDatabaseMethod; + if ((getCreateDatabaseMethod = FirestoreAdminGrpc.getCreateDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCreateDatabaseMethod = FirestoreAdminGrpc.getCreateDatabaseMethod) == null) { + FirestoreAdminGrpc.getCreateDatabaseMethod = + getCreateDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CreateDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CreateDatabase")) + .build(); + } + } + } + return getCreateDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetDatabaseRequest, com.google.firestore.admin.v1.Database> + getGetDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetDatabase", + requestType = com.google.firestore.admin.v1.GetDatabaseRequest.class, + responseType = com.google.firestore.admin.v1.Database.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetDatabaseRequest, com.google.firestore.admin.v1.Database> + getGetDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetDatabaseRequest, + com.google.firestore.admin.v1.Database> + getGetDatabaseMethod; + if ((getGetDatabaseMethod = FirestoreAdminGrpc.getGetDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetDatabaseMethod = FirestoreAdminGrpc.getGetDatabaseMethod) == null) { + FirestoreAdminGrpc.getGetDatabaseMethod = + getGetDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.Database.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("GetDatabase")) + .build(); + } + } + } + return getGetDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListDatabasesRequest, + com.google.firestore.admin.v1.ListDatabasesResponse> + getListDatabasesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListDatabases", + requestType = com.google.firestore.admin.v1.ListDatabasesRequest.class, + responseType = com.google.firestore.admin.v1.ListDatabasesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListDatabasesRequest, + com.google.firestore.admin.v1.ListDatabasesResponse> + getListDatabasesMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListDatabasesRequest, + com.google.firestore.admin.v1.ListDatabasesResponse> + getListDatabasesMethod; + if ((getListDatabasesMethod = FirestoreAdminGrpc.getListDatabasesMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListDatabasesMethod = FirestoreAdminGrpc.getListDatabasesMethod) == null) { + FirestoreAdminGrpc.getListDatabasesMethod = + getListDatabasesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListDatabases")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListDatabasesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListDatabasesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListDatabases")) + .build(); + } + } + } + return getListDatabasesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateDatabaseRequest, com.google.longrunning.Operation> + getUpdateDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateDatabase", + requestType = com.google.firestore.admin.v1.UpdateDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateDatabaseRequest, com.google.longrunning.Operation> + getUpdateDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateDatabaseRequest, com.google.longrunning.Operation> + getUpdateDatabaseMethod; + if ((getUpdateDatabaseMethod = FirestoreAdminGrpc.getUpdateDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getUpdateDatabaseMethod = FirestoreAdminGrpc.getUpdateDatabaseMethod) == null) { + FirestoreAdminGrpc.getUpdateDatabaseMethod = + getUpdateDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UpdateDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("UpdateDatabase")) + .build(); + } + } + } + return getUpdateDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteDatabaseRequest, com.google.longrunning.Operation> + getDeleteDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteDatabase", + requestType = com.google.firestore.admin.v1.DeleteDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteDatabaseRequest, com.google.longrunning.Operation> + getDeleteDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteDatabaseRequest, com.google.longrunning.Operation> + getDeleteDatabaseMethod; + if ((getDeleteDatabaseMethod = FirestoreAdminGrpc.getDeleteDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteDatabaseMethod = FirestoreAdminGrpc.getDeleteDatabaseMethod) == null) { + FirestoreAdminGrpc.getDeleteDatabaseMethod = + getDeleteDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteDatabase")) + .build(); + } + } + } + return getDeleteDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getCreateUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateUserCreds", + requestType = com.google.firestore.admin.v1.CreateUserCredsRequest.class, + responseType = com.google.firestore.admin.v1.UserCreds.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getCreateUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getCreateUserCredsMethod; + if ((getCreateUserCredsMethod = FirestoreAdminGrpc.getCreateUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCreateUserCredsMethod = FirestoreAdminGrpc.getCreateUserCredsMethod) == null) { + FirestoreAdminGrpc.getCreateUserCredsMethod = + getCreateUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CreateUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UserCreds.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CreateUserCreds")) + .build(); + } + } + } + return getCreateUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getGetUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetUserCreds", + requestType = com.google.firestore.admin.v1.GetUserCredsRequest.class, + responseType = com.google.firestore.admin.v1.UserCreds.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getGetUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getGetUserCredsMethod; + if ((getGetUserCredsMethod = FirestoreAdminGrpc.getGetUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetUserCredsMethod = FirestoreAdminGrpc.getGetUserCredsMethod) == null) { + FirestoreAdminGrpc.getGetUserCredsMethod = + getGetUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UserCreds.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("GetUserCreds")) + .build(); + } + } + } + return getGetUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListUserCredsRequest, + com.google.firestore.admin.v1.ListUserCredsResponse> + getListUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListUserCreds", + requestType = com.google.firestore.admin.v1.ListUserCredsRequest.class, + responseType = com.google.firestore.admin.v1.ListUserCredsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListUserCredsRequest, + com.google.firestore.admin.v1.ListUserCredsResponse> + getListUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListUserCredsRequest, + com.google.firestore.admin.v1.ListUserCredsResponse> + getListUserCredsMethod; + if ((getListUserCredsMethod = FirestoreAdminGrpc.getListUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListUserCredsMethod = FirestoreAdminGrpc.getListUserCredsMethod) == null) { + FirestoreAdminGrpc.getListUserCredsMethod = + getListUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListUserCredsResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListUserCreds")) + .build(); + } + } + } + return getListUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.EnableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getEnableUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "EnableUserCreds", + requestType = com.google.firestore.admin.v1.EnableUserCredsRequest.class, + responseType = com.google.firestore.admin.v1.UserCreds.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.EnableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getEnableUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.EnableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getEnableUserCredsMethod; + if ((getEnableUserCredsMethod = FirestoreAdminGrpc.getEnableUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getEnableUserCredsMethod = FirestoreAdminGrpc.getEnableUserCredsMethod) == null) { + FirestoreAdminGrpc.getEnableUserCredsMethod = + getEnableUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "EnableUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.EnableUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UserCreds.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("EnableUserCreds")) + .build(); + } + } + } + return getEnableUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DisableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getDisableUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DisableUserCreds", + requestType = com.google.firestore.admin.v1.DisableUserCredsRequest.class, + responseType = com.google.firestore.admin.v1.UserCreds.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DisableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getDisableUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DisableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds> + getDisableUserCredsMethod; + if ((getDisableUserCredsMethod = FirestoreAdminGrpc.getDisableUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDisableUserCredsMethod = FirestoreAdminGrpc.getDisableUserCredsMethod) == null) { + FirestoreAdminGrpc.getDisableUserCredsMethod = + getDisableUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DisableUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DisableUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UserCreds.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DisableUserCreds")) + .build(); + } + } + } + return getDisableUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ResetUserPasswordRequest, + com.google.firestore.admin.v1.UserCreds> + getResetUserPasswordMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ResetUserPassword", + requestType = com.google.firestore.admin.v1.ResetUserPasswordRequest.class, + responseType = com.google.firestore.admin.v1.UserCreds.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ResetUserPasswordRequest, + com.google.firestore.admin.v1.UserCreds> + getResetUserPasswordMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ResetUserPasswordRequest, + com.google.firestore.admin.v1.UserCreds> + getResetUserPasswordMethod; + if ((getResetUserPasswordMethod = FirestoreAdminGrpc.getResetUserPasswordMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getResetUserPasswordMethod = FirestoreAdminGrpc.getResetUserPasswordMethod) == null) { + FirestoreAdminGrpc.getResetUserPasswordMethod = + getResetUserPasswordMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ResetUserPassword")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ResetUserPasswordRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UserCreds.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ResetUserPassword")) + .build(); + } + } + } + return getResetUserPasswordMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteUserCredsRequest, com.google.protobuf.Empty> + getDeleteUserCredsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteUserCreds", + requestType = com.google.firestore.admin.v1.DeleteUserCredsRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteUserCredsRequest, com.google.protobuf.Empty> + getDeleteUserCredsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteUserCredsRequest, com.google.protobuf.Empty> + getDeleteUserCredsMethod; + if ((getDeleteUserCredsMethod = FirestoreAdminGrpc.getDeleteUserCredsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteUserCredsMethod = FirestoreAdminGrpc.getDeleteUserCredsMethod) == null) { + FirestoreAdminGrpc.getDeleteUserCredsMethod = + getDeleteUserCredsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteUserCreds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteUserCredsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteUserCreds")) + .build(); + } + } + } + return getDeleteUserCredsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetBackup", + requestType = com.google.firestore.admin.v1.GetBackupRequest.class, + responseType = com.google.firestore.admin.v1.Backup.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupRequest, com.google.firestore.admin.v1.Backup> + getGetBackupMethod; + if ((getGetBackupMethod = FirestoreAdminGrpc.getGetBackupMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetBackupMethod = FirestoreAdminGrpc.getGetBackupMethod) == null) { + FirestoreAdminGrpc.getGetBackupMethod = + getGetBackupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBackup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.Backup.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreAdminMethodDescriptorSupplier("GetBackup")) + .build(); + } + } + } + return getGetBackupMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListBackups", + requestType = com.google.firestore.admin.v1.ListBackupsRequest.class, + responseType = com.google.firestore.admin.v1.ListBackupsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse> + getListBackupsMethod; + if ((getListBackupsMethod = FirestoreAdminGrpc.getListBackupsMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListBackupsMethod = FirestoreAdminGrpc.getListBackupsMethod) == null) { + FirestoreAdminGrpc.getListBackupsMethod = + getListBackupsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListBackups")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupsResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListBackups")) + .build(); + } + } + } + return getListBackupsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteBackup", + requestType = com.google.firestore.admin.v1.DeleteBackupRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty> + getDeleteBackupMethod; + if ((getDeleteBackupMethod = FirestoreAdminGrpc.getDeleteBackupMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteBackupMethod = FirestoreAdminGrpc.getDeleteBackupMethod) == null) { + FirestoreAdminGrpc.getDeleteBackupMethod = + getDeleteBackupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteBackup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteBackupRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteBackup")) + .build(); + } + } + } + return getDeleteBackupMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RestoreDatabase", + requestType = com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.RestoreDatabaseRequest, com.google.longrunning.Operation> + getRestoreDatabaseMethod; + if ((getRestoreDatabaseMethod = FirestoreAdminGrpc.getRestoreDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getRestoreDatabaseMethod = FirestoreAdminGrpc.getRestoreDatabaseMethod) == null) { + FirestoreAdminGrpc.getRestoreDatabaseMethod = + getRestoreDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RestoreDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.RestoreDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("RestoreDatabase")) + .build(); + } + } + } + return getRestoreDatabaseMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateBackupSchedule", + requestType = com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getCreateBackupScheduleMethod; + if ((getCreateBackupScheduleMethod = FirestoreAdminGrpc.getCreateBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCreateBackupScheduleMethod = FirestoreAdminGrpc.getCreateBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getCreateBackupScheduleMethod = + getCreateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "CreateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CreateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CreateBackupSchedule")) + .build(); + } + } + } + return getCreateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetBackupSchedule", + requestType = com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getGetBackupScheduleMethod; + if ((getGetBackupScheduleMethod = FirestoreAdminGrpc.getGetBackupScheduleMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getGetBackupScheduleMethod = FirestoreAdminGrpc.getGetBackupScheduleMethod) == null) { + FirestoreAdminGrpc.getGetBackupScheduleMethod = + getGetBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.GetBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("GetBackupSchedule")) + .build(); + } + } + } + return getGetBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListBackupSchedules", + requestType = com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + responseType = com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + if ((getListBackupSchedulesMethod = FirestoreAdminGrpc.getListBackupSchedulesMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getListBackupSchedulesMethod = FirestoreAdminGrpc.getListBackupSchedulesMethod) + == null) { + FirestoreAdminGrpc.getListBackupSchedulesMethod = + getListBackupSchedulesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "ListBackupSchedules")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupSchedulesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.ListBackupSchedulesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("ListBackupSchedules")) + .build(); + } + } + } + return getListBackupSchedulesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateBackupSchedule", + requestType = com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + responseType = com.google.firestore.admin.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + if ((getUpdateBackupScheduleMethod = FirestoreAdminGrpc.getUpdateBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getUpdateBackupScheduleMethod = FirestoreAdminGrpc.getUpdateBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getUpdateBackupScheduleMethod = + getUpdateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "UpdateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("UpdateBackupSchedule")) + .build(); + } + } + } + return getUpdateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteBackupSchedule", + requestType = com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + if ((getDeleteBackupScheduleMethod = FirestoreAdminGrpc.getDeleteBackupScheduleMethod) + == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getDeleteBackupScheduleMethod = FirestoreAdminGrpc.getDeleteBackupScheduleMethod) + == null) { + FirestoreAdminGrpc.getDeleteBackupScheduleMethod = + getDeleteBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "DeleteBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("DeleteBackupSchedule")) + .build(); + } + } + } + return getDeleteBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CloneDatabaseRequest, com.google.longrunning.Operation> + getCloneDatabaseMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CloneDatabase", + requestType = com.google.firestore.admin.v1.CloneDatabaseRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CloneDatabaseRequest, com.google.longrunning.Operation> + getCloneDatabaseMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.admin.v1.CloneDatabaseRequest, com.google.longrunning.Operation> + getCloneDatabaseMethod; + if ((getCloneDatabaseMethod = FirestoreAdminGrpc.getCloneDatabaseMethod) == null) { + synchronized (FirestoreAdminGrpc.class) { + if ((getCloneDatabaseMethod = FirestoreAdminGrpc.getCloneDatabaseMethod) == null) { + FirestoreAdminGrpc.getCloneDatabaseMethod = + getCloneDatabaseMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CloneDatabase")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.admin.v1.CloneDatabaseRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreAdminMethodDescriptorSupplier("CloneDatabase")) + .build(); + } + } + } + return getCloneDatabaseMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static FirestoreAdminStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreAdminStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminStub(channel, callOptions); + } + }; + return FirestoreAdminStub.newStub(factory, channel); + } + + /** Creates a new blocking-style stub that supports all types of calls on the service */ + public static FirestoreAdminBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreAdminBlockingV2Stub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminBlockingV2Stub(channel, callOptions); + } + }; + return FirestoreAdminBlockingV2Stub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static FirestoreAdminBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreAdminBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminBlockingStub(channel, callOptions); + } + }; + return FirestoreAdminBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static FirestoreAdminFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreAdminFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminFutureStub(channel, callOptions); + } + }; + return FirestoreAdminFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Creates a composite index. This returns a
+     * [google.longrunning.Operation][google.longrunning.Operation] which may be
+     * used to track the status of the creation. The metadata for the operation
+     * will be the type
+     * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].
+     * 
+ */ + default void createIndex( + com.google.firestore.admin.v1.CreateIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists composite indexes.
+     * 
+ */ + default void listIndexes( + com.google.firestore.admin.v1.ListIndexesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListIndexesMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets a composite index.
+     * 
+ */ + default void getIndex( + com.google.firestore.admin.v1.GetIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a composite index.
+     * 
+ */ + default void deleteIndex( + com.google.firestore.admin.v1.DeleteIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets the metadata and configuration for a Field.
+     * 
+ */ + default void getField( + com.google.firestore.admin.v1.GetFieldRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetFieldMethod(), responseObserver); + } + + /** + * + * + *
+     * 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/*`.
+     * 
+ */ + default void updateField( + com.google.firestore.admin.v1.UpdateFieldRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateFieldMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists the field configuration and metadata for this database.
+     * Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with the filter set to `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ */ + default void listFields( + com.google.firestore.admin.v1.ListFieldsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getListFieldsMethod(), responseObserver); + } + + /** + * + * + *
+     * 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 export. The export occurs in the
+     * background and its progress can be monitored and managed via the
+     * Operation resource that is created. The output of an export may only be
+     * used once the associated operation is done. If an export operation is
+     * cancelled before completion it may leave partial data behind in Google
+     * Cloud Storage.
+     * For more details on export behavior and output format, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/export-import
+     * 
+ */ + default void exportDocuments( + com.google.firestore.admin.v1.ExportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getExportDocumentsMethod(), responseObserver); + } + + /** + * + * + *
+     * 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 via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + default void importDocuments( + com.google.firestore.admin.v1.ImportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getImportDocumentsMethod(), responseObserver); + } + + /** + * + * + *
+     * Bulk deletes a subset of documents from Google Cloud Firestore.
+     * Documents created or updated after the underlying system starts to process
+     * the request will not be deleted. The bulk delete occurs in the background
+     * and its progress can be monitored and managed via the Operation resource
+     * that is created.
+     * For more details on bulk delete behavior, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
+     * 
+ */ + default void bulkDeleteDocuments( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBulkDeleteDocumentsMethod(), responseObserver); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + default void createDatabase( + com.google.firestore.admin.v1.CreateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + default void getDatabase( + com.google.firestore.admin.v1.GetDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + default void listDatabases( + com.google.firestore.admin.v1.ListDatabasesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListDatabasesMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + default void updateDatabase( + com.google.firestore.admin.v1.UpdateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + default void deleteDatabase( + com.google.firestore.admin.v1.DeleteDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * Create a user creds.
+     * 
+ */ + default void createUserCreds( + com.google.firestore.admin.v1.CreateUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets a user creds resource. Note that the returned resource does not
+     * contain the secret value itself.
+     * 
+ */ + default void getUserCreds( + com.google.firestore.admin.v1.GetUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * List all user creds in the database. Note that the returned resource
+     * does not contain the secret value itself.
+     * 
+ */ + default void listUserCreds( + com.google.firestore.admin.v1.ListUserCredsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * Enables a user creds. No-op if the user creds are already enabled.
+     * 
+ */ + default void enableUserCreds( + com.google.firestore.admin.v1.EnableUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getEnableUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * Disables a user creds. No-op if the user creds are already disabled.
+     * 
+ */ + default void disableUserCreds( + com.google.firestore.admin.v1.DisableUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDisableUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * Resets the password of a user creds.
+     * 
+ */ + default void resetUserPassword( + com.google.firestore.admin.v1.ResetUserPasswordRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getResetUserPasswordMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a user creds.
+     * 
+ */ + default void deleteUserCreds( + com.google.firestore.admin.v1.DeleteUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteUserCredsMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + default void getBackup( + com.google.firestore.admin.v1.GetBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetBackupMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + default void listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListBackupsMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + default void deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteBackupMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + default void restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getRestoreDatabaseMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + default void createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + default void getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + default void listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListBackupSchedulesMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + default void updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + default void deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a new database by cloning an existing one.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing database. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * database.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the clone, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the clone was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + default void cloneDatabase( + com.google.firestore.admin.v1.CloneDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCloneDatabaseMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service FirestoreAdmin. + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public abstract static class FirestoreAdminImplBase + implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return FirestoreAdminGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service FirestoreAdmin. + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public static final class FirestoreAdminStub + extends io.grpc.stub.AbstractAsyncStub { + private FirestoreAdminStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreAdminStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a composite index. This returns a
+     * [google.longrunning.Operation][google.longrunning.Operation] which may be
+     * used to track the status of the creation. The metadata for the operation
+     * will be the type
+     * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].
+     * 
+ */ + public void createIndex( + com.google.firestore.admin.v1.CreateIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateIndexMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Lists composite indexes.
+     * 
+ */ + public void listIndexes( + com.google.firestore.admin.v1.ListIndexesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListIndexesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets a composite index.
+     * 
+ */ + public void getIndex( + com.google.firestore.admin.v1.GetIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetIndexMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Deletes a composite index.
+     * 
+ */ + public void deleteIndex( + com.google.firestore.admin.v1.DeleteIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets the metadata and configuration for a Field.
+     * 
+ */ + public void getField( + com.google.firestore.admin.v1.GetFieldRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetFieldMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * 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/*`.
+     * 
+ */ + public void updateField( + com.google.firestore.admin.v1.UpdateFieldRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateFieldMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Lists the field configuration and metadata for this database.
+     * Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with the filter set to `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ */ + public void listFields( + com.google.firestore.admin.v1.ListFieldsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListFieldsMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * 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 export. The export occurs in the
+     * background and its progress can be monitored and managed via the
+     * Operation resource that is created. The output of an export may only be
+     * used once the associated operation is done. If an export operation is
+     * cancelled before completion it may leave partial data behind in Google
+     * Cloud Storage.
+     * For more details on export behavior and output format, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/export-import
+     * 
+ */ + public void exportDocuments( + com.google.firestore.admin.v1.ExportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * 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 via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + public void importDocuments( + com.google.firestore.admin.v1.ImportDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Bulk deletes a subset of documents from Google Cloud Firestore.
+     * Documents created or updated after the underlying system starts to process
+     * the request will not be deleted. The bulk delete occurs in the background
+     * and its progress can be monitored and managed via the Operation resource
+     * that is created.
+     * For more details on bulk delete behavior, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
+     * 
+ */ + public void bulkDeleteDocuments( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getBulkDeleteDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + public void createDatabase( + com.google.firestore.admin.v1.CreateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + public void getDatabase( + com.google.firestore.admin.v1.GetDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + public void listDatabases( + com.google.firestore.admin.v1.ListDatabasesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListDatabasesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + public void updateDatabase( + com.google.firestore.admin.v1.UpdateDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + public void deleteDatabase( + com.google.firestore.admin.v1.DeleteDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Create a user creds.
+     * 
+ */ + public void createUserCreds( + com.google.firestore.admin.v1.CreateUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets a user creds resource. Note that the returned resource does not
+     * contain the secret value itself.
+     * 
+ */ + public void getUserCreds( + com.google.firestore.admin.v1.GetUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * List all user creds in the database. Note that the returned resource
+     * does not contain the secret value itself.
+     * 
+ */ + public void listUserCreds( + com.google.firestore.admin.v1.ListUserCredsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Enables a user creds. No-op if the user creds are already enabled.
+     * 
+ */ + public void enableUserCreds( + com.google.firestore.admin.v1.EnableUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getEnableUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Disables a user creds. No-op if the user creds are already disabled.
+     * 
+ */ + public void disableUserCreds( + com.google.firestore.admin.v1.DisableUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDisableUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Resets the password of a user creds.
+     * 
+ */ + public void resetUserPassword( + com.google.firestore.admin.v1.ResetUserPasswordRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getResetUserPasswordMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a user creds.
+     * 
+ */ + public void deleteUserCreds( + com.google.firestore.admin.v1.DeleteUserCredsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteUserCredsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public void getBackup( + com.google.firestore.admin.v1.GetBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetBackupMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public void listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListBackupsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public void deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteBackupMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public void restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRestoreDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public void createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public void getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public void listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public void updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public void deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Creates a new database by cloning an existing one.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing database. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * database.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the clone, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the clone was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public void cloneDatabase( + com.google.firestore.admin.v1.CloneDatabaseRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCloneDatabaseMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service FirestoreAdmin. + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public static final class FirestoreAdminBlockingV2Stub + extends io.grpc.stub.AbstractBlockingStub { + private FirestoreAdminBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreAdminBlockingV2Stub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminBlockingV2Stub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a composite index. This returns a
+     * [google.longrunning.Operation][google.longrunning.Operation] which may be
+     * used to track the status of the creation. The metadata for the operation
+     * will be the type
+     * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].
+     * 
+ */ + public com.google.longrunning.Operation createIndex( + com.google.firestore.admin.v1.CreateIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists composite indexes.
+     * 
+ */ + public com.google.firestore.admin.v1.ListIndexesResponse listIndexes( + com.google.firestore.admin.v1.ListIndexesRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListIndexesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets a composite index.
+     * 
+ */ + public com.google.firestore.admin.v1.Index getIndex( + com.google.firestore.admin.v1.GetIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a composite index.
+     * 
+ */ + public com.google.protobuf.Empty deleteIndex( + com.google.firestore.admin.v1.DeleteIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets the metadata and configuration for a Field.
+     * 
+ */ + public com.google.firestore.admin.v1.Field getField( + com.google.firestore.admin.v1.GetFieldRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetFieldMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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/*`.
+     * 
+ */ + public com.google.longrunning.Operation updateField( + com.google.firestore.admin.v1.UpdateFieldRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getUpdateFieldMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists the field configuration and metadata for this database.
+     * Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with the filter set to `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ */ + public com.google.firestore.admin.v1.ListFieldsResponse listFields( + com.google.firestore.admin.v1.ListFieldsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListFieldsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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 export. The export occurs in the
+     * background and its progress can be monitored and managed via the
+     * Operation resource that is created. The output of an export may only be
+     * used once the associated operation is done. If an export operation is
+     * cancelled before completion it may leave partial data behind in Google
+     * Cloud Storage.
+     * For more details on export behavior and output format, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/export-import
+     * 
+ */ + public com.google.longrunning.Operation exportDocuments( + com.google.firestore.admin.v1.ExportDocumentsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getExportDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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 via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + public com.google.longrunning.Operation importDocuments( + com.google.firestore.admin.v1.ImportDocumentsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getImportDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Bulk deletes a subset of documents from Google Cloud Firestore.
+     * Documents created or updated after the underlying system starts to process
+     * the request will not be deleted. The bulk delete occurs in the background
+     * and its progress can be monitored and managed via the Operation resource
+     * that is created.
+     * For more details on bulk delete behavior, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
+     * 
+ */ + public com.google.longrunning.Operation bulkDeleteDocuments( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getBulkDeleteDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + public com.google.longrunning.Operation createDatabase( + com.google.firestore.admin.v1.CreateDatabaseRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + public com.google.firestore.admin.v1.Database getDatabase( + com.google.firestore.admin.v1.GetDatabaseRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + public com.google.firestore.admin.v1.ListDatabasesResponse listDatabases( + com.google.firestore.admin.v1.ListDatabasesRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListDatabasesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + public com.google.longrunning.Operation updateDatabase( + com.google.firestore.admin.v1.UpdateDatabaseRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getUpdateDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + public com.google.longrunning.Operation deleteDatabase( + com.google.firestore.admin.v1.DeleteDatabaseRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Create a user creds.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds createUserCreds( + com.google.firestore.admin.v1.CreateUserCredsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets a user creds resource. Note that the returned resource does not
+     * contain the secret value itself.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds getUserCreds( + com.google.firestore.admin.v1.GetUserCredsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List all user creds in the database. Note that the returned resource
+     * does not contain the secret value itself.
+     * 
+ */ + public com.google.firestore.admin.v1.ListUserCredsResponse listUserCreds( + com.google.firestore.admin.v1.ListUserCredsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Enables a user creds. No-op if the user creds are already enabled.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds enableUserCreds( + com.google.firestore.admin.v1.EnableUserCredsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getEnableUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Disables a user creds. No-op if the user creds are already disabled.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds disableUserCreds( + com.google.firestore.admin.v1.DisableUserCredsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDisableUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Resets the password of a user creds.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds resetUserPassword( + com.google.firestore.admin.v1.ResetUserPasswordRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getResetUserPasswordMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a user creds.
+     * 
+ */ + public com.google.protobuf.Empty deleteUserCreds( + com.google.firestore.admin.v1.DeleteUserCredsRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public com.google.firestore.admin.v1.Backup getBackup( + com.google.firestore.admin.v1.GetBackupRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupsResponse listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListBackupsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.longrunning.Operation restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getRestoreDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupSchedulesResponse listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListBackupSchedulesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getUpdateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new database by cloning an existing one.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing database. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * database.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the clone, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the clone was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.longrunning.Operation cloneDatabase( + com.google.firestore.admin.v1.CloneDatabaseRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCloneDatabaseMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do limited synchronous rpc calls to service FirestoreAdmin. + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public static final class FirestoreAdminBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private FirestoreAdminBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreAdminBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a composite index. This returns a
+     * [google.longrunning.Operation][google.longrunning.Operation] which may be
+     * used to track the status of the creation. The metadata for the operation
+     * will be the type
+     * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].
+     * 
+ */ + public com.google.longrunning.Operation createIndex( + com.google.firestore.admin.v1.CreateIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists composite indexes.
+     * 
+ */ + public com.google.firestore.admin.v1.ListIndexesResponse listIndexes( + com.google.firestore.admin.v1.ListIndexesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListIndexesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets a composite index.
+     * 
+ */ + public com.google.firestore.admin.v1.Index getIndex( + com.google.firestore.admin.v1.GetIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a composite index.
+     * 
+ */ + public com.google.protobuf.Empty deleteIndex( + com.google.firestore.admin.v1.DeleteIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets the metadata and configuration for a Field.
+     * 
+ */ + public com.google.firestore.admin.v1.Field getField( + com.google.firestore.admin.v1.GetFieldRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetFieldMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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/*`.
+     * 
+ */ + public com.google.longrunning.Operation updateField( + com.google.firestore.admin.v1.UpdateFieldRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateFieldMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists the field configuration and metadata for this database.
+     * Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with the filter set to `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ */ + public com.google.firestore.admin.v1.ListFieldsResponse listFields( + com.google.firestore.admin.v1.ListFieldsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListFieldsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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 export. The export occurs in the
+     * background and its progress can be monitored and managed via the
+     * Operation resource that is created. The output of an export may only be
+     * used once the associated operation is done. If an export operation is
+     * cancelled before completion it may leave partial data behind in Google
+     * Cloud Storage.
+     * For more details on export behavior and output format, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/export-import
+     * 
+ */ + public com.google.longrunning.Operation exportDocuments( + com.google.firestore.admin.v1.ExportDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getExportDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * 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 via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + public com.google.longrunning.Operation importDocuments( + com.google.firestore.admin.v1.ImportDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getImportDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Bulk deletes a subset of documents from Google Cloud Firestore.
+     * Documents created or updated after the underlying system starts to process
+     * the request will not be deleted. The bulk delete occurs in the background
+     * and its progress can be monitored and managed via the Operation resource
+     * that is created.
+     * For more details on bulk delete behavior, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
+     * 
+ */ + public com.google.longrunning.Operation bulkDeleteDocuments( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getBulkDeleteDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + public com.google.longrunning.Operation createDatabase( + com.google.firestore.admin.v1.CreateDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + public com.google.firestore.admin.v1.Database getDatabase( + com.google.firestore.admin.v1.GetDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + public com.google.firestore.admin.v1.ListDatabasesResponse listDatabases( + com.google.firestore.admin.v1.ListDatabasesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListDatabasesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + public com.google.longrunning.Operation updateDatabase( + com.google.firestore.admin.v1.UpdateDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + public com.google.longrunning.Operation deleteDatabase( + com.google.firestore.admin.v1.DeleteDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Create a user creds.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds createUserCreds( + com.google.firestore.admin.v1.CreateUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets a user creds resource. Note that the returned resource does not
+     * contain the secret value itself.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds getUserCreds( + com.google.firestore.admin.v1.GetUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List all user creds in the database. Note that the returned resource
+     * does not contain the secret value itself.
+     * 
+ */ + public com.google.firestore.admin.v1.ListUserCredsResponse listUserCreds( + com.google.firestore.admin.v1.ListUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Enables a user creds. No-op if the user creds are already enabled.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds enableUserCreds( + com.google.firestore.admin.v1.EnableUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getEnableUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Disables a user creds. No-op if the user creds are already disabled.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds disableUserCreds( + com.google.firestore.admin.v1.DisableUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDisableUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Resets the password of a user creds.
+     * 
+ */ + public com.google.firestore.admin.v1.UserCreds resetUserPassword( + com.google.firestore.admin.v1.ResetUserPasswordRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getResetUserPasswordMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a user creds.
+     * 
+ */ + public com.google.protobuf.Empty deleteUserCreds( + com.google.firestore.admin.v1.DeleteUserCredsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteUserCredsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public com.google.firestore.admin.v1.Backup getBackup( + com.google.firestore.admin.v1.GetBackupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupsResponse listBackups( + com.google.firestore.admin.v1.ListBackupsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListBackupsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackup( + com.google.firestore.admin.v1.DeleteBackupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteBackupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.longrunning.Operation restoreDatabase( + com.google.firestore.admin.v1.RestoreDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRestoreDatabaseMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule createBackupSchedule( + com.google.firestore.admin.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule( + com.google.firestore.admin.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public com.google.firestore.admin.v1.ListBackupSchedulesResponse listBackupSchedules( + com.google.firestore.admin.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListBackupSchedulesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.firestore.admin.v1.BackupSchedule updateBackupSchedule( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackupSchedule( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new database by cloning an existing one.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing database. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * database.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the clone, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the clone was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.longrunning.Operation cloneDatabase( + com.google.firestore.admin.v1.CloneDatabaseRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCloneDatabaseMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service FirestoreAdmin. + * + *
+   * The Cloud Firestore Admin API.
+   * This API provides several administrative services for Cloud Firestore.
+   * Project, Database, Namespace, Collection, Collection Group, and Document are
+   * used as defined in the Google Cloud Firestore API.
+   * Operation: An Operation represents work being performed in the background.
+   * The index service manages Cloud Firestore indexes.
+   * Index creation is performed asynchronously.
+   * An Operation resource is created for each such asynchronous operation.
+   * The state of the operation (including any errors encountered)
+   * may be queried via the Operation resource.
+   * The Operations collection provides a record of actions performed for the
+   * specified Project (including any Operations in progress). Operations are not
+   * created directly but through calls on other collections or resources.
+   * An Operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection. Operations are garbage collected after
+   * 30 days. By default, ListOperations will only return in progress and failed
+   * operations. To list completed operation, issue a ListOperations request with
+   * the filter `done: true`.
+   * Operations are created by service `FirestoreAdmin`, but are accessed via
+   * service `google.longrunning.Operations`.
+   * 
+ */ + public static final class FirestoreAdminFutureStub + extends io.grpc.stub.AbstractFutureStub { + private FirestoreAdminFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreAdminFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreAdminFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Creates a composite index. This returns a
+     * [google.longrunning.Operation][google.longrunning.Operation] which may be
+     * used to track the status of the creation. The metadata for the operation
+     * will be the type
+     * [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata].
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + createIndex(com.google.firestore.admin.v1.CreateIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists composite indexes.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListIndexesResponse> + listIndexes(com.google.firestore.admin.v1.ListIndexesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListIndexesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets a composite index.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getIndex(com.google.firestore.admin.v1.GetIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a composite index.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteIndex(com.google.firestore.admin.v1.DeleteIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets the metadata and configuration for a Field.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getField(com.google.firestore.admin.v1.GetFieldRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetFieldMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * 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/*`.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + updateField(com.google.firestore.admin.v1.UpdateFieldRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateFieldMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists the field configuration and metadata for this database.
+     * Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with the filter set to `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListFieldsResponse> + listFields(com.google.firestore.admin.v1.ListFieldsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListFieldsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * 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 export. The export occurs in the
+     * background and its progress can be monitored and managed via the
+     * Operation resource that is created. The output of an export may only be
+     * used once the associated operation is done. If an export operation is
+     * cancelled before completion it may leave partial data behind in Google
+     * Cloud Storage.
+     * For more details on export behavior and output format, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/export-import
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + exportDocuments(com.google.firestore.admin.v1.ExportDocumentsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getExportDocumentsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * 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 via the Operation resource that is
+     * created. If an ImportDocuments operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Firestore.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + importDocuments(com.google.firestore.admin.v1.ImportDocumentsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getImportDocumentsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Bulk deletes a subset of documents from Google Cloud Firestore.
+     * Documents created or updated after the underlying system starts to process
+     * the request will not be deleted. The bulk delete occurs in the background
+     * and its progress can be monitored and managed via the Operation resource
+     * that is created.
+     * For more details on bulk delete behavior, refer to:
+     * https://cloud.google.com/firestore/docs/manage-data/bulk-delete
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + bulkDeleteDocuments(com.google.firestore.admin.v1.BulkDeleteDocumentsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getBulkDeleteDocumentsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Create a database.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + createDatabase(com.google.firestore.admin.v1.CreateDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets information about a database.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.Database> + getDatabase(com.google.firestore.admin.v1.GetDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * List all the databases in the project.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListDatabasesResponse> + listDatabases(com.google.firestore.admin.v1.ListDatabasesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListDatabasesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates a database.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + updateDatabase(com.google.firestore.admin.v1.UpdateDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a database.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteDatabase(com.google.firestore.admin.v1.DeleteDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Create a user creds.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.UserCreds> + createUserCreds(com.google.firestore.admin.v1.CreateUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets a user creds resource. Note that the returned resource does not
+     * contain the secret value itself.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.UserCreds> + getUserCreds(com.google.firestore.admin.v1.GetUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * List all user creds in the database. Note that the returned resource
+     * does not contain the secret value itself.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListUserCredsResponse> + listUserCreds(com.google.firestore.admin.v1.ListUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Enables a user creds. No-op if the user creds are already enabled.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.UserCreds> + enableUserCreds(com.google.firestore.admin.v1.EnableUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getEnableUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Disables a user creds. No-op if the user creds are already disabled.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.UserCreds> + disableUserCreds(com.google.firestore.admin.v1.DisableUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDisableUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Resets the password of a user creds.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.UserCreds> + resetUserPassword(com.google.firestore.admin.v1.ResetUserPasswordRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getResetUserPasswordMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a user creds.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteUserCreds(com.google.firestore.admin.v1.DeleteUserCredsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteUserCredsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets information about a backup.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getBackup(com.google.firestore.admin.v1.GetBackupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetBackupMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists all the backups.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListBackupsResponse> + listBackups(com.google.firestore.admin.v1.ListBackupsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListBackupsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a backup.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteBackup(com.google.firestore.admin.v1.DeleteBackupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteBackupMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a new database by restoring from an existing backup.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing backup. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * backup.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the restore, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the restore was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + restoreDatabase(com.google.firestore.admin.v1.RestoreDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRestoreDatabaseMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a backup schedule on a database.
+     * At most two backup schedules can be configured on a database, one daily
+     * backup schedule and one weekly backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + createBackupSchedule(com.google.firestore.admin.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets information about a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + getBackupSchedule(com.google.firestore.admin.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * List backup schedules.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.ListBackupSchedulesResponse> + listBackupSchedules(com.google.firestore.admin.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.admin.v1.BackupSchedule> + updateBackupSchedule(com.google.firestore.admin.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteBackupSchedule(com.google.firestore.admin.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a new database by cloning an existing one.
+     * The new database must be in the same cloud region or multi-region location
+     * as the existing database. This behaves similar to
+     * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]
+     * except instead of creating a new empty database, a new database is created
+     * with the database type, index configuration, and documents from an existing
+     * database.
+     * The [long-running operation][google.longrunning.Operation] can be used to
+     * track the progress of the clone, with the Operation's
+     * [metadata][google.longrunning.Operation.metadata] field type being the
+     * [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata].
+     * The [response][google.longrunning.Operation.response] type is the
+     * [Database][google.firestore.admin.v1.Database] if the clone was
+     * successful. The new database is not readable or writeable until the LRO has
+     * completed.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + cloneDatabase(com.google.firestore.admin.v1.CloneDatabaseRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCloneDatabaseMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_CREATE_INDEX = 0; + private static final int METHODID_LIST_INDEXES = 1; + private static final int METHODID_GET_INDEX = 2; + private static final int METHODID_DELETE_INDEX = 3; + private static final int METHODID_GET_FIELD = 4; + private static final int METHODID_UPDATE_FIELD = 5; + private static final int METHODID_LIST_FIELDS = 6; + private static final int METHODID_EXPORT_DOCUMENTS = 7; + private static final int METHODID_IMPORT_DOCUMENTS = 8; + private static final int METHODID_BULK_DELETE_DOCUMENTS = 9; + private static final int METHODID_CREATE_DATABASE = 10; + private static final int METHODID_GET_DATABASE = 11; + private static final int METHODID_LIST_DATABASES = 12; + private static final int METHODID_UPDATE_DATABASE = 13; + private static final int METHODID_DELETE_DATABASE = 14; + private static final int METHODID_CREATE_USER_CREDS = 15; + private static final int METHODID_GET_USER_CREDS = 16; + private static final int METHODID_LIST_USER_CREDS = 17; + private static final int METHODID_ENABLE_USER_CREDS = 18; + private static final int METHODID_DISABLE_USER_CREDS = 19; + private static final int METHODID_RESET_USER_PASSWORD = 20; + private static final int METHODID_DELETE_USER_CREDS = 21; + private static final int METHODID_GET_BACKUP = 22; + private static final int METHODID_LIST_BACKUPS = 23; + private static final int METHODID_DELETE_BACKUP = 24; + private static final int METHODID_RESTORE_DATABASE = 25; + private static final int METHODID_CREATE_BACKUP_SCHEDULE = 26; + private static final int METHODID_GET_BACKUP_SCHEDULE = 27; + private static final int METHODID_LIST_BACKUP_SCHEDULES = 28; + private static final int METHODID_UPDATE_BACKUP_SCHEDULE = 29; + private static final int METHODID_DELETE_BACKUP_SCHEDULE = 30; + private static final int METHODID_CLONE_DATABASE = 31; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final AsyncService serviceImpl; + private final int methodId; + + MethodHandlers(AsyncService serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_CREATE_INDEX: + serviceImpl.createIndex( + (com.google.firestore.admin.v1.CreateIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_INDEXES: + serviceImpl.listIndexes( + (com.google.firestore.admin.v1.ListIndexesRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_INDEX: + serviceImpl.getIndex( + (com.google.firestore.admin.v1.GetIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DELETE_INDEX: + serviceImpl.deleteIndex( + (com.google.firestore.admin.v1.DeleteIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_FIELD: + serviceImpl.getField( + (com.google.firestore.admin.v1.GetFieldRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_UPDATE_FIELD: + serviceImpl.updateField( + (com.google.firestore.admin.v1.UpdateFieldRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_FIELDS: + serviceImpl.listFields( + (com.google.firestore.admin.v1.ListFieldsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_EXPORT_DOCUMENTS: + serviceImpl.exportDocuments( + (com.google.firestore.admin.v1.ExportDocumentsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_IMPORT_DOCUMENTS: + serviceImpl.importDocuments( + (com.google.firestore.admin.v1.ImportDocumentsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BULK_DELETE_DOCUMENTS: + serviceImpl.bulkDeleteDocuments( + (com.google.firestore.admin.v1.BulkDeleteDocumentsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_DATABASE: + serviceImpl.createDatabase( + (com.google.firestore.admin.v1.CreateDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_DATABASE: + serviceImpl.getDatabase( + (com.google.firestore.admin.v1.GetDatabaseRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_DATABASES: + serviceImpl.listDatabases( + (com.google.firestore.admin.v1.ListDatabasesRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_UPDATE_DATABASE: + serviceImpl.updateDatabase( + (com.google.firestore.admin.v1.UpdateDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DELETE_DATABASE: + serviceImpl.deleteDatabase( + (com.google.firestore.admin.v1.DeleteDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_USER_CREDS: + serviceImpl.createUserCreds( + (com.google.firestore.admin.v1.CreateUserCredsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_USER_CREDS: + serviceImpl.getUserCreds( + (com.google.firestore.admin.v1.GetUserCredsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_USER_CREDS: + serviceImpl.listUserCreds( + (com.google.firestore.admin.v1.ListUserCredsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_ENABLE_USER_CREDS: + serviceImpl.enableUserCreds( + (com.google.firestore.admin.v1.EnableUserCredsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DISABLE_USER_CREDS: + serviceImpl.disableUserCreds( + (com.google.firestore.admin.v1.DisableUserCredsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_RESET_USER_PASSWORD: + serviceImpl.resetUserPassword( + (com.google.firestore.admin.v1.ResetUserPasswordRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_USER_CREDS: + serviceImpl.deleteUserCreds( + (com.google.firestore.admin.v1.DeleteUserCredsRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_BACKUP: + serviceImpl.getBackup( + (com.google.firestore.admin.v1.GetBackupRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_BACKUPS: + serviceImpl.listBackups( + (com.google.firestore.admin.v1.ListBackupsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_BACKUP: + serviceImpl.deleteBackup( + (com.google.firestore.admin.v1.DeleteBackupRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_RESTORE_DATABASE: + serviceImpl.restoreDatabase( + (com.google.firestore.admin.v1.RestoreDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_BACKUP_SCHEDULE: + serviceImpl.createBackupSchedule( + (com.google.firestore.admin.v1.CreateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_BACKUP_SCHEDULE: + serviceImpl.getBackupSchedule( + (com.google.firestore.admin.v1.GetBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_BACKUP_SCHEDULES: + serviceImpl.listBackupSchedules( + (com.google.firestore.admin.v1.ListBackupSchedulesRequest) request, + (io.grpc.stub.StreamObserver< + com.google.firestore.admin.v1.ListBackupSchedulesResponse>) + responseObserver); + break; + case METHODID_UPDATE_BACKUP_SCHEDULE: + serviceImpl.updateBackupSchedule( + (com.google.firestore.admin.v1.UpdateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_BACKUP_SCHEDULE: + serviceImpl.deleteBackupSchedule( + (com.google.firestore.admin.v1.DeleteBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CLONE_DATABASE: + serviceImpl.cloneDatabase( + (com.google.firestore.admin.v1.CloneDatabaseRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + default: + throw new AssertionError(); + } + } + } + + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getCreateIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CreateIndexRequest, + com.google.longrunning.Operation>(service, METHODID_CREATE_INDEX))) + .addMethod( + getListIndexesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListIndexesRequest, + com.google.firestore.admin.v1.ListIndexesResponse>( + service, METHODID_LIST_INDEXES))) + .addMethod( + getGetIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetIndexRequest, + com.google.firestore.admin.v1.Index>(service, METHODID_GET_INDEX))) + .addMethod( + getDeleteIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteIndexRequest, com.google.protobuf.Empty>( + service, METHODID_DELETE_INDEX))) + .addMethod( + getGetFieldMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetFieldRequest, + com.google.firestore.admin.v1.Field>(service, METHODID_GET_FIELD))) + .addMethod( + getUpdateFieldMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.UpdateFieldRequest, + com.google.longrunning.Operation>(service, METHODID_UPDATE_FIELD))) + .addMethod( + getListFieldsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListFieldsRequest, + com.google.firestore.admin.v1.ListFieldsResponse>( + service, METHODID_LIST_FIELDS))) + .addMethod( + getExportDocumentsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ExportDocumentsRequest, + com.google.longrunning.Operation>(service, METHODID_EXPORT_DOCUMENTS))) + .addMethod( + getImportDocumentsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ImportDocumentsRequest, + com.google.longrunning.Operation>(service, METHODID_IMPORT_DOCUMENTS))) + .addMethod( + getBulkDeleteDocumentsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest, + com.google.longrunning.Operation>(service, METHODID_BULK_DELETE_DOCUMENTS))) + .addMethod( + getCreateDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CreateDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_CREATE_DATABASE))) + .addMethod( + getGetDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetDatabaseRequest, + com.google.firestore.admin.v1.Database>(service, METHODID_GET_DATABASE))) + .addMethod( + getListDatabasesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListDatabasesRequest, + com.google.firestore.admin.v1.ListDatabasesResponse>( + service, METHODID_LIST_DATABASES))) + .addMethod( + getUpdateDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.UpdateDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_UPDATE_DATABASE))) + .addMethod( + getDeleteDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_DELETE_DATABASE))) + .addMethod( + getCreateUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CreateUserCredsRequest, + com.google.firestore.admin.v1.UserCreds>(service, METHODID_CREATE_USER_CREDS))) + .addMethod( + getGetUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetUserCredsRequest, + com.google.firestore.admin.v1.UserCreds>(service, METHODID_GET_USER_CREDS))) + .addMethod( + getListUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListUserCredsRequest, + com.google.firestore.admin.v1.ListUserCredsResponse>( + service, METHODID_LIST_USER_CREDS))) + .addMethod( + getEnableUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.EnableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds>(service, METHODID_ENABLE_USER_CREDS))) + .addMethod( + getDisableUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DisableUserCredsRequest, + com.google.firestore.admin.v1.UserCreds>(service, METHODID_DISABLE_USER_CREDS))) + .addMethod( + getResetUserPasswordMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ResetUserPasswordRequest, + com.google.firestore.admin.v1.UserCreds>( + service, METHODID_RESET_USER_PASSWORD))) + .addMethod( + getDeleteUserCredsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteUserCredsRequest, + com.google.protobuf.Empty>(service, METHODID_DELETE_USER_CREDS))) + .addMethod( + getGetBackupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetBackupRequest, + com.google.firestore.admin.v1.Backup>(service, METHODID_GET_BACKUP))) + .addMethod( + getListBackupsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListBackupsRequest, + com.google.firestore.admin.v1.ListBackupsResponse>( + service, METHODID_LIST_BACKUPS))) + .addMethod( + getDeleteBackupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteBackupRequest, com.google.protobuf.Empty>( + service, METHODID_DELETE_BACKUP))) + .addMethod( + getRestoreDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.RestoreDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_RESTORE_DATABASE))) + .addMethod( + getCreateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CreateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_CREATE_BACKUP_SCHEDULE))) + .addMethod( + getGetBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.GetBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_GET_BACKUP_SCHEDULE))) + .addMethod( + getListBackupSchedulesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.ListBackupSchedulesRequest, + com.google.firestore.admin.v1.ListBackupSchedulesResponse>( + service, METHODID_LIST_BACKUP_SCHEDULES))) + .addMethod( + getUpdateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.UpdateBackupScheduleRequest, + com.google.firestore.admin.v1.BackupSchedule>( + service, METHODID_UPDATE_BACKUP_SCHEDULE))) + .addMethod( + getDeleteBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty>(service, METHODID_DELETE_BACKUP_SCHEDULE))) + .addMethod( + getCloneDatabaseMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.admin.v1.CloneDatabaseRequest, + com.google.longrunning.Operation>(service, METHODID_CLONE_DATABASE))) + .build(); + } + + private abstract static class FirestoreAdminBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + FirestoreAdminBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("FirestoreAdmin"); + } + } + + private static final class FirestoreAdminFileDescriptorSupplier + extends FirestoreAdminBaseDescriptorSupplier { + FirestoreAdminFileDescriptorSupplier() {} + } + + private static final class FirestoreAdminMethodDescriptorSupplier + extends FirestoreAdminBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final java.lang.String methodName; + + FirestoreAdminMethodDescriptorSupplier(java.lang.String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (FirestoreAdminGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new FirestoreAdminFileDescriptorSupplier()) + .addMethod(getCreateIndexMethod()) + .addMethod(getListIndexesMethod()) + .addMethod(getGetIndexMethod()) + .addMethod(getDeleteIndexMethod()) + .addMethod(getGetFieldMethod()) + .addMethod(getUpdateFieldMethod()) + .addMethod(getListFieldsMethod()) + .addMethod(getExportDocumentsMethod()) + .addMethod(getImportDocumentsMethod()) + .addMethod(getBulkDeleteDocumentsMethod()) + .addMethod(getCreateDatabaseMethod()) + .addMethod(getGetDatabaseMethod()) + .addMethod(getListDatabasesMethod()) + .addMethod(getUpdateDatabaseMethod()) + .addMethod(getDeleteDatabaseMethod()) + .addMethod(getCreateUserCredsMethod()) + .addMethod(getGetUserCredsMethod()) + .addMethod(getListUserCredsMethod()) + .addMethod(getEnableUserCredsMethod()) + .addMethod(getDisableUserCredsMethod()) + .addMethod(getResetUserPasswordMethod()) + .addMethod(getDeleteUserCredsMethod()) + .addMethod(getGetBackupMethod()) + .addMethod(getListBackupsMethod()) + .addMethod(getDeleteBackupMethod()) + .addMethod(getRestoreDatabaseMethod()) + .addMethod(getCreateBackupScheduleMethod()) + .addMethod(getGetBackupScheduleMethod()) + .addMethod(getListBackupSchedulesMethod()) + .addMethod(getUpdateBackupScheduleMethod()) + .addMethod(getDeleteBackupScheduleMethod()) + .addMethod(getCloneDatabaseMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-firestore/grpc-google-cloud-firestore-v1/clirr-ignored-differences.xml b/java-firestore/grpc-google-cloud-firestore-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..96786faafc0d --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-v1/clirr-ignored-differences.xml @@ -0,0 +1,9 @@ + + + + + 7012 + com/google/firestore/v1/FirestoreGrpc$AsyncService + * executePipeline(*) + + diff --git a/java-firestore/grpc-google-cloud-firestore-v1/pom.xml b/java-firestore/grpc-google-cloud-firestore-v1/pom.xml new file mode 100644 index 000000000000..7696d0e76ef3 --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-v1/pom.xml @@ -0,0 +1,66 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + grpc-google-cloud-firestore-v1 + GRPC library for grpc-google-cloud-firestore-v1 + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + io.grpc + grpc-stub + compile + + + io.grpc + grpc-protobuf + compile + + + com.google.api.grpc + proto-google-cloud-firestore-v1 + compile + + + io.grpc + grpc-api + + + com.google.protobuf + protobuf-java + + + com.google.guava + guava + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java b/java-firestore/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java new file mode 100644 index 000000000000..ed1b22026a6f --- /dev/null +++ b/java-firestore/grpc-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreGrpc.java @@ -0,0 +1,2460 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.firestore.v1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * The Cloud Firestore service.
+ * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+ * document database that simplifies storing, syncing, and querying data for
+ * your mobile, web, and IoT apps at global scale. Its client libraries provide
+ * live synchronization and offline support, while its security features and
+ * integrations with Firebase and Google Cloud Platform accelerate building
+ * truly serverless apps.
+ * 
+ */ +@io.grpc.stub.annotations.GrpcGenerated +public final class FirestoreGrpc { + + private FirestoreGrpc() {} + + public static final java.lang.String SERVICE_NAME = "google.firestore.v1.Firestore"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.GetDocumentRequest, com.google.firestore.v1.Document> + getGetDocumentMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetDocument", + requestType = com.google.firestore.v1.GetDocumentRequest.class, + responseType = com.google.firestore.v1.Document.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.GetDocumentRequest, com.google.firestore.v1.Document> + getGetDocumentMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.GetDocumentRequest, com.google.firestore.v1.Document> + getGetDocumentMethod; + if ((getGetDocumentMethod = FirestoreGrpc.getGetDocumentMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getGetDocumentMethod = FirestoreGrpc.getGetDocumentMethod) == null) { + FirestoreGrpc.getGetDocumentMethod = + getGetDocumentMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetDocument")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.GetDocumentRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.Document.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("GetDocument")) + .build(); + } + } + } + return getGetDocumentMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.ListDocumentsRequest, + com.google.firestore.v1.ListDocumentsResponse> + getListDocumentsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListDocuments", + requestType = com.google.firestore.v1.ListDocumentsRequest.class, + responseType = com.google.firestore.v1.ListDocumentsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.ListDocumentsRequest, + com.google.firestore.v1.ListDocumentsResponse> + getListDocumentsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.ListDocumentsRequest, + com.google.firestore.v1.ListDocumentsResponse> + getListDocumentsMethod; + if ((getListDocumentsMethod = FirestoreGrpc.getListDocumentsMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getListDocumentsMethod = FirestoreGrpc.getListDocumentsMethod) == null) { + FirestoreGrpc.getListDocumentsMethod = + getListDocumentsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListDocuments")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListDocumentsRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListDocumentsResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("ListDocuments")) + .build(); + } + } + } + return getListDocumentsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.UpdateDocumentRequest, com.google.firestore.v1.Document> + getUpdateDocumentMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateDocument", + requestType = com.google.firestore.v1.UpdateDocumentRequest.class, + responseType = com.google.firestore.v1.Document.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.UpdateDocumentRequest, com.google.firestore.v1.Document> + getUpdateDocumentMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.UpdateDocumentRequest, com.google.firestore.v1.Document> + getUpdateDocumentMethod; + if ((getUpdateDocumentMethod = FirestoreGrpc.getUpdateDocumentMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getUpdateDocumentMethod = FirestoreGrpc.getUpdateDocumentMethod) == null) { + FirestoreGrpc.getUpdateDocumentMethod = + getUpdateDocumentMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "UpdateDocument")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.UpdateDocumentRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.Document.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("UpdateDocument")) + .build(); + } + } + } + return getUpdateDocumentMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.DeleteDocumentRequest, com.google.protobuf.Empty> + getDeleteDocumentMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteDocument", + requestType = com.google.firestore.v1.DeleteDocumentRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.DeleteDocumentRequest, com.google.protobuf.Empty> + getDeleteDocumentMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.DeleteDocumentRequest, com.google.protobuf.Empty> + getDeleteDocumentMethod; + if ((getDeleteDocumentMethod = FirestoreGrpc.getDeleteDocumentMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getDeleteDocumentMethod = FirestoreGrpc.getDeleteDocumentMethod) == null) { + FirestoreGrpc.getDeleteDocumentMethod = + getDeleteDocumentMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "DeleteDocument")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.DeleteDocumentRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("DeleteDocument")) + .build(); + } + } + } + return getDeleteDocumentMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchGetDocumentsRequest, + com.google.firestore.v1.BatchGetDocumentsResponse> + getBatchGetDocumentsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "BatchGetDocuments", + requestType = com.google.firestore.v1.BatchGetDocumentsRequest.class, + responseType = com.google.firestore.v1.BatchGetDocumentsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchGetDocumentsRequest, + com.google.firestore.v1.BatchGetDocumentsResponse> + getBatchGetDocumentsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchGetDocumentsRequest, + com.google.firestore.v1.BatchGetDocumentsResponse> + getBatchGetDocumentsMethod; + if ((getBatchGetDocumentsMethod = FirestoreGrpc.getBatchGetDocumentsMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getBatchGetDocumentsMethod = FirestoreGrpc.getBatchGetDocumentsMethod) == null) { + FirestoreGrpc.getBatchGetDocumentsMethod = + getBatchGetDocumentsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "BatchGetDocuments")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BatchGetDocumentsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BatchGetDocumentsResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreMethodDescriptorSupplier("BatchGetDocuments")) + .build(); + } + } + } + return getBatchGetDocumentsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.BeginTransactionRequest, + com.google.firestore.v1.BeginTransactionResponse> + getBeginTransactionMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "BeginTransaction", + requestType = com.google.firestore.v1.BeginTransactionRequest.class, + responseType = com.google.firestore.v1.BeginTransactionResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.BeginTransactionRequest, + com.google.firestore.v1.BeginTransactionResponse> + getBeginTransactionMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.BeginTransactionRequest, + com.google.firestore.v1.BeginTransactionResponse> + getBeginTransactionMethod; + if ((getBeginTransactionMethod = FirestoreGrpc.getBeginTransactionMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getBeginTransactionMethod = FirestoreGrpc.getBeginTransactionMethod) == null) { + FirestoreGrpc.getBeginTransactionMethod = + getBeginTransactionMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "BeginTransaction")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BeginTransactionRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BeginTransactionResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreMethodDescriptorSupplier("BeginTransaction")) + .build(); + } + } + } + return getBeginTransactionMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.CommitRequest, com.google.firestore.v1.CommitResponse> + getCommitMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Commit", + requestType = com.google.firestore.v1.CommitRequest.class, + responseType = com.google.firestore.v1.CommitResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.CommitRequest, com.google.firestore.v1.CommitResponse> + getCommitMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.CommitRequest, com.google.firestore.v1.CommitResponse> + getCommitMethod; + if ((getCommitMethod = FirestoreGrpc.getCommitMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getCommitMethod = FirestoreGrpc.getCommitMethod) == null) { + FirestoreGrpc.getCommitMethod = + getCommitMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Commit")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.CommitRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.CommitResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("Commit")) + .build(); + } + } + } + return getCommitMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.RollbackRequest, com.google.protobuf.Empty> + getRollbackMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Rollback", + requestType = com.google.firestore.v1.RollbackRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.RollbackRequest, com.google.protobuf.Empty> + getRollbackMethod() { + io.grpc.MethodDescriptor + getRollbackMethod; + if ((getRollbackMethod = FirestoreGrpc.getRollbackMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getRollbackMethod = FirestoreGrpc.getRollbackMethod) == null) { + FirestoreGrpc.getRollbackMethod = + getRollbackMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Rollback")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.RollbackRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("Rollback")) + .build(); + } + } + } + return getRollbackMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.RunQueryRequest, com.google.firestore.v1.RunQueryResponse> + getRunQueryMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RunQuery", + requestType = com.google.firestore.v1.RunQueryRequest.class, + responseType = com.google.firestore.v1.RunQueryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.RunQueryRequest, com.google.firestore.v1.RunQueryResponse> + getRunQueryMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.RunQueryRequest, com.google.firestore.v1.RunQueryResponse> + getRunQueryMethod; + if ((getRunQueryMethod = FirestoreGrpc.getRunQueryMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getRunQueryMethod = FirestoreGrpc.getRunQueryMethod) == null) { + FirestoreGrpc.getRunQueryMethod = + getRunQueryMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RunQuery")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.RunQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.RunQueryResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("RunQuery")) + .build(); + } + } + } + return getRunQueryMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ExecutePipeline", + requestType = com.google.firestore.v1.ExecutePipelineRequest.class, + responseType = com.google.firestore.v1.ExecutePipelineResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse> + getExecutePipelineMethod; + if ((getExecutePipelineMethod = FirestoreGrpc.getExecutePipelineMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getExecutePipelineMethod = FirestoreGrpc.getExecutePipelineMethod) == null) { + FirestoreGrpc.getExecutePipelineMethod = + getExecutePipelineMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExecutePipeline")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("ExecutePipeline")) + .build(); + } + } + } + return getExecutePipelineMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.RunAggregationQueryRequest, + com.google.firestore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RunAggregationQuery", + requestType = com.google.firestore.v1.RunAggregationQueryRequest.class, + responseType = com.google.firestore.v1.RunAggregationQueryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.RunAggregationQueryRequest, + com.google.firestore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.RunAggregationQueryRequest, + com.google.firestore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod; + if ((getRunAggregationQueryMethod = FirestoreGrpc.getRunAggregationQueryMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getRunAggregationQueryMethod = FirestoreGrpc.getRunAggregationQueryMethod) == null) { + FirestoreGrpc.getRunAggregationQueryMethod = + getRunAggregationQueryMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.SERVER_STREAMING) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "RunAggregationQuery")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.RunAggregationQueryRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.RunAggregationQueryResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreMethodDescriptorSupplier("RunAggregationQuery")) + .build(); + } + } + } + return getRunAggregationQueryMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.PartitionQueryRequest, + com.google.firestore.v1.PartitionQueryResponse> + getPartitionQueryMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "PartitionQuery", + requestType = com.google.firestore.v1.PartitionQueryRequest.class, + responseType = com.google.firestore.v1.PartitionQueryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.PartitionQueryRequest, + com.google.firestore.v1.PartitionQueryResponse> + getPartitionQueryMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.PartitionQueryRequest, + com.google.firestore.v1.PartitionQueryResponse> + getPartitionQueryMethod; + if ((getPartitionQueryMethod = FirestoreGrpc.getPartitionQueryMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getPartitionQueryMethod = FirestoreGrpc.getPartitionQueryMethod) == null) { + FirestoreGrpc.getPartitionQueryMethod = + getPartitionQueryMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "PartitionQuery")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.PartitionQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.PartitionQueryResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("PartitionQuery")) + .build(); + } + } + } + return getPartitionQueryMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse> + getWriteMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Write", + requestType = com.google.firestore.v1.WriteRequest.class, + responseType = com.google.firestore.v1.WriteResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse> + getWriteMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse> + getWriteMethod; + if ((getWriteMethod = FirestoreGrpc.getWriteMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getWriteMethod = FirestoreGrpc.getWriteMethod) == null) { + FirestoreGrpc.getWriteMethod = + getWriteMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Write")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.WriteRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.WriteResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("Write")) + .build(); + } + } + } + return getWriteMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse> + getListenMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Listen", + requestType = com.google.firestore.v1.ListenRequest.class, + responseType = com.google.firestore.v1.ListenResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse> + getListenMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse> + getListenMethod; + if ((getListenMethod = FirestoreGrpc.getListenMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getListenMethod = FirestoreGrpc.getListenMethod) == null) { + FirestoreGrpc.getListenMethod = + getListenMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.BIDI_STREAMING) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Listen")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListenRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListenResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("Listen")) + .build(); + } + } + } + return getListenMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.ListCollectionIdsRequest, + com.google.firestore.v1.ListCollectionIdsResponse> + getListCollectionIdsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListCollectionIds", + requestType = com.google.firestore.v1.ListCollectionIdsRequest.class, + responseType = com.google.firestore.v1.ListCollectionIdsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.ListCollectionIdsRequest, + com.google.firestore.v1.ListCollectionIdsResponse> + getListCollectionIdsMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.ListCollectionIdsRequest, + com.google.firestore.v1.ListCollectionIdsResponse> + getListCollectionIdsMethod; + if ((getListCollectionIdsMethod = FirestoreGrpc.getListCollectionIdsMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getListCollectionIdsMethod = FirestoreGrpc.getListCollectionIdsMethod) == null) { + FirestoreGrpc.getListCollectionIdsMethod = + getListCollectionIdsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ListCollectionIds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListCollectionIdsRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.ListCollectionIdsResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new FirestoreMethodDescriptorSupplier("ListCollectionIds")) + .build(); + } + } + } + return getListCollectionIdsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchWriteRequest, com.google.firestore.v1.BatchWriteResponse> + getBatchWriteMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "BatchWrite", + requestType = com.google.firestore.v1.BatchWriteRequest.class, + responseType = com.google.firestore.v1.BatchWriteResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchWriteRequest, com.google.firestore.v1.BatchWriteResponse> + getBatchWriteMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.BatchWriteRequest, com.google.firestore.v1.BatchWriteResponse> + getBatchWriteMethod; + if ((getBatchWriteMethod = FirestoreGrpc.getBatchWriteMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getBatchWriteMethod = FirestoreGrpc.getBatchWriteMethod) == null) { + FirestoreGrpc.getBatchWriteMethod = + getBatchWriteMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "BatchWrite")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BatchWriteRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.BatchWriteResponse.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("BatchWrite")) + .build(); + } + } + } + return getBatchWriteMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.firestore.v1.CreateDocumentRequest, com.google.firestore.v1.Document> + getCreateDocumentMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateDocument", + requestType = com.google.firestore.v1.CreateDocumentRequest.class, + responseType = com.google.firestore.v1.Document.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.firestore.v1.CreateDocumentRequest, com.google.firestore.v1.Document> + getCreateDocumentMethod() { + io.grpc.MethodDescriptor< + com.google.firestore.v1.CreateDocumentRequest, com.google.firestore.v1.Document> + getCreateDocumentMethod; + if ((getCreateDocumentMethod = FirestoreGrpc.getCreateDocumentMethod) == null) { + synchronized (FirestoreGrpc.class) { + if ((getCreateDocumentMethod = FirestoreGrpc.getCreateDocumentMethod) == null) { + FirestoreGrpc.getCreateDocumentMethod = + getCreateDocumentMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "CreateDocument")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.CreateDocumentRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.firestore.v1.Document.getDefaultInstance())) + .setSchemaDescriptor(new FirestoreMethodDescriptorSupplier("CreateDocument")) + .build(); + } + } + } + return getCreateDocumentMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static FirestoreStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreStub(channel, callOptions); + } + }; + return FirestoreStub.newStub(factory, channel); + } + + /** Creates a new blocking-style stub that supports all types of calls on the service */ + public static FirestoreBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreBlockingV2Stub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreBlockingV2Stub(channel, callOptions); + } + }; + return FirestoreBlockingV2Stub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static FirestoreBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreBlockingStub(channel, callOptions); + } + }; + return FirestoreBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static FirestoreFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public FirestoreFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreFutureStub(channel, callOptions); + } + }; + return FirestoreFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Gets a single document.
+     * 
+ */ + default void getDocument( + com.google.firestore.v1.GetDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetDocumentMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists documents.
+     * 
+ */ + default void listDocuments( + com.google.firestore.v1.ListDocumentsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListDocumentsMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates or inserts a document.
+     * 
+ */ + default void updateDocument( + com.google.firestore.v1.UpdateDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateDocumentMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a document.
+     * 
+ */ + default void deleteDocument( + com.google.firestore.v1.DeleteDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteDocumentMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets multiple documents.
+     * Documents returned by this method are not guaranteed to be returned in the
+     * same order that they were requested.
+     * 
+ */ + default void batchGetDocuments( + com.google.firestore.v1.BatchGetDocumentsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBatchGetDocumentsMethod(), responseObserver); + } + + /** + * + * + *
+     * Starts a new transaction.
+     * 
+ */ + default void beginTransaction( + com.google.firestore.v1.BeginTransactionRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBeginTransactionMethod(), responseObserver); + } + + /** + * + * + *
+     * Commits a transaction, while optionally updating documents.
+     * 
+ */ + default void commit( + com.google.firestore.v1.CommitRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getCommitMethod(), responseObserver); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + default void rollback( + com.google.firestore.v1.RollbackRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRollbackMethod(), responseObserver); + } + + /** + * + * + *
+     * Runs a query.
+     * 
+ */ + default void runQuery( + com.google.firestore.v1.RunQueryRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRunQueryMethod(), responseObserver); + } + + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + default void executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getExecutePipelineMethod(), responseObserver); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * Rather than producing [Document][google.firestore.v1.Document] results like
+     * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API
+     * allows running an aggregation to produce a series of
+     * [AggregationResult][google.firestore.v1.AggregationResult] server-side.
+     * High-Level Example:
+     * ```
+     * -- Return the number of documents in table given a filter.
+     * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
+     * ```
+     * 
+ */ + default void runAggregationQuery( + com.google.firestore.v1.RunAggregationQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getRunAggregationQueryMethod(), responseObserver); + } + + /** + * + * + *
+     * 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.
+     * 
+ */ + default void partitionQuery( + com.google.firestore.v1.PartitionQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getPartitionQueryMethod(), responseObserver); + } + + /** + * + * + *
+     * Streams batches of document updates and deletes, in order. This method is
+     * only available via gRPC or WebChannel (not REST).
+     * 
+ */ + default io.grpc.stub.StreamObserver write( + io.grpc.stub.StreamObserver responseObserver) { + return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall( + getWriteMethod(), responseObserver); + } + + /** + * + * + *
+     * Listens to changes. This method is only available via gRPC or WebChannel
+     * (not REST).
+     * 
+ */ + default io.grpc.stub.StreamObserver listen( + io.grpc.stub.StreamObserver responseObserver) { + return io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall( + getListenMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists all the collection IDs underneath a document.
+     * 
+ */ + default void listCollectionIds( + com.google.firestore.v1.ListCollectionIdsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListCollectionIdsMethod(), responseObserver); + } + + /** + * + * + *
+     * 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.
+     * 
+ */ + default void batchWrite( + com.google.firestore.v1.BatchWriteRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getBatchWriteMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates a new document.
+     * 
+ */ + default void createDocument( + com.google.firestore.v1.CreateDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateDocumentMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service Firestore. + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public abstract static class FirestoreImplBase implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return FirestoreGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service Firestore. + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public static final class FirestoreStub extends io.grpc.stub.AbstractAsyncStub { + private FirestoreStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreStub(channel, callOptions); + } + + /** + * + * + *
+     * Gets a single document.
+     * 
+ */ + public void getDocument( + com.google.firestore.v1.GetDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetDocumentMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Lists documents.
+     * 
+ */ + public void listDocuments( + com.google.firestore.v1.ListDocumentsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates or inserts a document.
+     * 
+ */ + public void updateDocument( + com.google.firestore.v1.UpdateDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateDocumentMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a document.
+     * 
+ */ + public void deleteDocument( + com.google.firestore.v1.DeleteDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteDocumentMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets multiple documents.
+     * Documents returned by this method are not guaranteed to be returned in the
+     * same order that they were requested.
+     * 
+ */ + public void batchGetDocuments( + com.google.firestore.v1.BatchGetDocumentsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getBatchGetDocumentsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Starts a new transaction.
+     * 
+ */ + public void beginTransaction( + com.google.firestore.v1.BeginTransactionRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Commits a transaction, while optionally updating documents.
+     * 
+ */ + public void commit( + com.google.firestore.v1.CommitRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCommitMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public void rollback( + com.google.firestore.v1.RollbackRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRollbackMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Runs a query.
+     * 
+ */ + public void runQuery( + com.google.firestore.v1.RunQueryRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getRunQueryMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + public void executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getExecutePipelineMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * Rather than producing [Document][google.firestore.v1.Document] results like
+     * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API
+     * allows running an aggregation to produce a series of
+     * [AggregationResult][google.firestore.v1.AggregationResult] server-side.
+     * High-Level Example:
+     * ```
+     * -- Return the number of documents in table given a filter.
+     * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
+     * ```
+     * 
+ */ + public void runAggregationQuery( + com.google.firestore.v1.RunAggregationQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncServerStreamingCall( + getChannel().newCall(getRunAggregationQueryMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * 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.
+     * 
+ */ + public void partitionQuery( + com.google.firestore.v1.PartitionQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getPartitionQueryMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Streams batches of document updates and deletes, in order. This method is
+     * only available via gRPC or WebChannel (not REST).
+     * 
+ */ + public io.grpc.stub.StreamObserver write( + io.grpc.stub.StreamObserver responseObserver) { + return io.grpc.stub.ClientCalls.asyncBidiStreamingCall( + getChannel().newCall(getWriteMethod(), getCallOptions()), responseObserver); + } + + /** + * + * + *
+     * Listens to changes. This method is only available via gRPC or WebChannel
+     * (not REST).
+     * 
+ */ + public io.grpc.stub.StreamObserver listen( + io.grpc.stub.StreamObserver responseObserver) { + return io.grpc.stub.ClientCalls.asyncBidiStreamingCall( + getChannel().newCall(getListenMethod(), getCallOptions()), responseObserver); + } + + /** + * + * + *
+     * Lists all the collection IDs underneath a document.
+     * 
+ */ + public void listCollectionIds( + com.google.firestore.v1.ListCollectionIdsRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListCollectionIdsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * 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.
+     * 
+ */ + public void batchWrite( + com.google.firestore.v1.BatchWriteRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getBatchWriteMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Creates a new document.
+     * 
+ */ + public void createDocument( + com.google.firestore.v1.CreateDocumentRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateDocumentMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service Firestore. + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public static final class FirestoreBlockingV2Stub + extends io.grpc.stub.AbstractBlockingStub { + private FirestoreBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreBlockingV2Stub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreBlockingV2Stub(channel, callOptions); + } + + /** + * + * + *
+     * Gets a single document.
+     * 
+ */ + public com.google.firestore.v1.Document getDocument( + com.google.firestore.v1.GetDocumentRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists documents.
+     * 
+ */ + public com.google.firestore.v1.ListDocumentsResponse listDocuments( + com.google.firestore.v1.ListDocumentsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates or inserts a document.
+     * 
+ */ + public com.google.firestore.v1.Document updateDocument( + com.google.firestore.v1.UpdateDocumentRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getUpdateDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a document.
+     * 
+ */ + public com.google.protobuf.Empty deleteDocument( + com.google.firestore.v1.DeleteDocumentRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets multiple documents.
+     * Documents returned by this method are not guaranteed to be returned in the
+     * same order that they were requested.
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall + batchGetDocuments(com.google.firestore.v1.BatchGetDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall( + getChannel(), getBatchGetDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Starts a new transaction.
+     * 
+ */ + public com.google.firestore.v1.BeginTransactionResponse beginTransaction( + com.google.firestore.v1.BeginTransactionRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getBeginTransactionMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Commits a transaction, while optionally updating documents.
+     * 
+ */ + public com.google.firestore.v1.CommitResponse commit( + com.google.firestore.v1.CommitRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCommitMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public com.google.protobuf.Empty rollback(com.google.firestore.v1.RollbackRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getRollbackMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs a query.
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall runQuery( + com.google.firestore.v1.RunQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall( + getChannel(), getRunQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall + executePipeline(com.google.firestore.v1.ExecutePipelineRequest request) { + return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall( + getChannel(), getExecutePipelineMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * Rather than producing [Document][google.firestore.v1.Document] results like
+     * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API
+     * allows running an aggregation to produce a series of
+     * [AggregationResult][google.firestore.v1.AggregationResult] server-side.
+     * High-Level Example:
+     * ```
+     * -- Return the number of documents in table given a filter.
+     * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
+     * ```
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall + runAggregationQuery(com.google.firestore.v1.RunAggregationQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingV2ServerStreamingCall( + getChannel(), getRunAggregationQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Partitions a query by returning partition cursors that can be used to run
+     * the query in parallel. The returned partition cursors are split points that
+     * can be used by RunQuery as starting/end points for the query results.
+     * 
+ */ + public com.google.firestore.v1.PartitionQueryResponse partitionQuery( + com.google.firestore.v1.PartitionQueryRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getPartitionQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Streams batches of document updates and deletes, in order. This method is
+     * only available via gRPC or WebChannel (not REST).
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall< + com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse> + write() { + return io.grpc.stub.ClientCalls.blockingBidiStreamingCall( + getChannel(), getWriteMethod(), getCallOptions()); + } + + /** + * + * + *
+     * Listens to changes. This method is only available via gRPC or WebChannel
+     * (not REST).
+     * 
+ */ + @io.grpc.ExperimentalApi("https://github.com/grpc/grpc-java/issues/10918") + public io.grpc.stub.BlockingClientCall< + com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse> + listen() { + return io.grpc.stub.ClientCalls.blockingBidiStreamingCall( + getChannel(), getListenMethod(), getCallOptions()); + } + + /** + * + * + *
+     * Lists all the collection IDs underneath a document.
+     * 
+ */ + public com.google.firestore.v1.ListCollectionIdsResponse listCollectionIds( + com.google.firestore.v1.ListCollectionIdsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListCollectionIdsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Applies a batch of write operations.
+     * The BatchWrite method does not apply the write operations atomically
+     * and can apply them out of order. Method does not allow more than one write
+     * per document. Each write succeeds or fails independently. See the
+     * [BatchWriteResponse][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.
+     * 
+ */ + public com.google.firestore.v1.BatchWriteResponse batchWrite( + com.google.firestore.v1.BatchWriteRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getBatchWriteMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new document.
+     * 
+ */ + public com.google.firestore.v1.Document createDocument( + com.google.firestore.v1.CreateDocumentRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateDocumentMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do limited synchronous rpc calls to service Firestore. + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public static final class FirestoreBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private FirestoreBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Gets a single document.
+     * 
+ */ + public com.google.firestore.v1.Document getDocument( + com.google.firestore.v1.GetDocumentRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists documents.
+     * 
+ */ + public com.google.firestore.v1.ListDocumentsResponse listDocuments( + com.google.firestore.v1.ListDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates or inserts a document.
+     * 
+ */ + public com.google.firestore.v1.Document updateDocument( + com.google.firestore.v1.UpdateDocumentRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a document.
+     * 
+ */ + public com.google.protobuf.Empty deleteDocument( + com.google.firestore.v1.DeleteDocumentRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteDocumentMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets multiple documents.
+     * Documents returned by this method are not guaranteed to be returned in the
+     * same order that they were requested.
+     * 
+ */ + public java.util.Iterator batchGetDocuments( + com.google.firestore.v1.BatchGetDocumentsRequest request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getBatchGetDocumentsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Starts a new transaction.
+     * 
+ */ + public com.google.firestore.v1.BeginTransactionResponse beginTransaction( + com.google.firestore.v1.BeginTransactionRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getBeginTransactionMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Commits a transaction, while optionally updating documents.
+     * 
+ */ + public com.google.firestore.v1.CommitResponse commit( + com.google.firestore.v1.CommitRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCommitMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public com.google.protobuf.Empty rollback(com.google.firestore.v1.RollbackRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRollbackMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs a query.
+     * 
+ */ + public java.util.Iterator runQuery( + com.google.firestore.v1.RunQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getRunQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Executes a pipeline query.
+     * 
+ */ + public java.util.Iterator executePipeline( + com.google.firestore.v1.ExecutePipelineRequest request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getExecutePipelineMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * Rather than producing [Document][google.firestore.v1.Document] results like
+     * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API
+     * allows running an aggregation to produce a series of
+     * [AggregationResult][google.firestore.v1.AggregationResult] server-side.
+     * High-Level Example:
+     * ```
+     * -- Return the number of documents in table given a filter.
+     * SELECT COUNT(*) FROM ( SELECT * FROM k where a = true );
+     * ```
+     * 
+ */ + public java.util.Iterator + runAggregationQuery(com.google.firestore.v1.RunAggregationQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingServerStreamingCall( + getChannel(), getRunAggregationQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Partitions a query by returning partition cursors that can be used to run
+     * the query in parallel. The returned partition cursors are split points that
+     * can be used by RunQuery as starting/end points for the query results.
+     * 
+ */ + public com.google.firestore.v1.PartitionQueryResponse partitionQuery( + com.google.firestore.v1.PartitionQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getPartitionQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists all the collection IDs underneath a document.
+     * 
+ */ + public com.google.firestore.v1.ListCollectionIdsResponse listCollectionIds( + com.google.firestore.v1.ListCollectionIdsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListCollectionIdsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Applies a batch of write operations.
+     * The BatchWrite method does not apply the write operations atomically
+     * and can apply them out of order. Method does not allow more than one write
+     * per document. Each write succeeds or fails independently. See the
+     * [BatchWriteResponse][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.
+     * 
+ */ + public com.google.firestore.v1.BatchWriteResponse batchWrite( + com.google.firestore.v1.BatchWriteRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getBatchWriteMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates a new document.
+     * 
+ */ + public com.google.firestore.v1.Document createDocument( + com.google.firestore.v1.CreateDocumentRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateDocumentMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service Firestore. + * + *
+   * The Cloud Firestore service.
+   * Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL
+   * document database that simplifies storing, syncing, and querying data for
+   * your mobile, web, and IoT apps at global scale. Its client libraries provide
+   * live synchronization and offline support, while its security features and
+   * integrations with Firebase and Google Cloud Platform accelerate building
+   * truly serverless apps.
+   * 
+ */ + public static final class FirestoreFutureStub + extends io.grpc.stub.AbstractFutureStub { + private FirestoreFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected FirestoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new FirestoreFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Gets a single document.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getDocument(com.google.firestore.v1.GetDocumentRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetDocumentMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists documents.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.ListDocumentsResponse> + listDocuments(com.google.firestore.v1.ListDocumentsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListDocumentsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates or inserts a document.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + updateDocument(com.google.firestore.v1.UpdateDocumentRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateDocumentMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a document.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteDocument(com.google.firestore.v1.DeleteDocumentRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteDocumentMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Starts a new transaction.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.BeginTransactionResponse> + beginTransaction(com.google.firestore.v1.BeginTransactionRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Commits a transaction, while optionally updating documents.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.CommitResponse> + commit(com.google.firestore.v1.CommitRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCommitMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture rollback( + com.google.firestore.v1.RollbackRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRollbackMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Partitions a query by returning partition cursors that can be used to run
+     * the query in parallel. The returned partition cursors are split points that
+     * can be used by RunQuery as starting/end points for the query results.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.PartitionQueryResponse> + partitionQuery(com.google.firestore.v1.PartitionQueryRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getPartitionQueryMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists all the collection IDs underneath a document.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.ListCollectionIdsResponse> + listCollectionIds(com.google.firestore.v1.ListCollectionIdsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListCollectionIdsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Applies a batch of write operations.
+     * The BatchWrite method does not apply the write operations atomically
+     * and can apply them out of order. Method does not allow more than one write
+     * per document. Each write succeeds or fails independently. See the
+     * [BatchWriteResponse][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.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.firestore.v1.BatchWriteResponse> + batchWrite(com.google.firestore.v1.BatchWriteRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getBatchWriteMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates a new document.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + createDocument(com.google.firestore.v1.CreateDocumentRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateDocumentMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_GET_DOCUMENT = 0; + private static final int METHODID_LIST_DOCUMENTS = 1; + private static final int METHODID_UPDATE_DOCUMENT = 2; + private static final int METHODID_DELETE_DOCUMENT = 3; + private static final int METHODID_BATCH_GET_DOCUMENTS = 4; + private static final int METHODID_BEGIN_TRANSACTION = 5; + private static final int METHODID_COMMIT = 6; + private static final int METHODID_ROLLBACK = 7; + private static final int METHODID_RUN_QUERY = 8; + private static final int METHODID_EXECUTE_PIPELINE = 9; + private static final int METHODID_RUN_AGGREGATION_QUERY = 10; + private static final int METHODID_PARTITION_QUERY = 11; + private static final int METHODID_LIST_COLLECTION_IDS = 12; + private static final int METHODID_BATCH_WRITE = 13; + private static final int METHODID_CREATE_DOCUMENT = 14; + private static final int METHODID_WRITE = 15; + private static final int METHODID_LISTEN = 16; + + private static final class MethodHandlers + implements io.grpc.stub.ServerCalls.UnaryMethod, + io.grpc.stub.ServerCalls.ServerStreamingMethod, + io.grpc.stub.ServerCalls.ClientStreamingMethod, + io.grpc.stub.ServerCalls.BidiStreamingMethod { + private final AsyncService serviceImpl; + private final int methodId; + + MethodHandlers(AsyncService serviceImpl, int methodId) { + this.serviceImpl = serviceImpl; + this.methodId = methodId; + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_GET_DOCUMENT: + serviceImpl.getDocument( + (com.google.firestore.v1.GetDocumentRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_DOCUMENTS: + serviceImpl.listDocuments( + (com.google.firestore.v1.ListDocumentsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_UPDATE_DOCUMENT: + serviceImpl.updateDocument( + (com.google.firestore.v1.UpdateDocumentRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DELETE_DOCUMENT: + serviceImpl.deleteDocument( + (com.google.firestore.v1.DeleteDocumentRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_BATCH_GET_DOCUMENTS: + serviceImpl.batchGetDocuments( + (com.google.firestore.v1.BatchGetDocumentsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_BEGIN_TRANSACTION: + serviceImpl.beginTransaction( + (com.google.firestore.v1.BeginTransactionRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_COMMIT: + serviceImpl.commit( + (com.google.firestore.v1.CommitRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_ROLLBACK: + serviceImpl.rollback( + (com.google.firestore.v1.RollbackRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_RUN_QUERY: + serviceImpl.runQuery( + (com.google.firestore.v1.RunQueryRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_EXECUTE_PIPELINE: + serviceImpl.executePipeline( + (com.google.firestore.v1.ExecutePipelineRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_RUN_AGGREGATION_QUERY: + serviceImpl.runAggregationQuery( + (com.google.firestore.v1.RunAggregationQueryRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_PARTITION_QUERY: + serviceImpl.partitionQuery( + (com.google.firestore.v1.PartitionQueryRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_LIST_COLLECTION_IDS: + serviceImpl.listCollectionIds( + (com.google.firestore.v1.ListCollectionIdsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_BATCH_WRITE: + serviceImpl.batchWrite( + (com.google.firestore.v1.BatchWriteRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_CREATE_DOCUMENT: + serviceImpl.createDocument( + (com.google.firestore.v1.CreateDocumentRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + default: + throw new AssertionError(); + } + } + + @java.lang.Override + @java.lang.SuppressWarnings("unchecked") + public io.grpc.stub.StreamObserver invoke( + io.grpc.stub.StreamObserver responseObserver) { + switch (methodId) { + case METHODID_WRITE: + return (io.grpc.stub.StreamObserver) + serviceImpl.write( + (io.grpc.stub.StreamObserver) + responseObserver); + case METHODID_LISTEN: + return (io.grpc.stub.StreamObserver) + serviceImpl.listen( + (io.grpc.stub.StreamObserver) + responseObserver); + default: + throw new AssertionError(); + } + } + } + + public static final io.grpc.ServerServiceDefinition bindService(AsyncService service) { + return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) + .addMethod( + getGetDocumentMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.GetDocumentRequest, com.google.firestore.v1.Document>( + service, METHODID_GET_DOCUMENT))) + .addMethod( + getListDocumentsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.ListDocumentsRequest, + com.google.firestore.v1.ListDocumentsResponse>( + service, METHODID_LIST_DOCUMENTS))) + .addMethod( + getUpdateDocumentMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.UpdateDocumentRequest, + com.google.firestore.v1.Document>(service, METHODID_UPDATE_DOCUMENT))) + .addMethod( + getDeleteDocumentMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.DeleteDocumentRequest, com.google.protobuf.Empty>( + service, METHODID_DELETE_DOCUMENT))) + .addMethod( + getBatchGetDocumentsMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + com.google.firestore.v1.BatchGetDocumentsRequest, + com.google.firestore.v1.BatchGetDocumentsResponse>( + service, METHODID_BATCH_GET_DOCUMENTS))) + .addMethod( + getBeginTransactionMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.BeginTransactionRequest, + com.google.firestore.v1.BeginTransactionResponse>( + service, METHODID_BEGIN_TRANSACTION))) + .addMethod( + getCommitMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.CommitRequest, com.google.firestore.v1.CommitResponse>( + service, METHODID_COMMIT))) + .addMethod( + getRollbackMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.RollbackRequest, com.google.protobuf.Empty>( + service, METHODID_ROLLBACK))) + .addMethod( + getRunQueryMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + com.google.firestore.v1.RunQueryRequest, + com.google.firestore.v1.RunQueryResponse>(service, METHODID_RUN_QUERY))) + .addMethod( + getExecutePipelineMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + com.google.firestore.v1.ExecutePipelineRequest, + com.google.firestore.v1.ExecutePipelineResponse>( + service, METHODID_EXECUTE_PIPELINE))) + .addMethod( + getRunAggregationQueryMethod(), + io.grpc.stub.ServerCalls.asyncServerStreamingCall( + new MethodHandlers< + com.google.firestore.v1.RunAggregationQueryRequest, + com.google.firestore.v1.RunAggregationQueryResponse>( + service, METHODID_RUN_AGGREGATION_QUERY))) + .addMethod( + getPartitionQueryMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.PartitionQueryRequest, + com.google.firestore.v1.PartitionQueryResponse>( + service, METHODID_PARTITION_QUERY))) + .addMethod( + getWriteMethod(), + io.grpc.stub.ServerCalls.asyncBidiStreamingCall( + new MethodHandlers< + com.google.firestore.v1.WriteRequest, com.google.firestore.v1.WriteResponse>( + service, METHODID_WRITE))) + .addMethod( + getListenMethod(), + io.grpc.stub.ServerCalls.asyncBidiStreamingCall( + new MethodHandlers< + com.google.firestore.v1.ListenRequest, com.google.firestore.v1.ListenResponse>( + service, METHODID_LISTEN))) + .addMethod( + getListCollectionIdsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.ListCollectionIdsRequest, + com.google.firestore.v1.ListCollectionIdsResponse>( + service, METHODID_LIST_COLLECTION_IDS))) + .addMethod( + getBatchWriteMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.BatchWriteRequest, + com.google.firestore.v1.BatchWriteResponse>(service, METHODID_BATCH_WRITE))) + .addMethod( + getCreateDocumentMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.firestore.v1.CreateDocumentRequest, + com.google.firestore.v1.Document>(service, METHODID_CREATE_DOCUMENT))) + .build(); + } + + private abstract static class FirestoreBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + FirestoreBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.firestore.v1.FirestoreProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("Firestore"); + } + } + + private static final class FirestoreFileDescriptorSupplier + extends FirestoreBaseDescriptorSupplier { + FirestoreFileDescriptorSupplier() {} + } + + private static final class FirestoreMethodDescriptorSupplier + extends FirestoreBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final java.lang.String methodName; + + FirestoreMethodDescriptorSupplier(java.lang.String methodName) { + this.methodName = methodName; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.MethodDescriptor getMethodDescriptor() { + return getServiceDescriptor().findMethodByName(methodName); + } + } + + private static volatile io.grpc.ServiceDescriptor serviceDescriptor; + + public static io.grpc.ServiceDescriptor getServiceDescriptor() { + io.grpc.ServiceDescriptor result = serviceDescriptor; + if (result == null) { + synchronized (FirestoreGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new FirestoreFileDescriptorSupplier()) + .addMethod(getGetDocumentMethod()) + .addMethod(getListDocumentsMethod()) + .addMethod(getUpdateDocumentMethod()) + .addMethod(getDeleteDocumentMethod()) + .addMethod(getBatchGetDocumentsMethod()) + .addMethod(getBeginTransactionMethod()) + .addMethod(getCommitMethod()) + .addMethod(getRollbackMethod()) + .addMethod(getRunQueryMethod()) + .addMethod(getExecutePipelineMethod()) + .addMethod(getRunAggregationQueryMethod()) + .addMethod(getPartitionQueryMethod()) + .addMethod(getWriteMethod()) + .addMethod(getListenMethod()) + .addMethod(getListCollectionIdsMethod()) + .addMethod(getBatchWriteMethod()) + .addMethod(getCreateDocumentMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-firestore/owlbot.py b/java-firestore/owlbot.py new file mode 100644 index 000000000000..96bf07d9bf2f --- /dev/null +++ b/java-firestore/owlbot.py @@ -0,0 +1,58 @@ +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import synthtool as s +from synthtool.languages import java + +'This script is used to synthesize generated parts of this library.' +import json +protobuf_header = '// Generated by the protocol buffer compiler. DO NOT EDIT!' +license_header = '/*\n * Copyright 2019 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n' +bad_license_header = '/\\*\n \\* Copyright 2018 Google LLC\n \\*\n \\* Licensed under the Apache License, Version 2.0 \\(the "License"\\); you may not use this file except\n \\* in compliance with the License. You may obtain a copy of the License at\n \\*\n \\* http://www.apache.org/licenses/LICENSE-2.0\n \\*\n \\* Unless required by applicable law or agreed to in writing, software distributed under the License\n \\* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\n \\* or implied. See the License for the specific language governing permissions and limitations under\n \\* the License.\n \\*/\n' +metadata_path = '.repo-metadata.json' +try: + with open(metadata_path, 'r') as f: + metadata = json.load(f) + if 'library_path_overrides' not in metadata: + metadata['library_path_overrides'] = {} + metadata['library_path_overrides']['FirestoreAdminClient'] = 'google-cloud-firestore-admin' + with open(metadata_path, 'w') as f: + json.dump(metadata, f, indent=2) + f.write('\n') +except Exception as e: + print(f'Failed to update .repo-metadata.json: {e}') + +for library in s.get_staging_dirs(): + # put any special-case replacements here + service = 'firestore' + version = 'v1' + s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', protobuf_header, f'{license_header}{protobuf_header}') + service == 'firestore-admin' + s.replace(f'owl-bot-staging/v1/grpc-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header) + s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', bad_license_header, license_header) + s.move(library) +s.remove_staging_dirs() +java.common_templates(monorepo=True, excludes=[ + ".github/*", + ".kokoro/*", + "samples/*", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "java.header", + "license-checks.xml", + "renovate.json", + ".gitignore" +]) diff --git a/java-firestore/pom.xml b/java-firestore/pom.xml new file mode 100644 index 000000000000..7dc457b77b5b --- /dev/null +++ b/java-firestore/pom.xml @@ -0,0 +1,245 @@ + + + 4.0.0 + com.google.cloud + google-cloud-firestore-parent + pom + 3.38.1-SNAPSHOT + Google Cloud Firestore Parent + https://github.com/googleapis/google-cloud-java + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-jar-parent + 1.82.0-SNAPSHOT + ../google-cloud-jar-parent/pom.xml + + + + + garrettjonesgoogle + Garrett Jones + garrettjones@google.com + Google + + Developer + + + + pongad + Michael Darakananda + pongad@google.com + Google + + Developer + + + + shinfan + Shin Fan + shinfan@google.com + Google + + Developer + + + + michaelbausor + Micheal Bausor + michaelbausor@google.com + Google + + Developer + + + + vam-google + Vadym Matsishevskyi + vam@google.com + Google + + Developer + + + + tswast + Tim Swast + tswast@google.com + Google + + Developer + + + + neozwu + Neo Wu + neowu@google.com + Google + + Developer + + + + lesv + Les Vogel + lesv@google.com + Google + + Developer + + + + schmidt_sebastian + Sebastian Schmidt + mrschmidt@google.com + Google + + Developer + + + + andreamlin + Andrea Lin + andrealin@google.com + + Developer + + + + hzyi-google + Hanzhen Yi + hzyi@google.com + + Developer + + + + + Google LLC + + + scm:git:git@github.com:googleapis/google-cloud-java.git + scm:git:git@github.com:googleapis/google-cloud-java.git + https://github.com/googleapis/google-cloud-java + HEAD + + + https://github.com/googleapis/google-cloud-java/issues + GitHub Issues + + + + + Apache-2.0 + https://www.apache.org/licenses/LICENSE-2.0.txt + + + + + UTF-8 + UTF-8 + github + google-cloud-firestore-parent + https://googleapis.dev/java/google-api-grpc/latest + + + + + + com.google.api.grpc + proto-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + + + com.google.cloud + google-cloud-firestore + 3.38.1-SNAPSHOT + + + com.google.cloud + proto-google-cloud-firestore-bundle-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + proto-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + + + com.google.api.grpc + grpc-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + + + + com.google.truth + truth + 1.4.4 + test + + + org.checkerframework + checker-qual + + + + + + + + google-cloud-firestore + grpc-google-cloud-firestore-admin-v1 + grpc-google-cloud-firestore-v1 + proto-google-cloud-firestore-admin-v1 + proto-google-cloud-firestore-v1 + proto-google-cloud-firestore-bundle-v1 + google-cloud-firestore-admin + google-cloud-firestore-bom + + + + + enable-samples + + samples + + + + + docFX + + + com/google/cloud/firestore/v1/package-info.java + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + ${sourceFileExclude} + + + + + aggregate + + aggregate + + + + + + + + + diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml b/java-firestore/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..1de79b7784f6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/clirr-ignored-differences.xml @@ -0,0 +1,97 @@ + + + + + + + 7012 + com/google/firestore/admin/v1/*OrBuilder + * get*(*) + + + 7012 + com/google/firestore/admin/v1/*OrBuilder + boolean contains*(*) + + + 7012 + com/google/firestore/admin/v1/*OrBuilder + boolean has*(*) + + + + + 7006 + com/google/firestore/admin/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/firestore/admin/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * clear() + ** + + + 7006 + com/google/firestore/admin/v1/** + * clearField(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * clone() + ** + + + 7006 + com/google/firestore/admin/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * setField(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/firestore/admin/v1/** + * setUnknownFields(*) + ** + + diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/pom.xml b/java-firestore/proto-google-cloud-firestore-admin-v1/pom.xml new file mode 100644 index 000000000000..15d7f51be74f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-firestore-admin-v1 + 3.38.1-SNAPSHOT + proto-google-cloud-firestore-admin-v1 + PROTO library for proto-google-cloud-firestore-admin-v1 + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + compile + + + com.google.api + api-common + compile + + + com.google.api.grpc + proto-google-common-protos + compile + + + com.google.guava + guava + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java new file mode 100644 index 000000000000..8d94821cb8bb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Backup.java @@ -0,0 +1,3080 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/backup.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A Backup of a Cloud Firestore Database.
+ *
+ * The backup contains all documents and index configurations for the given
+ * database at a specific point in time.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup} + */ +@com.google.protobuf.Generated +public final class Backup extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Backup) + BackupOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Backup"); + } + + // Use Backup.newBuilder() to construct. + private Backup(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Backup() { + name_ = ""; + database_ = ""; + databaseUid_ = ""; + state_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.class, + com.google.firestore.admin.v1.Backup.Builder.class); + } + + /** + * + * + *
+   * Indicate the current state of the backup.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Backup.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+     * The pending backup is still being created. Operations on the
+     * backup will be rejected in this state.
+     * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+     * The backup is complete and ready to use.
+     * 
+ * + * READY = 2; + */ + READY(2), + /** + * + * + *
+     * The backup is not available at this moment.
+     * 
+ * + * NOT_AVAILABLE = 3; + */ + NOT_AVAILABLE(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "State"); + } + + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The pending backup is still being created. Operations on the
+     * backup will be rejected in this state.
+     * 
+ * + * CREATING = 1; + */ + public static final int CREATING_VALUE = 1; + + /** + * + * + *
+     * The backup is complete and ready to use.
+     * 
+ * + * READY = 2; + */ + public static final int READY_VALUE = 2; + + /** + * + * + *
+     * The backup is not available at this moment.
+     * 
+ * + * NOT_AVAILABLE = 3; + */ + public static final int NOT_AVAILABLE_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return CREATING; + case 2: + return READY; + case 3: + return NOT_AVAILABLE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Backup.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Backup.State) + } + + public interface StatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Backup.Stats) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. Summation of the size of all documents and index entries in
+     * the backup, measured in bytes.
+     * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + long getSizeBytes(); + + /** + * + * + *
+     * Output only. The total number of documents contained in the backup.
+     * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + long getDocumentCount(); + + /** + * + * + *
+     * Output only. The total number of index entries contained in the backup.
+     * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + long getIndexCount(); + } + + /** + * + * + *
+   * Backup specific statistics.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup.Stats} + */ + public static final class Stats extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Backup.Stats) + StatsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Stats"); + } + + // Use Stats.newBuilder() to construct. + private Stats(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Stats() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.Stats.class, + com.google.firestore.admin.v1.Backup.Stats.Builder.class); + } + + public static final int SIZE_BYTES_FIELD_NUMBER = 1; + private long sizeBytes_ = 0L; + + /** + * + * + *
+     * Output only. Summation of the size of all documents and index entries in
+     * the backup, measured in bytes.
+     * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + @java.lang.Override + public long getSizeBytes() { + return sizeBytes_; + } + + public static final int DOCUMENT_COUNT_FIELD_NUMBER = 2; + private long documentCount_ = 0L; + + /** + * + * + *
+     * Output only. The total number of documents contained in the backup.
+     * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + @java.lang.Override + public long getDocumentCount() { + return documentCount_; + } + + public static final int INDEX_COUNT_FIELD_NUMBER = 3; + private long indexCount_ = 0L; + + /** + * + * + *
+     * Output only. The total number of index entries contained in the backup.
+     * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + @java.lang.Override + public long getIndexCount() { + return indexCount_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (sizeBytes_ != 0L) { + output.writeInt64(1, sizeBytes_); + } + if (documentCount_ != 0L) { + output.writeInt64(2, documentCount_); + } + if (indexCount_ != 0L) { + output.writeInt64(3, indexCount_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sizeBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, sizeBytes_); + } + if (documentCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, documentCount_); + } + if (indexCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, indexCount_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Backup.Stats)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Backup.Stats other = + (com.google.firestore.admin.v1.Backup.Stats) obj; + + if (getSizeBytes() != other.getSizeBytes()) return false; + if (getDocumentCount() != other.getDocumentCount()) return false; + if (getIndexCount() != other.getIndexCount()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + SIZE_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSizeBytes()); + hash = (37 * hash) + DOCUMENT_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getDocumentCount()); + hash = (37 * hash) + INDEX_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getIndexCount()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup.Stats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Backup.Stats prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Backup specific statistics.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup.Stats} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Backup.Stats) + com.google.firestore.admin.v1.Backup.StatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.Stats.class, + com.google.firestore.admin.v1.Backup.Stats.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Backup.Stats.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + sizeBytes_ = 0L; + documentCount_ = 0L; + indexCount_ = 0L; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats build() { + com.google.firestore.admin.v1.Backup.Stats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats buildPartial() { + com.google.firestore.admin.v1.Backup.Stats result = + new com.google.firestore.admin.v1.Backup.Stats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Backup.Stats result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.sizeBytes_ = sizeBytes_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.documentCount_ = documentCount_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.indexCount_ = indexCount_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Backup.Stats) { + return mergeFrom((com.google.firestore.admin.v1.Backup.Stats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Backup.Stats other) { + if (other == com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance()) return this; + if (other.getSizeBytes() != 0L) { + setSizeBytes(other.getSizeBytes()); + } + if (other.getDocumentCount() != 0L) { + setDocumentCount(other.getDocumentCount()); + } + if (other.getIndexCount() != 0L) { + setIndexCount(other.getIndexCount()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + sizeBytes_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + documentCount_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 24: + { + indexCount_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 24 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long sizeBytes_; + + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The sizeBytes. + */ + @java.lang.Override + public long getSizeBytes() { + return sizeBytes_; + } + + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The sizeBytes to set. + * @return This builder for chaining. + */ + public Builder setSizeBytes(long value) { + + sizeBytes_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Summation of the size of all documents and index entries in
+       * the backup, measured in bytes.
+       * 
+ * + * int64 size_bytes = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearSizeBytes() { + bitField0_ = (bitField0_ & ~0x00000001); + sizeBytes_ = 0L; + onChanged(); + return this; + } + + private long documentCount_; + + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The documentCount. + */ + @java.lang.Override + public long getDocumentCount() { + return documentCount_; + } + + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The documentCount to set. + * @return This builder for chaining. + */ + public Builder setDocumentCount(long value) { + + documentCount_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. The total number of documents contained in the backup.
+       * 
+ * + * int64 document_count = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearDocumentCount() { + bitField0_ = (bitField0_ & ~0x00000002); + documentCount_ = 0L; + onChanged(); + return this; + } + + private long indexCount_; + + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexCount. + */ + @java.lang.Override + public long getIndexCount() { + return indexCount_; + } + + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The indexCount to set. + * @return This builder for chaining. + */ + public Builder setIndexCount(long value) { + + indexCount_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. The total number of index entries contained in the backup.
+       * 
+ * + * int64 index_count = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearIndexCount() { + bitField0_ = (bitField0_ & ~0x00000004); + indexCount_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Backup.Stats) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Backup.Stats) + private static final com.google.firestore.admin.v1.Backup.Stats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Backup.Stats(); + } + + public static com.google.firestore.admin.v1.Backup.Stats getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Stats parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_UID_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseUid_ = ""; + + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + @java.lang.Override + public java.lang.String getDatabaseUid() { + java.lang.Object ref = databaseUid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseUid_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseUidBytes() { + java.lang.Object ref = databaseUid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseUid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp snapshotTime_; + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + public static final int EXPIRE_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp expireTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + @java.lang.Override + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExpireTime() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + return expireTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : expireTime_; + } + + public static final int STATS_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.Backup.Stats stats_; + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + @java.lang.Override + public boolean hasStats() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.Stats getStats() { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder() { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + + public static final int STATE_FIELD_NUMBER = 8; + private int state_ = 0; + + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.State getState() { + com.google.firestore.admin.v1.Backup.State result = + com.google.firestore.admin.v1.Backup.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Backup.State.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getSnapshotTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getExpireTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getStats()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseUid_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, databaseUid_); + } + if (state_ != com.google.firestore.admin.v1.Backup.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(8, state_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getSnapshotTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getExpireTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getStats()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseUid_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(7, databaseUid_); + } + if (state_ != com.google.firestore.admin.v1.Backup.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(8, state_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Backup)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Backup other = (com.google.firestore.admin.v1.Backup) obj; + + if (!getName().equals(other.getName())) return false; + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getDatabaseUid().equals(other.getDatabaseUid())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (hasExpireTime() != other.hasExpireTime()) return false; + if (hasExpireTime()) { + if (!getExpireTime().equals(other.getExpireTime())) return false; + } + if (hasStats() != other.hasStats()) return false; + if (hasStats()) { + if (!getStats().equals(other.getStats())) return false; + } + if (state_ != other.state_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + DATABASE_UID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseUid().hashCode(); + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + if (hasExpireTime()) { + hash = (37 * hash) + EXPIRE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExpireTime().hashCode(); + } + if (hasStats()) { + hash = (37 * hash) + STATS_FIELD_NUMBER; + hash = (53 * hash) + getStats().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Backup parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Backup parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Backup prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Backup of a Cloud Firestore Database.
+   *
+   * The backup contains all documents and index configurations for the given
+   * database at a specific point in time.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Backup} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Backup) + com.google.firestore.admin.v1.BackupOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Backup.class, + com.google.firestore.admin.v1.Backup.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Backup.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetSnapshotTimeFieldBuilder(); + internalGetExpireTimeFieldBuilder(); + internalGetStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + database_ = ""; + databaseUid_ = ""; + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + stats_ = null; + if (statsBuilder_ != null) { + statsBuilder_.dispose(); + statsBuilder_ = null; + } + state_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.BackupProto + .internal_static_google_firestore_admin_v1_Backup_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Backup.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup build() { + com.google.firestore.admin.v1.Backup result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup buildPartial() { + com.google.firestore.admin.v1.Backup result = new com.google.firestore.admin.v1.Backup(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Backup result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.databaseUid_ = databaseUid_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.expireTime_ = expireTimeBuilder_ == null ? expireTime_ : expireTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.stats_ = statsBuilder_ == null ? stats_ : statsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.state_ = state_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Backup) { + return mergeFrom((com.google.firestore.admin.v1.Backup) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Backup other) { + if (other == com.google.firestore.admin.v1.Backup.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getDatabaseUid().isEmpty()) { + databaseUid_ = other.databaseUid_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + if (other.hasExpireTime()) { + mergeExpireTime(other.getExpireTime()); + } + if (other.hasStats()) { + mergeStats(other.getStats()); + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetExpireTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 34 + case 50: + { + input.readMessage(internalGetStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: + { + databaseUid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 58 + case 64: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000040; + break; + } // case 64 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The unique resource name of the Backup.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Name of the Firestore database that the backup is from.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object databaseUid_ = ""; + + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + public java.lang.String getDatabaseUid() { + java.lang.Object ref = databaseUid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseUid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + public com.google.protobuf.ByteString getDatabaseUidBytes() { + java.lang.Object ref = databaseUid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseUid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The databaseUid to set. + * @return This builder for chaining. + */ + public Builder setDatabaseUid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseUid_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseUid() { + databaseUid_ = getDefaultInstance().getDatabaseUid(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for the Firestore database that the
+     * backup is from.
+     * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for databaseUid to set. + * @return This builder for chaining. + */ + public Builder setDatabaseUidBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseUid_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000008); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetSnapshotTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + + /** + * + * + *
+     * Output only. The backup contains an externally consistent copy of the
+     * database at this time.
+     * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + private com.google.protobuf.Timestamp expireTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + expireTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + public boolean hasExpireTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + public com.google.protobuf.Timestamp getExpireTime() { + if (expireTimeBuilder_ == null) { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } else { + return expireTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expireTime_ = value; + } else { + expireTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setExpireTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (expireTimeBuilder_ == null) { + expireTime_ = builderForValue.build(); + } else { + expireTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeExpireTime(com.google.protobuf.Timestamp value) { + if (expireTimeBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && expireTime_ != null + && expireTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExpireTimeBuilder().mergeFrom(value); + } else { + expireTime_ = value; + } + } else { + expireTimeBuilder_.mergeFrom(value); + } + if (expireTime_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearExpireTime() { + bitField0_ = (bitField0_ & ~0x00000010); + expireTime_ = null; + if (expireTimeBuilder_ != null) { + expireTimeBuilder_.dispose(); + expireTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getExpireTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetExpireTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder() { + if (expireTimeBuilder_ != null) { + return expireTimeBuilder_.getMessageOrBuilder(); + } else { + return expireTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : expireTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup expires.
+     * 
+ * + * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetExpireTimeFieldBuilder() { + if (expireTimeBuilder_ == null) { + expireTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExpireTime(), getParentForChildren(), isClean()); + expireTime_ = null; + } + return expireTimeBuilder_; + } + + private com.google.firestore.admin.v1.Backup.Stats stats_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder> + statsBuilder_; + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + public boolean hasStats() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + public com.google.firestore.admin.v1.Backup.Stats getStats() { + if (statsBuilder_ == null) { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } else { + return statsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setStats(com.google.firestore.admin.v1.Backup.Stats value) { + if (statsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + stats_ = value; + } else { + statsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setStats(com.google.firestore.admin.v1.Backup.Stats.Builder builderForValue) { + if (statsBuilder_ == null) { + stats_ = builderForValue.build(); + } else { + statsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeStats(com.google.firestore.admin.v1.Backup.Stats value) { + if (statsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && stats_ != null + && stats_ != com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance()) { + getStatsBuilder().mergeFrom(value); + } else { + stats_ = value; + } + } else { + statsBuilder_.mergeFrom(value); + } + if (stats_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearStats() { + bitField0_ = (bitField0_ & ~0x00000020); + stats_ = null; + if (statsBuilder_ != null) { + statsBuilder_.dispose(); + statsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Backup.Stats.Builder getStatsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetStatsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder() { + if (statsBuilder_ != null) { + return statsBuilder_.getMessageOrBuilder(); + } else { + return stats_ == null + ? com.google.firestore.admin.v1.Backup.Stats.getDefaultInstance() + : stats_; + } + } + + /** + * + * + *
+     * Output only. Statistics about the backup.
+     *
+     * This data only becomes available after the backup is fully materialized to
+     * secondary storage. This field will be empty till then.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder> + internalGetStatsFieldBuilder() { + if (statsBuilder_ == null) { + statsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Backup.Stats, + com.google.firestore.admin.v1.Backup.Stats.Builder, + com.google.firestore.admin.v1.Backup.StatsOrBuilder>( + getStats(), getParentForChildren(), isClean()); + stats_ = null; + } + return statsBuilder_; + } + + private int state_ = 0; + + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup.State getState() { + com.google.firestore.admin.v1.Backup.State result = + com.google.firestore.admin.v1.Backup.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Backup.State.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.Backup.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000040); + state_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Backup) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Backup) + private static final com.google.firestore.admin.v1.Backup DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Backup(); + } + + public static com.google.firestore.admin.v1.Backup getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Backup parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Backup getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java new file mode 100644 index 000000000000..d3015ee49412 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupName.java @@ -0,0 +1,223 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class BackupName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION_BACKUP = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/locations/{location}/backups/{backup}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + private final String backup; + + @Deprecated + protected BackupName() { + project = null; + location = null; + backup = null; + } + + private BackupName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + backup = Preconditions.checkNotNull(builder.getBackup()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBackup() { + return backup; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BackupName of(String project, String location, String backup) { + return newBuilder().setProject(project).setLocation(location).setBackup(backup).build(); + } + + public static String format(String project, String location, String backup) { + return newBuilder() + .setProject(project) + .setLocation(location) + .setBackup(backup) + .build() + .toString(); + } + + public static BackupName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION_BACKUP.validatedMatch( + formattedString, "BackupName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location"), matchMap.get("backup")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BackupName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION_BACKUP.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + if (backup != null) { + fieldMapBuilder.put("backup", backup); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION_BACKUP.instantiate( + "project", project, "location", location, "backup", backup); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + BackupName that = ((BackupName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location) + && Objects.equals(this.backup, that.backup); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + h *= 1000003; + h ^= Objects.hashCode(backup); + return h; + } + + /** Builder for projects/{project}/locations/{location}/backups/{backup}. */ + public static class Builder { + private String project; + private String location; + private String backup; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public String getBackup() { + return backup; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + public Builder setBackup(String backup) { + this.backup = backup; + return this; + } + + private Builder(BackupName backupName) { + this.project = backupName.project; + this.location = backupName.location; + this.backup = backupName.backup; + } + + public BackupName build() { + return new BackupName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java new file mode 100644 index 000000000000..693197231ae0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupOrBuilder.java @@ -0,0 +1,288 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/backup.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface BackupOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Backup) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Output only. The unique resource name of the Backup.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Output only. Name of the Firestore database that the backup is from.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 2 [(.google.api.field_behavior) = OUTPUT_ONLY, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + java.lang.String getDatabaseUid(); + + /** + * + * + *
+   * Output only. The system-generated UUID4 for the Firestore database that the
+   * backup is from.
+   * 
+ * + * string database_uid = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for databaseUid. + */ + com.google.protobuf.ByteString getDatabaseUidBytes(); + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + + /** + * + * + *
+   * Output only. The backup contains an externally consistent copy of the
+   * database at this time.
+   * 
+ * + * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the expireTime field is set. + */ + boolean hasExpireTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The expireTime. + */ + com.google.protobuf.Timestamp getExpireTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup expires.
+   * 
+ * + * .google.protobuf.Timestamp expire_time = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getExpireTimeOrBuilder(); + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the stats field is set. + */ + boolean hasStats(); + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The stats. + */ + com.google.firestore.admin.v1.Backup.Stats getStats(); + + /** + * + * + *
+   * Output only. Statistics about the backup.
+   *
+   * This data only becomes available after the backup is fully materialized to
+   * secondary storage. This field will be empty till then.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.Stats stats = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.firestore.admin.v1.Backup.StatsOrBuilder getStatsOrBuilder(); + + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * Output only. The current state of the backup.
+   * 
+ * + * + * .google.firestore.admin.v1.Backup.State state = 8 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.firestore.admin.v1.Backup.State getState(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java new file mode 100644 index 000000000000..3851cc9d7a07 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupProto.java @@ -0,0 +1,130 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/backup.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class BackupProto extends com.google.protobuf.GeneratedFile { + private BackupProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BackupProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Backup_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "&google/firestore/admin/v1/backup.proto" + + "\022\031google.firestore.admin.v1\032\037google/api/" + + "field_behavior.proto\032\031google/api/resourc" + + "e.proto\032\037google/protobuf/timestamp.proto\"\340\004\n" + + "\006Backup\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\003\022;\n" + + "\010database\030\002 \001(\tB)\340A\003\372A#\n" + + "!firestore.googleapis.com/Database\022\031\n" + + "\014database_uid\030\007 \001(\tB\003\340A\003\0226\n\r" + + "snapshot_time\030\003 \001(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n" + + "\013expire_time\030\004 \001(\0132\032.google.protobuf.TimestampB\003\340A\003\022;\n" + + "\005stats\030\006 " + + "\001(\0132\'.google.firestore.admin.v1.Backup.StatsB\003\340A\003\022;\n" + + "\005state\030\010" + + " \001(\0162\'.google.firestore.admin.v1.Backup.StateB\003\340A\003\032W\n" + + "\005Stats\022\027\n\n" + + "size_bytes\030\001 \001(\003B\003\340A\003\022\033\n" + + "\016document_count\030\002 \001(\003B\003\340A\003\022\030\n" + + "\013index_count\030\003 \001(\003B\003\340A\003\"J\n" + + "\005State\022\025\n" + + "\021STATE_UNSPECIFIED\020\000\022\014\n" + + "\010CREATING\020\001\022\t\n" + + "\005READY\020\002\022\021\n\r" + + "NOT_AVAILABLE\020\003:^\352A[\n" + + "\037firestore.googleapis.com/Backup\0228proje" + + "cts/{project}/locations/{location}/backups/{backup}B\332\001\n" + + "\035com.google.firestore.admin.v1B\013BackupProtoP\001Z9cloud.google.com/g" + + "o/firestore/apiv1/admin/adminpb;adminpb\242" + + "\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin.V1" + + "\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Goo" + + "gle::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_Backup_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_Backup_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Backup_descriptor, + new java.lang.String[] { + "Name", "Database", "DatabaseUid", "SnapshotTime", "ExpireTime", "Stats", "State", + }); + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor = + internal_static_google_firestore_admin_v1_Backup_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Backup_Stats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Backup_Stats_descriptor, + new java.lang.String[] { + "SizeBytes", "DocumentCount", "IndexCount", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java new file mode 100644 index 000000000000..809304978635 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupSchedule.java @@ -0,0 +1,2316 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A backup schedule for a Cloud Firestore Database.
+ *
+ * This resource is owned by the database it is backing up, and is deleted along
+ * with the database. The actual backups are not though.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BackupSchedule} + */ +@com.google.protobuf.Generated +public final class BackupSchedule extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.BackupSchedule) + BackupScheduleOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BackupSchedule"); + } + + // Use BackupSchedule.newBuilder() to construct. + private BackupSchedule(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BackupSchedule() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BackupSchedule.class, + com.google.firestore.admin.v1.BackupSchedule.Builder.class); + } + + private int bitField0_; + private int recurrenceCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object recurrence_; + + public enum RecurrenceCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + DAILY_RECURRENCE(7), + WEEKLY_RECURRENCE(8), + RECURRENCE_NOT_SET(0); + private final int value; + + private RecurrenceCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static RecurrenceCase valueOf(int value) { + return forNumber(value); + } + + public static RecurrenceCase forNumber(int value) { + switch (value) { + case 7: + return DAILY_RECURRENCE; + case 8: + return WEEKLY_RECURRENCE; + case 0: + return RECURRENCE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public RecurrenceCase getRecurrenceCase() { + return RecurrenceCase.forNumber(recurrenceCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 10; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int RETENTION_FIELD_NUMBER = 6; + private com.google.protobuf.Duration retention_; + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + @java.lang.Override + public boolean hasRetention() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + @java.lang.Override + public com.google.protobuf.Duration getRetention() { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getRetentionOrBuilder() { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + + public static final int DAILY_RECURRENCE_FIELD_NUMBER = 7; + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + @java.lang.Override + public boolean hasDailyRecurrence() { + return recurrenceCase_ == 7; + } + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence() { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder() { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + + public static final int WEEKLY_RECURRENCE_FIELD_NUMBER = 8; + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + @java.lang.Override + public boolean hasWeeklyRecurrence() { + return recurrenceCase_ == 8; + } + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence() { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder() { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getCreateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getRetention()); + } + if (recurrenceCase_ == 7) { + output.writeMessage(7, (com.google.firestore.admin.v1.DailyRecurrence) recurrence_); + } + if (recurrenceCase_ == 8) { + output.writeMessage(8, (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(10, getUpdateTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCreateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getRetention()); + } + if (recurrenceCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.firestore.admin.v1.DailyRecurrence) recurrence_); + } + if (recurrenceCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 8, (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getUpdateTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.BackupSchedule)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.BackupSchedule other = + (com.google.firestore.admin.v1.BackupSchedule) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (hasRetention() != other.hasRetention()) return false; + if (hasRetention()) { + if (!getRetention().equals(other.getRetention())) return false; + } + if (!getRecurrenceCase().equals(other.getRecurrenceCase())) return false; + switch (recurrenceCase_) { + case 7: + if (!getDailyRecurrence().equals(other.getDailyRecurrence())) return false; + break; + case 8: + if (!getWeeklyRecurrence().equals(other.getWeeklyRecurrence())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + if (hasRetention()) { + hash = (37 * hash) + RETENTION_FIELD_NUMBER; + hash = (53 * hash) + getRetention().hashCode(); + } + switch (recurrenceCase_) { + case 7: + hash = (37 * hash) + DAILY_RECURRENCE_FIELD_NUMBER; + hash = (53 * hash) + getDailyRecurrence().hashCode(); + break; + case 8: + hash = (37 * hash) + WEEKLY_RECURRENCE_FIELD_NUMBER; + hash = (53 * hash) + getWeeklyRecurrence().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BackupSchedule parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.BackupSchedule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A backup schedule for a Cloud Firestore Database.
+   *
+   * This resource is owned by the database it is backing up, and is deleted along
+   * with the database. The actual backups are not though.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BackupSchedule} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.BackupSchedule) + com.google.firestore.admin.v1.BackupScheduleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BackupSchedule.class, + com.google.firestore.admin.v1.BackupSchedule.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.BackupSchedule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCreateTimeFieldBuilder(); + internalGetUpdateTimeFieldBuilder(); + internalGetRetentionFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + retention_ = null; + if (retentionBuilder_ != null) { + retentionBuilder_.dispose(); + retentionBuilder_ = null; + } + if (dailyRecurrenceBuilder_ != null) { + dailyRecurrenceBuilder_.clear(); + } + if (weeklyRecurrenceBuilder_ != null) { + weeklyRecurrenceBuilder_.clear(); + } + recurrenceCase_ = 0; + recurrence_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getDefaultInstanceForType() { + return com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule build() { + com.google.firestore.admin.v1.BackupSchedule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule buildPartial() { + com.google.firestore.admin.v1.BackupSchedule result = + new com.google.firestore.admin.v1.BackupSchedule(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.BackupSchedule result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.retention_ = retentionBuilder_ == null ? retention_ : retentionBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.admin.v1.BackupSchedule result) { + result.recurrenceCase_ = recurrenceCase_; + result.recurrence_ = this.recurrence_; + if (recurrenceCase_ == 7 && dailyRecurrenceBuilder_ != null) { + result.recurrence_ = dailyRecurrenceBuilder_.build(); + } + if (recurrenceCase_ == 8 && weeklyRecurrenceBuilder_ != null) { + result.recurrence_ = weeklyRecurrenceBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.BackupSchedule) { + return mergeFrom((com.google.firestore.admin.v1.BackupSchedule) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.BackupSchedule other) { + if (other == com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.hasRetention()) { + mergeRetention(other.getRetention()); + } + switch (other.getRecurrenceCase()) { + case DAILY_RECURRENCE: + { + mergeDailyRecurrence(other.getDailyRecurrence()); + break; + } + case WEEKLY_RECURRENCE: + { + mergeWeeklyRecurrence(other.getWeeklyRecurrence()); + break; + } + case RECURRENCE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + input.readMessage( + internalGetCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 50: + { + input.readMessage( + internalGetRetentionFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetDailyRecurrenceFieldBuilder().getBuilder(), extensionRegistry); + recurrenceCase_ = 7; + break; + } // case 58 + case 66: + { + input.readMessage( + internalGetWeeklyRecurrenceFieldBuilder().getBuilder(), extensionRegistry); + recurrenceCase_ = 8; + break; + } // case 66 + case 82: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 82 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int recurrenceCase_ = 0; + private java.lang.Object recurrence_; + + public RecurrenceCase getRecurrenceCase() { + return RecurrenceCase.forNumber(recurrenceCase_); + } + + public Builder clearRecurrence() { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The unique backup schedule identifier across all locations and
+     * databases for the given project.
+     *
+     * This will be auto-assigned.
+     *
+     * Format is
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was created and
+     * effective since.
+     *
+     * No backups will be created for this schedule before this time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this backup schedule was most recently
+     * updated. When a backup schedule is first created, this is the same as
+     * create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private com.google.protobuf.Duration retention_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + retentionBuilder_; + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + public boolean hasRetention() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + public com.google.protobuf.Duration getRetention() { + if (retentionBuilder_ == null) { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } else { + return retentionBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder setRetention(com.google.protobuf.Duration value) { + if (retentionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + retention_ = value; + } else { + retentionBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder setRetention(com.google.protobuf.Duration.Builder builderForValue) { + if (retentionBuilder_ == null) { + retention_ = builderForValue.build(); + } else { + retentionBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder mergeRetention(com.google.protobuf.Duration value) { + if (retentionBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && retention_ != null + && retention_ != com.google.protobuf.Duration.getDefaultInstance()) { + getRetentionBuilder().mergeFrom(value); + } else { + retention_ = value; + } + } else { + retentionBuilder_.mergeFrom(value); + } + if (retention_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public Builder clearRetention() { + bitField0_ = (bitField0_ & ~0x00000008); + retention_ = null; + if (retentionBuilder_ != null) { + retentionBuilder_.dispose(); + retentionBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public com.google.protobuf.Duration.Builder getRetentionBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetRetentionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + public com.google.protobuf.DurationOrBuilder getRetentionOrBuilder() { + if (retentionBuilder_ != null) { + return retentionBuilder_.getMessageOrBuilder(); + } else { + return retention_ == null ? com.google.protobuf.Duration.getDefaultInstance() : retention_; + } + } + + /** + * + * + *
+     * At what relative time in the future, compared to its creation time,
+     * the backup should be deleted, e.g. keep backups for 7 days.
+     *
+     * The maximum supported retention period is 14 weeks.
+     * 
+ * + * .google.protobuf.Duration retention = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + internalGetRetentionFieldBuilder() { + if (retentionBuilder_ == null) { + retentionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getRetention(), getParentForChildren(), isClean()); + retention_ = null; + } + return retentionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder> + dailyRecurrenceBuilder_; + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + @java.lang.Override + public boolean hasDailyRecurrence() { + return recurrenceCase_ == 7; + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence() { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } else { + if (recurrenceCase_ == 7) { + return dailyRecurrenceBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder setDailyRecurrence(com.google.firestore.admin.v1.DailyRecurrence value) { + if (dailyRecurrenceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + recurrence_ = value; + onChanged(); + } else { + dailyRecurrenceBuilder_.setMessage(value); + } + recurrenceCase_ = 7; + return this; + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder setDailyRecurrence( + com.google.firestore.admin.v1.DailyRecurrence.Builder builderForValue) { + if (dailyRecurrenceBuilder_ == null) { + recurrence_ = builderForValue.build(); + onChanged(); + } else { + dailyRecurrenceBuilder_.setMessage(builderForValue.build()); + } + recurrenceCase_ = 7; + return this; + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder mergeDailyRecurrence(com.google.firestore.admin.v1.DailyRecurrence value) { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7 + && recurrence_ != com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance()) { + recurrence_ = + com.google.firestore.admin.v1.DailyRecurrence.newBuilder( + (com.google.firestore.admin.v1.DailyRecurrence) recurrence_) + .mergeFrom(value) + .buildPartial(); + } else { + recurrence_ = value; + } + onChanged(); + } else { + if (recurrenceCase_ == 7) { + dailyRecurrenceBuilder_.mergeFrom(value); + } else { + dailyRecurrenceBuilder_.setMessage(value); + } + } + recurrenceCase_ = 7; + return this; + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public Builder clearDailyRecurrence() { + if (dailyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 7) { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + } + } else { + if (recurrenceCase_ == 7) { + recurrenceCase_ = 0; + recurrence_ = null; + } + dailyRecurrenceBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + public com.google.firestore.admin.v1.DailyRecurrence.Builder getDailyRecurrenceBuilder() { + return internalGetDailyRecurrenceFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder() { + if ((recurrenceCase_ == 7) && (dailyRecurrenceBuilder_ != null)) { + return dailyRecurrenceBuilder_.getMessageOrBuilder(); + } else { + if (recurrenceCase_ == 7) { + return (com.google.firestore.admin.v1.DailyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + } + + /** + * + * + *
+     * For a schedule that runs daily.
+     * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder> + internalGetDailyRecurrenceFieldBuilder() { + if (dailyRecurrenceBuilder_ == null) { + if (!(recurrenceCase_ == 7)) { + recurrence_ = com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + dailyRecurrenceBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.DailyRecurrence, + com.google.firestore.admin.v1.DailyRecurrence.Builder, + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder>( + (com.google.firestore.admin.v1.DailyRecurrence) recurrence_, + getParentForChildren(), + isClean()); + recurrence_ = null; + } + recurrenceCase_ = 7; + onChanged(); + return dailyRecurrenceBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder> + weeklyRecurrenceBuilder_; + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + @java.lang.Override + public boolean hasWeeklyRecurrence() { + return recurrenceCase_ == 8; + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence() { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } else { + if (recurrenceCase_ == 8) { + return weeklyRecurrenceBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder setWeeklyRecurrence(com.google.firestore.admin.v1.WeeklyRecurrence value) { + if (weeklyRecurrenceBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + recurrence_ = value; + onChanged(); + } else { + weeklyRecurrenceBuilder_.setMessage(value); + } + recurrenceCase_ = 8; + return this; + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder setWeeklyRecurrence( + com.google.firestore.admin.v1.WeeklyRecurrence.Builder builderForValue) { + if (weeklyRecurrenceBuilder_ == null) { + recurrence_ = builderForValue.build(); + onChanged(); + } else { + weeklyRecurrenceBuilder_.setMessage(builderForValue.build()); + } + recurrenceCase_ = 8; + return this; + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder mergeWeeklyRecurrence(com.google.firestore.admin.v1.WeeklyRecurrence value) { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8 + && recurrence_ != com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance()) { + recurrence_ = + com.google.firestore.admin.v1.WeeklyRecurrence.newBuilder( + (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_) + .mergeFrom(value) + .buildPartial(); + } else { + recurrence_ = value; + } + onChanged(); + } else { + if (recurrenceCase_ == 8) { + weeklyRecurrenceBuilder_.mergeFrom(value); + } else { + weeklyRecurrenceBuilder_.setMessage(value); + } + } + recurrenceCase_ = 8; + return this; + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public Builder clearWeeklyRecurrence() { + if (weeklyRecurrenceBuilder_ == null) { + if (recurrenceCase_ == 8) { + recurrenceCase_ = 0; + recurrence_ = null; + onChanged(); + } + } else { + if (recurrenceCase_ == 8) { + recurrenceCase_ = 0; + recurrence_ = null; + } + weeklyRecurrenceBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + public com.google.firestore.admin.v1.WeeklyRecurrence.Builder getWeeklyRecurrenceBuilder() { + return internalGetWeeklyRecurrenceFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder() { + if ((recurrenceCase_ == 8) && (weeklyRecurrenceBuilder_ != null)) { + return weeklyRecurrenceBuilder_.getMessageOrBuilder(); + } else { + if (recurrenceCase_ == 8) { + return (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_; + } + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + } + + /** + * + * + *
+     * For a schedule that runs weekly on a specific day.
+     * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder> + internalGetWeeklyRecurrenceFieldBuilder() { + if (weeklyRecurrenceBuilder_ == null) { + if (!(recurrenceCase_ == 8)) { + recurrence_ = com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + weeklyRecurrenceBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.WeeklyRecurrence, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder, + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder>( + (com.google.firestore.admin.v1.WeeklyRecurrence) recurrence_, + getParentForChildren(), + isClean()); + recurrence_ = null; + } + recurrenceCase_ = 8; + onChanged(); + return weeklyRecurrenceBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.BackupSchedule) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.BackupSchedule) + private static final com.google.firestore.admin.v1.BackupSchedule DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.BackupSchedule(); + } + + public static com.google.firestore.admin.v1.BackupSchedule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BackupSchedule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java new file mode 100644 index 000000000000..2408242ef763 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleName.java @@ -0,0 +1,227 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class BackupScheduleName implements ResourceName { + private static final PathTemplate PROJECT_DATABASE_BACKUP_SCHEDULE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/backupSchedules/{backup_schedule}"); + private volatile Map fieldValuesMap; + private final String project; + private final String database; + private final String backupSchedule; + + @Deprecated + protected BackupScheduleName() { + project = null; + database = null; + backupSchedule = null; + } + + private BackupScheduleName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + backupSchedule = Preconditions.checkNotNull(builder.getBackupSchedule()); + } + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getBackupSchedule() { + return backupSchedule; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BackupScheduleName of(String project, String database, String backupSchedule) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setBackupSchedule(backupSchedule) + .build(); + } + + public static String format(String project, String database, String backupSchedule) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setBackupSchedule(backupSchedule) + .build() + .toString(); + } + + public static BackupScheduleName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_BACKUP_SCHEDULE.validatedMatch( + formattedString, "BackupScheduleName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("backup_schedule")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BackupScheduleName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_DATABASE_BACKUP_SCHEDULE.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (backupSchedule != null) { + fieldMapBuilder.put("backup_schedule", backupSchedule); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_BACKUP_SCHEDULE.instantiate( + "project", project, "database", database, "backup_schedule", backupSchedule); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + BackupScheduleName that = ((BackupScheduleName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.backupSchedule, that.backupSchedule); + } + 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(backupSchedule); + return h; + } + + /** Builder for projects/{project}/databases/{database}/backupSchedules/{backup_schedule}. */ + public static class Builder { + private String project; + private String database; + private String backupSchedule; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getBackupSchedule() { + return backupSchedule; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setBackupSchedule(String backupSchedule) { + this.backupSchedule = backupSchedule; + return this; + } + + private Builder(BackupScheduleName backupScheduleName) { + this.project = backupScheduleName.project; + this.database = backupScheduleName.database; + this.backupSchedule = backupScheduleName.backupSchedule; + } + + public BackupScheduleName build() { + return new BackupScheduleName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java new file mode 100644 index 000000000000..1541c8c05b15 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BackupScheduleOrBuilder.java @@ -0,0 +1,283 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface BackupScheduleOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.BackupSchedule) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Output only. The unique backup schedule identifier across all locations and
+   * databases for the given project.
+   *
+   * This will be auto-assigned.
+   *
+   * Format is
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was created and
+   * effective since.
+   *
+   * No backups will be created for this schedule before this time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this backup schedule was most recently
+   * updated. When a backup schedule is first created, this is the same as
+   * create_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 10 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return Whether the retention field is set. + */ + boolean hasRetention(); + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + * + * @return The retention. + */ + com.google.protobuf.Duration getRetention(); + + /** + * + * + *
+   * At what relative time in the future, compared to its creation time,
+   * the backup should be deleted, e.g. keep backups for 7 days.
+   *
+   * The maximum supported retention period is 14 weeks.
+   * 
+ * + * .google.protobuf.Duration retention = 6; + */ + com.google.protobuf.DurationOrBuilder getRetentionOrBuilder(); + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return Whether the dailyRecurrence field is set. + */ + boolean hasDailyRecurrence(); + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + * + * @return The dailyRecurrence. + */ + com.google.firestore.admin.v1.DailyRecurrence getDailyRecurrence(); + + /** + * + * + *
+   * For a schedule that runs daily.
+   * 
+ * + * .google.firestore.admin.v1.DailyRecurrence daily_recurrence = 7; + */ + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder getDailyRecurrenceOrBuilder(); + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return Whether the weeklyRecurrence field is set. + */ + boolean hasWeeklyRecurrence(); + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + * + * @return The weeklyRecurrence. + */ + com.google.firestore.admin.v1.WeeklyRecurrence getWeeklyRecurrence(); + + /** + * + * + *
+   * For a schedule that runs weekly on a specific day.
+   * 
+ * + * .google.firestore.admin.v1.WeeklyRecurrence weekly_recurrence = 8; + */ + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder getWeeklyRecurrenceOrBuilder(); + + com.google.firestore.admin.v1.BackupSchedule.RecurrenceCase getRecurrenceCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadata.java new file mode 100644 index 000000000000..42cb6d4c8802 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadata.java @@ -0,0 +1,2603 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+ * results from
+ * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsMetadata} + */ +@com.google.protobuf.Generated +public final class BulkDeleteDocumentsMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.BulkDeleteDocumentsMetadata) + BulkDeleteDocumentsMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BulkDeleteDocumentsMetadata"); + } + + // Use BulkDeleteDocumentsMetadata.newBuilder() to construct. + private BulkDeleteDocumentsMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BulkDeleteDocumentsMetadata() { + operationState_ = 0; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int PROGRESS_DOCUMENTS_FIELD_NUMBER = 4; + private com.google.firestore.admin.v1.Progress progressDocuments_; + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + @java.lang.Override + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 5; + private com.google.firestore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 8; + private com.google.protobuf.Timestamp snapshotTime_; + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(5, getProgressBytes()); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, collectionIds_.getRaw(i)); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, namespaceIds_.getRaw(i)); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(8, getSnapshotTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getProgressBytes()); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getSnapshotTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata other = + (com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (hasProgressDocuments() != other.hasProgressDocuments()) return false; + if (hasProgressDocuments()) { + if (!getProgressDocuments().equals(other.getProgressDocuments())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + if (hasProgressDocuments()) { + hash = (37 * hash) + PROGRESS_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getProgressDocuments().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+   * results from
+   * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.BulkDeleteDocumentsMetadata) + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetProgressDocumentsFieldBuilder(); + internalGetProgressBytesFieldBuilder(); + internalGetSnapshotTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata build() { + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata buildPartial() { + com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata result = + new com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.progressDocuments_ = + progressDocumentsBuilder_ == null + ? progressDocuments_ + : progressDocumentsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata) { + return mergeFrom((com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata other) { + if (other == com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (other.hasProgressDocuments()) { + mergeProgressDocuments(other.getProgressDocuments()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000020; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000040; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage( + internalGetProgressDocumentsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 50 + case 58: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 58 + case 66: + { + input.readMessage( + internalGetSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressDocuments_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressDocumentsBuilder_; + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + if (progressDocumentsBuilder_ == null) { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } else { + return progressDocumentsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressDocuments_ = value; + } else { + progressDocumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressDocumentsBuilder_ == null) { + progressDocuments_ = builderForValue.build(); + } else { + progressDocumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder mergeProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && progressDocuments_ != null + && progressDocuments_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressDocumentsBuilder().mergeFrom(value); + } else { + progressDocuments_ = value; + } + } else { + progressDocumentsBuilder_.mergeFrom(value); + } + if (progressDocuments_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder clearProgressDocuments() { + bitField0_ = (bitField0_ & ~0x00000008); + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressDocumentsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetProgressDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + if (progressDocumentsBuilder_ != null) { + return progressDocumentsBuilder_.getMessageOrBuilder(); + } else { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressDocumentsFieldBuilder() { + if (progressDocumentsBuilder_ == null) { + progressDocumentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressDocuments(), getParentForChildren(), isClean()); + progressDocuments_ = null; + } + return progressDocumentsBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + public com.google.firestore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder mergeProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000010); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000020; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The IDs of the collection groups that are being deleted.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000040; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000040); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being deleted.
+     * 
+ * + * repeated string namespace_ids = 7; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000080); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return internalGetSnapshotTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * read to get the list of documents to delete. This time can also be used as
+     * the timestamp of PITR in case of disaster recovery (subject to PITR window
+     * limit).
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.BulkDeleteDocumentsMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.BulkDeleteDocumentsMetadata) + private static final com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata(); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BulkDeleteDocumentsMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadataOrBuilder.java new file mode 100644 index 000000000000..af6d8f2247ee --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsMetadataOrBuilder.java @@ -0,0 +1,359 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface BulkDeleteDocumentsMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.BulkDeleteDocumentsMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + boolean hasProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + com.google.firestore.admin.v1.Progress getProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + com.google.firestore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * The IDs of the collection groups that are being deleted.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * Which namespace IDs are being deleted.
+   * 
+ * + * repeated string namespace_ids = 7; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * read to get the list of documents to delete. This time can also be used as
+   * the timestamp of PITR in case of disaster recovery (subject to PITR window
+   * limit).
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 8; + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequest.java new file mode 100644 index 000000000000..e0be4d40d8e3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequest.java @@ -0,0 +1,1372 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+ *
+ * When both collection_ids and namespace_ids are set, only documents satisfying
+ * both conditions will be deleted.
+ *
+ * Requests with namespace_ids and collection_ids both empty will be rejected.
+ * Please use
+ * [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase]
+ * instead.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsRequest} + */ +@com.google.protobuf.Generated +public final class BulkDeleteDocumentsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.BulkDeleteDocumentsRequest) + BulkDeleteDocumentsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BulkDeleteDocumentsRequest"); + } + + // Use BulkDeleteDocumentsRequest.newBuilder() to construct. + private BulkDeleteDocumentsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BulkDeleteDocumentsRequest() { + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. Database to operate. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Database to operate. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionIds_.getRaw(i)); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, namespaceIds_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest other = + (com.google.firestore.admin.v1.BulkDeleteDocumentsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+   *
+   * When both collection_ids and namespace_ids are set, only documents satisfying
+   * both conditions will be deleted.
+   *
+   * Requests with namespace_ids and collection_ids both empty will be rejected.
+   * Please use
+   * [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase]
+   * instead.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.BulkDeleteDocumentsRequest) + com.google.firestore.admin.v1.BulkDeleteDocumentsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsRequest build() { + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsRequest buildPartial() { + com.google.firestore.admin.v1.BulkDeleteDocumentsRequest result = + new com.google.firestore.admin.v1.BulkDeleteDocumentsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.BulkDeleteDocumentsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsRequest) { + return mergeFrom((com.google.firestore.admin.v1.BulkDeleteDocumentsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.BulkDeleteDocumentsRequest other) { + if (other == com.google.firestore.admin.v1.BulkDeleteDocumentsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000002; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000004; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 18 + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. Database to operate. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Database to operate. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Database to operate. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to operate. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to operate. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. IDs of the collection groups to delete. Unspecified means all
+     * collection groups.
+     *
+     * Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000004; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Namespaces to delete.
+     *
+     * An empty list means all namespaces. This is the recommended
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to delete from them.
+     *
+     * Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.BulkDeleteDocumentsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.BulkDeleteDocumentsRequest) + private static final com.google.firestore.admin.v1.BulkDeleteDocumentsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.BulkDeleteDocumentsRequest(); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BulkDeleteDocumentsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequestOrBuilder.java new file mode 100644 index 000000000000..3722d3e7e3b5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsRequestOrBuilder.java @@ -0,0 +1,216 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface BulkDeleteDocumentsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.BulkDeleteDocumentsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Database to operate. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. Database to operate. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * Optional. IDs of the collection groups to delete. Unspecified means all
+   * collection groups.
+   *
+   * Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * Optional. Namespaces to delete.
+   *
+   * An empty list means all namespaces. This is the recommended
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to delete from them.
+   *
+   * Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponse.java new file mode 100644 index 000000000000..0d34f2b3b61e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponse.java @@ -0,0 +1,399 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsResponse} + */ +@com.google.protobuf.Generated +public final class BulkDeleteDocumentsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.BulkDeleteDocumentsResponse) + BulkDeleteDocumentsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BulkDeleteDocumentsResponse"); + } + + // Use BulkDeleteDocumentsResponse.newBuilder() to construct. + private BulkDeleteDocumentsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BulkDeleteDocumentsResponse() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse other = + (com.google.firestore.admin.v1.BulkDeleteDocumentsResponse) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.BulkDeleteDocumentsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.BulkDeleteDocumentsResponse) + com.google.firestore.admin.v1.BulkDeleteDocumentsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.class, + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsResponse build() { + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsResponse buildPartial() { + com.google.firestore.admin.v1.BulkDeleteDocumentsResponse result = + new com.google.firestore.admin.v1.BulkDeleteDocumentsResponse(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.BulkDeleteDocumentsResponse) { + return mergeFrom((com.google.firestore.admin.v1.BulkDeleteDocumentsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.BulkDeleteDocumentsResponse other) { + if (other == com.google.firestore.admin.v1.BulkDeleteDocumentsResponse.getDefaultInstance()) + return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.BulkDeleteDocumentsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.BulkDeleteDocumentsResponse) + private static final com.google.firestore.admin.v1.BulkDeleteDocumentsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.BulkDeleteDocumentsResponse(); + } + + public static com.google.firestore.admin.v1.BulkDeleteDocumentsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BulkDeleteDocumentsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.BulkDeleteDocumentsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponseOrBuilder.java new file mode 100644 index 000000000000..0cf82145ca68 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/BulkDeleteDocumentsResponseOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface BulkDeleteDocumentsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.BulkDeleteDocumentsResponse) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadata.java new file mode 100644 index 000000000000..23f965dcb028 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadata.java @@ -0,0 +1,1879 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for the [long-running operation][google.longrunning.Operation] from
+ * the [CloneDatabase][google.firestore.admin.v1.CloneDatabase] request.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CloneDatabaseMetadata} + */ +@com.google.protobuf.Generated +public final class CloneDatabaseMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CloneDatabaseMetadata) + CloneDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CloneDatabaseMetadata"); + } + + // Use CloneDatabaseMetadata.newBuilder() to construct. + private CloneDatabaseMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CloneDatabaseMetadata() { + operationState_ = 0; + database_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CloneDatabaseMetadata.class, + com.google.firestore.admin.v1.CloneDatabaseMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + + /** + * + * + *
+   * The operation state of the clone.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+   * The operation state of the clone.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int DATABASE_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * The name of the database being cloned to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * The name of the database being cloned to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PITR_SNAPSHOT_FIELD_NUMBER = 7; + private com.google.firestore.admin.v1.PitrSnapshot pitrSnapshot_; + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return Whether the pitrSnapshot field is set. + */ + @java.lang.Override + public boolean hasPitrSnapshot() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return The pitrSnapshot. + */ + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot() { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder() { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + + public static final int PROGRESS_PERCENTAGE_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.Progress progressPercentage_; + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return Whether the progressPercentage field is set. + */ + @java.lang.Override + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return The progressPercentage. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, database_); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(6, getProgressPercentage()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(7, getPitrSnapshot()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, database_); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getProgressPercentage()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getPitrSnapshot()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CloneDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CloneDatabaseMetadata other = + (com.google.firestore.admin.v1.CloneDatabaseMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (!getDatabase().equals(other.getDatabase())) return false; + if (hasPitrSnapshot() != other.hasPitrSnapshot()) return false; + if (hasPitrSnapshot()) { + if (!getPitrSnapshot().equals(other.getPitrSnapshot())) return false; + } + if (hasProgressPercentage() != other.hasProgressPercentage()) return false; + if (hasProgressPercentage()) { + if (!getProgressPercentage().equals(other.getProgressPercentage())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (hasPitrSnapshot()) { + hash = (37 * hash) + PITR_SNAPSHOT_FIELD_NUMBER; + hash = (53 * hash) + getPitrSnapshot().hashCode(); + } + if (hasProgressPercentage()) { + hash = (37 * hash) + PROGRESS_PERCENTAGE_FIELD_NUMBER; + hash = (53 * hash) + getProgressPercentage().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CloneDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for the [long-running operation][google.longrunning.Operation] from
+   * the [CloneDatabase][google.firestore.admin.v1.CloneDatabase] request.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CloneDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CloneDatabaseMetadata) + com.google.firestore.admin.v1.CloneDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CloneDatabaseMetadata.class, + com.google.firestore.admin.v1.CloneDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CloneDatabaseMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetPitrSnapshotFieldBuilder(); + internalGetProgressPercentageFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + database_ = ""; + pitrSnapshot_ = null; + if (pitrSnapshotBuilder_ != null) { + pitrSnapshotBuilder_.dispose(); + pitrSnapshotBuilder_ = null; + } + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CloneDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseMetadata build() { + com.google.firestore.admin.v1.CloneDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.CloneDatabaseMetadata result = + new com.google.firestore.admin.v1.CloneDatabaseMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CloneDatabaseMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.pitrSnapshot_ = + pitrSnapshotBuilder_ == null ? pitrSnapshot_ : pitrSnapshotBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.progressPercentage_ = + progressPercentageBuilder_ == null + ? progressPercentage_ + : progressPercentageBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CloneDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.CloneDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CloneDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.CloneDatabaseMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (other.hasPitrSnapshot()) { + mergePitrSnapshot(other.getPitrSnapshot()); + } + if (other.hasProgressPercentage()) { + mergeProgressPercentage(other.getProgressPercentage()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 50: + { + input.readMessage( + internalGetProgressPercentageFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetPitrSnapshotFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time the clone was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time the clone finished, unset for ongoing clones.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + + /** + * + * + *
+     * The operation state of the clone.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+     * The operation state of the clone.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The operation state of the clone.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The operation state of the clone.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The operation state of the clone.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * The name of the database being cloned to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The name of the database being cloned to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The name of the database being cloned to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the database being cloned to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the database being cloned to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.PitrSnapshot pitrSnapshot_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder> + pitrSnapshotBuilder_; + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return Whether the pitrSnapshot field is set. + */ + public boolean hasPitrSnapshot() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return The pitrSnapshot. + */ + public com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot() { + if (pitrSnapshotBuilder_ == null) { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } else { + return pitrSnapshotBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public Builder setPitrSnapshot(com.google.firestore.admin.v1.PitrSnapshot value) { + if (pitrSnapshotBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pitrSnapshot_ = value; + } else { + pitrSnapshotBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public Builder setPitrSnapshot( + com.google.firestore.admin.v1.PitrSnapshot.Builder builderForValue) { + if (pitrSnapshotBuilder_ == null) { + pitrSnapshot_ = builderForValue.build(); + } else { + pitrSnapshotBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public Builder mergePitrSnapshot(com.google.firestore.admin.v1.PitrSnapshot value) { + if (pitrSnapshotBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && pitrSnapshot_ != null + && pitrSnapshot_ != com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance()) { + getPitrSnapshotBuilder().mergeFrom(value); + } else { + pitrSnapshot_ = value; + } + } else { + pitrSnapshotBuilder_.mergeFrom(value); + } + if (pitrSnapshot_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public Builder clearPitrSnapshot() { + bitField0_ = (bitField0_ & ~0x00000010); + pitrSnapshot_ = null; + if (pitrSnapshotBuilder_ != null) { + pitrSnapshotBuilder_.dispose(); + pitrSnapshotBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public com.google.firestore.admin.v1.PitrSnapshot.Builder getPitrSnapshotBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetPitrSnapshotFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + public com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder() { + if (pitrSnapshotBuilder_ != null) { + return pitrSnapshotBuilder_.getMessageOrBuilder(); + } else { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + } + + /** + * + * + *
+     * The snapshot from which this database was cloned.
+     * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder> + internalGetPitrSnapshotFieldBuilder() { + if (pitrSnapshotBuilder_ == null) { + pitrSnapshotBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder>( + getPitrSnapshot(), getParentForChildren(), isClean()); + pitrSnapshot_ = null; + } + return pitrSnapshotBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressPercentage_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressPercentageBuilder_; + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return Whether the progressPercentage field is set. + */ + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return The progressPercentage. + */ + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + if (progressPercentageBuilder_ == null) { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } else { + return progressPercentageBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public Builder setProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressPercentage_ = value; + } else { + progressPercentageBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public Builder setProgressPercentage( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressPercentageBuilder_ == null) { + progressPercentage_ = builderForValue.build(); + } else { + progressPercentageBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public Builder mergeProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && progressPercentage_ != null + && progressPercentage_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressPercentageBuilder().mergeFrom(value); + } else { + progressPercentage_ = value; + } + } else { + progressPercentageBuilder_.mergeFrom(value); + } + if (progressPercentage_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public Builder clearProgressPercentage() { + bitField0_ = (bitField0_ & ~0x00000020); + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressPercentageBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetProgressPercentageFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + if (progressPercentageBuilder_ != null) { + return progressPercentageBuilder_.getMessageOrBuilder(); + } else { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + } + + /** + * + * + *
+     * How far along the clone is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressPercentageFieldBuilder() { + if (progressPercentageBuilder_ == null) { + progressPercentageBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressPercentage(), getParentForChildren(), isClean()); + progressPercentage_ = null; + } + return progressPercentageBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CloneDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CloneDatabaseMetadata) + private static final com.google.firestore.admin.v1.CloneDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CloneDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.CloneDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CloneDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000000..5d1af6aef611 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseMetadataOrBuilder.java @@ -0,0 +1,228 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CloneDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CloneDatabaseMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time the clone was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time the clone finished, unset for ongoing clones.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The operation state of the clone.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + + /** + * + * + *
+   * The operation state of the clone.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The name of the database being cloned to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * The name of the database being cloned to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return Whether the pitrSnapshot field is set. + */ + boolean hasPitrSnapshot(); + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + * + * @return The pitrSnapshot. + */ + com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot(); + + /** + * + * + *
+   * The snapshot from which this database was cloned.
+   * 
+ * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 7; + */ + com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder(); + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return Whether the progressPercentage field is set. + */ + boolean hasProgressPercentage(); + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + * + * @return The progressPercentage. + */ + com.google.firestore.admin.v1.Progress getProgressPercentage(); + + /** + * + * + *
+   * How far along the clone is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 6; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequest.java new file mode 100644 index 000000000000..e3f29a2dc2df --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequest.java @@ -0,0 +1,1992 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request message for
+ * [FirestoreAdmin.CloneDatabase][google.firestore.admin.v1.FirestoreAdmin.CloneDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CloneDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class CloneDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CloneDatabaseRequest) + CloneDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CloneDatabaseRequest"); + } + + // Use CloneDatabaseRequest.newBuilder() to construct. + private CloneDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CloneDatabaseRequest() { + parent_ = ""; + databaseId_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CloneDatabaseRequest.class, + com.google.firestore.admin.v1.CloneDatabaseRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The project to clone the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The project to clone the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + @java.lang.Override + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PITR_SNAPSHOT_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.PitrSnapshot pitrSnapshot_; + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pitrSnapshot field is set. + */ + @java.lang.Override + public boolean hasPitrSnapshot() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pitrSnapshot. + */ + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot() { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder() { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + + public static final int ENCRYPTION_CONFIG_FIELD_NUMBER = 4; + private com.google.firestore.admin.v1.Database.EncryptionConfig encryptionConfig_; + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + @java.lang.Override + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig() { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + + public static final int TAGS_FIELD_NUMBER = 5; + + private static final class TagsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, databaseId_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getEncryptionConfig()); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetTags(), TagsDefaultEntryHolder.defaultEntry, 5); + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(6, getPitrSnapshot()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, databaseId_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getEncryptionConfig()); + } + for (java.util.Map.Entry entry : + internalGetTags().getMap().entrySet()) { + com.google.protobuf.MapEntry tags__ = + TagsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, tags__); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getPitrSnapshot()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CloneDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CloneDatabaseRequest other = + (com.google.firestore.admin.v1.CloneDatabaseRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (hasPitrSnapshot() != other.hasPitrSnapshot()) return false; + if (hasPitrSnapshot()) { + if (!getPitrSnapshot().equals(other.getPitrSnapshot())) return false; + } + if (hasEncryptionConfig() != other.hasEncryptionConfig()) return false; + if (hasEncryptionConfig()) { + if (!getEncryptionConfig().equals(other.getEncryptionConfig())) return false; + } + if (!internalGetTags().equals(other.internalGetTags())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (hasPitrSnapshot()) { + hash = (37 * hash) + PITR_SNAPSHOT_FIELD_NUMBER; + hash = (53 * hash) + getPitrSnapshot().hashCode(); + } + if (hasEncryptionConfig()) { + hash = (37 * hash) + ENCRYPTION_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getEncryptionConfig().hashCode(); + } + if (!internalGetTags().getMap().isEmpty()) { + hash = (37 * hash) + TAGS_FIELD_NUMBER; + hash = (53 * hash) + internalGetTags().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CloneDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request message for
+   * [FirestoreAdmin.CloneDatabase][google.firestore.admin.v1.FirestoreAdmin.CloneDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CloneDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CloneDatabaseRequest) + com.google.firestore.admin.v1.CloneDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetMutableTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CloneDatabaseRequest.class, + com.google.firestore.admin.v1.CloneDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CloneDatabaseRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetPitrSnapshotFieldBuilder(); + internalGetEncryptionConfigFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + databaseId_ = ""; + pitrSnapshot_ = null; + if (pitrSnapshotBuilder_ != null) { + pitrSnapshotBuilder_.dispose(); + pitrSnapshotBuilder_ = null; + } + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + internalGetMutableTags().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CloneDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseRequest build() { + com.google.firestore.admin.v1.CloneDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.CloneDatabaseRequest result = + new com.google.firestore.admin.v1.CloneDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CloneDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pitrSnapshot_ = + pitrSnapshotBuilder_ == null ? pitrSnapshot_ : pitrSnapshotBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.encryptionConfig_ = + encryptionConfigBuilder_ == null ? encryptionConfig_ : encryptionConfigBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.tags_ = internalGetTags(); + result.tags_.makeImmutable(); + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CloneDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.CloneDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CloneDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.CloneDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasPitrSnapshot()) { + mergePitrSnapshot(other.getPitrSnapshot()); + } + if (other.hasEncryptionConfig()) { + mergeEncryptionConfig(other.getEncryptionConfig()); + } + internalGetMutableTags().mergeFrom(other.internalGetTags()); + bitField0_ |= 0x00000010; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 34: + { + input.readMessage( + internalGetEncryptionConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + com.google.protobuf.MapEntry tags__ = + input.readMessage( + TagsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableTags().getMutableMap().put(tags__.getKey(), tags__.getValue()); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetPitrSnapshotFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The project to clone the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The project to clone the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The project to clone the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The project to clone the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The project to clone the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.PitrSnapshot pitrSnapshot_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder> + pitrSnapshotBuilder_; + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pitrSnapshot field is set. + */ + public boolean hasPitrSnapshot() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pitrSnapshot. + */ + public com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot() { + if (pitrSnapshotBuilder_ == null) { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } else { + return pitrSnapshotBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPitrSnapshot(com.google.firestore.admin.v1.PitrSnapshot value) { + if (pitrSnapshotBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pitrSnapshot_ = value; + } else { + pitrSnapshotBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPitrSnapshot( + com.google.firestore.admin.v1.PitrSnapshot.Builder builderForValue) { + if (pitrSnapshotBuilder_ == null) { + pitrSnapshot_ = builderForValue.build(); + } else { + pitrSnapshotBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergePitrSnapshot(com.google.firestore.admin.v1.PitrSnapshot value) { + if (pitrSnapshotBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && pitrSnapshot_ != null + && pitrSnapshot_ != com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance()) { + getPitrSnapshotBuilder().mergeFrom(value); + } else { + pitrSnapshot_ = value; + } + } else { + pitrSnapshotBuilder_.mergeFrom(value); + } + if (pitrSnapshot_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearPitrSnapshot() { + bitField0_ = (bitField0_ & ~0x00000004); + pitrSnapshot_ = null; + if (pitrSnapshotBuilder_ != null) { + pitrSnapshotBuilder_.dispose(); + pitrSnapshotBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.PitrSnapshot.Builder getPitrSnapshotBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetPitrSnapshotFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder() { + if (pitrSnapshotBuilder_ != null) { + return pitrSnapshotBuilder_.getMessageOrBuilder(); + } else { + return pitrSnapshot_ == null + ? com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance() + : pitrSnapshot_; + } + } + + /** + * + * + *
+     * Required. Specification of the PITR data to clone from. The source database
+     * must exist.
+     *
+     * The cloned database will be created in the same location as the source
+     * database.
+     * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder> + internalGetPitrSnapshotFieldBuilder() { + if (pitrSnapshotBuilder_ == null) { + pitrSnapshotBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.PitrSnapshot, + com.google.firestore.admin.v1.PitrSnapshot.Builder, + com.google.firestore.admin.v1.PitrSnapshotOrBuilder>( + getPitrSnapshot(), getParentForChildren(), isClean()); + pitrSnapshot_ = null; + } + return pitrSnapshotBuilder_; + } + + private com.google.firestore.admin.v1.Database.EncryptionConfig encryptionConfig_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder> + encryptionConfigBuilder_; + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig() { + if (encryptionConfigBuilder_ == null) { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } else { + return encryptionConfigBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionConfig_ = value; + } else { + encryptionConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder builderForValue) { + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = builderForValue.build(); + } else { + encryptionConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && encryptionConfig_ != null + && encryptionConfig_ + != com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance()) { + getEncryptionConfigBuilder().mergeFrom(value); + } else { + encryptionConfig_ = value; + } + } else { + encryptionConfigBuilder_.mergeFrom(value); + } + if (encryptionConfig_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearEncryptionConfig() { + bitField0_ = (bitField0_ & ~0x00000008); + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig.Builder + getEncryptionConfigBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetEncryptionConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + if (encryptionConfigBuilder_ != null) { + return encryptionConfigBuilder_.getMessageOrBuilder(); + } else { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + } + + /** + * + * + *
+     * Optional. Encryption configuration for the cloned database.
+     *
+     * If this field is not specified, the cloned database will use
+     * the same encryption configuration as the source database, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder> + internalGetEncryptionConfigFieldBuilder() { + if (encryptionConfigBuilder_ == null) { + encryptionConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder>( + getEncryptionConfig(), getParentForChildren(), isClean()); + encryptionConfig_ = null; + } + return encryptionConfigBuilder_; + } + + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + private com.google.protobuf.MapField + internalGetMutableTags() { + if (tags_ == null) { + tags_ = com.google.protobuf.MapField.newMapField(TagsDefaultEntryHolder.defaultEntry); + } + if (!tags_.isMutable()) { + tags_ = tags_.copy(); + } + bitField0_ |= 0x00000010; + onChanged(); + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearTags() { + bitField0_ = (bitField0_ & ~0x00000010); + internalGetMutableTags().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableTags().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableTags() { + bitField0_ |= 0x00000010; + return internalGetMutableTags().getMutableMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putTags(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableTags().getMutableMap().put(key, value); + bitField0_ |= 0x00000010; + return this; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the cloned database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllTags(java.util.Map values) { + internalGetMutableTags().getMutableMap().putAll(values); + bitField0_ |= 0x00000010; + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CloneDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CloneDatabaseRequest) + private static final com.google.firestore.admin.v1.CloneDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CloneDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.CloneDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CloneDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CloneDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..a3500aac195b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CloneDatabaseRequestOrBuilder.java @@ -0,0 +1,300 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CloneDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CloneDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The project to clone the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The project to clone the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pitrSnapshot field is set. + */ + boolean hasPitrSnapshot(); + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pitrSnapshot. + */ + com.google.firestore.admin.v1.PitrSnapshot getPitrSnapshot(); + + /** + * + * + *
+   * Required. Specification of the PITR data to clone from. The source database
+   * must exist.
+   *
+   * The cloned database will be created in the same location as the source
+   * database.
+   * 
+ * + * + * .google.firestore.admin.v1.PitrSnapshot pitr_snapshot = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.PitrSnapshotOrBuilder getPitrSnapshotOrBuilder(); + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + boolean hasEncryptionConfig(); + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig(); + + /** + * + * + *
+   * Optional. Encryption configuration for the cloned database.
+   *
+   * If this field is not specified, the cloned database will use
+   * the same encryption configuration as the source database, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder getEncryptionConfigOrBuilder(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + int getTagsCount(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsTags(java.lang.String key); + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getTags(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getTagsMap(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the cloned database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 5 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.lang.String getTagsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java new file mode 100644 index 000000000000..7800401244b1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CollectionGroupName.java @@ -0,0 +1,223 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class CollectionGroupName implements ResourceName { + 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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static CollectionGroupName of(String project, String database, String collection) { + return newBuilder().setProject(project).setDatabase(database).setCollection(collection).build(); + } + + public static String format(String project, String database, String collection) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollection(collection) + .build() + .toString(); + } + + public static CollectionGroupName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_COLLECTION.validatedMatch( + formattedString, "CollectionGroupName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("collection")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (CollectionGroupName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_DATABASE_COLLECTION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (collection != null) { + fieldMapBuilder.put("collection", collection); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_COLLECTION.instantiate( + "project", project, "database", database, "collection", collection); + } + + @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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setCollection(String collection) { + this.collection = collection; + return this; + } + + private Builder(CollectionGroupName collectionGroupName) { + this.project = collectionGroupName.project; + this.database = collectionGroupName.database; + this.collection = collectionGroupName.collection; + } + + public CollectionGroupName build() { + return new CollectionGroupName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java new file mode 100644 index 000000000000..336733345136 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequest.java @@ -0,0 +1,946 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateBackupScheduleRequest} + */ +@com.google.protobuf.Generated +public final class CreateBackupScheduleRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateBackupScheduleRequest) + CreateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateBackupScheduleRequest"); + } + + // Use CreateBackupScheduleRequest.newBuilder() to construct. + private CreateBackupScheduleRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateBackupScheduleRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + com.google.firestore.admin.v1.CreateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getBackupSchedule()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getBackupSchedule()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateBackupScheduleRequest other = + (com.google.firestore.admin.v1.CreateBackupScheduleRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.CreateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateBackupScheduleRequest) + com.google.firestore.admin.v1.CreateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateBackupScheduleRequest.class, + com.google.firestore.admin.v1.CreateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetBackupScheduleFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest build() { + com.google.firestore.admin.v1.CreateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.CreateBackupScheduleRequest result = + new com.google.firestore.admin.v1.CreateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CreateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.CreateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.CreateBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format `projects/{project}/databases/{database}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000002); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetBackupScheduleFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + internalGetBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateBackupScheduleRequest) + private static final com.google.firestore.admin.v1.CreateBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000000..725368984453 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,105 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CreateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format `projects/{project}/databases/{database}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedule(); + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadata.java new file mode 100644 index 000000000000..1719dc86fdc5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadata.java @@ -0,0 +1,396 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata related to the create database operation.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateDatabaseMetadata} + */ +@com.google.protobuf.Generated +public final class CreateDatabaseMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateDatabaseMetadata) + CreateDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateDatabaseMetadata"); + } + + // Use CreateDatabaseMetadata.newBuilder() to construct. + private CreateDatabaseMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateDatabaseMetadata() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateDatabaseMetadata.class, + com.google.firestore.admin.v1.CreateDatabaseMetadata.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateDatabaseMetadata other = + (com.google.firestore.admin.v1.CreateDatabaseMetadata) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CreateDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata related to the create database operation.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateDatabaseMetadata) + com.google.firestore.admin.v1.CreateDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateDatabaseMetadata.class, + com.google.firestore.admin.v1.CreateDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateDatabaseMetadata.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseMetadata build() { + com.google.firestore.admin.v1.CreateDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.CreateDatabaseMetadata result = + new com.google.firestore.admin.v1.CreateDatabaseMetadata(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.CreateDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.CreateDatabaseMetadata.getDefaultInstance()) + return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateDatabaseMetadata) + private static final com.google.firestore.admin.v1.CreateDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.CreateDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000000..a60be3e5951c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseMetadataOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CreateDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateDatabaseMetadata) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequest.java new file mode 100644 index 000000000000..d336324cc6a4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequest.java @@ -0,0 +1,1173 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class CreateDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateDatabaseRequest) + CreateDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateDatabaseRequest"); + } + + // Use CreateDatabaseRequest.newBuilder() to construct. + private CreateDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateDatabaseRequest() { + parent_ = ""; + databaseId_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateDatabaseRequest.class, + com.google.firestore.admin.v1.CreateDatabaseRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.Database database_; + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + @java.lang.Override + public boolean hasDatabase() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database getDatabase() { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder() { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + + public static final int DATABASE_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + @java.lang.Override + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getDatabase()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, databaseId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getDatabase()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, databaseId_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateDatabaseRequest other = + (com.google.firestore.admin.v1.CreateDatabaseRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasDatabase() != other.hasDatabase()) return false; + if (hasDatabase()) { + if (!getDatabase().equals(other.getDatabase())) return false; + } + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasDatabase()) { + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + } + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CreateDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateDatabaseRequest) + com.google.firestore.admin.v1.CreateDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateDatabaseRequest.class, + com.google.firestore.admin.v1.CreateDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateDatabaseRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDatabaseFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + database_ = null; + if (databaseBuilder_ != null) { + databaseBuilder_.dispose(); + databaseBuilder_ = null; + } + databaseId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseRequest build() { + com.google.firestore.admin.v1.CreateDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.CreateDatabaseRequest result = + new com.google.firestore.admin.v1.CreateDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CreateDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.database_ = databaseBuilder_ == null ? database_ : databaseBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.databaseId_ = databaseId_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.CreateDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.CreateDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasDatabase()) { + mergeDatabase(other.getDatabase()); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetDatabaseFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Database database_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + databaseBuilder_; + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + public boolean hasDatabase() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + public com.google.firestore.admin.v1.Database getDatabase() { + if (databaseBuilder_ == null) { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } else { + return databaseBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDatabase(com.google.firestore.admin.v1.Database value) { + if (databaseBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + } else { + databaseBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDatabase(com.google.firestore.admin.v1.Database.Builder builderForValue) { + if (databaseBuilder_ == null) { + database_ = builderForValue.build(); + } else { + databaseBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeDatabase(com.google.firestore.admin.v1.Database value) { + if (databaseBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && database_ != null + && database_ != com.google.firestore.admin.v1.Database.getDefaultInstance()) { + getDatabaseBuilder().mergeFrom(value); + } else { + database_ = value; + } + } else { + databaseBuilder_.mergeFrom(value); + } + if (database_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearDatabase() { + bitField0_ = (bitField0_ & ~0x00000002); + database_ = null; + if (databaseBuilder_ != null) { + databaseBuilder_.dispose(); + databaseBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.Database.Builder getDatabaseBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetDatabaseFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder() { + if (databaseBuilder_ != null) { + return databaseBuilder_.getMessageOrBuilder(); + } else { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + } + + /** + * + * + *
+     * Required. The Database to create.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + internalGetDatabaseFieldBuilder() { + if (databaseBuilder_ == null) { + databaseBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder>( + getDatabase(), getParentForChildren(), isClean()); + database_ = null; + } + return databaseBuilder_; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateDatabaseRequest) + private static final com.google.firestore.admin.v1.CreateDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.CreateDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..d2bea27eaff6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateDatabaseRequestOrBuilder.java @@ -0,0 +1,143 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CreateDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + boolean hasDatabase(); + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + com.google.firestore.admin.v1.Database getDatabase(); + + /** + * + * + *
+   * Required. The Database to create.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequest.java new file mode 100644 index 000000000000..bbea3c9c7d88 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequest.java @@ -0,0 +1,914 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateIndexRequest} + */ +@com.google.protobuf.Generated +public final class CreateIndexRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateIndexRequest) + CreateIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateIndexRequest"); + } + + // Use CreateIndexRequest.newBuilder() to construct. + private CreateIndexRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateIndexRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateIndexRequest.class, + com.google.firestore.admin.v1.CreateIndexRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.Index index_; + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the index field is set. + */ + @java.lang.Override + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The index. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index getIndex() { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getIndex()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndex()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateIndexRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateIndexRequest other = + (com.google.firestore.admin.v1.CreateIndexRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasIndex() != other.hasIndex()) return false; + if (hasIndex()) { + if (!getIndex().equals(other.getIndex())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasIndex()) { + hash = (37 * hash) + INDEX_FIELD_NUMBER; + hash = (53 * hash) + getIndex().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CreateIndexRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateIndexRequest) + com.google.firestore.admin.v1.CreateIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateIndexRequest.class, + com.google.firestore.admin.v1.CreateIndexRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateIndexRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetIndexFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateIndexRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateIndexRequest build() { + com.google.firestore.admin.v1.CreateIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateIndexRequest buildPartial() { + com.google.firestore.admin.v1.CreateIndexRequest result = + new com.google.firestore.admin.v1.CreateIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CreateIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.index_ = indexBuilder_ == null ? index_ : indexBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateIndexRequest) { + return mergeFrom((com.google.firestore.admin.v1.CreateIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateIndexRequest other) { + if (other == com.google.firestore.admin.v1.CreateIndexRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasIndex()) { + mergeIndex(other.getIndex()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetIndexFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Index index_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + indexBuilder_; + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the index field is set. + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The index. + */ + public com.google.firestore.admin.v1.Index getIndex() { + if (indexBuilder_ == null) { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } else { + return indexBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setIndex(com.google.firestore.admin.v1.Index value) { + if (indexBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + index_ = value; + } else { + indexBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setIndex(com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexBuilder_ == null) { + index_ = builderForValue.build(); + } else { + indexBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeIndex(com.google.firestore.admin.v1.Index value) { + if (indexBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && index_ != null + && index_ != com.google.firestore.admin.v1.Index.getDefaultInstance()) { + getIndexBuilder().mergeFrom(value); + } else { + index_ = value; + } + } else { + indexBuilder_.mergeFrom(value); + } + if (index_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000002); + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.Index.Builder getIndexBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetIndexFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + if (indexBuilder_ != null) { + return indexBuilder_.getMessageOrBuilder(); + } else { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + } + + /** + * + * + *
+     * Required. The composite index to create.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + internalGetIndexFieldBuilder() { + if (indexBuilder_ == null) { + indexBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder>( + getIndex(), getParentForChildren(), isClean()); + index_ = null; + } + return indexBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateIndexRequest) + private static final com.google.firestore.admin.v1.CreateIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateIndexRequest(); + } + + public static com.google.firestore.admin.v1.CreateIndexRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateIndexRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequestOrBuilder.java new file mode 100644 index 000000000000..5bf3e3d341e5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateIndexRequestOrBuilder.java @@ -0,0 +1,100 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CreateIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the index field is set. + */ + boolean hasIndex(); + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The index. + */ + com.google.firestore.admin.v1.Index getIndex(); + + /** + * + * + *
+   * Required. The composite index to create.
+   * 
+ * + * .google.firestore.admin.v1.Index index = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequest.java new file mode 100644 index 000000000000..5500905b1c4a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequest.java @@ -0,0 +1,1159 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.CreateUserCreds][google.firestore.admin.v1.FirestoreAdmin.CreateUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class CreateUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.CreateUserCredsRequest) + CreateUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateUserCredsRequest"); + } + + // Use CreateUserCredsRequest.newBuilder() to construct. + private CreateUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateUserCredsRequest() { + parent_ = ""; + userCredsId_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateUserCredsRequest.class, + com.google.firestore.admin.v1.CreateUserCredsRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int USER_CREDS_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.UserCreds userCreds_; + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the userCreds field is set. + */ + @java.lang.Override + public boolean hasUserCreds() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The userCreds. + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds getUserCreds() { + return userCreds_ == null + ? com.google.firestore.admin.v1.UserCreds.getDefaultInstance() + : userCreds_; + } + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder() { + return userCreds_ == null + ? com.google.firestore.admin.v1.UserCreds.getDefaultInstance() + : userCreds_; + } + + public static final int USER_CREDS_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object userCredsId_ = ""; + + /** + * + * + *
+   * Required. The ID to use for the user creds, which will become the final
+   * component of the user creds's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The userCredsId. + */ + @java.lang.Override + public java.lang.String getUserCredsId() { + java.lang.Object ref = userCredsId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + userCredsId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID to use for the user creds, which will become the final
+   * component of the user creds's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for userCredsId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getUserCredsIdBytes() { + java.lang.Object ref = userCredsId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + userCredsId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getUserCreds()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(userCredsId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, userCredsId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUserCreds()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(userCredsId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, userCredsId_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.CreateUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.CreateUserCredsRequest other = + (com.google.firestore.admin.v1.CreateUserCredsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasUserCreds() != other.hasUserCreds()) return false; + if (hasUserCreds()) { + if (!getUserCreds().equals(other.getUserCreds())) return false; + } + if (!getUserCredsId().equals(other.getUserCredsId())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasUserCreds()) { + hash = (37 * hash) + USER_CREDS_FIELD_NUMBER; + hash = (53 * hash) + getUserCreds().hashCode(); + } + hash = (37 * hash) + USER_CREDS_ID_FIELD_NUMBER; + hash = (53 * hash) + getUserCredsId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.CreateUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.CreateUserCreds][google.firestore.admin.v1.FirestoreAdmin.CreateUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.CreateUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.CreateUserCredsRequest) + com.google.firestore.admin.v1.CreateUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.CreateUserCredsRequest.class, + com.google.firestore.admin.v1.CreateUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.CreateUserCredsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetUserCredsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + userCreds_ = null; + if (userCredsBuilder_ != null) { + userCredsBuilder_.dispose(); + userCredsBuilder_ = null; + } + userCredsId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.CreateUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateUserCredsRequest build() { + com.google.firestore.admin.v1.CreateUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.CreateUserCredsRequest result = + new com.google.firestore.admin.v1.CreateUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.CreateUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.userCreds_ = userCredsBuilder_ == null ? userCreds_ : userCredsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.userCredsId_ = userCredsId_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.CreateUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.CreateUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.CreateUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.CreateUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasUserCreds()) { + mergeUserCreds(other.getUserCreds()); + } + if (!other.getUserCredsId().isEmpty()) { + userCredsId_ = other.userCredsId_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUserCredsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + userCredsId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.UserCreds userCreds_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder> + userCredsBuilder_; + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the userCreds field is set. + */ + public boolean hasUserCreds() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The userCreds. + */ + public com.google.firestore.admin.v1.UserCreds getUserCreds() { + if (userCredsBuilder_ == null) { + return userCreds_ == null + ? com.google.firestore.admin.v1.UserCreds.getDefaultInstance() + : userCreds_; + } else { + return userCredsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setUserCreds(com.google.firestore.admin.v1.UserCreds value) { + if (userCredsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + userCreds_ = value; + } else { + userCredsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setUserCreds(com.google.firestore.admin.v1.UserCreds.Builder builderForValue) { + if (userCredsBuilder_ == null) { + userCreds_ = builderForValue.build(); + } else { + userCredsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeUserCreds(com.google.firestore.admin.v1.UserCreds value) { + if (userCredsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && userCreds_ != null + && userCreds_ != com.google.firestore.admin.v1.UserCreds.getDefaultInstance()) { + getUserCredsBuilder().mergeFrom(value); + } else { + userCreds_ = value; + } + } else { + userCredsBuilder_.mergeFrom(value); + } + if (userCreds_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearUserCreds() { + bitField0_ = (bitField0_ & ~0x00000002); + userCreds_ = null; + if (userCredsBuilder_ != null) { + userCredsBuilder_.dispose(); + userCredsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.UserCreds.Builder getUserCredsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetUserCredsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder() { + if (userCredsBuilder_ != null) { + return userCredsBuilder_.getMessageOrBuilder(); + } else { + return userCreds_ == null + ? com.google.firestore.admin.v1.UserCreds.getDefaultInstance() + : userCreds_; + } + } + + /** + * + * + *
+     * Required. The user creds to create.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder> + internalGetUserCredsFieldBuilder() { + if (userCredsBuilder_ == null) { + userCredsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder>( + getUserCreds(), getParentForChildren(), isClean()); + userCreds_ = null; + } + return userCredsBuilder_; + } + + private java.lang.Object userCredsId_ = ""; + + /** + * + * + *
+     * Required. The ID to use for the user creds, which will become the final
+     * component of the user creds's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The userCredsId. + */ + public java.lang.String getUserCredsId() { + java.lang.Object ref = userCredsId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + userCredsId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the user creds, which will become the final
+     * component of the user creds's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for userCredsId. + */ + public com.google.protobuf.ByteString getUserCredsIdBytes() { + java.lang.Object ref = userCredsId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + userCredsId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the user creds, which will become the final
+     * component of the user creds's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The userCredsId to set. + * @return This builder for chaining. + */ + public Builder setUserCredsId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + userCredsId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the user creds, which will become the final
+     * component of the user creds's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearUserCredsId() { + userCredsId_ = getDefaultInstance().getUserCredsId(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the user creds, which will become the final
+     * component of the user creds's resource name.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for userCredsId to set. + * @return This builder for chaining. + */ + public Builder setUserCredsIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + userCredsId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.CreateUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.CreateUserCredsRequest) + private static final com.google.firestore.admin.v1.CreateUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.CreateUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.CreateUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.CreateUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..5a6b3cbaff8f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/CreateUserCredsRequestOrBuilder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface CreateUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.CreateUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the userCreds field is set. + */ + boolean hasUserCreds(); + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The userCreds. + */ + com.google.firestore.admin.v1.UserCreds getUserCreds(); + + /** + * + * + *
+   * Required. The user creds to create.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds user_creds = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder(); + + /** + * + * + *
+   * Required. The ID to use for the user creds, which will become the final
+   * component of the user creds's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The userCredsId. + */ + java.lang.String getUserCredsId(); + + /** + * + * + *
+   * Required. The ID to use for the user creds, which will become the final
+   * component of the user creds's resource name.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   * 
+ * + * string user_creds_id = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for userCredsId. + */ + com.google.protobuf.ByteString getUserCredsIdBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java new file mode 100644 index 000000000000..e45433230298 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrence.java @@ -0,0 +1,399 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Represents a recurring schedule that runs every day.
+ *
+ * The time zone is UTC.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DailyRecurrence} + */ +@com.google.protobuf.Generated +public final class DailyRecurrence extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DailyRecurrence) + DailyRecurrenceOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DailyRecurrence"); + } + + // Use DailyRecurrence.newBuilder() to construct. + private DailyRecurrence(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DailyRecurrence() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DailyRecurrence.class, + com.google.firestore.admin.v1.DailyRecurrence.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DailyRecurrence)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DailyRecurrence other = + (com.google.firestore.admin.v1.DailyRecurrence) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DailyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DailyRecurrence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Represents a recurring schedule that runs every day.
+   *
+   * The time zone is UTC.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DailyRecurrence} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DailyRecurrence) + com.google.firestore.admin.v1.DailyRecurrenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DailyRecurrence.class, + com.google.firestore.admin.v1.DailyRecurrence.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DailyRecurrence.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence build() { + com.google.firestore.admin.v1.DailyRecurrence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence buildPartial() { + com.google.firestore.admin.v1.DailyRecurrence result = + new com.google.firestore.admin.v1.DailyRecurrence(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DailyRecurrence) { + return mergeFrom((com.google.firestore.admin.v1.DailyRecurrence) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DailyRecurrence other) { + if (other == com.google.firestore.admin.v1.DailyRecurrence.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DailyRecurrence) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DailyRecurrence) + private static final com.google.firestore.admin.v1.DailyRecurrence DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DailyRecurrence(); + } + + public static com.google.firestore.admin.v1.DailyRecurrence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DailyRecurrence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DailyRecurrence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java new file mode 100644 index 000000000000..eaf44c8b4c3f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DailyRecurrenceOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DailyRecurrenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DailyRecurrence) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java new file mode 100644 index 000000000000..77dcb4f68053 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Database.java @@ -0,0 +1,13805 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/database.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A Cloud Firestore Database.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database} + */ +@com.google.protobuf.Generated +public final class Database extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database) + DatabaseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Database"); + } + + // Use Database.newBuilder() to construct. + private Database(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Database() { + name_ = ""; + uid_ = ""; + locationId_ = ""; + type_ = 0; + concurrencyMode_ = 0; + pointInTimeRecoveryEnablement_ = 0; + appEngineIntegrationMode_ = 0; + keyPrefix_ = ""; + deleteProtectionState_ = 0; + previousId_ = ""; + etag_ = ""; + databaseEdition_ = 0; + realtimeUpdatesMode_ = 0; + firestoreDataAccessMode_ = 0; + mongodbCompatibleDataAccessMode_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 29: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.class, + com.google.firestore.admin.v1.Database.Builder.class); + } + + /** + * + * + *
+   * The type of the database.
+   * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+   * information about how to choose.
+   *
+   * Mode changes are only allowed if the database is empty.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.DatabaseType} + */ + public enum DatabaseType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * DATABASE_TYPE_UNSPECIFIED = 0; + */ + DATABASE_TYPE_UNSPECIFIED(0), + /** + * + * + *
+     * Firestore Native Mode
+     * 
+ * + * FIRESTORE_NATIVE = 1; + */ + FIRESTORE_NATIVE(1), + /** + * + * + *
+     * Firestore in Datastore Mode.
+     * 
+ * + * DATASTORE_MODE = 2; + */ + DATASTORE_MODE(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DatabaseType"); + } + + /** + * + * + *
+     * Not used.
+     * 
+ * + * DATABASE_TYPE_UNSPECIFIED = 0; + */ + public static final int DATABASE_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Firestore Native Mode
+     * 
+ * + * FIRESTORE_NATIVE = 1; + */ + public static final int FIRESTORE_NATIVE_VALUE = 1; + + /** + * + * + *
+     * Firestore in Datastore Mode.
+     * 
+ * + * DATASTORE_MODE = 2; + */ + public static final int DATASTORE_MODE_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DatabaseType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DatabaseType forNumber(int value) { + switch (value) { + case 0: + return DATABASE_TYPE_UNSPECIFIED; + case 1: + return FIRESTORE_NATIVE; + case 2: + return DATASTORE_MODE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DatabaseType findValueByNumber(int number) { + return DatabaseType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(0); + } + + private static final DatabaseType[] VALUES = values(); + + public static DatabaseType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DatabaseType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.DatabaseType) + } + + /** + * + * + *
+   * The type of concurrency control mode for transactions.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.ConcurrencyMode} + */ + public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * CONCURRENCY_MODE_UNSPECIFIED = 0; + */ + CONCURRENCY_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * Use optimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
+     *
+     * This is the default setting for Cloud Firestore Enterprise Edition
+     * databases.
+     * 
+ * + * OPTIMISTIC = 1; + */ + OPTIMISTIC(1), + /** + * + * + *
+     * Use pessimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
+     *
+     * This is the default setting for Cloud Firestore Standard Edition
+     * databases.
+     * 
+ * + * PESSIMISTIC = 2; + */ + PESSIMISTIC(2), + /** + * + * + *
+     * Use optimistic concurrency control with entity groups by default.
+     *
+     * This mode is enabled for some databases that were automatically upgraded
+     * from Cloud Datastore to Cloud Firestore with Datastore Mode.
+     *
+     * It is not recommended for any new databases, and not supported for
+     * Firestore Native databases.
+     * 
+ * + * OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + */ + OPTIMISTIC_WITH_ENTITY_GROUPS(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ConcurrencyMode"); + } + + /** + * + * + *
+     * Not used.
+     * 
+ * + * CONCURRENCY_MODE_UNSPECIFIED = 0; + */ + public static final int CONCURRENCY_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Use optimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
+     *
+     * This is the default setting for Cloud Firestore Enterprise Edition
+     * databases.
+     * 
+ * + * OPTIMISTIC = 1; + */ + public static final int OPTIMISTIC_VALUE = 1; + + /** + * + * + *
+     * Use pessimistic concurrency control by default. This mode is available
+     * for Cloud Firestore databases.
+     *
+     * This is the default setting for Cloud Firestore Standard Edition
+     * databases.
+     * 
+ * + * PESSIMISTIC = 2; + */ + public static final int PESSIMISTIC_VALUE = 2; + + /** + * + * + *
+     * Use optimistic concurrency control with entity groups by default.
+     *
+     * This mode is enabled for some databases that were automatically upgraded
+     * from Cloud Datastore to Cloud Firestore with Datastore Mode.
+     *
+     * It is not recommended for any new databases, and not supported for
+     * Firestore Native databases.
+     * 
+ * + * OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + */ + public static final int OPTIMISTIC_WITH_ENTITY_GROUPS_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConcurrencyMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ConcurrencyMode forNumber(int value) { + switch (value) { + case 0: + return CONCURRENCY_MODE_UNSPECIFIED; + case 1: + return OPTIMISTIC; + case 2: + return PESSIMISTIC; + case 3: + return OPTIMISTIC_WITH_ENTITY_GROUPS; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ConcurrencyMode findValueByNumber(int number) { + return ConcurrencyMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(1); + } + + private static final ConcurrencyMode[] VALUES = values(); + + public static ConcurrencyMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ConcurrencyMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.ConcurrencyMode) + } + + /** + * + * + *
+   * Point In Time Recovery feature enablement.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement} + */ + public enum PointInTimeRecoveryEnablement implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED = 0; + */ + POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED(0), + /** + * + * + *
+     * Reads are supported on selected versions of the data from within the past
+     * 7 days:
+     *
+     * * Reads against any timestamp within the past hour
+     * * Reads against 1-minute snapshots beyond 1 hour and within 7 days
+     *
+     * `version_retention_period` and `earliest_version_time` can be
+     * used to determine the supported versions.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_ENABLED = 1; + */ + POINT_IN_TIME_RECOVERY_ENABLED(1), + /** + * + * + *
+     * Reads are supported on any version of the data from within the past 1
+     * hour.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_DISABLED = 2; + */ + POINT_IN_TIME_RECOVERY_DISABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PointInTimeRecoveryEnablement"); + } + + /** + * + * + *
+     * Not used.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED = 0; + */ + public static final int POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Reads are supported on selected versions of the data from within the past
+     * 7 days:
+     *
+     * * Reads against any timestamp within the past hour
+     * * Reads against 1-minute snapshots beyond 1 hour and within 7 days
+     *
+     * `version_retention_period` and `earliest_version_time` can be
+     * used to determine the supported versions.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_ENABLED = 1; + */ + public static final int POINT_IN_TIME_RECOVERY_ENABLED_VALUE = 1; + + /** + * + * + *
+     * Reads are supported on any version of the data from within the past 1
+     * hour.
+     * 
+ * + * POINT_IN_TIME_RECOVERY_DISABLED = 2; + */ + public static final int POINT_IN_TIME_RECOVERY_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static PointInTimeRecoveryEnablement valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static PointInTimeRecoveryEnablement forNumber(int value) { + switch (value) { + case 0: + return POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED; + case 1: + return POINT_IN_TIME_RECOVERY_ENABLED; + case 2: + return POINT_IN_TIME_RECOVERY_DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public PointInTimeRecoveryEnablement findValueByNumber(int number) { + return PointInTimeRecoveryEnablement.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(2); + } + + private static final PointInTimeRecoveryEnablement[] VALUES = values(); + + public static PointInTimeRecoveryEnablement valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private PointInTimeRecoveryEnablement(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement) + } + + /** + * + * + *
+   * The type of App Engine integration mode.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.AppEngineIntegrationMode} + */ + public enum AppEngineIntegrationMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + */ + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * If an App Engine application exists in the same region as this database,
+     * App Engine configuration will impact this database. This includes
+     * disabling of the application & database, as well as disabling writes to
+     * the database.
+     * 
+ * + * ENABLED = 1; + */ + ENABLED(1), + /** + * + * + *
+     * App Engine has no effect on the ability of this database to serve
+     * requests.
+     *
+     * This is the default setting for databases created with the Firestore API.
+     * 
+ * + * DISABLED = 2; + */ + DISABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "AppEngineIntegrationMode"); + } + + /** + * + * + *
+     * Not used.
+     * 
+ * + * APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + */ + public static final int APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * If an App Engine application exists in the same region as this database,
+     * App Engine configuration will impact this database. This includes
+     * disabling of the application & database, as well as disabling writes to
+     * the database.
+     * 
+ * + * ENABLED = 1; + */ + public static final int ENABLED_VALUE = 1; + + /** + * + * + *
+     * App Engine has no effect on the ability of this database to serve
+     * requests.
+     *
+     * This is the default setting for databases created with the Firestore API.
+     * 
+ * + * DISABLED = 2; + */ + public static final int DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static AppEngineIntegrationMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static AppEngineIntegrationMode forNumber(int value) { + switch (value) { + case 0: + return APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED; + case 1: + return ENABLED; + case 2: + return DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public AppEngineIntegrationMode findValueByNumber(int number) { + return AppEngineIntegrationMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(3); + } + + private static final AppEngineIntegrationMode[] VALUES = values(); + + public static AppEngineIntegrationMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private AppEngineIntegrationMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.AppEngineIntegrationMode) + } + + /** + * + * + *
+   * The delete protection state of the database.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.DeleteProtectionState} + */ + public enum DeleteProtectionState implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The default value. Delete protection type is not specified
+     * 
+ * + * DELETE_PROTECTION_STATE_UNSPECIFIED = 0; + */ + DELETE_PROTECTION_STATE_UNSPECIFIED(0), + /** + * + * + *
+     * Delete protection is disabled
+     * 
+ * + * DELETE_PROTECTION_DISABLED = 1; + */ + DELETE_PROTECTION_DISABLED(1), + /** + * + * + *
+     * Delete protection is enabled
+     * 
+ * + * DELETE_PROTECTION_ENABLED = 2; + */ + DELETE_PROTECTION_ENABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteProtectionState"); + } + + /** + * + * + *
+     * The default value. Delete protection type is not specified
+     * 
+ * + * DELETE_PROTECTION_STATE_UNSPECIFIED = 0; + */ + public static final int DELETE_PROTECTION_STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Delete protection is disabled
+     * 
+ * + * DELETE_PROTECTION_DISABLED = 1; + */ + public static final int DELETE_PROTECTION_DISABLED_VALUE = 1; + + /** + * + * + *
+     * Delete protection is enabled
+     * 
+ * + * DELETE_PROTECTION_ENABLED = 2; + */ + public static final int DELETE_PROTECTION_ENABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DeleteProtectionState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DeleteProtectionState forNumber(int value) { + switch (value) { + case 0: + return DELETE_PROTECTION_STATE_UNSPECIFIED; + case 1: + return DELETE_PROTECTION_DISABLED; + case 2: + return DELETE_PROTECTION_ENABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DeleteProtectionState findValueByNumber(int number) { + return DeleteProtectionState.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(4); + } + + private static final DeleteProtectionState[] VALUES = values(); + + public static DeleteProtectionState valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DeleteProtectionState(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.DeleteProtectionState) + } + + /** + * + * + *
+   * The edition of the database.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.DatabaseEdition} + */ + public enum DatabaseEdition implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not used.
+     * 
+ * + * DATABASE_EDITION_UNSPECIFIED = 0; + */ + DATABASE_EDITION_UNSPECIFIED(0), + /** + * + * + *
+     * Standard edition.
+     *
+     * This is the default setting if not specified.
+     * 
+ * + * STANDARD = 1; + */ + STANDARD(1), + /** + * + * + *
+     * Enterprise edition.
+     * 
+ * + * ENTERPRISE = 2; + */ + ENTERPRISE(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DatabaseEdition"); + } + + /** + * + * + *
+     * Not used.
+     * 
+ * + * DATABASE_EDITION_UNSPECIFIED = 0; + */ + public static final int DATABASE_EDITION_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Standard edition.
+     *
+     * This is the default setting if not specified.
+     * 
+ * + * STANDARD = 1; + */ + public static final int STANDARD_VALUE = 1; + + /** + * + * + *
+     * Enterprise edition.
+     * 
+ * + * ENTERPRISE = 2; + */ + public static final int ENTERPRISE_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DatabaseEdition valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DatabaseEdition forNumber(int value) { + switch (value) { + case 0: + return DATABASE_EDITION_UNSPECIFIED; + case 1: + return STANDARD; + case 2: + return ENTERPRISE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DatabaseEdition findValueByNumber(int number) { + return DatabaseEdition.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(5); + } + + private static final DatabaseEdition[] VALUES = values(); + + public static DatabaseEdition valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DatabaseEdition(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.DatabaseEdition) + } + + /** + * + * + *
+   * The data access mode.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Database.DataAccessMode} + */ + public enum DataAccessMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Not Used.
+     * 
+ * + * DATA_ACCESS_MODE_UNSPECIFIED = 0; + */ + DATA_ACCESS_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * Accessing the database through the API is allowed.
+     * 
+ * + * DATA_ACCESS_MODE_ENABLED = 1; + */ + DATA_ACCESS_MODE_ENABLED(1), + /** + * + * + *
+     * Accessing the database through the API is disallowed.
+     * 
+ * + * DATA_ACCESS_MODE_DISABLED = 2; + */ + DATA_ACCESS_MODE_DISABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DataAccessMode"); + } + + /** + * + * + *
+     * Not Used.
+     * 
+ * + * DATA_ACCESS_MODE_UNSPECIFIED = 0; + */ + public static final int DATA_ACCESS_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Accessing the database through the API is allowed.
+     * 
+ * + * DATA_ACCESS_MODE_ENABLED = 1; + */ + public static final int DATA_ACCESS_MODE_ENABLED_VALUE = 1; + + /** + * + * + *
+     * Accessing the database through the API is disallowed.
+     * 
+ * + * DATA_ACCESS_MODE_DISABLED = 2; + */ + public static final int DATA_ACCESS_MODE_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DataAccessMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DataAccessMode forNumber(int value) { + switch (value) { + case 0: + return DATA_ACCESS_MODE_UNSPECIFIED; + case 1: + return DATA_ACCESS_MODE_ENABLED; + case 2: + return DATA_ACCESS_MODE_DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DataAccessMode findValueByNumber(int number) { + return DataAccessMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Database.getDescriptor().getEnumTypes().get(6); + } + + private static final DataAccessMode[] VALUES = values(); + + public static DataAccessMode valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DataAccessMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Database.DataAccessMode) + } + + public interface CmekConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.CmekConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Required. Only keys in the same location as this database are allowed to
+     * be used for encryption.
+     *
+     * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+     * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+     * Cloud KMS multi-region europe. See
+     * https://cloud.google.com/kms/docs/locations.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+     * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + java.lang.String getKmsKeyName(); + + /** + * + * + *
+     * Required. Only keys in the same location as this database are allowed to
+     * be used for encryption.
+     *
+     * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+     * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+     * Cloud KMS multi-region europe. See
+     * https://cloud.google.com/kms/docs/locations.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+     * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + com.google.protobuf.ByteString getKmsKeyNameBytes(); + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the activeKeyVersion. + */ + java.util.List getActiveKeyVersionList(); + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of activeKeyVersion. + */ + int getActiveKeyVersionCount(); + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The activeKeyVersion at the given index. + */ + java.lang.String getActiveKeyVersion(int index); + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the activeKeyVersion at the given index. + */ + com.google.protobuf.ByteString getActiveKeyVersionBytes(int index); + } + + /** + * + * + *
+   * The CMEK (Customer Managed Encryption Key) configuration for a Firestore
+   * database. If not present, the database is secured by the default Google
+   * encryption key.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.CmekConfig} + */ + public static final class CmekConfig extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.CmekConfig) + CmekConfigOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CmekConfig"); + } + + // Use CmekConfig.newBuilder() to construct. + private CmekConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CmekConfig() { + kmsKeyName_ = ""; + activeKeyVersion_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_CmekConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.CmekConfig.class, + com.google.firestore.admin.v1.Database.CmekConfig.Builder.class); + } + + public static final int KMS_KEY_NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object kmsKeyName_ = ""; + + /** + * + * + *
+     * Required. Only keys in the same location as this database are allowed to
+     * be used for encryption.
+     *
+     * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+     * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+     * Cloud KMS multi-region europe. See
+     * https://cloud.google.com/kms/docs/locations.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+     * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + @java.lang.Override + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } + } + + /** + * + * + *
+     * Required. Only keys in the same location as this database are allowed to
+     * be used for encryption.
+     *
+     * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+     * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+     * Cloud KMS multi-region europe. See
+     * https://cloud.google.com/kms/docs/locations.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+     * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ACTIVE_KEY_VERSION_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList activeKeyVersion_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the activeKeyVersion. + */ + public com.google.protobuf.ProtocolStringList getActiveKeyVersionList() { + return activeKeyVersion_; + } + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of activeKeyVersion. + */ + public int getActiveKeyVersionCount() { + return activeKeyVersion_.size(); + } + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The activeKeyVersion at the given index. + */ + public java.lang.String getActiveKeyVersion(int index) { + return activeKeyVersion_.get(index); + } + + /** + * + * + *
+     * Output only. Currently in-use [KMS key
+     * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+     * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+     * there can be multiple in-use key versions.
+     *
+     * The expected format is
+     * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+     * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the activeKeyVersion at the given index. + */ + public com.google.protobuf.ByteString getActiveKeyVersionBytes(int index) { + return activeKeyVersion_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(kmsKeyName_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, kmsKeyName_); + } + for (int i = 0; i < activeKeyVersion_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, activeKeyVersion_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(kmsKeyName_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, kmsKeyName_); + } + { + int dataSize = 0; + for (int i = 0; i < activeKeyVersion_.size(); i++) { + dataSize += computeStringSizeNoTag(activeKeyVersion_.getRaw(i)); + } + size += dataSize; + size += 1 * getActiveKeyVersionList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Database.CmekConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.CmekConfig other = + (com.google.firestore.admin.v1.Database.CmekConfig) obj; + + if (!getKmsKeyName().equals(other.getKmsKeyName())) return false; + if (!getActiveKeyVersionList().equals(other.getActiveKeyVersionList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KMS_KEY_NAME_FIELD_NUMBER; + hash = (53 * hash) + getKmsKeyName().hashCode(); + if (getActiveKeyVersionCount() > 0) { + hash = (37 * hash) + ACTIVE_KEY_VERSION_FIELD_NUMBER; + hash = (53 * hash) + getActiveKeyVersionList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Database.CmekConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * The CMEK (Customer Managed Encryption Key) configuration for a Firestore
+     * database. If not present, the database is secured by the default Google
+     * encryption key.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.CmekConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.CmekConfig) + com.google.firestore.admin.v1.Database.CmekConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_CmekConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.CmekConfig.class, + com.google.firestore.admin.v1.Database.CmekConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Database.CmekConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + kmsKeyName_ = ""; + activeKeyVersion_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfig getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfig build() { + com.google.firestore.admin.v1.Database.CmekConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfig buildPartial() { + com.google.firestore.admin.v1.Database.CmekConfig result = + new com.google.firestore.admin.v1.Database.CmekConfig(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Database.CmekConfig result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.kmsKeyName_ = kmsKeyName_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + activeKeyVersion_.makeImmutable(); + result.activeKeyVersion_ = activeKeyVersion_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Database.CmekConfig) { + return mergeFrom((com.google.firestore.admin.v1.Database.CmekConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Database.CmekConfig other) { + if (other == com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance()) + return this; + if (!other.getKmsKeyName().isEmpty()) { + kmsKeyName_ = other.kmsKeyName_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.activeKeyVersion_.isEmpty()) { + if (activeKeyVersion_.isEmpty()) { + activeKeyVersion_ = other.activeKeyVersion_; + bitField0_ |= 0x00000002; + } else { + ensureActiveKeyVersionIsMutable(); + activeKeyVersion_.addAll(other.activeKeyVersion_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + kmsKeyName_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureActiveKeyVersionIsMutable(); + activeKeyVersion_.add(s); + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object kmsKeyName_ = ""; + + /** + * + * + *
+       * Required. Only keys in the same location as this database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Required. Only keys in the same location as this database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Required. Only keys in the same location as this database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + kmsKeyName_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. Only keys in the same location as this database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearKmsKeyName() { + kmsKeyName_ = getDefaultInstance().getKmsKeyName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. Only keys in the same location as this database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + kmsKeyName_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList activeKeyVersion_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureActiveKeyVersionIsMutable() { + if (!activeKeyVersion_.isModifiable()) { + activeKeyVersion_ = new com.google.protobuf.LazyStringArrayList(activeKeyVersion_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the activeKeyVersion. + */ + public com.google.protobuf.ProtocolStringList getActiveKeyVersionList() { + activeKeyVersion_.makeImmutable(); + return activeKeyVersion_; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of activeKeyVersion. + */ + public int getActiveKeyVersionCount() { + return activeKeyVersion_.size(); + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The activeKeyVersion at the given index. + */ + public java.lang.String getActiveKeyVersion(int index) { + return activeKeyVersion_.get(index); + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the activeKeyVersion at the given index. + */ + public com.google.protobuf.ByteString getActiveKeyVersionBytes(int index) { + return activeKeyVersion_.getByteString(index); + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index to set the value at. + * @param value The activeKeyVersion to set. + * @return This builder for chaining. + */ + public Builder setActiveKeyVersion(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureActiveKeyVersionIsMutable(); + activeKeyVersion_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The activeKeyVersion to add. + * @return This builder for chaining. + */ + public Builder addActiveKeyVersion(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureActiveKeyVersionIsMutable(); + activeKeyVersion_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param values The activeKeyVersion to add. + * @return This builder for chaining. + */ + public Builder addAllActiveKeyVersion(java.lang.Iterable values) { + ensureActiveKeyVersionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, activeKeyVersion_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearActiveKeyVersion() { + activeKeyVersion_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Currently in-use [KMS key
+       * versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions).
+       * During [key rotation](https://cloud.google.com/kms/docs/key-rotation),
+       * there can be multiple in-use key versions.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`.
+       * 
+ * + * repeated string active_key_version = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The bytes of the activeKeyVersion to add. + * @return This builder for chaining. + */ + public Builder addActiveKeyVersionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureActiveKeyVersionIsMutable(); + activeKeyVersion_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.CmekConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.CmekConfig) + private static final com.google.firestore.admin.v1.Database.CmekConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Database.CmekConfig(); + } + + public static com.google.firestore.admin.v1.Database.CmekConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CmekConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface SourceInfoOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.SourceInfo) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return Whether the backup field is set. + */ + boolean hasBackup(); + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return The backup. + */ + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource getBackup(); + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder getBackupOrBuilder(); + + /** + * + * + *
+     * The associated long-running operation. This field may not be set after
+     * the operation has completed. Format:
+     * `projects/{project}/databases/{database}/operations/{operation}`.
+     * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The operation. + */ + java.lang.String getOperation(); + + /** + * + * + *
+     * The associated long-running operation. This field may not be set after
+     * the operation has completed. Format:
+     * `projects/{project}/databases/{database}/operations/{operation}`.
+     * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for operation. + */ + com.google.protobuf.ByteString getOperationBytes(); + + com.google.firestore.admin.v1.Database.SourceInfo.SourceCase getSourceCase(); + } + + /** + * + * + *
+   * Information about the provenance of this database.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.SourceInfo} + */ + public static final class SourceInfo extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.SourceInfo) + SourceInfoOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "SourceInfo"); + } + + // Use SourceInfo.newBuilder() to construct. + private SourceInfo(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private SourceInfo() { + operation_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.SourceInfo.class, + com.google.firestore.admin.v1.Database.SourceInfo.Builder.class); + } + + public interface BackupSourceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.SourceInfo.BackupSource) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * The resource name of the backup that was used to restore this
+       * database. Format:
+       * `projects/{project}/locations/{location}/backups/{backup}`.
+       * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + java.lang.String getBackup(); + + /** + * + * + *
+       * The resource name of the backup that was used to restore this
+       * database. Format:
+       * `projects/{project}/locations/{location}/backups/{backup}`.
+       * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + com.google.protobuf.ByteString getBackupBytes(); + } + + /** + * + * + *
+     * Information about a backup that was used to restore a database.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.SourceInfo.BackupSource} + */ + public static final class BackupSource extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.SourceInfo.BackupSource) + BackupSourceOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BackupSource"); + } + + // Use BackupSource.newBuilder() to construct. + private BackupSource(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BackupSource() { + backup_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.class, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder.class); + } + + public static final int BACKUP_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object backup_ = ""; + + /** + * + * + *
+       * The resource name of the backup that was used to restore this
+       * database. Format:
+       * `projects/{project}/locations/{location}/backups/{backup}`.
+       * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + @java.lang.Override + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } + } + + /** + * + * + *
+       * The resource name of the backup that was used to restore this
+       * database. Format:
+       * `projects/{project}/locations/{location}/backups/{backup}`.
+       * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, backup_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, backup_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Database.SourceInfo.BackupSource)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource other = + (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) obj; + + if (!getBackup().equals(other.getBackup())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Information about a backup that was used to restore a database.
+       * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.SourceInfo.BackupSource} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.SourceInfo.BackupSource) + com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.class, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + backup_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource build() { + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource buildPartial() { + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource result = + new com.google.firestore.admin.v1.Database.SourceInfo.BackupSource(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.backup_ = backup_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) { + return mergeFrom( + (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource other) { + if (other + == com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance()) return this; + if (!other.getBackup().isEmpty()) { + backup_ = other.backup_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + backup_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object backup_ = ""; + + /** + * + * + *
+         * The resource name of the backup that was used to restore this
+         * database. Format:
+         * `projects/{project}/locations/{location}/backups/{backup}`.
+         * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+         * The resource name of the backup that was used to restore this
+         * database. Format:
+         * `projects/{project}/locations/{location}/backups/{backup}`.
+         * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+         * The resource name of the backup that was used to restore this
+         * database. Format:
+         * `projects/{project}/locations/{location}/backups/{backup}`.
+         * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The backup to set. + * @return This builder for chaining. + */ + public Builder setBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backup_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The resource name of the backup that was used to restore this
+         * database. Format:
+         * `projects/{project}/locations/{location}/backups/{backup}`.
+         * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearBackup() { + backup_ = getDefaultInstance().getBackup(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+         * The resource name of the backup that was used to restore this
+         * database. Format:
+         * `projects/{project}/locations/{location}/backups/{backup}`.
+         * 
+ * + * string backup = 1 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for backup to set. + * @return This builder for chaining. + */ + public Builder setBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backup_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.SourceInfo.BackupSource) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.SourceInfo.BackupSource) + private static final com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Database.SourceInfo.BackupSource(); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BackupSource parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int sourceCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object source_; + + public enum SourceCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + BACKUP(1), + SOURCE_NOT_SET(0); + private final int value; + + private SourceCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static SourceCase valueOf(int value) { + return forNumber(value); + } + + public static SourceCase forNumber(int value) { + switch (value) { + case 1: + return BACKUP; + case 0: + return SOURCE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public SourceCase getSourceCase() { + return SourceCase.forNumber(sourceCase_); + } + + public static final int BACKUP_FIELD_NUMBER = 1; + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return Whether the backup field is set. + */ + @java.lang.Override + public boolean hasBackup() { + return sourceCase_ == 1; + } + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return The backup. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource getBackup() { + if (sourceCase_ == 1) { + return (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_; + } + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.getDefaultInstance(); + } + + /** + * + * + *
+     * If set, this database was restored from the specified backup (or a
+     * snapshot thereof).
+     * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder + getBackupOrBuilder() { + if (sourceCase_ == 1) { + return (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_; + } + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.getDefaultInstance(); + } + + public static final int OPERATION_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object operation_ = ""; + + /** + * + * + *
+     * The associated long-running operation. This field may not be set after
+     * the operation has completed. Format:
+     * `projects/{project}/databases/{database}/operations/{operation}`.
+     * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The operation. + */ + @java.lang.Override + public java.lang.String getOperation() { + java.lang.Object ref = operation_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + operation_ = s; + return s; + } + } + + /** + * + * + *
+     * The associated long-running operation. This field may not be set after
+     * the operation has completed. Format:
+     * `projects/{project}/databases/{database}/operations/{operation}`.
+     * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for operation. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOperationBytes() { + java.lang.Object ref = operation_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + operation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (sourceCase_ == 1) { + output.writeMessage( + 1, (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(operation_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, operation_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (sourceCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(operation_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, operation_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Database.SourceInfo)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.SourceInfo other = + (com.google.firestore.admin.v1.Database.SourceInfo) obj; + + if (!getOperation().equals(other.getOperation())) return false; + if (!getSourceCase().equals(other.getSourceCase())) return false; + switch (sourceCase_) { + case 1: + if (!getBackup().equals(other.getBackup())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OPERATION_FIELD_NUMBER; + hash = (53 * hash) + getOperation().hashCode(); + switch (sourceCase_) { + case 1: + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Database.SourceInfo prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Information about the provenance of this database.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.SourceInfo} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.SourceInfo) + com.google.firestore.admin.v1.Database.SourceInfoOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.SourceInfo.class, + com.google.firestore.admin.v1.Database.SourceInfo.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Database.SourceInfo.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupBuilder_ != null) { + backupBuilder_.clear(); + } + operation_ = ""; + sourceCase_ = 0; + source_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo build() { + com.google.firestore.admin.v1.Database.SourceInfo result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo buildPartial() { + com.google.firestore.admin.v1.Database.SourceInfo result = + new com.google.firestore.admin.v1.Database.SourceInfo(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Database.SourceInfo result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.operation_ = operation_; + } + } + + private void buildPartialOneofs(com.google.firestore.admin.v1.Database.SourceInfo result) { + result.sourceCase_ = sourceCase_; + result.source_ = this.source_; + if (sourceCase_ == 1 && backupBuilder_ != null) { + result.source_ = backupBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Database.SourceInfo) { + return mergeFrom((com.google.firestore.admin.v1.Database.SourceInfo) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Database.SourceInfo other) { + if (other == com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance()) + return this; + if (!other.getOperation().isEmpty()) { + operation_ = other.operation_; + bitField0_ |= 0x00000002; + onChanged(); + } + switch (other.getSourceCase()) { + case BACKUP: + { + mergeBackup(other.getBackup()); + break; + } + case SOURCE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetBackupFieldBuilder().getBuilder(), extensionRegistry); + sourceCase_ = 1; + break; + } // case 10 + case 26: + { + operation_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int sourceCase_ = 0; + private java.lang.Object source_; + + public SourceCase getSourceCase() { + return SourceCase.forNumber(sourceCase_); + } + + public Builder clearSource() { + sourceCase_ = 0; + source_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder> + backupBuilder_; + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return Whether the backup field is set. + */ + @java.lang.Override + public boolean hasBackup() { + return sourceCase_ == 1; + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + * + * @return The backup. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource getBackup() { + if (backupBuilder_ == null) { + if (sourceCase_ == 1) { + return (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_; + } + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance(); + } else { + if (sourceCase_ == 1) { + return backupBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + public Builder setBackup( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource value) { + if (backupBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + source_ = value; + onChanged(); + } else { + backupBuilder_.setMessage(value); + } + sourceCase_ = 1; + return this; + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + public Builder setBackup( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder builderForValue) { + if (backupBuilder_ == null) { + source_ = builderForValue.build(); + onChanged(); + } else { + backupBuilder_.setMessage(builderForValue.build()); + } + sourceCase_ = 1; + return this; + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + public Builder mergeBackup( + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource value) { + if (backupBuilder_ == null) { + if (sourceCase_ == 1 + && source_ + != com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance()) { + source_ = + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.newBuilder( + (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_) + .mergeFrom(value) + .buildPartial(); + } else { + source_ = value; + } + onChanged(); + } else { + if (sourceCase_ == 1) { + backupBuilder_.mergeFrom(value); + } else { + backupBuilder_.setMessage(value); + } + } + sourceCase_ = 1; + return this; + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + public Builder clearBackup() { + if (backupBuilder_ == null) { + if (sourceCase_ == 1) { + sourceCase_ = 0; + source_ = null; + onChanged(); + } + } else { + if (sourceCase_ == 1) { + sourceCase_ = 0; + source_ = null; + } + backupBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder + getBackupBuilder() { + return internalGetBackupFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder + getBackupOrBuilder() { + if ((sourceCase_ == 1) && (backupBuilder_ != null)) { + return backupBuilder_.getMessageOrBuilder(); + } else { + if (sourceCase_ == 1) { + return (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_; + } + return com.google.firestore.admin.v1.Database.SourceInfo.BackupSource + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * If set, this database was restored from the specified backup (or a
+       * snapshot thereof).
+       * 
+ * + * .google.firestore.admin.v1.Database.SourceInfo.BackupSource backup = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder> + internalGetBackupFieldBuilder() { + if (backupBuilder_ == null) { + if (!(sourceCase_ == 1)) { + source_ = + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.getDefaultInstance(); + } + backupBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSource.Builder, + com.google.firestore.admin.v1.Database.SourceInfo.BackupSourceOrBuilder>( + (com.google.firestore.admin.v1.Database.SourceInfo.BackupSource) source_, + getParentForChildren(), + isClean()); + source_ = null; + } + sourceCase_ = 1; + onChanged(); + return backupBuilder_; + } + + private java.lang.Object operation_ = ""; + + /** + * + * + *
+       * The associated long-running operation. This field may not be set after
+       * the operation has completed. Format:
+       * `projects/{project}/databases/{database}/operations/{operation}`.
+       * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The operation. + */ + public java.lang.String getOperation() { + java.lang.Object ref = operation_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + operation_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The associated long-running operation. This field may not be set after
+       * the operation has completed. Format:
+       * `projects/{project}/databases/{database}/operations/{operation}`.
+       * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for operation. + */ + public com.google.protobuf.ByteString getOperationBytes() { + java.lang.Object ref = operation_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + operation_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The associated long-running operation. This field may not be set after
+       * the operation has completed. Format:
+       * `projects/{project}/databases/{database}/operations/{operation}`.
+       * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @param value The operation to set. + * @return This builder for chaining. + */ + public Builder setOperation(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * The associated long-running operation. This field may not be set after
+       * the operation has completed. Format:
+       * `projects/{project}/databases/{database}/operations/{operation}`.
+       * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearOperation() { + operation_ = getDefaultInstance().getOperation(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+       * The associated long-running operation. This field may not be set after
+       * the operation has completed. Format:
+       * `projects/{project}/databases/{database}/operations/{operation}`.
+       * 
+ * + * string operation = 3 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for operation to set. + * @return This builder for chaining. + */ + public Builder setOperationBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + operation_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.SourceInfo) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.SourceInfo) + private static final com.google.firestore.admin.v1.Database.SourceInfo DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Database.SourceInfo(); + } + + public static com.google.firestore.admin.v1.Database.SourceInfo getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SourceInfo parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface EncryptionConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.EncryptionConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return Whether the googleDefaultEncryption field is set. + */ + boolean hasGoogleDefaultEncryption(); + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return The googleDefaultEncryption. + */ + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + getGoogleDefaultEncryption(); + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptionsOrBuilder + getGoogleDefaultEncryptionOrBuilder(); + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return Whether the useSourceEncryption field is set. + */ + boolean hasUseSourceEncryption(); + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return The useSourceEncryption. + */ + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getUseSourceEncryption(); + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptionsOrBuilder + getUseSourceEncryptionOrBuilder(); + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return Whether the customerManagedEncryption field is set. + */ + boolean hasCustomerManagedEncryption(); + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return The customerManagedEncryption. + */ + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + getCustomerManagedEncryption(); + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder + getCustomerManagedEncryptionOrBuilder(); + + com.google.firestore.admin.v1.Database.EncryptionConfig.EncryptionTypeCase + getEncryptionTypeCase(); + } + + /** + * + * + *
+   * Encryption configuration for a new database being created from another
+   * source.
+   *
+   * The source could be a [Backup][google.firestore.admin.v1.Backup] or a
+   * [PitrSnapshot][google.firestore.admin.v1.PitrSnapshot].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.EncryptionConfig} + */ + public static final class EncryptionConfig extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.EncryptionConfig) + EncryptionConfigOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "EncryptionConfig"); + } + + // Use EncryptionConfig.newBuilder() to construct. + private EncryptionConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private EncryptionConfig() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig.class, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder.class); + } + + public interface GoogleDefaultEncryptionOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + com.google.protobuf.MessageOrBuilder {} + + /** + * + * + *
+     * The configuration options for using Google default encryption.
+     * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions} + */ + public static final class GoogleDefaultEncryptionOptions + extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + GoogleDefaultEncryptionOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GoogleDefaultEncryptionOptions"); + } + + // Use GoogleDefaultEncryptionOptions.newBuilder() to construct. + private GoogleDefaultEncryptionOptions( + com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GoogleDefaultEncryptionOptions() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.class, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + other = + (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * The configuration options for using Google default encryption.
+       * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.class, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + build() { + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + buildPartial() { + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + result = + new com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) { + return mergeFrom( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + other) { + if (other + == com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + private static final com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions(); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GoogleDefaultEncryptionOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface SourceEncryptionOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + com.google.protobuf.MessageOrBuilder {} + + /** + * + * + *
+     * The configuration options for using the same encryption method as the
+     * source.
+     * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions} + */ + public static final class SourceEncryptionOptions extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + SourceEncryptionOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "SourceEncryptionOptions"); + } + + // Use SourceEncryptionOptions.newBuilder() to construct. + private SourceEncryptionOptions(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private SourceEncryptionOptions() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .class, + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions other = + (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * The configuration options for using the same encryption method as the
+       * source.
+       * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .class, + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + build() { + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + buildPartial() { + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions result = + new com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions( + this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) { + return mergeFrom( + (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions other) { + if (other + == com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + private static final com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptions + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions(); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public SourceEncryptionOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface CustomerManagedEncryptionOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * Required. Only keys in the same location as the database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + java.lang.String getKmsKeyName(); + + /** + * + * + *
+       * Required. Only keys in the same location as the database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + com.google.protobuf.ByteString getKmsKeyNameBytes(); + } + + /** + * + * + *
+     * The configuration options for using CMEK (Customer Managed Encryption
+     * Key) encryption.
+     * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions} + */ + public static final class CustomerManagedEncryptionOptions + extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions) + CustomerManagedEncryptionOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CustomerManagedEncryptionOptions"); + } + + // Use CustomerManagedEncryptionOptions.newBuilder() to construct. + private CustomerManagedEncryptionOptions( + com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CustomerManagedEncryptionOptions() { + kmsKeyName_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.class, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder.class); + } + + public static final int KMS_KEY_NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object kmsKeyName_ = ""; + + /** + * + * + *
+       * Required. Only keys in the same location as the database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + @java.lang.Override + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } + } + + /** + * + * + *
+       * Required. Only keys in the same location as the database are allowed to
+       * be used for encryption.
+       *
+       * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+       * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+       * Cloud KMS multi-region europe. See
+       * https://cloud.google.com/kms/docs/locations.
+       *
+       * The expected format is
+       * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+       * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(kmsKeyName_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, kmsKeyName_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(kmsKeyName_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, kmsKeyName_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + other = + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + obj; + + if (!getKmsKeyName().equals(other.getKmsKeyName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + KMS_KEY_NAME_FIELD_NUMBER; + hash = (53 * hash) + getKmsKeyName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * The configuration options for using CMEK (Customer Managed Encryption
+       * Key) encryption.
+       * 
+ * + * Protobuf type {@code + * google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions) + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.class, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + kmsKeyName_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + build() { + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + buildPartial() { + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + result = + new com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.kmsKeyName_ = kmsKeyName_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) { + return mergeFrom( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + other) { + if (other + == com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance()) return this; + if (!other.getKmsKeyName().isEmpty()) { + kmsKeyName_ = other.kmsKeyName_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + kmsKeyName_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object kmsKeyName_ = ""; + + /** + * + * + *
+         * Required. Only keys in the same location as the database are allowed to
+         * be used for encryption.
+         *
+         * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+         * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+         * Cloud KMS multi-region europe. See
+         * https://cloud.google.com/kms/docs/locations.
+         *
+         * The expected format is
+         * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+         * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kmsKeyName. + */ + public java.lang.String getKmsKeyName() { + java.lang.Object ref = kmsKeyName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kmsKeyName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+         * Required. Only keys in the same location as the database are allowed to
+         * be used for encryption.
+         *
+         * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+         * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+         * Cloud KMS multi-region europe. See
+         * https://cloud.google.com/kms/docs/locations.
+         *
+         * The expected format is
+         * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+         * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kmsKeyName. + */ + public com.google.protobuf.ByteString getKmsKeyNameBytes() { + java.lang.Object ref = kmsKeyName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kmsKeyName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+         * Required. Only keys in the same location as the database are allowed to
+         * be used for encryption.
+         *
+         * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+         * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+         * Cloud KMS multi-region europe. See
+         * https://cloud.google.com/kms/docs/locations.
+         *
+         * The expected format is
+         * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+         * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + kmsKeyName_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * Required. Only keys in the same location as the database are allowed to
+         * be used for encryption.
+         *
+         * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+         * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+         * Cloud KMS multi-region europe. See
+         * https://cloud.google.com/kms/docs/locations.
+         *
+         * The expected format is
+         * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+         * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearKmsKeyName() { + kmsKeyName_ = getDefaultInstance().getKmsKeyName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+         * Required. Only keys in the same location as the database are allowed to
+         * be used for encryption.
+         *
+         * For Firestore's nam5 multi-region, this corresponds to Cloud KMS
+         * multi-region us. For Firestore's eur3 multi-region, this corresponds to
+         * Cloud KMS multi-region europe. See
+         * https://cloud.google.com/kms/docs/locations.
+         *
+         * The expected format is
+         * `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`.
+         * 
+ * + * string kms_key_name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for kmsKeyName to set. + * @return This builder for chaining. + */ + public Builder setKmsKeyNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + kmsKeyName_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions) + private static final com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions(); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CustomerManagedEncryptionOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int encryptionTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object encryptionType_; + + public enum EncryptionTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + GOOGLE_DEFAULT_ENCRYPTION(1), + USE_SOURCE_ENCRYPTION(2), + CUSTOMER_MANAGED_ENCRYPTION(3), + ENCRYPTIONTYPE_NOT_SET(0); + private final int value; + + private EncryptionTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static EncryptionTypeCase valueOf(int value) { + return forNumber(value); + } + + public static EncryptionTypeCase forNumber(int value) { + switch (value) { + case 1: + return GOOGLE_DEFAULT_ENCRYPTION; + case 2: + return USE_SOURCE_ENCRYPTION; + case 3: + return CUSTOMER_MANAGED_ENCRYPTION; + case 0: + return ENCRYPTIONTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public EncryptionTypeCase getEncryptionTypeCase() { + return EncryptionTypeCase.forNumber(encryptionTypeCase_); + } + + public static final int GOOGLE_DEFAULT_ENCRYPTION_FIELD_NUMBER = 1; + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return Whether the googleDefaultEncryption field is set. + */ + @java.lang.Override + public boolean hasGoogleDefaultEncryption() { + return encryptionTypeCase_ == 1; + } + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return The googleDefaultEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + getGoogleDefaultEncryption() { + if (encryptionTypeCase_ == 1) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .getDefaultInstance(); + } + + /** + * + * + *
+     * Use Google default encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder + getGoogleDefaultEncryptionOrBuilder() { + if (encryptionTypeCase_ == 1) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .getDefaultInstance(); + } + + public static final int USE_SOURCE_ENCRYPTION_FIELD_NUMBER = 2; + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return Whether the useSourceEncryption field is set. + */ + @java.lang.Override + public boolean hasUseSourceEncryption() { + return encryptionTypeCase_ == 2; + } + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return The useSourceEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getUseSourceEncryption() { + if (encryptionTypeCase_ == 2) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + + /** + * + * + *
+     * The database will use the same encryption configuration as the source.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptionsOrBuilder + getUseSourceEncryptionOrBuilder() { + if (encryptionTypeCase_ == 2) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + + public static final int CUSTOMER_MANAGED_ENCRYPTION_FIELD_NUMBER = 3; + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return Whether the customerManagedEncryption field is set. + */ + @java.lang.Override + public boolean hasCustomerManagedEncryption() { + return encryptionTypeCase_ == 3; + } + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return The customerManagedEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + getCustomerManagedEncryption() { + if (encryptionTypeCase_ == 3) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + + /** + * + * + *
+     * Use Customer Managed Encryption Keys (CMEK) for encryption.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder + getCustomerManagedEncryptionOrBuilder() { + if (encryptionTypeCase_ == 3) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (encryptionTypeCase_ == 1) { + output.writeMessage( + 1, + (com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions) + encryptionType_); + } + if (encryptionTypeCase_ == 2) { + output.writeMessage( + 2, + (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_); + } + if (encryptionTypeCase_ == 3) { + output.writeMessage( + 3, + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (encryptionTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, + (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_); + } + if (encryptionTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, + (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_); + } + if (encryptionTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Database.EncryptionConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database.EncryptionConfig other = + (com.google.firestore.admin.v1.Database.EncryptionConfig) obj; + + if (!getEncryptionTypeCase().equals(other.getEncryptionTypeCase())) return false; + switch (encryptionTypeCase_) { + case 1: + if (!getGoogleDefaultEncryption().equals(other.getGoogleDefaultEncryption())) + return false; + break; + case 2: + if (!getUseSourceEncryption().equals(other.getUseSourceEncryption())) return false; + break; + case 3: + if (!getCustomerManagedEncryption().equals(other.getCustomerManagedEncryption())) + return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (encryptionTypeCase_) { + case 1: + hash = (37 * hash) + GOOGLE_DEFAULT_ENCRYPTION_FIELD_NUMBER; + hash = (53 * hash) + getGoogleDefaultEncryption().hashCode(); + break; + case 2: + hash = (37 * hash) + USE_SOURCE_ENCRYPTION_FIELD_NUMBER; + hash = (53 * hash) + getUseSourceEncryption().hashCode(); + break; + case 3: + hash = (37 * hash) + CUSTOMER_MANAGED_ENCRYPTION_FIELD_NUMBER; + hash = (53 * hash) + getCustomerManagedEncryption().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Database.EncryptionConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Encryption configuration for a new database being created from another
+     * source.
+     *
+     * The source could be a [Backup][google.firestore.admin.v1.Backup] or a
+     * [PitrSnapshot][google.firestore.admin.v1.PitrSnapshot].
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database.EncryptionConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database.EncryptionConfig) + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.EncryptionConfig.class, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Database.EncryptionConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (googleDefaultEncryptionBuilder_ != null) { + googleDefaultEncryptionBuilder_.clear(); + } + if (useSourceEncryptionBuilder_ != null) { + useSourceEncryptionBuilder_.clear(); + } + if (customerManagedEncryptionBuilder_ != null) { + customerManagedEncryptionBuilder_.clear(); + } + encryptionTypeCase_ = 0; + encryptionType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig build() { + com.google.firestore.admin.v1.Database.EncryptionConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig buildPartial() { + com.google.firestore.admin.v1.Database.EncryptionConfig result = + new com.google.firestore.admin.v1.Database.EncryptionConfig(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Database.EncryptionConfig result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs( + com.google.firestore.admin.v1.Database.EncryptionConfig result) { + result.encryptionTypeCase_ = encryptionTypeCase_; + result.encryptionType_ = this.encryptionType_; + if (encryptionTypeCase_ == 1 && googleDefaultEncryptionBuilder_ != null) { + result.encryptionType_ = googleDefaultEncryptionBuilder_.build(); + } + if (encryptionTypeCase_ == 2 && useSourceEncryptionBuilder_ != null) { + result.encryptionType_ = useSourceEncryptionBuilder_.build(); + } + if (encryptionTypeCase_ == 3 && customerManagedEncryptionBuilder_ != null) { + result.encryptionType_ = customerManagedEncryptionBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Database.EncryptionConfig) { + return mergeFrom((com.google.firestore.admin.v1.Database.EncryptionConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Database.EncryptionConfig other) { + if (other == com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance()) + return this; + switch (other.getEncryptionTypeCase()) { + case GOOGLE_DEFAULT_ENCRYPTION: + { + mergeGoogleDefaultEncryption(other.getGoogleDefaultEncryption()); + break; + } + case USE_SOURCE_ENCRYPTION: + { + mergeUseSourceEncryption(other.getUseSourceEncryption()); + break; + } + case CUSTOMER_MANAGED_ENCRYPTION: + { + mergeCustomerManagedEncryption(other.getCustomerManagedEncryption()); + break; + } + case ENCRYPTIONTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetGoogleDefaultEncryptionFieldBuilder().getBuilder(), + extensionRegistry); + encryptionTypeCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUseSourceEncryptionFieldBuilder().getBuilder(), extensionRegistry); + encryptionTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetCustomerManagedEncryptionFieldBuilder().getBuilder(), + extensionRegistry); + encryptionTypeCase_ = 3; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int encryptionTypeCase_ = 0; + private java.lang.Object encryptionType_; + + public EncryptionTypeCase getEncryptionTypeCase() { + return EncryptionTypeCase.forNumber(encryptionTypeCase_); + } + + public Builder clearEncryptionType() { + encryptionTypeCase_ = 0; + encryptionType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder> + googleDefaultEncryptionBuilder_; + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return Whether the googleDefaultEncryption field is set. + */ + @java.lang.Override + public boolean hasGoogleDefaultEncryption() { + return encryptionTypeCase_ == 1; + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + * + * @return The googleDefaultEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + getGoogleDefaultEncryption() { + if (googleDefaultEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 1) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance(); + } else { + if (encryptionTypeCase_ == 1) { + return googleDefaultEncryptionBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + public Builder setGoogleDefaultEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + value) { + if (googleDefaultEncryptionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionType_ = value; + onChanged(); + } else { + googleDefaultEncryptionBuilder_.setMessage(value); + } + encryptionTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + public Builder setGoogleDefaultEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .Builder + builderForValue) { + if (googleDefaultEncryptionBuilder_ == null) { + encryptionType_ = builderForValue.build(); + onChanged(); + } else { + googleDefaultEncryptionBuilder_.setMessage(builderForValue.build()); + } + encryptionTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + public Builder mergeGoogleDefaultEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + value) { + if (googleDefaultEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 1 + && encryptionType_ + != com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance()) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.newBuilder( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_) + .mergeFrom(value) + .buildPartial(); + } else { + encryptionType_ = value; + } + onChanged(); + } else { + if (encryptionTypeCase_ == 1) { + googleDefaultEncryptionBuilder_.mergeFrom(value); + } else { + googleDefaultEncryptionBuilder_.setMessage(value); + } + } + encryptionTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + public Builder clearGoogleDefaultEncryption() { + if (googleDefaultEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 1) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + onChanged(); + } + } else { + if (encryptionTypeCase_ == 1) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + } + googleDefaultEncryptionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .Builder + getGoogleDefaultEncryptionBuilder() { + return internalGetGoogleDefaultEncryptionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder + getGoogleDefaultEncryptionOrBuilder() { + if ((encryptionTypeCase_ == 1) && (googleDefaultEncryptionBuilder_ != null)) { + return googleDefaultEncryptionBuilder_.getMessageOrBuilder(); + } else { + if (encryptionTypeCase_ == 1) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Use Google default encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions google_default_encryption = 1; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig.GoogleDefaultEncryptionOptions + .Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder> + internalGetGoogleDefaultEncryptionFieldBuilder() { + if (googleDefaultEncryptionBuilder_ == null) { + if (!(encryptionTypeCase_ == 1)) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.getDefaultInstance(); + } + googleDefaultEncryptionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptionsOrBuilder>( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .GoogleDefaultEncryptionOptions) + encryptionType_, + getParentForChildren(), + isClean()); + encryptionType_ = null; + } + encryptionTypeCase_ = 1; + onChanged(); + return googleDefaultEncryptionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptionsOrBuilder> + useSourceEncryptionBuilder_; + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return Whether the useSourceEncryption field is set. + */ + @java.lang.Override + public boolean hasUseSourceEncryption() { + return encryptionTypeCase_ == 2; + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + * + * @return The useSourceEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + getUseSourceEncryption() { + if (useSourceEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 2) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } else { + if (encryptionTypeCase_ == 2) { + return useSourceEncryptionBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + public Builder setUseSourceEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions value) { + if (useSourceEncryptionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionType_ = value; + onChanged(); + } else { + useSourceEncryptionBuilder_.setMessage(value); + } + encryptionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + public Builder setUseSourceEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions.Builder + builderForValue) { + if (useSourceEncryptionBuilder_ == null) { + encryptionType_ = builderForValue.build(); + onChanged(); + } else { + useSourceEncryptionBuilder_.setMessage(builderForValue.build()); + } + encryptionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + public Builder mergeUseSourceEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions value) { + if (useSourceEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 2 + && encryptionType_ + != com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance()) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .newBuilder( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptions) + encryptionType_) + .mergeFrom(value) + .buildPartial(); + } else { + encryptionType_ = value; + } + onChanged(); + } else { + if (encryptionTypeCase_ == 2) { + useSourceEncryptionBuilder_.mergeFrom(value); + } else { + useSourceEncryptionBuilder_.setMessage(value); + } + } + encryptionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + public Builder clearUseSourceEncryption() { + if (useSourceEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 2) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + onChanged(); + } + } else { + if (encryptionTypeCase_ == 2) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + } + useSourceEncryptionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions.Builder + getUseSourceEncryptionBuilder() { + return internalGetUseSourceEncryptionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptionsOrBuilder + getUseSourceEncryptionOrBuilder() { + if ((encryptionTypeCase_ == 2) && (useSourceEncryptionBuilder_ != null)) { + return useSourceEncryptionBuilder_.getMessageOrBuilder(); + } else { + if (encryptionTypeCase_ == 2) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * The database will use the same encryption configuration as the source.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions use_source_encryption = 2; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptionsOrBuilder> + internalGetUseSourceEncryptionFieldBuilder() { + if (useSourceEncryptionBuilder_ == null) { + if (!(encryptionTypeCase_ == 2)) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .getDefaultInstance(); + } + useSourceEncryptionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions + .Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .SourceEncryptionOptionsOrBuilder>( + (com.google.firestore.admin.v1.Database.EncryptionConfig.SourceEncryptionOptions) + encryptionType_, + getParentForChildren(), + isClean()); + encryptionType_ = null; + } + encryptionTypeCase_ = 2; + onChanged(); + return useSourceEncryptionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder> + customerManagedEncryptionBuilder_; + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return Whether the customerManagedEncryption field is set. + */ + @java.lang.Override + public boolean hasCustomerManagedEncryption() { + return encryptionTypeCase_ == 3; + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + * + * @return The customerManagedEncryption. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions + getCustomerManagedEncryption() { + if (customerManagedEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 3) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } else { + if (encryptionTypeCase_ == 3) { + return customerManagedEncryptionBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + public Builder setCustomerManagedEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + value) { + if (customerManagedEncryptionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionType_ = value; + onChanged(); + } else { + customerManagedEncryptionBuilder_.setMessage(value); + } + encryptionTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + public Builder setCustomerManagedEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + .Builder + builderForValue) { + if (customerManagedEncryptionBuilder_ == null) { + encryptionType_ = builderForValue.build(); + onChanged(); + } else { + customerManagedEncryptionBuilder_.setMessage(builderForValue.build()); + } + encryptionTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + public Builder mergeCustomerManagedEncryption( + com.google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions + value) { + if (customerManagedEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 3 + && encryptionType_ + != com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance()) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.newBuilder( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_) + .mergeFrom(value) + .buildPartial(); + } else { + encryptionType_ = value; + } + onChanged(); + } else { + if (encryptionTypeCase_ == 3) { + customerManagedEncryptionBuilder_.mergeFrom(value); + } else { + customerManagedEncryptionBuilder_.setMessage(value); + } + } + encryptionTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + public Builder clearCustomerManagedEncryption() { + if (customerManagedEncryptionBuilder_ == null) { + if (encryptionTypeCase_ == 3) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + onChanged(); + } + } else { + if (encryptionTypeCase_ == 3) { + encryptionTypeCase_ = 0; + encryptionType_ = null; + } + customerManagedEncryptionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder + getCustomerManagedEncryptionBuilder() { + return internalGetCustomerManagedEncryptionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder + getCustomerManagedEncryptionOrBuilder() { + if ((encryptionTypeCase_ == 3) && (customerManagedEncryptionBuilder_ != null)) { + return customerManagedEncryptionBuilder_.getMessageOrBuilder(); + } else { + if (encryptionTypeCase_ == 3) { + return (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_; + } + return com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Use Customer Managed Encryption Keys (CMEK) for encryption.
+       * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig.CustomerManagedEncryptionOptions customer_managed_encryption = 3; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder> + internalGetCustomerManagedEncryptionFieldBuilder() { + if (customerManagedEncryptionBuilder_ == null) { + if (!(encryptionTypeCase_ == 3)) { + encryptionType_ = + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.getDefaultInstance(); + } + customerManagedEncryptionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptionsOrBuilder>( + (com.google.firestore.admin.v1.Database.EncryptionConfig + .CustomerManagedEncryptionOptions) + encryptionType_, + getParentForChildren(), + isClean()); + encryptionType_ = null; + } + encryptionTypeCase_ = 3; + onChanged(); + return customerManagedEncryptionBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database.EncryptionConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database.EncryptionConfig) + private static final com.google.firestore.admin.v1.Database.EncryptionConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Database.EncryptionConfig(); + } + + public static com.google.firestore.admin.v1.Database.EncryptionConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EncryptionConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * The resource name of the Database.
+   * Format: `projects/{project}/databases/{database}`
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource name of the Database.
+   * Format: `projects/{project}/databases/{database}`
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int UID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object uid_ = ""; + + /** + * + * + *
+   * Output only. The system-generated UUID4 for this Database.
+   * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The uid. + */ + @java.lang.Override + public java.lang.String getUid() { + java.lang.Object ref = uid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uid_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The system-generated UUID4 for this Database.
+   * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for uid. + */ + @java.lang.Override + public com.google.protobuf.ByteString getUidBytes() { + java.lang.Object ref = uid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + uid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 5; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 6; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int DELETE_TIME_FIELD_NUMBER = 7; + private com.google.protobuf.Timestamp deleteTime_; + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the deleteTime field is set. + */ + @java.lang.Override + public boolean hasDeleteTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The deleteTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getDeleteTime() { + return deleteTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : deleteTime_; + } + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getDeleteTimeOrBuilder() { + return deleteTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : deleteTime_; + } + + public static final int LOCATION_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object locationId_ = ""; + + /** + * + * + *
+   * The location of the database. Available locations are listed at
+   * https://cloud.google.com/firestore/docs/locations.
+   * 
+ * + * string location_id = 9; + * + * @return The locationId. + */ + @java.lang.Override + public java.lang.String getLocationId() { + java.lang.Object ref = locationId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + locationId_ = s; + return s; + } + } + + /** + * + * + *
+   * The location of the database. Available locations are listed at
+   * https://cloud.google.com/firestore/docs/locations.
+   * 
+ * + * string location_id = 9; + * + * @return The bytes for locationId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getLocationIdBytes() { + java.lang.Object ref = locationId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + locationId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 10; + private int type_ = 0; + + /** + * + * + *
+   * The type of the database.
+   * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+   * information about how to choose.
+   * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The enum numeric value on the wire for type. + */ + @java.lang.Override + public int getTypeValue() { + return type_; + } + + /** + * + * + *
+   * The type of the database.
+   * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+   * information about how to choose.
+   * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The type. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DatabaseType getType() { + com.google.firestore.admin.v1.Database.DatabaseType result = + com.google.firestore.admin.v1.Database.DatabaseType.forNumber(type_); + return result == null + ? com.google.firestore.admin.v1.Database.DatabaseType.UNRECOGNIZED + : result; + } + + public static final int CONCURRENCY_MODE_FIELD_NUMBER = 15; + private int concurrencyMode_ = 0; + + /** + * + * + *
+   * The concurrency control mode to use for this database.
+   *
+   * If unspecified in a CreateDatabase request, this will default based on the
+   * database edition: Optimistic for Enterprise and Pessimistic for all other
+   * databases.
+   * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+   * The concurrency control mode to use for this database.
+   *
+   * If unspecified in a CreateDatabase request, this will default based on the
+   * database edition: Optimistic for Enterprise and Pessimistic for all other
+   * databases.
+   * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.ConcurrencyMode getConcurrencyMode() { + com.google.firestore.admin.v1.Database.ConcurrencyMode result = + com.google.firestore.admin.v1.Database.ConcurrencyMode.forNumber(concurrencyMode_); + return result == null + ? com.google.firestore.admin.v1.Database.ConcurrencyMode.UNRECOGNIZED + : result; + } + + public static final int VERSION_RETENTION_PERIOD_FIELD_NUMBER = 17; + private com.google.protobuf.Duration versionRetentionPeriod_; + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the versionRetentionPeriod field is set. + */ + @java.lang.Override + public boolean hasVersionRetentionPeriod() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The versionRetentionPeriod. + */ + @java.lang.Override + public com.google.protobuf.Duration getVersionRetentionPeriod() { + return versionRetentionPeriod_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : versionRetentionPeriod_; + } + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getVersionRetentionPeriodOrBuilder() { + return versionRetentionPeriod_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : versionRetentionPeriod_; + } + + public static final int EARLIEST_VERSION_TIME_FIELD_NUMBER = 18; + private com.google.protobuf.Timestamp earliestVersionTime_; + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the earliestVersionTime field is set. + */ + @java.lang.Override + public boolean hasEarliestVersionTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The earliestVersionTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEarliestVersionTime() { + return earliestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : earliestVersionTime_; + } + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEarliestVersionTimeOrBuilder() { + return earliestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : earliestVersionTime_; + } + + public static final int POINT_IN_TIME_RECOVERY_ENABLEMENT_FIELD_NUMBER = 21; + private int pointInTimeRecoveryEnablement_ = 0; + + /** + * + * + *
+   * Whether to enable the PITR feature on this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The enum numeric value on the wire for pointInTimeRecoveryEnablement. + */ + @java.lang.Override + public int getPointInTimeRecoveryEnablementValue() { + return pointInTimeRecoveryEnablement_; + } + + /** + * + * + *
+   * Whether to enable the PITR feature on this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The pointInTimeRecoveryEnablement. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement + getPointInTimeRecoveryEnablement() { + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement result = + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement.forNumber( + pointInTimeRecoveryEnablement_); + return result == null + ? com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement.UNRECOGNIZED + : result; + } + + public static final int APP_ENGINE_INTEGRATION_MODE_FIELD_NUMBER = 19; + private int appEngineIntegrationMode_ = 0; + + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + @java.lang.Override + public int getAppEngineIntegrationModeValue() { + return appEngineIntegrationMode_; + } + + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + getAppEngineIntegrationMode() { + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode result = + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.forNumber( + appEngineIntegrationMode_); + return result == null + ? com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.UNRECOGNIZED + : result; + } + + public static final int KEY_PREFIX_FIELD_NUMBER = 20; + + @SuppressWarnings("serial") + private volatile java.lang.Object keyPrefix_ = ""; + + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in
+   * combination with the project ID ("<key prefix>~<project id>") to construct
+   * the application ID that is returned from the Cloud Datastore APIs in Google
+   * App Engine first generation runtimes.
+   *
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + @java.lang.Override + public java.lang.String getKeyPrefix() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in
+   * combination with the project ID ("<key prefix>~<project id>") to construct
+   * the application ID that is returned from the Cloud Datastore APIs in Google
+   * App Engine first generation runtimes.
+   *
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKeyPrefixBytes() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + keyPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DELETE_PROTECTION_STATE_FIELD_NUMBER = 22; + private int deleteProtectionState_ = 0; + + /** + * + * + *
+   * State of delete protection for the database.
+   * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The enum numeric value on the wire for deleteProtectionState. + */ + @java.lang.Override + public int getDeleteProtectionStateValue() { + return deleteProtectionState_; + } + + /** + * + * + *
+   * State of delete protection for the database.
+   * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The deleteProtectionState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DeleteProtectionState getDeleteProtectionState() { + com.google.firestore.admin.v1.Database.DeleteProtectionState result = + com.google.firestore.admin.v1.Database.DeleteProtectionState.forNumber( + deleteProtectionState_); + return result == null + ? com.google.firestore.admin.v1.Database.DeleteProtectionState.UNRECOGNIZED + : result; + } + + public static final int CMEK_CONFIG_FIELD_NUMBER = 23; + private com.google.firestore.admin.v1.Database.CmekConfig cmekConfig_; + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the cmekConfig field is set. + */ + @java.lang.Override + public boolean hasCmekConfig() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The cmekConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfig getCmekConfig() { + return cmekConfig_ == null + ? com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance() + : cmekConfig_; + } + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.CmekConfigOrBuilder getCmekConfigOrBuilder() { + return cmekConfig_ == null + ? com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance() + : cmekConfig_; + } + + public static final int PREVIOUS_ID_FIELD_NUMBER = 25; + + @SuppressWarnings("serial") + private volatile java.lang.Object previousId_ = ""; + + /** + * + * + *
+   * Output only. The database resource's prior database ID. This field is only
+   * populated for deleted databases.
+   * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The previousId. + */ + @java.lang.Override + public java.lang.String getPreviousId() { + java.lang.Object ref = previousId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + previousId_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The database resource's prior database ID. This field is only
+   * populated for deleted databases.
+   * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for previousId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPreviousIdBytes() { + java.lang.Object ref = previousId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + previousId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SOURCE_INFO_FIELD_NUMBER = 26; + private com.google.firestore.admin.v1.Database.SourceInfo sourceInfo_; + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the sourceInfo field is set. + */ + @java.lang.Override + public boolean hasSourceInfo() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The sourceInfo. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfo getSourceInfo() { + return sourceInfo_ == null + ? com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance() + : sourceInfo_; + } + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.SourceInfoOrBuilder getSourceInfoOrBuilder() { + return sourceInfo_ == null + ? com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance() + : sourceInfo_; + } + + public static final int TAGS_FIELD_NUMBER = 29; + + private static final class TagsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_TagsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int FREE_TIER_FIELD_NUMBER = 30; + private boolean freeTier_ = false; + + /** + * + * + *
+   * Output only. Background: Free tier is the ability of a Firestore database
+   * to use a small amount of resources every day without being charged. Once
+   * usage exceeds the free tier limit further usage is charged.
+   *
+   * Whether this database can make use of the free tier. Only one database
+   * per project can be eligible for the free tier.
+   *
+   * The first (or next) database that is created in a project without a free
+   * tier database will be marked as eligible for the free tier. Databases that
+   * are created while there is a free tier database will not be eligible for
+   * the free tier.
+   * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the freeTier field is set. + */ + @java.lang.Override + public boolean hasFreeTier() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+   * Output only. Background: Free tier is the ability of a Firestore database
+   * to use a small amount of resources every day without being charged. Once
+   * usage exceeds the free tier limit further usage is charged.
+   *
+   * Whether this database can make use of the free tier. Only one database
+   * per project can be eligible for the free tier.
+   *
+   * The first (or next) database that is created in a project without a free
+   * tier database will be marked as eligible for the free tier. Databases that
+   * are created while there is a free tier database will not be eligible for
+   * the free tier.
+   * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The freeTier. + */ + @java.lang.Override + public boolean getFreeTier() { + return freeTier_; + } + + public static final int ETAG_FIELD_NUMBER = 99; + + @SuppressWarnings("serial") + private volatile java.lang.Object etag_ = ""; + + /** + * + * + *
+   * This checksum is computed by the server based on the value of other
+   * fields, and may be sent on update and delete requests to ensure the
+   * client has an up-to-date value before proceeding.
+   * 
+ * + * string etag = 99; + * + * @return The etag. + */ + @java.lang.Override + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + etag_ = s; + return s; + } + } + + /** + * + * + *
+   * This checksum is computed by the server based on the value of other
+   * fields, and may be sent on update and delete requests to ensure the
+   * client has an up-to-date value before proceeding.
+   * 
+ * + * string etag = 99; + * + * @return The bytes for etag. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_EDITION_FIELD_NUMBER = 28; + private int databaseEdition_ = 0; + + /** + * + * + *
+   * Immutable. The edition of the database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for databaseEdition. + */ + @java.lang.Override + public int getDatabaseEditionValue() { + return databaseEdition_; + } + + /** + * + * + *
+   * Immutable. The edition of the database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The databaseEdition. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DatabaseEdition getDatabaseEdition() { + com.google.firestore.admin.v1.Database.DatabaseEdition result = + com.google.firestore.admin.v1.Database.DatabaseEdition.forNumber(databaseEdition_); + return result == null + ? com.google.firestore.admin.v1.Database.DatabaseEdition.UNRECOGNIZED + : result; + } + + public static final int REALTIME_UPDATES_MODE_FIELD_NUMBER = 31; + private int realtimeUpdatesMode_ = 0; + + /** + * + * + *
+   * Immutable. The default Realtime Updates mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for realtimeUpdatesMode. + */ + @java.lang.Override + public int getRealtimeUpdatesModeValue() { + return realtimeUpdatesMode_; + } + + /** + * + * + *
+   * Immutable. The default Realtime Updates mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The realtimeUpdatesMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.RealtimeUpdatesMode getRealtimeUpdatesMode() { + com.google.firestore.admin.v1.RealtimeUpdatesMode result = + com.google.firestore.admin.v1.RealtimeUpdatesMode.forNumber(realtimeUpdatesMode_); + return result == null ? com.google.firestore.admin.v1.RealtimeUpdatesMode.UNRECOGNIZED : result; + } + + public static final int FIRESTORE_DATA_ACCESS_MODE_FIELD_NUMBER = 33; + private int firestoreDataAccessMode_ = 0; + + /** + * + * + *
+   * Optional. The Firestore API data access mode to use for this database. If
+   * not set on write:
+   * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+   * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for firestoreDataAccessMode. + */ + @java.lang.Override + public int getFirestoreDataAccessModeValue() { + return firestoreDataAccessMode_; + } + + /** + * + * + *
+   * Optional. The Firestore API data access mode to use for this database. If
+   * not set on write:
+   * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+   * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The firestoreDataAccessMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DataAccessMode getFirestoreDataAccessMode() { + com.google.firestore.admin.v1.Database.DataAccessMode result = + com.google.firestore.admin.v1.Database.DataAccessMode.forNumber(firestoreDataAccessMode_); + return result == null + ? com.google.firestore.admin.v1.Database.DataAccessMode.UNRECOGNIZED + : result; + } + + public static final int MONGODB_COMPATIBLE_DATA_ACCESS_MODE_FIELD_NUMBER = 34; + private int mongodbCompatibleDataAccessMode_ = 0; + + /** + * + * + *
+   * Optional. The MongoDB compatible API data access mode to use for this
+   * database. If not set on write, the default value is
+   * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+   * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for mongodbCompatibleDataAccessMode. + */ + @java.lang.Override + public int getMongodbCompatibleDataAccessModeValue() { + return mongodbCompatibleDataAccessMode_; + } + + /** + * + * + *
+   * Optional. The MongoDB compatible API data access mode to use for this
+   * database. If not set on write, the default value is
+   * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+   * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mongodbCompatibleDataAccessMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DataAccessMode + getMongodbCompatibleDataAccessMode() { + com.google.firestore.admin.v1.Database.DataAccessMode result = + com.google.firestore.admin.v1.Database.DataAccessMode.forNumber( + mongodbCompatibleDataAccessMode_); + return result == null + ? com.google.firestore.admin.v1.Database.DataAccessMode.UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uid_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, uid_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(5, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(6, getUpdateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(7, getDeleteTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(locationId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 9, locationId_); + } + if (type_ + != com.google.firestore.admin.v1.Database.DatabaseType.DATABASE_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(10, type_); + } + if (concurrencyMode_ + != com.google.firestore.admin.v1.Database.ConcurrencyMode.CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(15, concurrencyMode_); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(17, getVersionRetentionPeriod()); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(18, getEarliestVersionTime()); + } + if (appEngineIntegrationMode_ + != com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + .APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(19, appEngineIntegrationMode_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(keyPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 20, keyPrefix_); + } + if (pointInTimeRecoveryEnablement_ + != com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement + .POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED + .getNumber()) { + output.writeEnum(21, pointInTimeRecoveryEnablement_); + } + if (deleteProtectionState_ + != com.google.firestore.admin.v1.Database.DeleteProtectionState + .DELETE_PROTECTION_STATE_UNSPECIFIED + .getNumber()) { + output.writeEnum(22, deleteProtectionState_); + } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(23, getCmekConfig()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(previousId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 25, previousId_); + } + if (((bitField0_ & 0x00000040) != 0)) { + output.writeMessage(26, getSourceInfo()); + } + if (databaseEdition_ + != com.google.firestore.admin.v1.Database.DatabaseEdition.DATABASE_EDITION_UNSPECIFIED + .getNumber()) { + output.writeEnum(28, databaseEdition_); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetTags(), TagsDefaultEntryHolder.defaultEntry, 29); + if (((bitField0_ & 0x00000080) != 0)) { + output.writeBool(30, freeTier_); + } + if (realtimeUpdatesMode_ + != com.google.firestore.admin.v1.RealtimeUpdatesMode.REALTIME_UPDATES_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(31, realtimeUpdatesMode_); + } + if (firestoreDataAccessMode_ + != com.google.firestore.admin.v1.Database.DataAccessMode.DATA_ACCESS_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(33, firestoreDataAccessMode_); + } + if (mongodbCompatibleDataAccessMode_ + != com.google.firestore.admin.v1.Database.DataAccessMode.DATA_ACCESS_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(34, mongodbCompatibleDataAccessMode_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(etag_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 99, etag_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(uid_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, uid_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getUpdateTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getDeleteTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(locationId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(9, locationId_); + } + if (type_ + != com.google.firestore.admin.v1.Database.DatabaseType.DATABASE_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(10, type_); + } + if (concurrencyMode_ + != com.google.firestore.admin.v1.Database.ConcurrencyMode.CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(15, concurrencyMode_); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(17, getVersionRetentionPeriod()); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(18, getEarliestVersionTime()); + } + if (appEngineIntegrationMode_ + != com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + .APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(19, appEngineIntegrationMode_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(keyPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(20, keyPrefix_); + } + if (pointInTimeRecoveryEnablement_ + != com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement + .POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED + .getNumber()) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize(21, pointInTimeRecoveryEnablement_); + } + if (deleteProtectionState_ + != com.google.firestore.admin.v1.Database.DeleteProtectionState + .DELETE_PROTECTION_STATE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(22, deleteProtectionState_); + } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(23, getCmekConfig()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(previousId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(25, previousId_); + } + if (((bitField0_ & 0x00000040) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(26, getSourceInfo()); + } + if (databaseEdition_ + != com.google.firestore.admin.v1.Database.DatabaseEdition.DATABASE_EDITION_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(28, databaseEdition_); + } + for (java.util.Map.Entry entry : + internalGetTags().getMap().entrySet()) { + com.google.protobuf.MapEntry tags__ = + TagsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(29, tags__); + } + if (((bitField0_ & 0x00000080) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(30, freeTier_); + } + if (realtimeUpdatesMode_ + != com.google.firestore.admin.v1.RealtimeUpdatesMode.REALTIME_UPDATES_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(31, realtimeUpdatesMode_); + } + if (firestoreDataAccessMode_ + != com.google.firestore.admin.v1.Database.DataAccessMode.DATA_ACCESS_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(33, firestoreDataAccessMode_); + } + if (mongodbCompatibleDataAccessMode_ + != com.google.firestore.admin.v1.Database.DataAccessMode.DATA_ACCESS_MODE_UNSPECIFIED + .getNumber()) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 34, mongodbCompatibleDataAccessMode_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(etag_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(99, etag_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Database)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Database other = (com.google.firestore.admin.v1.Database) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUid().equals(other.getUid())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (hasDeleteTime() != other.hasDeleteTime()) return false; + if (hasDeleteTime()) { + if (!getDeleteTime().equals(other.getDeleteTime())) return false; + } + if (!getLocationId().equals(other.getLocationId())) return false; + if (type_ != other.type_) return false; + if (concurrencyMode_ != other.concurrencyMode_) return false; + if (hasVersionRetentionPeriod() != other.hasVersionRetentionPeriod()) return false; + if (hasVersionRetentionPeriod()) { + if (!getVersionRetentionPeriod().equals(other.getVersionRetentionPeriod())) return false; + } + if (hasEarliestVersionTime() != other.hasEarliestVersionTime()) return false; + if (hasEarliestVersionTime()) { + if (!getEarliestVersionTime().equals(other.getEarliestVersionTime())) return false; + } + if (pointInTimeRecoveryEnablement_ != other.pointInTimeRecoveryEnablement_) return false; + if (appEngineIntegrationMode_ != other.appEngineIntegrationMode_) return false; + if (!getKeyPrefix().equals(other.getKeyPrefix())) return false; + if (deleteProtectionState_ != other.deleteProtectionState_) return false; + if (hasCmekConfig() != other.hasCmekConfig()) return false; + if (hasCmekConfig()) { + if (!getCmekConfig().equals(other.getCmekConfig())) return false; + } + if (!getPreviousId().equals(other.getPreviousId())) return false; + if (hasSourceInfo() != other.hasSourceInfo()) return false; + if (hasSourceInfo()) { + if (!getSourceInfo().equals(other.getSourceInfo())) return false; + } + if (!internalGetTags().equals(other.internalGetTags())) return false; + if (hasFreeTier() != other.hasFreeTier()) return false; + if (hasFreeTier()) { + if (getFreeTier() != other.getFreeTier()) return false; + } + if (!getEtag().equals(other.getEtag())) return false; + if (databaseEdition_ != other.databaseEdition_) return false; + if (realtimeUpdatesMode_ != other.realtimeUpdatesMode_) return false; + if (firestoreDataAccessMode_ != other.firestoreDataAccessMode_) return false; + if (mongodbCompatibleDataAccessMode_ != other.mongodbCompatibleDataAccessMode_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + UID_FIELD_NUMBER; + hash = (53 * hash) + getUid().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + if (hasDeleteTime()) { + hash = (37 * hash) + DELETE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getDeleteTime().hashCode(); + } + hash = (37 * hash) + LOCATION_ID_FIELD_NUMBER; + hash = (53 * hash) + getLocationId().hashCode(); + hash = (37 * hash) + TYPE_FIELD_NUMBER; + hash = (53 * hash) + type_; + hash = (37 * hash) + CONCURRENCY_MODE_FIELD_NUMBER; + hash = (53 * hash) + concurrencyMode_; + if (hasVersionRetentionPeriod()) { + hash = (37 * hash) + VERSION_RETENTION_PERIOD_FIELD_NUMBER; + hash = (53 * hash) + getVersionRetentionPeriod().hashCode(); + } + if (hasEarliestVersionTime()) { + hash = (37 * hash) + EARLIEST_VERSION_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEarliestVersionTime().hashCode(); + } + hash = (37 * hash) + POINT_IN_TIME_RECOVERY_ENABLEMENT_FIELD_NUMBER; + hash = (53 * hash) + pointInTimeRecoveryEnablement_; + hash = (37 * hash) + APP_ENGINE_INTEGRATION_MODE_FIELD_NUMBER; + hash = (53 * hash) + appEngineIntegrationMode_; + hash = (37 * hash) + KEY_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getKeyPrefix().hashCode(); + hash = (37 * hash) + DELETE_PROTECTION_STATE_FIELD_NUMBER; + hash = (53 * hash) + deleteProtectionState_; + if (hasCmekConfig()) { + hash = (37 * hash) + CMEK_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getCmekConfig().hashCode(); + } + hash = (37 * hash) + PREVIOUS_ID_FIELD_NUMBER; + hash = (53 * hash) + getPreviousId().hashCode(); + if (hasSourceInfo()) { + hash = (37 * hash) + SOURCE_INFO_FIELD_NUMBER; + hash = (53 * hash) + getSourceInfo().hashCode(); + } + if (!internalGetTags().getMap().isEmpty()) { + hash = (37 * hash) + TAGS_FIELD_NUMBER; + hash = (53 * hash) + internalGetTags().hashCode(); + } + if (hasFreeTier()) { + hash = (37 * hash) + FREE_TIER_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getFreeTier()); + } + hash = (37 * hash) + ETAG_FIELD_NUMBER; + hash = (53 * hash) + getEtag().hashCode(); + hash = (37 * hash) + DATABASE_EDITION_FIELD_NUMBER; + hash = (53 * hash) + databaseEdition_; + hash = (37 * hash) + REALTIME_UPDATES_MODE_FIELD_NUMBER; + hash = (53 * hash) + realtimeUpdatesMode_; + hash = (37 * hash) + FIRESTORE_DATA_ACCESS_MODE_FIELD_NUMBER; + hash = (53 * hash) + firestoreDataAccessMode_; + hash = (37 * hash) + MONGODB_COMPATIBLE_DATA_ACCESS_MODE_FIELD_NUMBER; + hash = (53 * hash) + mongodbCompatibleDataAccessMode_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Database parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Database parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Database prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Cloud Firestore Database.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Database} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Database) + com.google.firestore.admin.v1.DatabaseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 29: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 29: + return internalGetMutableTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Database.class, + com.google.firestore.admin.v1.Database.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Database.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCreateTimeFieldBuilder(); + internalGetUpdateTimeFieldBuilder(); + internalGetDeleteTimeFieldBuilder(); + internalGetVersionRetentionPeriodFieldBuilder(); + internalGetEarliestVersionTimeFieldBuilder(); + internalGetCmekConfigFieldBuilder(); + internalGetSourceInfoFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + uid_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + deleteTime_ = null; + if (deleteTimeBuilder_ != null) { + deleteTimeBuilder_.dispose(); + deleteTimeBuilder_ = null; + } + locationId_ = ""; + type_ = 0; + concurrencyMode_ = 0; + versionRetentionPeriod_ = null; + if (versionRetentionPeriodBuilder_ != null) { + versionRetentionPeriodBuilder_.dispose(); + versionRetentionPeriodBuilder_ = null; + } + earliestVersionTime_ = null; + if (earliestVersionTimeBuilder_ != null) { + earliestVersionTimeBuilder_.dispose(); + earliestVersionTimeBuilder_ = null; + } + pointInTimeRecoveryEnablement_ = 0; + appEngineIntegrationMode_ = 0; + keyPrefix_ = ""; + deleteProtectionState_ = 0; + cmekConfig_ = null; + if (cmekConfigBuilder_ != null) { + cmekConfigBuilder_.dispose(); + cmekConfigBuilder_ = null; + } + previousId_ = ""; + sourceInfo_ = null; + if (sourceInfoBuilder_ != null) { + sourceInfoBuilder_.dispose(); + sourceInfoBuilder_ = null; + } + internalGetMutableTags().clear(); + freeTier_ = false; + etag_ = ""; + databaseEdition_ = 0; + realtimeUpdatesMode_ = 0; + firestoreDataAccessMode_ = 0; + mongodbCompatibleDataAccessMode_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.DatabaseProto + .internal_static_google_firestore_admin_v1_Database_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Database.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database build() { + com.google.firestore.admin.v1.Database result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database buildPartial() { + com.google.firestore.admin.v1.Database result = + new com.google.firestore.admin.v1.Database(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Database result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.uid_ = uid_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.deleteTime_ = deleteTimeBuilder_ == null ? deleteTime_ : deleteTimeBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.locationId_ = locationId_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.type_ = type_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.concurrencyMode_ = concurrencyMode_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.versionRetentionPeriod_ = + versionRetentionPeriodBuilder_ == null + ? versionRetentionPeriod_ + : versionRetentionPeriodBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.earliestVersionTime_ = + earliestVersionTimeBuilder_ == null + ? earliestVersionTime_ + : earliestVersionTimeBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + if (((from_bitField0_ & 0x00000400) != 0)) { + result.pointInTimeRecoveryEnablement_ = pointInTimeRecoveryEnablement_; + } + if (((from_bitField0_ & 0x00000800) != 0)) { + result.appEngineIntegrationMode_ = appEngineIntegrationMode_; + } + if (((from_bitField0_ & 0x00001000) != 0)) { + result.keyPrefix_ = keyPrefix_; + } + if (((from_bitField0_ & 0x00002000) != 0)) { + result.deleteProtectionState_ = deleteProtectionState_; + } + if (((from_bitField0_ & 0x00004000) != 0)) { + result.cmekConfig_ = cmekConfigBuilder_ == null ? cmekConfig_ : cmekConfigBuilder_.build(); + to_bitField0_ |= 0x00000020; + } + if (((from_bitField0_ & 0x00008000) != 0)) { + result.previousId_ = previousId_; + } + if (((from_bitField0_ & 0x00010000) != 0)) { + result.sourceInfo_ = sourceInfoBuilder_ == null ? sourceInfo_ : sourceInfoBuilder_.build(); + to_bitField0_ |= 0x00000040; + } + if (((from_bitField0_ & 0x00020000) != 0)) { + result.tags_ = internalGetTags(); + result.tags_.makeImmutable(); + } + if (((from_bitField0_ & 0x00040000) != 0)) { + result.freeTier_ = freeTier_; + to_bitField0_ |= 0x00000080; + } + if (((from_bitField0_ & 0x00080000) != 0)) { + result.etag_ = etag_; + } + if (((from_bitField0_ & 0x00100000) != 0)) { + result.databaseEdition_ = databaseEdition_; + } + if (((from_bitField0_ & 0x00200000) != 0)) { + result.realtimeUpdatesMode_ = realtimeUpdatesMode_; + } + if (((from_bitField0_ & 0x00400000) != 0)) { + result.firestoreDataAccessMode_ = firestoreDataAccessMode_; + } + if (((from_bitField0_ & 0x00800000) != 0)) { + result.mongodbCompatibleDataAccessMode_ = mongodbCompatibleDataAccessMode_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Database) { + return mergeFrom((com.google.firestore.admin.v1.Database) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Database other) { + if (other == com.google.firestore.admin.v1.Database.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getUid().isEmpty()) { + uid_ = other.uid_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.hasDeleteTime()) { + mergeDeleteTime(other.getDeleteTime()); + } + if (!other.getLocationId().isEmpty()) { + locationId_ = other.locationId_; + bitField0_ |= 0x00000020; + onChanged(); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + if (other.concurrencyMode_ != 0) { + setConcurrencyModeValue(other.getConcurrencyModeValue()); + } + if (other.hasVersionRetentionPeriod()) { + mergeVersionRetentionPeriod(other.getVersionRetentionPeriod()); + } + if (other.hasEarliestVersionTime()) { + mergeEarliestVersionTime(other.getEarliestVersionTime()); + } + if (other.pointInTimeRecoveryEnablement_ != 0) { + setPointInTimeRecoveryEnablementValue(other.getPointInTimeRecoveryEnablementValue()); + } + if (other.appEngineIntegrationMode_ != 0) { + setAppEngineIntegrationModeValue(other.getAppEngineIntegrationModeValue()); + } + if (!other.getKeyPrefix().isEmpty()) { + keyPrefix_ = other.keyPrefix_; + bitField0_ |= 0x00001000; + onChanged(); + } + if (other.deleteProtectionState_ != 0) { + setDeleteProtectionStateValue(other.getDeleteProtectionStateValue()); + } + if (other.hasCmekConfig()) { + mergeCmekConfig(other.getCmekConfig()); + } + if (!other.getPreviousId().isEmpty()) { + previousId_ = other.previousId_; + bitField0_ |= 0x00008000; + onChanged(); + } + if (other.hasSourceInfo()) { + mergeSourceInfo(other.getSourceInfo()); + } + internalGetMutableTags().mergeFrom(other.internalGetTags()); + bitField0_ |= 0x00020000; + if (other.hasFreeTier()) { + setFreeTier(other.getFreeTier()); + } + if (!other.getEtag().isEmpty()) { + etag_ = other.etag_; + bitField0_ |= 0x00080000; + onChanged(); + } + if (other.databaseEdition_ != 0) { + setDatabaseEditionValue(other.getDatabaseEditionValue()); + } + if (other.realtimeUpdatesMode_ != 0) { + setRealtimeUpdatesModeValue(other.getRealtimeUpdatesModeValue()); + } + if (other.firestoreDataAccessMode_ != 0) { + setFirestoreDataAccessModeValue(other.getFirestoreDataAccessModeValue()); + } + if (other.mongodbCompatibleDataAccessMode_ != 0) { + setMongodbCompatibleDataAccessModeValue(other.getMongodbCompatibleDataAccessModeValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + uid_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 42: + { + input.readMessage( + internalGetCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetDeleteTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 58 + case 74: + { + locationId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000020; + break; + } // case 74 + case 80: + { + type_ = input.readEnum(); + bitField0_ |= 0x00000040; + break; + } // case 80 + case 120: + { + concurrencyMode_ = input.readEnum(); + bitField0_ |= 0x00000080; + break; + } // case 120 + case 138: + { + input.readMessage( + internalGetVersionRetentionPeriodFieldBuilder().getBuilder(), + extensionRegistry); + bitField0_ |= 0x00000100; + break; + } // case 138 + case 146: + { + input.readMessage( + internalGetEarliestVersionTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000200; + break; + } // case 146 + case 152: + { + appEngineIntegrationMode_ = input.readEnum(); + bitField0_ |= 0x00000800; + break; + } // case 152 + case 162: + { + keyPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00001000; + break; + } // case 162 + case 168: + { + pointInTimeRecoveryEnablement_ = input.readEnum(); + bitField0_ |= 0x00000400; + break; + } // case 168 + case 176: + { + deleteProtectionState_ = input.readEnum(); + bitField0_ |= 0x00002000; + break; + } // case 176 + case 186: + { + input.readMessage( + internalGetCmekConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00004000; + break; + } // case 186 + case 202: + { + previousId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00008000; + break; + } // case 202 + case 210: + { + input.readMessage( + internalGetSourceInfoFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00010000; + break; + } // case 210 + case 224: + { + databaseEdition_ = input.readEnum(); + bitField0_ |= 0x00100000; + break; + } // case 224 + case 234: + { + com.google.protobuf.MapEntry tags__ = + input.readMessage( + TagsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableTags().getMutableMap().put(tags__.getKey(), tags__.getValue()); + bitField0_ |= 0x00020000; + break; + } // case 234 + case 240: + { + freeTier_ = input.readBool(); + bitField0_ |= 0x00040000; + break; + } // case 240 + case 248: + { + realtimeUpdatesMode_ = input.readEnum(); + bitField0_ |= 0x00200000; + break; + } // case 248 + case 264: + { + firestoreDataAccessMode_ = input.readEnum(); + bitField0_ |= 0x00400000; + break; + } // case 264 + case 272: + { + mongodbCompatibleDataAccessMode_ = input.readEnum(); + bitField0_ |= 0x00800000; + break; + } // case 272 + case 794: + { + etag_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00080000; + break; + } // case 794 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * The resource name of the Database.
+     * Format: `projects/{project}/databases/{database}`
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource name of the Database.
+     * Format: `projects/{project}/databases/{database}`
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource name of the Database.
+     * Format: `projects/{project}/databases/{database}`
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the Database.
+     * Format: `projects/{project}/databases/{database}`
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the Database.
+     * Format: `projects/{project}/databases/{database}`
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object uid_ = ""; + + /** + * + * + *
+     * Output only. The system-generated UUID4 for this Database.
+     * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The uid. + */ + public java.lang.String getUid() { + java.lang.Object ref = uid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + uid_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for this Database.
+     * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for uid. + */ + public com.google.protobuf.ByteString getUidBytes() { + java.lang.Object ref = uid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + uid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for this Database.
+     * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The uid to set. + * @return This builder for chaining. + */ + public Builder setUid(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + uid_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for this Database.
+     * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearUid() { + uid_ = getDefaultInstance().getUid(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The system-generated UUID4 for this Database.
+     * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for uid to set. + * @return This builder for chaining. + */ + public Builder setUidBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + uid_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was created. Databases
+     * created before 2016 do not populate create_time.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000008); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was most recently
+     * updated. Note this only includes updates to the database resource and not
+     * data contained by the database.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private com.google.protobuf.Timestamp deleteTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + deleteTimeBuilder_; + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the deleteTime field is set. + */ + public boolean hasDeleteTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The deleteTime. + */ + public com.google.protobuf.Timestamp getDeleteTime() { + if (deleteTimeBuilder_ == null) { + return deleteTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : deleteTime_; + } else { + return deleteTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setDeleteTime(com.google.protobuf.Timestamp value) { + if (deleteTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + deleteTime_ = value; + } else { + deleteTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setDeleteTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (deleteTimeBuilder_ == null) { + deleteTime_ = builderForValue.build(); + } else { + deleteTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeDeleteTime(com.google.protobuf.Timestamp value) { + if (deleteTimeBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && deleteTime_ != null + && deleteTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getDeleteTimeBuilder().mergeFrom(value); + } else { + deleteTime_ = value; + } + } else { + deleteTimeBuilder_.mergeFrom(value); + } + if (deleteTime_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearDeleteTime() { + bitField0_ = (bitField0_ & ~0x00000010); + deleteTime_ = null; + if (deleteTimeBuilder_ != null) { + deleteTimeBuilder_.dispose(); + deleteTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getDeleteTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetDeleteTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getDeleteTimeOrBuilder() { + if (deleteTimeBuilder_ != null) { + return deleteTimeBuilder_.getMessageOrBuilder(); + } else { + return deleteTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : deleteTime_; + } + } + + /** + * + * + *
+     * Output only. The timestamp at which this database was deleted. Only set if
+     * the database has been deleted.
+     * 
+ * + * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetDeleteTimeFieldBuilder() { + if (deleteTimeBuilder_ == null) { + deleteTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getDeleteTime(), getParentForChildren(), isClean()); + deleteTime_ = null; + } + return deleteTimeBuilder_; + } + + private java.lang.Object locationId_ = ""; + + /** + * + * + *
+     * The location of the database. Available locations are listed at
+     * https://cloud.google.com/firestore/docs/locations.
+     * 
+ * + * string location_id = 9; + * + * @return The locationId. + */ + public java.lang.String getLocationId() { + java.lang.Object ref = locationId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + locationId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The location of the database. Available locations are listed at
+     * https://cloud.google.com/firestore/docs/locations.
+     * 
+ * + * string location_id = 9; + * + * @return The bytes for locationId. + */ + public com.google.protobuf.ByteString getLocationIdBytes() { + java.lang.Object ref = locationId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + locationId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The location of the database. Available locations are listed at
+     * https://cloud.google.com/firestore/docs/locations.
+     * 
+ * + * string location_id = 9; + * + * @param value The locationId to set. + * @return This builder for chaining. + */ + public Builder setLocationId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + locationId_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the database. Available locations are listed at
+     * https://cloud.google.com/firestore/docs/locations.
+     * 
+ * + * string location_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearLocationId() { + locationId_ = getDefaultInstance().getLocationId(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the database. Available locations are listed at
+     * https://cloud.google.com/firestore/docs/locations.
+     * 
+ * + * string location_id = 9; + * + * @param value The bytes for locationId to set. + * @return This builder for chaining. + */ + public Builder setLocationIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + locationId_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private int type_ = 0; + + /** + * + * + *
+     * The type of the database.
+     * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+     * information about how to choose.
+     * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The enum numeric value on the wire for type. + */ + @java.lang.Override + public int getTypeValue() { + return type_; + } + + /** + * + * + *
+     * The type of the database.
+     * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+     * information about how to choose.
+     * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @param value The enum numeric value on the wire for type to set. + * @return This builder for chaining. + */ + public Builder setTypeValue(int value) { + type_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of the database.
+     * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+     * information about how to choose.
+     * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The type. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DatabaseType getType() { + com.google.firestore.admin.v1.Database.DatabaseType result = + com.google.firestore.admin.v1.Database.DatabaseType.forNumber(type_); + return result == null + ? com.google.firestore.admin.v1.Database.DatabaseType.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The type of the database.
+     * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+     * information about how to choose.
+     * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @param value The type to set. + * @return This builder for chaining. + */ + public Builder setType(com.google.firestore.admin.v1.Database.DatabaseType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + type_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of the database.
+     * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+     * information about how to choose.
+     * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return This builder for chaining. + */ + public Builder clearType() { + bitField0_ = (bitField0_ & ~0x00000040); + type_ = 0; + onChanged(); + return this; + } + + private int concurrencyMode_ = 0; + + /** + * + * + *
+     * The concurrency control mode to use for this database.
+     *
+     * If unspecified in a CreateDatabase request, this will default based on the
+     * database edition: Optimistic for Enterprise and Pessimistic for all other
+     * databases.
+     * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+     * The concurrency control mode to use for this database.
+     *
+     * If unspecified in a CreateDatabase request, this will default based on the
+     * database edition: Optimistic for Enterprise and Pessimistic for all other
+     * databases.
+     * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @param value The enum numeric value on the wire for concurrencyMode to set. + * @return This builder for chaining. + */ + public Builder setConcurrencyModeValue(int value) { + concurrencyMode_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The concurrency control mode to use for this database.
+     *
+     * If unspecified in a CreateDatabase request, this will default based on the
+     * database edition: Optimistic for Enterprise and Pessimistic for all other
+     * databases.
+     * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.ConcurrencyMode getConcurrencyMode() { + com.google.firestore.admin.v1.Database.ConcurrencyMode result = + com.google.firestore.admin.v1.Database.ConcurrencyMode.forNumber(concurrencyMode_); + return result == null + ? com.google.firestore.admin.v1.Database.ConcurrencyMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The concurrency control mode to use for this database.
+     *
+     * If unspecified in a CreateDatabase request, this will default based on the
+     * database edition: Optimistic for Enterprise and Pessimistic for all other
+     * databases.
+     * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @param value The concurrencyMode to set. + * @return This builder for chaining. + */ + public Builder setConcurrencyMode( + com.google.firestore.admin.v1.Database.ConcurrencyMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000080; + concurrencyMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The concurrency control mode to use for this database.
+     *
+     * If unspecified in a CreateDatabase request, this will default based on the
+     * database edition: Optimistic for Enterprise and Pessimistic for all other
+     * databases.
+     * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return This builder for chaining. + */ + public Builder clearConcurrencyMode() { + bitField0_ = (bitField0_ & ~0x00000080); + concurrencyMode_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Duration versionRetentionPeriod_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + versionRetentionPeriodBuilder_; + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the versionRetentionPeriod field is set. + */ + public boolean hasVersionRetentionPeriod() { + return ((bitField0_ & 0x00000100) != 0); + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The versionRetentionPeriod. + */ + public com.google.protobuf.Duration getVersionRetentionPeriod() { + if (versionRetentionPeriodBuilder_ == null) { + return versionRetentionPeriod_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : versionRetentionPeriod_; + } else { + return versionRetentionPeriodBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setVersionRetentionPeriod(com.google.protobuf.Duration value) { + if (versionRetentionPeriodBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + versionRetentionPeriod_ = value; + } else { + versionRetentionPeriodBuilder_.setMessage(value); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setVersionRetentionPeriod(com.google.protobuf.Duration.Builder builderForValue) { + if (versionRetentionPeriodBuilder_ == null) { + versionRetentionPeriod_ = builderForValue.build(); + } else { + versionRetentionPeriodBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeVersionRetentionPeriod(com.google.protobuf.Duration value) { + if (versionRetentionPeriodBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0) + && versionRetentionPeriod_ != null + && versionRetentionPeriod_ != com.google.protobuf.Duration.getDefaultInstance()) { + getVersionRetentionPeriodBuilder().mergeFrom(value); + } else { + versionRetentionPeriod_ = value; + } + } else { + versionRetentionPeriodBuilder_.mergeFrom(value); + } + if (versionRetentionPeriod_ != null) { + bitField0_ |= 0x00000100; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearVersionRetentionPeriod() { + bitField0_ = (bitField0_ & ~0x00000100); + versionRetentionPeriod_ = null; + if (versionRetentionPeriodBuilder_ != null) { + versionRetentionPeriodBuilder_.dispose(); + versionRetentionPeriodBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Duration.Builder getVersionRetentionPeriodBuilder() { + bitField0_ |= 0x00000100; + onChanged(); + return internalGetVersionRetentionPeriodFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.DurationOrBuilder getVersionRetentionPeriodOrBuilder() { + if (versionRetentionPeriodBuilder_ != null) { + return versionRetentionPeriodBuilder_.getMessageOrBuilder(); + } else { + return versionRetentionPeriod_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : versionRetentionPeriod_; + } + } + + /** + * + * + *
+     * Output only. The period during which past versions of data are retained in
+     * the database.
+     *
+     * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+     * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+     * a `read_time` within this window, and will read the state of the database
+     * at that time.
+     *
+     * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+     * the retention period is 1 hour.
+     * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + internalGetVersionRetentionPeriodFieldBuilder() { + if (versionRetentionPeriodBuilder_ == null) { + versionRetentionPeriodBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getVersionRetentionPeriod(), getParentForChildren(), isClean()); + versionRetentionPeriod_ = null; + } + return versionRetentionPeriodBuilder_; + } + + private com.google.protobuf.Timestamp earliestVersionTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + earliestVersionTimeBuilder_; + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the earliestVersionTime field is set. + */ + public boolean hasEarliestVersionTime() { + return ((bitField0_ & 0x00000200) != 0); + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The earliestVersionTime. + */ + public com.google.protobuf.Timestamp getEarliestVersionTime() { + if (earliestVersionTimeBuilder_ == null) { + return earliestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : earliestVersionTime_; + } else { + return earliestVersionTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setEarliestVersionTime(com.google.protobuf.Timestamp value) { + if (earliestVersionTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + earliestVersionTime_ = value; + } else { + earliestVersionTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setEarliestVersionTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (earliestVersionTimeBuilder_ == null) { + earliestVersionTime_ = builderForValue.build(); + } else { + earliestVersionTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000200; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeEarliestVersionTime(com.google.protobuf.Timestamp value) { + if (earliestVersionTimeBuilder_ == null) { + if (((bitField0_ & 0x00000200) != 0) + && earliestVersionTime_ != null + && earliestVersionTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEarliestVersionTimeBuilder().mergeFrom(value); + } else { + earliestVersionTime_ = value; + } + } else { + earliestVersionTimeBuilder_.mergeFrom(value); + } + if (earliestVersionTime_ != null) { + bitField0_ |= 0x00000200; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearEarliestVersionTime() { + bitField0_ = (bitField0_ & ~0x00000200); + earliestVersionTime_ = null; + if (earliestVersionTimeBuilder_ != null) { + earliestVersionTimeBuilder_.dispose(); + earliestVersionTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getEarliestVersionTimeBuilder() { + bitField0_ |= 0x00000200; + onChanged(); + return internalGetEarliestVersionTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getEarliestVersionTimeOrBuilder() { + if (earliestVersionTimeBuilder_ != null) { + return earliestVersionTimeBuilder_.getMessageOrBuilder(); + } else { + return earliestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : earliestVersionTime_; + } + } + + /** + * + * + *
+     * Output only. The earliest timestamp at which older versions of the data can
+     * be read from the database. See [version_retention_period] above; this field
+     * is populated with `now - version_retention_period`.
+     *
+     * This value is continuously updated, and becomes stale the moment it is
+     * queried. If you are using this value to recover data, make sure to account
+     * for the time from the moment when the value is queried to the moment when
+     * you initiate the recovery.
+     * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEarliestVersionTimeFieldBuilder() { + if (earliestVersionTimeBuilder_ == null) { + earliestVersionTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEarliestVersionTime(), getParentForChildren(), isClean()); + earliestVersionTime_ = null; + } + return earliestVersionTimeBuilder_; + } + + private int pointInTimeRecoveryEnablement_ = 0; + + /** + * + * + *
+     * Whether to enable the PITR feature on this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The enum numeric value on the wire for pointInTimeRecoveryEnablement. + */ + @java.lang.Override + public int getPointInTimeRecoveryEnablementValue() { + return pointInTimeRecoveryEnablement_; + } + + /** + * + * + *
+     * Whether to enable the PITR feature on this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @param value The enum numeric value on the wire for pointInTimeRecoveryEnablement to set. + * @return This builder for chaining. + */ + public Builder setPointInTimeRecoveryEnablementValue(int value) { + pointInTimeRecoveryEnablement_ = value; + bitField0_ |= 0x00000400; + onChanged(); + return this; + } + + /** + * + * + *
+     * Whether to enable the PITR feature on this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The pointInTimeRecoveryEnablement. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement + getPointInTimeRecoveryEnablement() { + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement result = + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement.forNumber( + pointInTimeRecoveryEnablement_); + return result == null + ? com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Whether to enable the PITR feature on this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @param value The pointInTimeRecoveryEnablement to set. + * @return This builder for chaining. + */ + public Builder setPointInTimeRecoveryEnablement( + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000400; + pointInTimeRecoveryEnablement_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Whether to enable the PITR feature on this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return This builder for chaining. + */ + public Builder clearPointInTimeRecoveryEnablement() { + bitField0_ = (bitField0_ & ~0x00000400); + pointInTimeRecoveryEnablement_ = 0; + onChanged(); + return this; + } + + private int appEngineIntegrationMode_ = 0; + + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + @java.lang.Override + public int getAppEngineIntegrationModeValue() { + return appEngineIntegrationMode_; + } + + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @param value The enum numeric value on the wire for appEngineIntegrationMode to set. + * @return This builder for chaining. + */ + public Builder setAppEngineIntegrationModeValue(int value) { + appEngineIntegrationMode_ = value; + bitField0_ |= 0x00000800; + onChanged(); + return this; + } + + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.AppEngineIntegrationMode + getAppEngineIntegrationMode() { + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode result = + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.forNumber( + appEngineIntegrationMode_); + return result == null + ? com.google.firestore.admin.v1.Database.AppEngineIntegrationMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @param value The appEngineIntegrationMode to set. + * @return This builder for chaining. + */ + public Builder setAppEngineIntegrationMode( + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000800; + appEngineIntegrationMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The App Engine integration mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return This builder for chaining. + */ + public Builder clearAppEngineIntegrationMode() { + bitField0_ = (bitField0_ & ~0x00000800); + appEngineIntegrationMode_ = 0; + onChanged(); + return this; + } + + private java.lang.Object keyPrefix_ = ""; + + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in
+     * combination with the project ID ("<key prefix>~<project id>") to construct
+     * the application ID that is returned from the Cloud Datastore APIs in Google
+     * App Engine first generation runtimes.
+     *
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + public java.lang.String getKeyPrefix() { + java.lang.Object ref = keyPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + keyPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in
+     * combination with the project ID ("<key prefix>~<project id>") to construct
+     * the application ID that is returned from the Cloud Datastore APIs in Google
+     * App Engine first generation runtimes.
+     *
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + public com.google.protobuf.ByteString getKeyPrefixBytes() { + java.lang.Object ref = keyPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + keyPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in
+     * combination with the project ID ("<key prefix>~<project id>") to construct
+     * the application ID that is returned from the Cloud Datastore APIs in Google
+     * App Engine first generation runtimes.
+     *
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The keyPrefix to set. + * @return This builder for chaining. + */ + public Builder setKeyPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + keyPrefix_ = value; + bitField0_ |= 0x00001000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in
+     * combination with the project ID ("<key prefix>~<project id>") to construct
+     * the application ID that is returned from the Cloud Datastore APIs in Google
+     * App Engine first generation runtimes.
+     *
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearKeyPrefix() { + keyPrefix_ = getDefaultInstance().getKeyPrefix(); + bitField0_ = (bitField0_ & ~0x00001000); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The key_prefix for this database. This key_prefix is used, in
+     * combination with the project ID ("<key prefix>~<project id>") to construct
+     * the application ID that is returned from the Cloud Datastore APIs in Google
+     * App Engine first generation runtimes.
+     *
+     * This value may be empty in which case the appid to use for URL-encoded keys
+     * is the project_id (eg: foo instead of v~foo).
+     * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for keyPrefix to set. + * @return This builder for chaining. + */ + public Builder setKeyPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + keyPrefix_ = value; + bitField0_ |= 0x00001000; + onChanged(); + return this; + } + + private int deleteProtectionState_ = 0; + + /** + * + * + *
+     * State of delete protection for the database.
+     * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The enum numeric value on the wire for deleteProtectionState. + */ + @java.lang.Override + public int getDeleteProtectionStateValue() { + return deleteProtectionState_; + } + + /** + * + * + *
+     * State of delete protection for the database.
+     * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @param value The enum numeric value on the wire for deleteProtectionState to set. + * @return This builder for chaining. + */ + public Builder setDeleteProtectionStateValue(int value) { + deleteProtectionState_ = value; + bitField0_ |= 0x00002000; + onChanged(); + return this; + } + + /** + * + * + *
+     * State of delete protection for the database.
+     * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The deleteProtectionState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DeleteProtectionState getDeleteProtectionState() { + com.google.firestore.admin.v1.Database.DeleteProtectionState result = + com.google.firestore.admin.v1.Database.DeleteProtectionState.forNumber( + deleteProtectionState_); + return result == null + ? com.google.firestore.admin.v1.Database.DeleteProtectionState.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * State of delete protection for the database.
+     * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @param value The deleteProtectionState to set. + * @return This builder for chaining. + */ + public Builder setDeleteProtectionState( + com.google.firestore.admin.v1.Database.DeleteProtectionState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00002000; + deleteProtectionState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * State of delete protection for the database.
+     * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return This builder for chaining. + */ + public Builder clearDeleteProtectionState() { + bitField0_ = (bitField0_ & ~0x00002000); + deleteProtectionState_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Database.CmekConfig cmekConfig_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.CmekConfig, + com.google.firestore.admin.v1.Database.CmekConfig.Builder, + com.google.firestore.admin.v1.Database.CmekConfigOrBuilder> + cmekConfigBuilder_; + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the cmekConfig field is set. + */ + public boolean hasCmekConfig() { + return ((bitField0_ & 0x00004000) != 0); + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The cmekConfig. + */ + public com.google.firestore.admin.v1.Database.CmekConfig getCmekConfig() { + if (cmekConfigBuilder_ == null) { + return cmekConfig_ == null + ? com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance() + : cmekConfig_; + } else { + return cmekConfigBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setCmekConfig(com.google.firestore.admin.v1.Database.CmekConfig value) { + if (cmekConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + cmekConfig_ = value; + } else { + cmekConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00004000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setCmekConfig( + com.google.firestore.admin.v1.Database.CmekConfig.Builder builderForValue) { + if (cmekConfigBuilder_ == null) { + cmekConfig_ = builderForValue.build(); + } else { + cmekConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00004000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeCmekConfig(com.google.firestore.admin.v1.Database.CmekConfig value) { + if (cmekConfigBuilder_ == null) { + if (((bitField0_ & 0x00004000) != 0) + && cmekConfig_ != null + && cmekConfig_ + != com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance()) { + getCmekConfigBuilder().mergeFrom(value); + } else { + cmekConfig_ = value; + } + } else { + cmekConfigBuilder_.mergeFrom(value); + } + if (cmekConfig_ != null) { + bitField0_ |= 0x00004000; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearCmekConfig() { + bitField0_ = (bitField0_ & ~0x00004000); + cmekConfig_ = null; + if (cmekConfigBuilder_ != null) { + cmekConfigBuilder_.dispose(); + cmekConfigBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.CmekConfig.Builder getCmekConfigBuilder() { + bitField0_ |= 0x00004000; + onChanged(); + return internalGetCmekConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.CmekConfigOrBuilder getCmekConfigOrBuilder() { + if (cmekConfigBuilder_ != null) { + return cmekConfigBuilder_.getMessageOrBuilder(); + } else { + return cmekConfig_ == null + ? com.google.firestore.admin.v1.Database.CmekConfig.getDefaultInstance() + : cmekConfig_; + } + } + + /** + * + * + *
+     * Optional. Presence indicates CMEK is enabled for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.CmekConfig, + com.google.firestore.admin.v1.Database.CmekConfig.Builder, + com.google.firestore.admin.v1.Database.CmekConfigOrBuilder> + internalGetCmekConfigFieldBuilder() { + if (cmekConfigBuilder_ == null) { + cmekConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.CmekConfig, + com.google.firestore.admin.v1.Database.CmekConfig.Builder, + com.google.firestore.admin.v1.Database.CmekConfigOrBuilder>( + getCmekConfig(), getParentForChildren(), isClean()); + cmekConfig_ = null; + } + return cmekConfigBuilder_; + } + + private java.lang.Object previousId_ = ""; + + /** + * + * + *
+     * Output only. The database resource's prior database ID. This field is only
+     * populated for deleted databases.
+     * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The previousId. + */ + public java.lang.String getPreviousId() { + java.lang.Object ref = previousId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + previousId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The database resource's prior database ID. This field is only
+     * populated for deleted databases.
+     * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for previousId. + */ + public com.google.protobuf.ByteString getPreviousIdBytes() { + java.lang.Object ref = previousId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + previousId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The database resource's prior database ID. This field is only
+     * populated for deleted databases.
+     * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The previousId to set. + * @return This builder for chaining. + */ + public Builder setPreviousId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + previousId_ = value; + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The database resource's prior database ID. This field is only
+     * populated for deleted databases.
+     * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearPreviousId() { + previousId_ = getDefaultInstance().getPreviousId(); + bitField0_ = (bitField0_ & ~0x00008000); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The database resource's prior database ID. This field is only
+     * populated for deleted databases.
+     * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for previousId to set. + * @return This builder for chaining. + */ + public Builder setPreviousIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + previousId_ = value; + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Database.SourceInfo sourceInfo_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo, + com.google.firestore.admin.v1.Database.SourceInfo.Builder, + com.google.firestore.admin.v1.Database.SourceInfoOrBuilder> + sourceInfoBuilder_; + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the sourceInfo field is set. + */ + public boolean hasSourceInfo() { + return ((bitField0_ & 0x00010000) != 0); + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The sourceInfo. + */ + public com.google.firestore.admin.v1.Database.SourceInfo getSourceInfo() { + if (sourceInfoBuilder_ == null) { + return sourceInfo_ == null + ? com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance() + : sourceInfo_; + } else { + return sourceInfoBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSourceInfo(com.google.firestore.admin.v1.Database.SourceInfo value) { + if (sourceInfoBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + sourceInfo_ = value; + } else { + sourceInfoBuilder_.setMessage(value); + } + bitField0_ |= 0x00010000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setSourceInfo( + com.google.firestore.admin.v1.Database.SourceInfo.Builder builderForValue) { + if (sourceInfoBuilder_ == null) { + sourceInfo_ = builderForValue.build(); + } else { + sourceInfoBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00010000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeSourceInfo(com.google.firestore.admin.v1.Database.SourceInfo value) { + if (sourceInfoBuilder_ == null) { + if (((bitField0_ & 0x00010000) != 0) + && sourceInfo_ != null + && sourceInfo_ + != com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance()) { + getSourceInfoBuilder().mergeFrom(value); + } else { + sourceInfo_ = value; + } + } else { + sourceInfoBuilder_.mergeFrom(value); + } + if (sourceInfo_ != null) { + bitField0_ |= 0x00010000; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearSourceInfo() { + bitField0_ = (bitField0_ & ~0x00010000); + sourceInfo_ = null; + if (sourceInfoBuilder_ != null) { + sourceInfoBuilder_.dispose(); + sourceInfoBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Database.SourceInfo.Builder getSourceInfoBuilder() { + bitField0_ |= 0x00010000; + onChanged(); + return internalGetSourceInfoFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.firestore.admin.v1.Database.SourceInfoOrBuilder getSourceInfoOrBuilder() { + if (sourceInfoBuilder_ != null) { + return sourceInfoBuilder_.getMessageOrBuilder(); + } else { + return sourceInfo_ == null + ? com.google.firestore.admin.v1.Database.SourceInfo.getDefaultInstance() + : sourceInfo_; + } + } + + /** + * + * + *
+     * Output only. Information about the provenance of this database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo, + com.google.firestore.admin.v1.Database.SourceInfo.Builder, + com.google.firestore.admin.v1.Database.SourceInfoOrBuilder> + internalGetSourceInfoFieldBuilder() { + if (sourceInfoBuilder_ == null) { + sourceInfoBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.SourceInfo, + com.google.firestore.admin.v1.Database.SourceInfo.Builder, + com.google.firestore.admin.v1.Database.SourceInfoOrBuilder>( + getSourceInfo(), getParentForChildren(), isClean()); + sourceInfo_ = null; + } + return sourceInfoBuilder_; + } + + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + private com.google.protobuf.MapField + internalGetMutableTags() { + if (tags_ == null) { + tags_ = com.google.protobuf.MapField.newMapField(TagsDefaultEntryHolder.defaultEntry); + } + if (!tags_.isMutable()) { + tags_ = tags_.copy(); + } + bitField0_ |= 0x00020000; + onChanged(); + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearTags() { + bitField0_ = (bitField0_ & ~0x00020000); + internalGetMutableTags().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableTags().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableTags() { + bitField0_ |= 0x00020000; + return internalGetMutableTags().getMutableMap(); + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putTags(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableTags().getMutableMap().put(key, value); + bitField0_ |= 0x00020000; + return this; + } + + /** + * + * + *
+     * Optional. Input only. Immutable. Tag keys/values directly bound to this
+     * resource. For example:
+     * "123/environment": "production",
+     * "123/costCenter": "marketing"
+     * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllTags(java.util.Map values) { + internalGetMutableTags().getMutableMap().putAll(values); + bitField0_ |= 0x00020000; + return this; + } + + private boolean freeTier_; + + /** + * + * + *
+     * Output only. Background: Free tier is the ability of a Firestore database
+     * to use a small amount of resources every day without being charged. Once
+     * usage exceeds the free tier limit further usage is charged.
+     *
+     * Whether this database can make use of the free tier. Only one database
+     * per project can be eligible for the free tier.
+     *
+     * The first (or next) database that is created in a project without a free
+     * tier database will be marked as eligible for the free tier. Databases that
+     * are created while there is a free tier database will not be eligible for
+     * the free tier.
+     * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the freeTier field is set. + */ + @java.lang.Override + public boolean hasFreeTier() { + return ((bitField0_ & 0x00040000) != 0); + } + + /** + * + * + *
+     * Output only. Background: Free tier is the ability of a Firestore database
+     * to use a small amount of resources every day without being charged. Once
+     * usage exceeds the free tier limit further usage is charged.
+     *
+     * Whether this database can make use of the free tier. Only one database
+     * per project can be eligible for the free tier.
+     *
+     * The first (or next) database that is created in a project without a free
+     * tier database will be marked as eligible for the free tier. Databases that
+     * are created while there is a free tier database will not be eligible for
+     * the free tier.
+     * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The freeTier. + */ + @java.lang.Override + public boolean getFreeTier() { + return freeTier_; + } + + /** + * + * + *
+     * Output only. Background: Free tier is the ability of a Firestore database
+     * to use a small amount of resources every day without being charged. Once
+     * usage exceeds the free tier limit further usage is charged.
+     *
+     * Whether this database can make use of the free tier. Only one database
+     * per project can be eligible for the free tier.
+     *
+     * The first (or next) database that is created in a project without a free
+     * tier database will be marked as eligible for the free tier. Databases that
+     * are created while there is a free tier database will not be eligible for
+     * the free tier.
+     * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The freeTier to set. + * @return This builder for chaining. + */ + public Builder setFreeTier(boolean value) { + + freeTier_ = value; + bitField0_ |= 0x00040000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Background: Free tier is the ability of a Firestore database
+     * to use a small amount of resources every day without being charged. Once
+     * usage exceeds the free tier limit further usage is charged.
+     *
+     * Whether this database can make use of the free tier. Only one database
+     * per project can be eligible for the free tier.
+     *
+     * The first (or next) database that is created in a project without a free
+     * tier database will be marked as eligible for the free tier. Databases that
+     * are created while there is a free tier database will not be eligible for
+     * the free tier.
+     * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearFreeTier() { + bitField0_ = (bitField0_ & ~0x00040000); + freeTier_ = false; + onChanged(); + return this; + } + + private java.lang.Object etag_ = ""; + + /** + * + * + *
+     * This checksum is computed by the server based on the value of other
+     * fields, and may be sent on update and delete requests to ensure the
+     * client has an up-to-date value before proceeding.
+     * 
+ * + * string etag = 99; + * + * @return The etag. + */ + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + etag_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * This checksum is computed by the server based on the value of other
+     * fields, and may be sent on update and delete requests to ensure the
+     * client has an up-to-date value before proceeding.
+     * 
+ * + * string etag = 99; + * + * @return The bytes for etag. + */ + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * This checksum is computed by the server based on the value of other
+     * fields, and may be sent on update and delete requests to ensure the
+     * client has an up-to-date value before proceeding.
+     * 
+ * + * string etag = 99; + * + * @param value The etag to set. + * @return This builder for chaining. + */ + public Builder setEtag(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + etag_ = value; + bitField0_ |= 0x00080000; + onChanged(); + return this; + } + + /** + * + * + *
+     * This checksum is computed by the server based on the value of other
+     * fields, and may be sent on update and delete requests to ensure the
+     * client has an up-to-date value before proceeding.
+     * 
+ * + * string etag = 99; + * + * @return This builder for chaining. + */ + public Builder clearEtag() { + etag_ = getDefaultInstance().getEtag(); + bitField0_ = (bitField0_ & ~0x00080000); + onChanged(); + return this; + } + + /** + * + * + *
+     * This checksum is computed by the server based on the value of other
+     * fields, and may be sent on update and delete requests to ensure the
+     * client has an up-to-date value before proceeding.
+     * 
+ * + * string etag = 99; + * + * @param value The bytes for etag to set. + * @return This builder for chaining. + */ + public Builder setEtagBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + etag_ = value; + bitField0_ |= 0x00080000; + onChanged(); + return this; + } + + private int databaseEdition_ = 0; + + /** + * + * + *
+     * Immutable. The edition of the database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for databaseEdition. + */ + @java.lang.Override + public int getDatabaseEditionValue() { + return databaseEdition_; + } + + /** + * + * + *
+     * Immutable. The edition of the database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The enum numeric value on the wire for databaseEdition to set. + * @return This builder for chaining. + */ + public Builder setDatabaseEditionValue(int value) { + databaseEdition_ = value; + bitField0_ |= 0x00100000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The edition of the database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The databaseEdition. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DatabaseEdition getDatabaseEdition() { + com.google.firestore.admin.v1.Database.DatabaseEdition result = + com.google.firestore.admin.v1.Database.DatabaseEdition.forNumber(databaseEdition_); + return result == null + ? com.google.firestore.admin.v1.Database.DatabaseEdition.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Immutable. The edition of the database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The databaseEdition to set. + * @return This builder for chaining. + */ + public Builder setDatabaseEdition( + com.google.firestore.admin.v1.Database.DatabaseEdition value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00100000; + databaseEdition_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The edition of the database.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return This builder for chaining. + */ + public Builder clearDatabaseEdition() { + bitField0_ = (bitField0_ & ~0x00100000); + databaseEdition_ = 0; + onChanged(); + return this; + } + + private int realtimeUpdatesMode_ = 0; + + /** + * + * + *
+     * Immutable. The default Realtime Updates mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for realtimeUpdatesMode. + */ + @java.lang.Override + public int getRealtimeUpdatesModeValue() { + return realtimeUpdatesMode_; + } + + /** + * + * + *
+     * Immutable. The default Realtime Updates mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The enum numeric value on the wire for realtimeUpdatesMode to set. + * @return This builder for chaining. + */ + public Builder setRealtimeUpdatesModeValue(int value) { + realtimeUpdatesMode_ = value; + bitField0_ |= 0x00200000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The default Realtime Updates mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The realtimeUpdatesMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.RealtimeUpdatesMode getRealtimeUpdatesMode() { + com.google.firestore.admin.v1.RealtimeUpdatesMode result = + com.google.firestore.admin.v1.RealtimeUpdatesMode.forNumber(realtimeUpdatesMode_); + return result == null + ? com.google.firestore.admin.v1.RealtimeUpdatesMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Immutable. The default Realtime Updates mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The realtimeUpdatesMode to set. + * @return This builder for chaining. + */ + public Builder setRealtimeUpdatesMode(com.google.firestore.admin.v1.RealtimeUpdatesMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00200000; + realtimeUpdatesMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The default Realtime Updates mode to use for this database.
+     * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return This builder for chaining. + */ + public Builder clearRealtimeUpdatesMode() { + bitField0_ = (bitField0_ & ~0x00200000); + realtimeUpdatesMode_ = 0; + onChanged(); + return this; + } + + private int firestoreDataAccessMode_ = 0; + + /** + * + * + *
+     * Optional. The Firestore API data access mode to use for this database. If
+     * not set on write:
+     * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+     * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for firestoreDataAccessMode. + */ + @java.lang.Override + public int getFirestoreDataAccessModeValue() { + return firestoreDataAccessMode_; + } + + /** + * + * + *
+     * Optional. The Firestore API data access mode to use for this database. If
+     * not set on write:
+     * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+     * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The enum numeric value on the wire for firestoreDataAccessMode to set. + * @return This builder for chaining. + */ + public Builder setFirestoreDataAccessModeValue(int value) { + firestoreDataAccessMode_ = value; + bitField0_ |= 0x00400000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The Firestore API data access mode to use for this database. If
+     * not set on write:
+     * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+     * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The firestoreDataAccessMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DataAccessMode getFirestoreDataAccessMode() { + com.google.firestore.admin.v1.Database.DataAccessMode result = + com.google.firestore.admin.v1.Database.DataAccessMode.forNumber(firestoreDataAccessMode_); + return result == null + ? com.google.firestore.admin.v1.Database.DataAccessMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Optional. The Firestore API data access mode to use for this database. If
+     * not set on write:
+     * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+     * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The firestoreDataAccessMode to set. + * @return This builder for chaining. + */ + public Builder setFirestoreDataAccessMode( + com.google.firestore.admin.v1.Database.DataAccessMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00400000; + firestoreDataAccessMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The Firestore API data access mode to use for this database. If
+     * not set on write:
+     * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+     * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return This builder for chaining. + */ + public Builder clearFirestoreDataAccessMode() { + bitField0_ = (bitField0_ & ~0x00400000); + firestoreDataAccessMode_ = 0; + onChanged(); + return this; + } + + private int mongodbCompatibleDataAccessMode_ = 0; + + /** + * + * + *
+     * Optional. The MongoDB compatible API data access mode to use for this
+     * database. If not set on write, the default value is
+     * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+     * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for mongodbCompatibleDataAccessMode. + */ + @java.lang.Override + public int getMongodbCompatibleDataAccessModeValue() { + return mongodbCompatibleDataAccessMode_; + } + + /** + * + * + *
+     * Optional. The MongoDB compatible API data access mode to use for this
+     * database. If not set on write, the default value is
+     * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+     * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The enum numeric value on the wire for mongodbCompatibleDataAccessMode to set. + * @return This builder for chaining. + */ + public Builder setMongodbCompatibleDataAccessModeValue(int value) { + mongodbCompatibleDataAccessMode_ = value; + bitField0_ |= 0x00800000; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The MongoDB compatible API data access mode to use for this
+     * database. If not set on write, the default value is
+     * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+     * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mongodbCompatibleDataAccessMode. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.DataAccessMode + getMongodbCompatibleDataAccessMode() { + com.google.firestore.admin.v1.Database.DataAccessMode result = + com.google.firestore.admin.v1.Database.DataAccessMode.forNumber( + mongodbCompatibleDataAccessMode_); + return result == null + ? com.google.firestore.admin.v1.Database.DataAccessMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Optional. The MongoDB compatible API data access mode to use for this
+     * database. If not set on write, the default value is
+     * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+     * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @param value The mongodbCompatibleDataAccessMode to set. + * @return This builder for chaining. + */ + public Builder setMongodbCompatibleDataAccessMode( + com.google.firestore.admin.v1.Database.DataAccessMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00800000; + mongodbCompatibleDataAccessMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The MongoDB compatible API data access mode to use for this
+     * database. If not set on write, the default value is
+     * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+     * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+     * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return This builder for chaining. + */ + public Builder clearMongodbCompatibleDataAccessMode() { + bitField0_ = (bitField0_ & ~0x00800000); + mongodbCompatibleDataAccessMode_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Database) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Database) + private static final com.google.firestore.admin.v1.Database DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Database(); + } + + public static com.google.firestore.admin.v1.Database getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Database parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Database getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java new file mode 100644 index 000000000000..3e680f233d62 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseName.java @@ -0,0 +1,192 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class DatabaseName implements ResourceName { + 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; + } + + public String getDatabase() { + return database; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static DatabaseName of(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build(); + } + + public static String format(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build().toString(); + } + + public static DatabaseName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE.validatedMatch( + formattedString, "DatabaseName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (DatabaseName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_DATABASE.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE.instantiate("project", project, "database", database); + } + + @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; + } + + public String getDatabase() { + return database; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + private Builder(DatabaseName databaseName) { + this.project = databaseName.project; + this.database = databaseName.database; + } + + public DatabaseName build() { + return new DatabaseName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java new file mode 100644 index 000000000000..230ca4a3454b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseOrBuilder.java @@ -0,0 +1,977 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/database.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DatabaseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Database) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The resource name of the Database.
+   * Format: `projects/{project}/databases/{database}`
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * The resource name of the Database.
+   * Format: `projects/{project}/databases/{database}`
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The system-generated UUID4 for this Database.
+   * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The uid. + */ + java.lang.String getUid(); + + /** + * + * + *
+   * Output only. The system-generated UUID4 for this Database.
+   * 
+ * + * string uid = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for uid. + */ + com.google.protobuf.ByteString getUidBytes(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was created. Databases
+   * created before 2016 do not populate create_time.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was most recently
+   * updated. Note this only includes updates to the database resource and not
+   * data contained by the database.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the deleteTime field is set. + */ + boolean hasDeleteTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The deleteTime. + */ + com.google.protobuf.Timestamp getDeleteTime(); + + /** + * + * + *
+   * Output only. The timestamp at which this database was deleted. Only set if
+   * the database has been deleted.
+   * 
+ * + * .google.protobuf.Timestamp delete_time = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getDeleteTimeOrBuilder(); + + /** + * + * + *
+   * The location of the database. Available locations are listed at
+   * https://cloud.google.com/firestore/docs/locations.
+   * 
+ * + * string location_id = 9; + * + * @return The locationId. + */ + java.lang.String getLocationId(); + + /** + * + * + *
+   * The location of the database. Available locations are listed at
+   * https://cloud.google.com/firestore/docs/locations.
+   * 
+ * + * string location_id = 9; + * + * @return The bytes for locationId. + */ + com.google.protobuf.ByteString getLocationIdBytes(); + + /** + * + * + *
+   * The type of the database.
+   * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+   * information about how to choose.
+   * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The enum numeric value on the wire for type. + */ + int getTypeValue(); + + /** + * + * + *
+   * The type of the database.
+   * See https://cloud.google.com/datastore/docs/firestore-or-datastore for
+   * information about how to choose.
+   * 
+ * + * .google.firestore.admin.v1.Database.DatabaseType type = 10; + * + * @return The type. + */ + com.google.firestore.admin.v1.Database.DatabaseType getType(); + + /** + * + * + *
+   * The concurrency control mode to use for this database.
+   *
+   * If unspecified in a CreateDatabase request, this will default based on the
+   * database edition: Optimistic for Enterprise and Pessimistic for all other
+   * databases.
+   * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + int getConcurrencyModeValue(); + + /** + * + * + *
+   * The concurrency control mode to use for this database.
+   *
+   * If unspecified in a CreateDatabase request, this will default based on the
+   * database edition: Optimistic for Enterprise and Pessimistic for all other
+   * databases.
+   * 
+ * + * .google.firestore.admin.v1.Database.ConcurrencyMode concurrency_mode = 15; + * + * @return The concurrencyMode. + */ + com.google.firestore.admin.v1.Database.ConcurrencyMode getConcurrencyMode(); + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the versionRetentionPeriod field is set. + */ + boolean hasVersionRetentionPeriod(); + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The versionRetentionPeriod. + */ + com.google.protobuf.Duration getVersionRetentionPeriod(); + + /** + * + * + *
+   * Output only. The period during which past versions of data are retained in
+   * the database.
+   *
+   * Any [read][google.firestore.v1.GetDocumentRequest.read_time]
+   * or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify
+   * a `read_time` within this window, and will read the state of the database
+   * at that time.
+   *
+   * If the PITR feature is enabled, the retention period is 7 days. Otherwise,
+   * the retention period is 1 hour.
+   * 
+ * + * + * .google.protobuf.Duration version_retention_period = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.DurationOrBuilder getVersionRetentionPeriodOrBuilder(); + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the earliestVersionTime field is set. + */ + boolean hasEarliestVersionTime(); + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The earliestVersionTime. + */ + com.google.protobuf.Timestamp getEarliestVersionTime(); + + /** + * + * + *
+   * Output only. The earliest timestamp at which older versions of the data can
+   * be read from the database. See [version_retention_period] above; this field
+   * is populated with `now - version_retention_period`.
+   *
+   * This value is continuously updated, and becomes stale the moment it is
+   * queried. If you are using this value to recover data, make sure to account
+   * for the time from the moment when the value is queried to the moment when
+   * you initiate the recovery.
+   * 
+ * + * + * .google.protobuf.Timestamp earliest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getEarliestVersionTimeOrBuilder(); + + /** + * + * + *
+   * Whether to enable the PITR feature on this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The enum numeric value on the wire for pointInTimeRecoveryEnablement. + */ + int getPointInTimeRecoveryEnablementValue(); + + /** + * + * + *
+   * Whether to enable the PITR feature on this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + * + * + * @return The pointInTimeRecoveryEnablement. + */ + com.google.firestore.admin.v1.Database.PointInTimeRecoveryEnablement + getPointInTimeRecoveryEnablement(); + + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The enum numeric value on the wire for appEngineIntegrationMode. + */ + int getAppEngineIntegrationModeValue(); + + /** + * + * + *
+   * The App Engine integration mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.AppEngineIntegrationMode app_engine_integration_mode = 19; + * + * + * @return The appEngineIntegrationMode. + */ + com.google.firestore.admin.v1.Database.AppEngineIntegrationMode getAppEngineIntegrationMode(); + + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in
+   * combination with the project ID ("<key prefix>~<project id>") to construct
+   * the application ID that is returned from the Cloud Datastore APIs in Google
+   * App Engine first generation runtimes.
+   *
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The keyPrefix. + */ + java.lang.String getKeyPrefix(); + + /** + * + * + *
+   * Output only. The key_prefix for this database. This key_prefix is used, in
+   * combination with the project ID ("<key prefix>~<project id>") to construct
+   * the application ID that is returned from the Cloud Datastore APIs in Google
+   * App Engine first generation runtimes.
+   *
+   * This value may be empty in which case the appid to use for URL-encoded keys
+   * is the project_id (eg: foo instead of v~foo).
+   * 
+ * + * string key_prefix = 20 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for keyPrefix. + */ + com.google.protobuf.ByteString getKeyPrefixBytes(); + + /** + * + * + *
+   * State of delete protection for the database.
+   * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The enum numeric value on the wire for deleteProtectionState. + */ + int getDeleteProtectionStateValue(); + + /** + * + * + *
+   * State of delete protection for the database.
+   * 
+ * + * .google.firestore.admin.v1.Database.DeleteProtectionState delete_protection_state = 22; + * + * + * @return The deleteProtectionState. + */ + com.google.firestore.admin.v1.Database.DeleteProtectionState getDeleteProtectionState(); + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the cmekConfig field is set. + */ + boolean hasCmekConfig(); + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The cmekConfig. + */ + com.google.firestore.admin.v1.Database.CmekConfig getCmekConfig(); + + /** + * + * + *
+   * Optional. Presence indicates CMEK is enabled for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.CmekConfig cmek_config = 23 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.admin.v1.Database.CmekConfigOrBuilder getCmekConfigOrBuilder(); + + /** + * + * + *
+   * Output only. The database resource's prior database ID. This field is only
+   * populated for deleted databases.
+   * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The previousId. + */ + java.lang.String getPreviousId(); + + /** + * + * + *
+   * Output only. The database resource's prior database ID. This field is only
+   * populated for deleted databases.
+   * 
+ * + * string previous_id = 25 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for previousId. + */ + com.google.protobuf.ByteString getPreviousIdBytes(); + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the sourceInfo field is set. + */ + boolean hasSourceInfo(); + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The sourceInfo. + */ + com.google.firestore.admin.v1.Database.SourceInfo getSourceInfo(); + + /** + * + * + *
+   * Output only. Information about the provenance of this database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.SourceInfo source_info = 26 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.firestore.admin.v1.Database.SourceInfoOrBuilder getSourceInfoOrBuilder(); + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + int getTagsCount(); + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsTags(java.lang.String key); + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getTags(); + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getTagsMap(); + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Optional. Input only. Immutable. Tag keys/values directly bound to this
+   * resource. For example:
+   * "123/environment": "production",
+   * "123/costCenter": "marketing"
+   * 
+ * + * + * map<string, string> tags = 29 [(.google.api.field_behavior) = INPUT_ONLY, (.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.lang.String getTagsOrThrow(java.lang.String key); + + /** + * + * + *
+   * Output only. Background: Free tier is the ability of a Firestore database
+   * to use a small amount of resources every day without being charged. Once
+   * usage exceeds the free tier limit further usage is charged.
+   *
+   * Whether this database can make use of the free tier. Only one database
+   * per project can be eligible for the free tier.
+   *
+   * The first (or next) database that is created in a project without a free
+   * tier database will be marked as eligible for the free tier. Databases that
+   * are created while there is a free tier database will not be eligible for
+   * the free tier.
+   * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return Whether the freeTier field is set. + */ + boolean hasFreeTier(); + + /** + * + * + *
+   * Output only. Background: Free tier is the ability of a Firestore database
+   * to use a small amount of resources every day without being charged. Once
+   * usage exceeds the free tier limit further usage is charged.
+   *
+   * Whether this database can make use of the free tier. Only one database
+   * per project can be eligible for the free tier.
+   *
+   * The first (or next) database that is created in a project without a free
+   * tier database will be marked as eligible for the free tier. Databases that
+   * are created while there is a free tier database will not be eligible for
+   * the free tier.
+   * 
+ * + * optional bool free_tier = 30 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The freeTier. + */ + boolean getFreeTier(); + + /** + * + * + *
+   * This checksum is computed by the server based on the value of other
+   * fields, and may be sent on update and delete requests to ensure the
+   * client has an up-to-date value before proceeding.
+   * 
+ * + * string etag = 99; + * + * @return The etag. + */ + java.lang.String getEtag(); + + /** + * + * + *
+   * This checksum is computed by the server based on the value of other
+   * fields, and may be sent on update and delete requests to ensure the
+   * client has an up-to-date value before proceeding.
+   * 
+ * + * string etag = 99; + * + * @return The bytes for etag. + */ + com.google.protobuf.ByteString getEtagBytes(); + + /** + * + * + *
+   * Immutable. The edition of the database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for databaseEdition. + */ + int getDatabaseEditionValue(); + + /** + * + * + *
+   * Immutable. The edition of the database.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DatabaseEdition database_edition = 28 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The databaseEdition. + */ + com.google.firestore.admin.v1.Database.DatabaseEdition getDatabaseEdition(); + + /** + * + * + *
+   * Immutable. The default Realtime Updates mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for realtimeUpdatesMode. + */ + int getRealtimeUpdatesModeValue(); + + /** + * + * + *
+   * Immutable. The default Realtime Updates mode to use for this database.
+   * 
+ * + * + * .google.firestore.admin.v1.RealtimeUpdatesMode realtime_updates_mode = 31 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The realtimeUpdatesMode. + */ + com.google.firestore.admin.v1.RealtimeUpdatesMode getRealtimeUpdatesMode(); + + /** + * + * + *
+   * Optional. The Firestore API data access mode to use for this database. If
+   * not set on write:
+   * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+   * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for firestoreDataAccessMode. + */ + int getFirestoreDataAccessModeValue(); + + /** + * + * + *
+   * Optional. The Firestore API data access mode to use for this database. If
+   * not set on write:
+   * - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition.
+   * - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode firestore_data_access_mode = 33 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The firestoreDataAccessMode. + */ + com.google.firestore.admin.v1.Database.DataAccessMode getFirestoreDataAccessMode(); + + /** + * + * + *
+   * Optional. The MongoDB compatible API data access mode to use for this
+   * database. If not set on write, the default value is
+   * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+   * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The enum numeric value on the wire for mongodbCompatibleDataAccessMode. + */ + int getMongodbCompatibleDataAccessModeValue(); + + /** + * + * + *
+   * Optional. The MongoDB compatible API data access mode to use for this
+   * database. If not set on write, the default value is
+   * DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always
+   * DATA_ACCESS_MODE_DISABLED for Standard Edition.
+   * 
+ * + * + * .google.firestore.admin.v1.Database.DataAccessMode mongodb_compatible_data_access_mode = 34 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mongodbCompatibleDataAccessMode. + */ + com.google.firestore.admin.v1.Database.DataAccessMode getMongodbCompatibleDataAccessMode(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java new file mode 100644 index 000000000000..21f1b63a0d08 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DatabaseProto.java @@ -0,0 +1,325 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/database.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class DatabaseProto extends com.google.protobuf.GeneratedFile { + private DatabaseProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DatabaseProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_CmekConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_SourceInfo_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Database_TagsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Database_TagsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "(google/firestore/admin/v1/database.pro" + + "to\022\031google.firestore.admin.v1\032\037google/ap" + + "i/field_behavior.proto\032\031google/api/resou" + + "rce.proto\0320google/firestore/admin/v1/rea" + + "ltime_updates.proto\032\036google/protobuf/dur" + + "ation.proto\032\037google/protobuf/timestamp.proto\"\253\031\n" + + "\010Database\022\014\n" + + "\004name\030\001 \001(\t\022\020\n" + + "\003uid\030\003 \001(\tB\003\340A\003\0224\n" + + "\013create_time\030\005 \001(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n" + + "\013update_time\030\006 \001(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n" + + "\013delete_time\030\007" + + " \001(\0132\032.google.protobuf.TimestampB\003\340A\003\022\023\n" + + "\013location_id\030\t \001(\t\022>\n" + + "\004type\030\n" + + " \001(\01620.google.firestore.admin.v1.Database.DatabaseType\022M\n" + + "\020concurrency_mode\030\017 \001" + + "(\01623.google.firestore.admin.v1.Database.ConcurrencyMode\022@\n" + + "\030version_retention_period\030\021" + + " \001(\0132\031.google.protobuf.DurationB\003\340A\003\022>\n" + + "\025earliest_version_time\030\022" + + " \001(\0132\032.google.protobuf.TimestampB\003\340A\003\022l\n" + + "!point_in_time_recovery_enablement\030\025 \001(\0162A.google.fi" + + "restore.admin.v1.Database.PointInTimeRecoveryEnablement\022a\n" + + "\033app_engine_integration_mode\030\023" + + " \001(\0162<.google.firestore.admin.v1.Database.AppEngineIntegrationMode\022\027\n\n" + + "key_prefix\030\024 \001(\tB\003\340A\003\022Z\n" + + "\027delete_protection_state\030\026" + + " \001(\01629.google.firestore.admin.v1.Database.DeleteProtectionState\022H\n" + + "\013cmek_config\030\027" + + " \001(\0132..google.firestore.admin.v1.Database.CmekConfigB\003\340A\001\022\030\n" + + "\013previous_id\030\031 \001(\tB\003\340A\003\022H\n" + + "\013source_info\030\032 \001(\0132..googl" + + "e.firestore.admin.v1.Database.SourceInfoB\003\340A\003\022F\n" + + "\004tags\030\035 \003(\0132-.google.firestore.admin.v1.Database.TagsEntryB" + + "\t\340A\004\340A\005\340A\001\022\033\n" + + "\tfree_tier\030\036 \001(\010B\003\340A\003H\000\210\001\001\022\014\n" + + "\004etag\030c \001(\t\022R\n" + + "\020database_edition\030\034 \001(\01623.google.fire" + + "store.admin.v1.Database.DatabaseEditionB\003\340A\005\022R\n" + + "\025realtime_updates_mode\030\037 \001(\0162..go" + + "ogle.firestore.admin.v1.RealtimeUpdatesModeB\003\340A\005\022[\n" + + "\032firestore_data_access_mode\030!" + + " \001(\01622.google.firestore.admin.v1.Database.DataAccessModeB\003\340A\001\022d\n" + + "#mongodb_compatible_data_access_mode\030\" \001(\01622.google.fire" + + "store.admin.v1.Database.DataAccessModeB\003\340A\001\032H\n\n" + + "CmekConfig\022\031\n" + + "\014kms_key_name\030\001 \001(\tB\003\340A\002\022\037\n" + + "\022active_key_version\030\002 \003(\tB\003\340A\003\032\347\001\n\n" + + "SourceInfo\022M\n" + + "\006backup\030\001 \001(\0132;.google.fi" + + "restore.admin.v1.Database.SourceInfo.BackupSourceH\000\022:\n" + + "\toperation\030\003 \001(\tB\'\372A$\n" + + "\"firestore.googleapis.com/Operation\032D\n" + + "\014BackupSource\0224\n" + + "\006backup\030\001 \001(\tB$\372A!\n" + + "\037firestore.googleapis.com/BackupB\010\n" + + "\006source\032\210\004\n" + + "\020EncryptionConfig\022x\n" + + "\031google_default_encryption\030\001 \001(\0132S.google.firestore.admin.v1.Data" + + "base.EncryptionConfig.GoogleDefaultEncryptionOptionsH\000\022m\n" + + "\025use_source_encryption\030\002 \001(\0132L.google.firestore.admin.v1.Databa" + + "se.EncryptionConfig.SourceEncryptionOptionsH\000\022|\n" + + "\033customer_managed_encryption\030\003 \001" + + "(\0132U.google.firestore.admin.v1.Database." + + "EncryptionConfig.CustomerManagedEncryptionOptionsH\000\032 \n" + + "\036GoogleDefaultEncryptionOptions\032\031\n" + + "\027SourceEncryptionOptions\032=\n" + + " CustomerManagedEncryptionOptions\022\031\n" + + "\014kms_key_name\030\001 \001(\tB\003\340A\002B\021\n" + + "\017encryption_type\032+\n" + + "\tTagsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\"W\n" + + "\014DatabaseType\022\035\n" + + "\031DATABASE_TYPE_UNSPECIFIED\020\000\022\024\n" + + "\020FIRESTORE_NATIVE\020\001\022\022\n" + + "\016DATASTORE_MODE\020\002\"w\n" + + "\017ConcurrencyMode\022 \n" + + "\034CONCURRENCY_MODE_UNSPECIFIED\020\000\022\016\n\n" + + "OPTIMISTIC\020\001\022\017\n" + + "\013PESSIMISTIC\020\002\022!\n" + + "\035OPTIMISTIC_WITH_ENTITY_GROUPS\020\003\"\233\001\n" + + "\035PointInTimeRecoveryEnablement\0221\n" + + "-POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED\020\000\022\"\n" + + "\036POINT_IN_TIME_RECOVERY_ENABLED\020\001\022#\n" + + "\037POINT_IN_TIME_RECOVERY_DISABLED\020\002\"b\n" + + "\030AppEngineIntegrationMode\022+\n" + + "\'APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED\020\000\022\013\n" + + "\007ENABLED\020\001\022\014\n" + + "\010DISABLED\020\002\"\177\n" + + "\025DeleteProtectionState\022\'\n" + + "#DELETE_PROTECTION_STATE_UNSPECIFIED\020\000\022\036\n" + + "\032DELETE_PROTECTION_DISABLED\020\001\022\035\n" + + "\031DELETE_PROTECTION_ENABLED\020\002\"Q\n" + + "\017DatabaseEdition\022 \n" + + "\034DATABASE_EDITION_UNSPECIFIED\020\000\022\014\n" + + "\010STANDARD\020\001\022\016\n\n" + + "ENTERPRISE\020\002\"o\n" + + "\016DataAccessMode\022 \n" + + "\034DATA_ACCESS_MODE_UNSPECIFIED\020\000\022\034\n" + + "\030DATA_ACCESS_MODE_ENABLED\020\001\022\035\n" + + "\031DATA_ACCESS_MODE_DISABLED\020\002:R\352AO\n" + + "!firestore.googleapis.com/Database\022\'projects/{project}/databases/{database}R\001\001B\014\n\n" + + "_free_tierB\303\002\n" + + "\035com.google.firestore.admin.v1B\r" + + "DatabaseProtoP\001Z9cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb" + + "\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin.V" + + "1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Google::Cloud::Firestore::Admin::V1\352Ad\n" + + "\"firestore.googleapis.com/Operation\022>projec" + + "ts/{project}/databases/{database}/operations/{operation}b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.firestore.admin.v1.RealtimeUpdatesProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_Database_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_Database_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_descriptor, + new java.lang.String[] { + "Name", + "Uid", + "CreateTime", + "UpdateTime", + "DeleteTime", + "LocationId", + "Type", + "ConcurrencyMode", + "VersionRetentionPeriod", + "EarliestVersionTime", + "PointInTimeRecoveryEnablement", + "AppEngineIntegrationMode", + "KeyPrefix", + "DeleteProtectionState", + "CmekConfig", + "PreviousId", + "SourceInfo", + "Tags", + "FreeTier", + "Etag", + "DatabaseEdition", + "RealtimeUpdatesMode", + "FirestoreDataAccessMode", + "MongodbCompatibleDataAccessMode", + }); + internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor = + internal_static_google_firestore_admin_v1_Database_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Database_CmekConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_CmekConfig_descriptor, + new java.lang.String[] { + "KmsKeyName", "ActiveKeyVersion", + }); + internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor = + internal_static_google_firestore_admin_v1_Database_descriptor.getNestedType(1); + internal_static_google_firestore_admin_v1_Database_SourceInfo_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor, + new java.lang.String[] { + "Backup", "Operation", "Source", + }); + internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor = + internal_static_google_firestore_admin_v1_Database_SourceInfo_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_SourceInfo_BackupSource_descriptor, + new java.lang.String[] { + "Backup", + }); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor = + internal_static_google_firestore_admin_v1_Database_descriptor.getNestedType(2); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor, + new java.lang.String[] { + "GoogleDefaultEncryption", + "UseSourceEncryption", + "CustomerManagedEncryption", + "EncryptionType", + }); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor = + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor + .getNestedType(0); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_GoogleDefaultEncryptionOptions_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor = + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor + .getNestedType(1); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_SourceEncryptionOptions_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor = + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_descriptor + .getNestedType(2); + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_EncryptionConfig_CustomerManagedEncryptionOptions_descriptor, + new java.lang.String[] { + "KmsKeyName", + }); + internal_static_google_firestore_admin_v1_Database_TagsEntry_descriptor = + internal_static_google_firestore_admin_v1_Database_descriptor.getNestedType(3); + internal_static_google_firestore_admin_v1_Database_TagsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Database_TagsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.firestore.admin.v1.RealtimeUpdatesProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceDefinition); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java new file mode 100644 index 000000000000..2bcac602dab2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequest.java @@ -0,0 +1,626 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupRequest} + */ +@com.google.protobuf.Generated +public final class DeleteBackupRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteBackupRequest) + DeleteBackupRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteBackupRequest"); + } + + // Use DeleteBackupRequest.newBuilder() to construct. + private DeleteBackupRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteBackupRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupRequest.class, + com.google.firestore.admin.v1.DeleteBackupRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteBackupRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteBackupRequest other = + (com.google.firestore.admin.v1.DeleteBackupRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteBackupRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteBackupRequest) + com.google.firestore.admin.v1.DeleteBackupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupRequest.class, + com.google.firestore.admin.v1.DeleteBackupRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteBackupRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteBackupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest build() { + com.google.firestore.admin.v1.DeleteBackupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest buildPartial() { + com.google.firestore.admin.v1.DeleteBackupRequest result = + new com.google.firestore.admin.v1.DeleteBackupRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteBackupRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteBackupRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteBackupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteBackupRequest other) { + if (other == com.google.firestore.admin.v1.DeleteBackupRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Name of the backup to delete.
+     *
+     * format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteBackupRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteBackupRequest) + private static final com.google.firestore.admin.v1.DeleteBackupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteBackupRequest(); + } + + public static com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteBackupRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java new file mode 100644 index 000000000000..ba464590f89f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupRequestOrBuilder.java @@ -0,0 +1,62 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteBackupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteBackupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. Name of the backup to delete.
+   *
+   * format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java new file mode 100644 index 000000000000..7e9aadcff7f9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequest.java @@ -0,0 +1,632 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for [FirestoreAdmin.DeleteBackupSchedules][].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupScheduleRequest} + */ +@com.google.protobuf.Generated +public final class DeleteBackupScheduleRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteBackupScheduleRequest) + DeleteBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteBackupScheduleRequest"); + } + + // Use DeleteBackupScheduleRequest.newBuilder() to construct. + private DeleteBackupScheduleRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteBackupScheduleRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteBackupScheduleRequest other = + (com.google.firestore.admin.v1.DeleteBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [FirestoreAdmin.DeleteBackupSchedules][].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteBackupScheduleRequest) + com.google.firestore.admin.v1.DeleteBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.class, + com.google.firestore.admin.v1.DeleteBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteBackupScheduleRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest build() { + com.google.firestore.admin.v1.DeleteBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.DeleteBackupScheduleRequest result = + new com.google.firestore.admin.v1.DeleteBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.DeleteBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteBackupScheduleRequest) + private static final com.google.firestore.admin.v1.DeleteBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000000..0cc210bddc85 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteBackupScheduleRequestOrBuilder.java @@ -0,0 +1,64 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadata.java new file mode 100644 index 000000000000..af7f3585fcc4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadata.java @@ -0,0 +1,396 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata related to the delete database operation.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteDatabaseMetadata} + */ +@com.google.protobuf.Generated +public final class DeleteDatabaseMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteDatabaseMetadata) + DeleteDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteDatabaseMetadata"); + } + + // Use DeleteDatabaseMetadata.newBuilder() to construct. + private DeleteDatabaseMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteDatabaseMetadata() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteDatabaseMetadata.class, + com.google.firestore.admin.v1.DeleteDatabaseMetadata.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteDatabaseMetadata other = + (com.google.firestore.admin.v1.DeleteDatabaseMetadata) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata related to the delete database operation.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteDatabaseMetadata) + com.google.firestore.admin.v1.DeleteDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteDatabaseMetadata.class, + com.google.firestore.admin.v1.DeleteDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteDatabaseMetadata.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseMetadata build() { + com.google.firestore.admin.v1.DeleteDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.DeleteDatabaseMetadata result = + new com.google.firestore.admin.v1.DeleteDatabaseMetadata(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.DeleteDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.DeleteDatabaseMetadata.getDefaultInstance()) + return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteDatabaseMetadata) + private static final com.google.firestore.admin.v1.DeleteDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000000..45493100393e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseMetadataOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteDatabaseMetadata) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequest.java new file mode 100644 index 000000000000..6d19d7973eac --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequest.java @@ -0,0 +1,822 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class DeleteDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteDatabaseRequest) + DeleteDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteDatabaseRequest"); + } + + // Use DeleteDatabaseRequest.newBuilder() to construct. + private DeleteDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteDatabaseRequest() { + name_ = ""; + etag_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteDatabaseRequest.class, + com.google.firestore.admin.v1.DeleteDatabaseRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ETAG_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object etag_ = ""; + + /** + * + * + *
+   * The current etag of the Database.
+   * If an etag is provided and does not match the current etag of the database,
+   * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+   * 
+ * + * string etag = 3; + * + * @return The etag. + */ + @java.lang.Override + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + etag_ = s; + return s; + } + } + + /** + * + * + *
+   * The current etag of the Database.
+   * If an etag is provided and does not match the current etag of the database,
+   * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+   * 
+ * + * string etag = 3; + * + * @return The bytes for etag. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(etag_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, etag_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(etag_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, etag_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteDatabaseRequest other = + (com.google.firestore.admin.v1.DeleteDatabaseRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getEtag().equals(other.getEtag())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + ETAG_FIELD_NUMBER; + hash = (53 * hash) + getEtag().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteDatabaseRequest) + com.google.firestore.admin.v1.DeleteDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteDatabaseRequest.class, + com.google.firestore.admin.v1.DeleteDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteDatabaseRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + etag_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseRequest build() { + com.google.firestore.admin.v1.DeleteDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.DeleteDatabaseRequest result = + new com.google.firestore.admin.v1.DeleteDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.etag_ = etag_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.DeleteDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getEtag().isEmpty()) { + etag_ = other.etag_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + etag_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object etag_ = ""; + + /** + * + * + *
+     * The current etag of the Database.
+     * If an etag is provided and does not match the current etag of the database,
+     * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+     * 
+ * + * string etag = 3; + * + * @return The etag. + */ + public java.lang.String getEtag() { + java.lang.Object ref = etag_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + etag_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The current etag of the Database.
+     * If an etag is provided and does not match the current etag of the database,
+     * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+     * 
+ * + * string etag = 3; + * + * @return The bytes for etag. + */ + public com.google.protobuf.ByteString getEtagBytes() { + java.lang.Object ref = etag_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + etag_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The current etag of the Database.
+     * If an etag is provided and does not match the current etag of the database,
+     * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+     * 
+ * + * string etag = 3; + * + * @param value The etag to set. + * @return This builder for chaining. + */ + public Builder setEtag(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + etag_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The current etag of the Database.
+     * If an etag is provided and does not match the current etag of the database,
+     * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+     * 
+ * + * string etag = 3; + * + * @return This builder for chaining. + */ + public Builder clearEtag() { + etag_ = getDefaultInstance().getEtag(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The current etag of the Database.
+     * If an etag is provided and does not match the current etag of the database,
+     * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+     * 
+ * + * string etag = 3; + * + * @param value The bytes for etag to set. + * @return This builder for chaining. + */ + public Builder setEtagBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + etag_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteDatabaseRequest) + private static final com.google.firestore.admin.v1.DeleteDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.DeleteDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..5d7009cb67d8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteDatabaseRequestOrBuilder.java @@ -0,0 +1,90 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The current etag of the Database.
+   * If an etag is provided and does not match the current etag of the database,
+   * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+   * 
+ * + * string etag = 3; + * + * @return The etag. + */ + java.lang.String getEtag(); + + /** + * + * + *
+   * The current etag of the Database.
+   * If an etag is provided and does not match the current etag of the database,
+   * deletion will be blocked and a FAILED_PRECONDITION error will be returned.
+   * 
+ * + * string etag = 3; + * + * @return The bytes for etag. + */ + com.google.protobuf.ByteString getEtagBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequest.java new file mode 100644 index 000000000000..e2cac39e8f6f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteIndexRequest} + */ +@com.google.protobuf.Generated +public final class DeleteIndexRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteIndexRequest) + DeleteIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteIndexRequest"); + } + + // Use DeleteIndexRequest.newBuilder() to construct. + private DeleteIndexRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteIndexRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteIndexRequest.class, + com.google.firestore.admin.v1.DeleteIndexRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteIndexRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteIndexRequest other = + (com.google.firestore.admin.v1.DeleteIndexRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteIndexRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteIndexRequest) + com.google.firestore.admin.v1.DeleteIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteIndexRequest.class, + com.google.firestore.admin.v1.DeleteIndexRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteIndexRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteIndexRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteIndexRequest build() { + com.google.firestore.admin.v1.DeleteIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteIndexRequest buildPartial() { + com.google.firestore.admin.v1.DeleteIndexRequest result = + new com.google.firestore.admin.v1.DeleteIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteIndexRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteIndexRequest other) { + if (other == com.google.firestore.admin.v1.DeleteIndexRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteIndexRequest) + private static final com.google.firestore.admin.v1.DeleteIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteIndexRequest(); + } + + public static com.google.firestore.admin.v1.DeleteIndexRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteIndexRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequestOrBuilder.java new file mode 100644 index 000000000000..5cef3a8a5321 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteIndexRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequest.java new file mode 100644 index 000000000000..2aa0a6ae8c23 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DeleteUserCreds][google.firestore.admin.v1.FirestoreAdmin.DeleteUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class DeleteUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DeleteUserCredsRequest) + DeleteUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteUserCredsRequest"); + } + + // Use DeleteUserCredsRequest.newBuilder() to construct. + private DeleteUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteUserCredsRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteUserCredsRequest.class, + com.google.firestore.admin.v1.DeleteUserCredsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DeleteUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DeleteUserCredsRequest other = + (com.google.firestore.admin.v1.DeleteUserCredsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.DeleteUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DeleteUserCreds][google.firestore.admin.v1.FirestoreAdmin.DeleteUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DeleteUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DeleteUserCredsRequest) + com.google.firestore.admin.v1.DeleteUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DeleteUserCredsRequest.class, + com.google.firestore.admin.v1.DeleteUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DeleteUserCredsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DeleteUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteUserCredsRequest build() { + com.google.firestore.admin.v1.DeleteUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.DeleteUserCredsRequest result = + new com.google.firestore.admin.v1.DeleteUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DeleteUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DeleteUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.DeleteUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DeleteUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.DeleteUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DeleteUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DeleteUserCredsRequest) + private static final com.google.firestore.admin.v1.DeleteUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DeleteUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.DeleteUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DeleteUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..2912c95dcdde --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DeleteUserCredsRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DeleteUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DeleteUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequest.java new file mode 100644 index 000000000000..fd74f07fea36 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequest.java @@ -0,0 +1,620 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.DisableUserCreds][google.firestore.admin.v1.FirestoreAdmin.DisableUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DisableUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class DisableUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.DisableUserCredsRequest) + DisableUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DisableUserCredsRequest"); + } + + // Use DisableUserCredsRequest.newBuilder() to construct. + private DisableUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DisableUserCredsRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DisableUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DisableUserCredsRequest.class, + com.google.firestore.admin.v1.DisableUserCredsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.DisableUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.DisableUserCredsRequest other = + (com.google.firestore.admin.v1.DisableUserCredsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.DisableUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.DisableUserCreds][google.firestore.admin.v1.FirestoreAdmin.DisableUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.DisableUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.DisableUserCredsRequest) + com.google.firestore.admin.v1.DisableUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DisableUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.DisableUserCredsRequest.class, + com.google.firestore.admin.v1.DisableUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.DisableUserCredsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DisableUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.DisableUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.DisableUserCredsRequest build() { + com.google.firestore.admin.v1.DisableUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DisableUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.DisableUserCredsRequest result = + new com.google.firestore.admin.v1.DisableUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.DisableUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.DisableUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.DisableUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.DisableUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.DisableUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.DisableUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.DisableUserCredsRequest) + private static final com.google.firestore.admin.v1.DisableUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.DisableUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.DisableUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DisableUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.DisableUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..13c35c5c0581 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/DisableUserCredsRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface DisableUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.DisableUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequest.java new file mode 100644 index 000000000000..ad0b7b8b46e3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.EnableUserCreds][google.firestore.admin.v1.FirestoreAdmin.EnableUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.EnableUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class EnableUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.EnableUserCredsRequest) + EnableUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "EnableUserCredsRequest"); + } + + // Use EnableUserCredsRequest.newBuilder() to construct. + private EnableUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private EnableUserCredsRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_EnableUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.EnableUserCredsRequest.class, + com.google.firestore.admin.v1.EnableUserCredsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.EnableUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.EnableUserCredsRequest other = + (com.google.firestore.admin.v1.EnableUserCredsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.EnableUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.EnableUserCreds][google.firestore.admin.v1.FirestoreAdmin.EnableUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.EnableUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.EnableUserCredsRequest) + com.google.firestore.admin.v1.EnableUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_EnableUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.EnableUserCredsRequest.class, + com.google.firestore.admin.v1.EnableUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.EnableUserCredsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.EnableUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.EnableUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.EnableUserCredsRequest build() { + com.google.firestore.admin.v1.EnableUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.EnableUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.EnableUserCredsRequest result = + new com.google.firestore.admin.v1.EnableUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.EnableUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.EnableUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.EnableUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.EnableUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.EnableUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.EnableUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.EnableUserCredsRequest) + private static final com.google.firestore.admin.v1.EnableUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.EnableUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.EnableUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EnableUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.EnableUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..20b566f9602d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/EnableUserCredsRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface EnableUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.EnableUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadata.java new file mode 100644 index 000000000000..8a245f4d7c6e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadata.java @@ -0,0 +1,2780 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+ * results from
+ * [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsMetadata} + */ +@com.google.protobuf.Generated +public final class ExportDocumentsMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ExportDocumentsMetadata) + ExportDocumentsMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExportDocumentsMetadata"); + } + + // Use ExportDocumentsMetadata.newBuilder() to construct. + private ExportDocumentsMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExportDocumentsMetadata() { + operationState_ = 0; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + outputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsMetadata.class, + com.google.firestore.admin.v1.ExportDocumentsMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + + /** + * + * + *
+   * The state of the export operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+   * The state of the export operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int PROGRESS_DOCUMENTS_FIELD_NUMBER = 4; + private com.google.firestore.admin.v1.Progress progressDocuments_; + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + @java.lang.Override + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 5; + private com.google.firestore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int OUTPUT_URI_PREFIX_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+   * Where the documents are being exported to.
+   * 
+ * + * string output_uri_prefix = 7; + * + * @return The outputUriPrefix. + */ + @java.lang.Override + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Where the documents are being exported to.
+   * 
+ * + * string output_uri_prefix = 7; + * + * @return The bytes for outputUriPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 9; + private com.google.protobuf.Timestamp snapshotTime_; + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(5, getProgressBytes()); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, collectionIds_.getRaw(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, outputUriPrefix_); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 8, namespaceIds_.getRaw(i)); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(9, getSnapshotTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getProgressBytes()); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(7, outputUriPrefix_); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getSnapshotTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ExportDocumentsMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ExportDocumentsMetadata other = + (com.google.firestore.admin.v1.ExportDocumentsMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (hasProgressDocuments() != other.hasProgressDocuments()) return false; + if (hasProgressDocuments()) { + if (!getProgressDocuments().equals(other.getProgressDocuments())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getOutputUriPrefix().equals(other.getOutputUriPrefix())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + if (hasProgressDocuments()) { + hash = (37 * hash) + PROGRESS_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getProgressDocuments().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + hash = (37 * hash) + OUTPUT_URI_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getOutputUriPrefix().hashCode(); + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ExportDocumentsMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+   * results from
+   * [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ExportDocumentsMetadata) + com.google.firestore.admin.v1.ExportDocumentsMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsMetadata.class, + com.google.firestore.admin.v1.ExportDocumentsMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ExportDocumentsMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetProgressDocumentsFieldBuilder(); + internalGetProgressBytesFieldBuilder(); + internalGetSnapshotTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + outputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ExportDocumentsMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsMetadata build() { + com.google.firestore.admin.v1.ExportDocumentsMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsMetadata buildPartial() { + com.google.firestore.admin.v1.ExportDocumentsMetadata result = + new com.google.firestore.admin.v1.ExportDocumentsMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ExportDocumentsMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.progressDocuments_ = + progressDocumentsBuilder_ == null + ? progressDocuments_ + : progressDocumentsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.outputUriPrefix_ = outputUriPrefix_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ExportDocumentsMetadata) { + return mergeFrom((com.google.firestore.admin.v1.ExportDocumentsMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ExportDocumentsMetadata other) { + if (other == com.google.firestore.admin.v1.ExportDocumentsMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (other.hasProgressDocuments()) { + mergeProgressDocuments(other.getProgressDocuments()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000020; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.getOutputUriPrefix().isEmpty()) { + outputUriPrefix_ = other.outputUriPrefix_; + bitField0_ |= 0x00000040; + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000080; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage( + internalGetProgressDocumentsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 50 + case 58: + { + outputUriPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000040; + break; + } // case 58 + case 66: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 66 + case 74: + { + input.readMessage( + internalGetSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000100; + break; + } // case 74 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + + /** + * + * + *
+     * The state of the export operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+     * The state of the export operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the export operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The state of the export operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the export operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressDocuments_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressDocumentsBuilder_; + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + if (progressDocumentsBuilder_ == null) { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } else { + return progressDocumentsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressDocuments_ = value; + } else { + progressDocumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressDocumentsBuilder_ == null) { + progressDocuments_ = builderForValue.build(); + } else { + progressDocumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder mergeProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && progressDocuments_ != null + && progressDocuments_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressDocumentsBuilder().mergeFrom(value); + } else { + progressDocuments_ = value; + } + } else { + progressDocumentsBuilder_.mergeFrom(value); + } + if (progressDocuments_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder clearProgressDocuments() { + bitField0_ = (bitField0_ & ~0x00000008); + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressDocumentsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetProgressDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + if (progressDocumentsBuilder_ != null) { + return progressDocumentsBuilder_.getMessageOrBuilder(); + } else { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressDocumentsFieldBuilder() { + if (progressDocumentsBuilder_ == null) { + progressDocumentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressDocuments(), getParentForChildren(), isClean()); + progressDocuments_ = null; + } + return progressDocumentsBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + public com.google.firestore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder mergeProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000010); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000020; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being exported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+     * Where the documents are being exported to.
+     * 
+ * + * string output_uri_prefix = 7; + * + * @return The outputUriPrefix. + */ + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Where the documents are being exported to.
+     * 
+ * + * string output_uri_prefix = 7; + * + * @return The bytes for outputUriPrefix. + */ + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Where the documents are being exported to.
+     * 
+ * + * string output_uri_prefix = 7; + * + * @param value The outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUriPrefix_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Where the documents are being exported to.
+     * 
+ * + * string output_uri_prefix = 7; + * + * @return This builder for chaining. + */ + public Builder clearOutputUriPrefix() { + outputUriPrefix_ = getDefaultInstance().getOutputUriPrefix(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + + /** + * + * + *
+     * Where the documents are being exported to.
+     * 
+ * + * string output_uri_prefix = 7; + * + * @param value The bytes for outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUriPrefix_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000080; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being exported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000100) != 0); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000100; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000100); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000100; + onChanged(); + return internalGetSnapshotTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database that is being
+     * exported. If unspecified, there are no guarantees about the consistency of
+     * the documents being exported.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ExportDocumentsMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ExportDocumentsMetadata) + private static final com.google.firestore.admin.v1.ExportDocumentsMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ExportDocumentsMetadata(); + } + + public static com.google.firestore.admin.v1.ExportDocumentsMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportDocumentsMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadataOrBuilder.java new file mode 100644 index 000000000000..e40bd8d1edf5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsMetadataOrBuilder.java @@ -0,0 +1,382 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ExportDocumentsMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ExportDocumentsMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The state of the export operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + + /** + * + * + *
+   * The state of the export operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + boolean hasProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + com.google.firestore.admin.v1.Progress getProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + com.google.firestore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * Which collection IDs are being exported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * Where the documents are being exported to.
+   * 
+ * + * string output_uri_prefix = 7; + * + * @return The outputUriPrefix. + */ + java.lang.String getOutputUriPrefix(); + + /** + * + * + *
+   * Where the documents are being exported to.
+   * 
+ * + * string output_uri_prefix = 7; + * + * @return The bytes for outputUriPrefix. + */ + com.google.protobuf.ByteString getOutputUriPrefixBytes(); + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * Which namespace IDs are being exported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database that is being
+   * exported. If unspecified, there are no guarantees about the consistency of
+   * the documents being exported.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 9; + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequest.java new file mode 100644 index 000000000000..9688a5b044a0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequest.java @@ -0,0 +1,1880 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsRequest} + */ +@com.google.protobuf.Generated +public final class ExportDocumentsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ExportDocumentsRequest) + ExportDocumentsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExportDocumentsRequest"); + } + + // Use ExportDocumentsRequest.newBuilder() to construct. + private ExportDocumentsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExportDocumentsRequest() { + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + outputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ExportDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsRequest.class, + com.google.firestore.admin.v1.ExportDocumentsRequest.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. Database to export. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Database to export. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int OUTPUT_URI_PREFIX_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+   * The output URI. Currently only supports Google Cloud Storage URIs of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+   * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+   * Google Cloud Storage namespace path. When
+   * choosing a name, be sure to consider Google Cloud Storage naming
+   * guidelines: https://cloud.google.com/storage/docs/naming.
+   * If the URI is a bucket (without a namespace path), a prefix will be
+   * generated based on the start time.
+   * 
+ * + * string output_uri_prefix = 3; + * + * @return The outputUriPrefix. + */ + @java.lang.Override + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * The output URI. Currently only supports Google Cloud Storage URIs of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+   * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+   * Google Cloud Storage namespace path. When
+   * choosing a name, be sure to consider Google Cloud Storage naming
+   * guidelines: https://cloud.google.com/storage/docs/naming.
+   * If the URI is a bucket (without a namespace path), a prefix will be
+   * generated based on the start time.
+   * 
+ * + * string output_uri_prefix = 3; + * + * @return The bytes for outputUriPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 5; + private com.google.protobuf.Timestamp snapshotTime_; + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionIds_.getRaw(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, outputUriPrefix_); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, namespaceIds_.getRaw(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(5, getSnapshotTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, outputUriPrefix_); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getSnapshotTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ExportDocumentsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ExportDocumentsRequest other = + (com.google.firestore.admin.v1.ExportDocumentsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getOutputUriPrefix().equals(other.getOutputUriPrefix())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + hash = (37 * hash) + OUTPUT_URI_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getOutputUriPrefix().hashCode(); + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ExportDocumentsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ExportDocumentsRequest) + com.google.firestore.admin.v1.ExportDocumentsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ExportDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsRequest.class, + com.google.firestore.admin.v1.ExportDocumentsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ExportDocumentsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetSnapshotTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + outputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ExportDocumentsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsRequest build() { + com.google.firestore.admin.v1.ExportDocumentsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsRequest buildPartial() { + com.google.firestore.admin.v1.ExportDocumentsRequest result = + new com.google.firestore.admin.v1.ExportDocumentsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ExportDocumentsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.outputUriPrefix_ = outputUriPrefix_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000010) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ExportDocumentsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ExportDocumentsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ExportDocumentsRequest other) { + if (other == com.google.firestore.admin.v1.ExportDocumentsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000002; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.getOutputUriPrefix().isEmpty()) { + outputUriPrefix_ = other.outputUriPrefix_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000008; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 18 + case 26: + { + outputUriPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. Database to export. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Database to export. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Database to export. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to export. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to export. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to export. Unspecified means all
+     * collection groups. Each collection group in this list must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+     * The output URI. Currently only supports Google Cloud Storage URIs of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+     * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+     * Google Cloud Storage namespace path. When
+     * choosing a name, be sure to consider Google Cloud Storage naming
+     * guidelines: https://cloud.google.com/storage/docs/naming.
+     * If the URI is a bucket (without a namespace path), a prefix will be
+     * generated based on the start time.
+     * 
+ * + * string output_uri_prefix = 3; + * + * @return The outputUriPrefix. + */ + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The output URI. Currently only supports Google Cloud Storage URIs of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+     * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+     * Google Cloud Storage namespace path. When
+     * choosing a name, be sure to consider Google Cloud Storage naming
+     * guidelines: https://cloud.google.com/storage/docs/naming.
+     * If the URI is a bucket (without a namespace path), a prefix will be
+     * generated based on the start time.
+     * 
+ * + * string output_uri_prefix = 3; + * + * @return The bytes for outputUriPrefix. + */ + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The output URI. Currently only supports Google Cloud Storage URIs of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+     * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+     * Google Cloud Storage namespace path. When
+     * choosing a name, be sure to consider Google Cloud Storage naming
+     * guidelines: https://cloud.google.com/storage/docs/naming.
+     * If the URI is a bucket (without a namespace path), a prefix will be
+     * generated based on the start time.
+     * 
+ * + * string output_uri_prefix = 3; + * + * @param value The outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUriPrefix_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The output URI. Currently only supports Google Cloud Storage URIs of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+     * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+     * Google Cloud Storage namespace path. When
+     * choosing a name, be sure to consider Google Cloud Storage naming
+     * guidelines: https://cloud.google.com/storage/docs/naming.
+     * If the URI is a bucket (without a namespace path), a prefix will be
+     * generated based on the start time.
+     * 
+ * + * string output_uri_prefix = 3; + * + * @return This builder for chaining. + */ + public Builder clearOutputUriPrefix() { + outputUriPrefix_ = getDefaultInstance().getOutputUriPrefix(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * The output URI. Currently only supports Google Cloud Storage URIs of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+     * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+     * Google Cloud Storage namespace path. When
+     * choosing a name, be sure to consider Google Cloud Storage naming
+     * guidelines: https://cloud.google.com/storage/docs/naming.
+     * If the URI is a bucket (without a namespace path), a prefix will be
+     * generated based on the start time.
+     * 
+ * + * string output_uri_prefix = 3; + * + * @param value The bytes for outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUriPrefix_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000008; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000010); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetSnapshotTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + + /** + * + * + *
+     * The timestamp that corresponds to the version of the database to be
+     * exported. The timestamp must be in the past, rounded to the minute and not
+     * older than
+     * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+     * If specified, then the exported documents will represent a consistent view
+     * of the database at the provided time. Otherwise, there are no guarantees
+     * about the consistency of the exported documents.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ExportDocumentsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ExportDocumentsRequest) + private static final com.google.firestore.admin.v1.ExportDocumentsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ExportDocumentsRequest(); + } + + public static com.google.firestore.admin.v1.ExportDocumentsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportDocumentsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequestOrBuilder.java new file mode 100644 index 000000000000..fb55c9ec8ec0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsRequestOrBuilder.java @@ -0,0 +1,287 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ExportDocumentsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ExportDocumentsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Database to export. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. Database to export. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * IDs of the collection groups to export. Unspecified means all
+   * collection groups. Each collection group in this list must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * The output URI. Currently only supports Google Cloud Storage URIs of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+   * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+   * Google Cloud Storage namespace path. When
+   * choosing a name, be sure to consider Google Cloud Storage naming
+   * guidelines: https://cloud.google.com/storage/docs/naming.
+   * If the URI is a bucket (without a namespace path), a prefix will be
+   * generated based on the start time.
+   * 
+ * + * string output_uri_prefix = 3; + * + * @return The outputUriPrefix. + */ + java.lang.String getOutputUriPrefix(); + + /** + * + * + *
+   * The output URI. Currently only supports Google Cloud Storage URIs of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name
+   * of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional
+   * Google Cloud Storage namespace path. When
+   * choosing a name, be sure to consider Google Cloud Storage naming
+   * guidelines: https://cloud.google.com/storage/docs/naming.
+   * If the URI is a bucket (without a namespace path), a prefix will be
+   * generated based on the start time.
+   * 
+ * + * string output_uri_prefix = 3; + * + * @return The bytes for outputUriPrefix. + */ + com.google.protobuf.ByteString getOutputUriPrefixBytes(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + + /** + * + * + *
+   * The timestamp that corresponds to the version of the database to be
+   * exported. The timestamp must be in the past, rounded to the minute and not
+   * older than
+   * [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time].
+   * If specified, then the exported documents will represent a consistent view
+   * of the database at the provided time. Otherwise, there are no guarantees
+   * about the consistency of the exported documents.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 5; + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponse.java new file mode 100644 index 000000000000..630a78fa75e7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponse.java @@ -0,0 +1,613 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Returned in the [google.longrunning.Operation][google.longrunning.Operation]
+ * response field.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsResponse} + */ +@com.google.protobuf.Generated +public final class ExportDocumentsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ExportDocumentsResponse) + ExportDocumentsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExportDocumentsResponse"); + } + + // Use ExportDocumentsResponse.newBuilder() to construct. + private ExportDocumentsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExportDocumentsResponse() { + outputUriPrefix_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsResponse.class, + com.google.firestore.admin.v1.ExportDocumentsResponse.Builder.class); + } + + public static final int OUTPUT_URI_PREFIX_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+   * Location of the output files. This can be used to begin an import
+   * into Cloud Firestore (this project or another project) after the operation
+   * completes successfully.
+   * 
+ * + * string output_uri_prefix = 1; + * + * @return The outputUriPrefix. + */ + @java.lang.Override + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Location of the output files. This can be used to begin an import
+   * into Cloud Firestore (this project or another project) after the operation
+   * completes successfully.
+   * 
+ * + * string output_uri_prefix = 1; + * + * @return The bytes for outputUriPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, outputUriPrefix_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(outputUriPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, outputUriPrefix_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ExportDocumentsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ExportDocumentsResponse other = + (com.google.firestore.admin.v1.ExportDocumentsResponse) obj; + + if (!getOutputUriPrefix().equals(other.getOutputUriPrefix())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OUTPUT_URI_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getOutputUriPrefix().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ExportDocumentsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Returned in the [google.longrunning.Operation][google.longrunning.Operation]
+   * response field.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ExportDocumentsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ExportDocumentsResponse) + com.google.firestore.admin.v1.ExportDocumentsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ExportDocumentsResponse.class, + com.google.firestore.admin.v1.ExportDocumentsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ExportDocumentsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + outputUriPrefix_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ExportDocumentsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsResponse build() { + com.google.firestore.admin.v1.ExportDocumentsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsResponse buildPartial() { + com.google.firestore.admin.v1.ExportDocumentsResponse result = + new com.google.firestore.admin.v1.ExportDocumentsResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ExportDocumentsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.outputUriPrefix_ = outputUriPrefix_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ExportDocumentsResponse) { + return mergeFrom((com.google.firestore.admin.v1.ExportDocumentsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ExportDocumentsResponse other) { + if (other == com.google.firestore.admin.v1.ExportDocumentsResponse.getDefaultInstance()) + return this; + if (!other.getOutputUriPrefix().isEmpty()) { + outputUriPrefix_ = other.outputUriPrefix_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + outputUriPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object outputUriPrefix_ = ""; + + /** + * + * + *
+     * Location of the output files. This can be used to begin an import
+     * into Cloud Firestore (this project or another project) after the operation
+     * completes successfully.
+     * 
+ * + * string output_uri_prefix = 1; + * + * @return The outputUriPrefix. + */ + public java.lang.String getOutputUriPrefix() { + java.lang.Object ref = outputUriPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUriPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Location of the output files. This can be used to begin an import
+     * into Cloud Firestore (this project or another project) after the operation
+     * completes successfully.
+     * 
+ * + * string output_uri_prefix = 1; + * + * @return The bytes for outputUriPrefix. + */ + public com.google.protobuf.ByteString getOutputUriPrefixBytes() { + java.lang.Object ref = outputUriPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Location of the output files. This can be used to begin an import
+     * into Cloud Firestore (this project or another project) after the operation
+     * completes successfully.
+     * 
+ * + * string output_uri_prefix = 1; + * + * @param value The outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUriPrefix_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the output files. This can be used to begin an import
+     * into Cloud Firestore (this project or another project) after the operation
+     * completes successfully.
+     * 
+ * + * string output_uri_prefix = 1; + * + * @return This builder for chaining. + */ + public Builder clearOutputUriPrefix() { + outputUriPrefix_ = getDefaultInstance().getOutputUriPrefix(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the output files. This can be used to begin an import
+     * into Cloud Firestore (this project or another project) after the operation
+     * completes successfully.
+     * 
+ * + * string output_uri_prefix = 1; + * + * @param value The bytes for outputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUriPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUriPrefix_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ExportDocumentsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ExportDocumentsResponse) + private static final com.google.firestore.admin.v1.ExportDocumentsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ExportDocumentsResponse(); + } + + public static com.google.firestore.admin.v1.ExportDocumentsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportDocumentsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ExportDocumentsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponseOrBuilder.java new file mode 100644 index 000000000000..c3f353bba888 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ExportDocumentsResponseOrBuilder.java @@ -0,0 +1,58 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ExportDocumentsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ExportDocumentsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Location of the output files. This can be used to begin an import
+   * into Cloud Firestore (this project or another project) after the operation
+   * completes successfully.
+   * 
+ * + * string output_uri_prefix = 1; + * + * @return The outputUriPrefix. + */ + java.lang.String getOutputUriPrefix(); + + /** + * + * + *
+   * Location of the output files. This can be used to begin an import
+   * into Cloud Firestore (this project or another project) after the operation
+   * completes successfully.
+   * 
+ * + * string output_uri_prefix = 1; + * + * @return The bytes for outputUriPrefix. + */ + com.google.protobuf.ByteString getOutputUriPrefixBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java new file mode 100644 index 000000000000..74cde456c46a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Field.java @@ -0,0 +1,3673 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/field.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Represents a single field in the database.
+ *
+ * Fields are grouped by their "Collection Group", which represent all
+ * collections in the database with the same ID.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field} + */ +@com.google.protobuf.Generated +public final class Field extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Field) + FieldOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Field"); + } + + // Use Field.newBuilder() to construct. + private Field(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Field() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.class, + com.google.firestore.admin.v1.Field.Builder.class); + } + + public interface IndexConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Field.IndexConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + java.util.List getIndexesList(); + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + com.google.firestore.admin.v1.Index getIndexes(int index); + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + int getIndexesCount(); + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + java.util.List + getIndexesOrBuilderList(); + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index); + + /** + * + * + *
+     * Output only. When true, the `Field`'s index configuration is set from the
+     * configuration specified by the `ancestor_field`.
+     * When false, the `Field`'s index configuration is defined explicitly.
+     * 
+ * + * bool uses_ancestor_config = 2; + * + * @return The usesAncestorConfig. + */ + boolean getUsesAncestorConfig(); + + /** + * + * + *
+     * Output only. Specifies the resource name of the `Field` from which this
+     * field's index configuration is set (when `uses_ancestor_config` is true),
+     * or from which it *would* be set if this field had no index configuration
+     * (when `uses_ancestor_config` is false).
+     * 
+ * + * string ancestor_field = 3; + * + * @return The ancestorField. + */ + java.lang.String getAncestorField(); + + /** + * + * + *
+     * Output only. Specifies the resource name of the `Field` from which this
+     * field's index configuration is set (when `uses_ancestor_config` is true),
+     * or from which it *would* be set if this field had no index configuration
+     * (when `uses_ancestor_config` is false).
+     * 
+ * + * string ancestor_field = 3; + * + * @return The bytes for ancestorField. + */ + com.google.protobuf.ByteString getAncestorFieldBytes(); + + /** + * + * + *
+     * Output only
+     * When true, the `Field`'s index configuration is in the process of being
+     * reverted. Once complete, the index config will transition to the same
+     * state as the field specified by `ancestor_field`, at which point
+     * `uses_ancestor_config` will be `true` and `reverting` will be `false`.
+     * 
+ * + * bool reverting = 4; + * + * @return The reverting. + */ + boolean getReverting(); + } + + /** + * + * + *
+   * The index configuration for this field.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field.IndexConfig} + */ + public static final class IndexConfig extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Field.IndexConfig) + IndexConfigOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "IndexConfig"); + } + + // Use IndexConfig.newBuilder() to construct. + private IndexConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private IndexConfig() { + indexes_ = java.util.Collections.emptyList(); + ancestorField_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_IndexConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.IndexConfig.class, + com.google.firestore.admin.v1.Field.IndexConfig.Builder.class); + } + + public static final int INDEXES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List indexes_; + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List getIndexesList() { + return indexes_; + } + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List + getIndexesOrBuilderList() { + return indexes_; + } + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public int getIndexesCount() { + return indexes_.size(); + } + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index getIndexes(int index) { + return indexes_.get(index); + } + + /** + * + * + *
+     * The indexes supported for this field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index) { + return indexes_.get(index); + } + + public static final int USES_ANCESTOR_CONFIG_FIELD_NUMBER = 2; + private boolean usesAncestorConfig_ = false; + + /** + * + * + *
+     * Output only. When true, the `Field`'s index configuration is set from the
+     * configuration specified by the `ancestor_field`.
+     * When false, the `Field`'s index configuration is defined explicitly.
+     * 
+ * + * bool uses_ancestor_config = 2; + * + * @return The usesAncestorConfig. + */ + @java.lang.Override + public boolean getUsesAncestorConfig() { + return usesAncestorConfig_; + } + + public static final int ANCESTOR_FIELD_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object ancestorField_ = ""; + + /** + * + * + *
+     * Output only. Specifies the resource name of the `Field` from which this
+     * field's index configuration is set (when `uses_ancestor_config` is true),
+     * or from which it *would* be set if this field had no index configuration
+     * (when `uses_ancestor_config` is false).
+     * 
+ * + * string ancestor_field = 3; + * + * @return The ancestorField. + */ + @java.lang.Override + public java.lang.String getAncestorField() { + java.lang.Object ref = ancestorField_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ancestorField_ = s; + return s; + } + } + + /** + * + * + *
+     * Output only. Specifies the resource name of the `Field` from which this
+     * field's index configuration is set (when `uses_ancestor_config` is true),
+     * or from which it *would* be set if this field had no index configuration
+     * (when `uses_ancestor_config` is false).
+     * 
+ * + * string ancestor_field = 3; + * + * @return The bytes for ancestorField. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAncestorFieldBytes() { + java.lang.Object ref = ancestorField_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + ancestorField_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REVERTING_FIELD_NUMBER = 4; + private boolean reverting_ = false; + + /** + * + * + *
+     * Output only
+     * When true, the `Field`'s index configuration is in the process of being
+     * reverted. Once complete, the index config will transition to the same
+     * state as the field specified by `ancestor_field`, at which point
+     * `uses_ancestor_config` will be `true` and `reverting` will be `false`.
+     * 
+ * + * bool reverting = 4; + * + * @return The reverting. + */ + @java.lang.Override + public boolean getReverting() { + return reverting_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < indexes_.size(); i++) { + output.writeMessage(1, indexes_.get(i)); + } + if (usesAncestorConfig_ != false) { + output.writeBool(2, usesAncestorConfig_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(ancestorField_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, ancestorField_); + } + if (reverting_ != false) { + output.writeBool(4, reverting_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < indexes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, indexes_.get(i)); + } + if (usesAncestorConfig_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, usesAncestorConfig_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(ancestorField_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, ancestorField_); + } + if (reverting_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, reverting_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Field.IndexConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Field.IndexConfig other = + (com.google.firestore.admin.v1.Field.IndexConfig) obj; + + if (!getIndexesList().equals(other.getIndexesList())) return false; + if (getUsesAncestorConfig() != other.getUsesAncestorConfig()) return false; + if (!getAncestorField().equals(other.getAncestorField())) return false; + if (getReverting() != other.getReverting()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIndexesCount() > 0) { + hash = (37 * hash) + INDEXES_FIELD_NUMBER; + hash = (53 * hash) + getIndexesList().hashCode(); + } + hash = (37 * hash) + USES_ANCESTOR_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getUsesAncestorConfig()); + hash = (37 * hash) + ANCESTOR_FIELD_FIELD_NUMBER; + hash = (53 * hash) + getAncestorField().hashCode(); + hash = (37 * hash) + REVERTING_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getReverting()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Field.IndexConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * The index configuration for this field.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field.IndexConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Field.IndexConfig) + com.google.firestore.admin.v1.Field.IndexConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_IndexConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.IndexConfig.class, + com.google.firestore.admin.v1.Field.IndexConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Field.IndexConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (indexesBuilder_ == null) { + indexes_ = java.util.Collections.emptyList(); + } else { + indexes_ = null; + indexesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + usesAncestorConfig_ = false; + ancestorField_ = ""; + reverting_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig build() { + com.google.firestore.admin.v1.Field.IndexConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig buildPartial() { + com.google.firestore.admin.v1.Field.IndexConfig result = + new com.google.firestore.admin.v1.Field.IndexConfig(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.Field.IndexConfig result) { + if (indexesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + indexes_ = java.util.Collections.unmodifiableList(indexes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.indexes_ = indexes_; + } else { + result.indexes_ = indexesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.Field.IndexConfig result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.usesAncestorConfig_ = usesAncestorConfig_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.ancestorField_ = ancestorField_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.reverting_ = reverting_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Field.IndexConfig) { + return mergeFrom((com.google.firestore.admin.v1.Field.IndexConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Field.IndexConfig other) { + if (other == com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance()) + return this; + if (indexesBuilder_ == null) { + if (!other.indexes_.isEmpty()) { + if (indexes_.isEmpty()) { + indexes_ = other.indexes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIndexesIsMutable(); + indexes_.addAll(other.indexes_); + } + onChanged(); + } + } else { + if (!other.indexes_.isEmpty()) { + if (indexesBuilder_.isEmpty()) { + indexesBuilder_.dispose(); + indexesBuilder_ = null; + indexes_ = other.indexes_; + bitField0_ = (bitField0_ & ~0x00000001); + indexesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetIndexesFieldBuilder() + : null; + } else { + indexesBuilder_.addAllMessages(other.indexes_); + } + } + } + if (other.getUsesAncestorConfig() != false) { + setUsesAncestorConfig(other.getUsesAncestorConfig()); + } + if (!other.getAncestorField().isEmpty()) { + ancestorField_ = other.ancestorField_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.getReverting() != false) { + setReverting(other.getReverting()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Index m = + input.readMessage( + com.google.firestore.admin.v1.Index.parser(), extensionRegistry); + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(m); + } else { + indexesBuilder_.addMessage(m); + } + break; + } // case 10 + case 16: + { + usesAncestorConfig_ = input.readBool(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + ancestorField_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + reverting_ = input.readBool(); + bitField0_ |= 0x00000008; + break; + } // case 32 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List indexes_ = + java.util.Collections.emptyList(); + + private void ensureIndexesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + indexes_ = new java.util.ArrayList(indexes_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + indexesBuilder_; + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List getIndexesList() { + if (indexesBuilder_ == null) { + return java.util.Collections.unmodifiableList(indexes_); + } else { + return indexesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public int getIndexesCount() { + if (indexesBuilder_ == null) { + return indexes_.size(); + } else { + return indexesBuilder_.getCount(); + } + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index getIndexes(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes(int index, com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.set(index, value); + onChanged(); + } else { + indexesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes( + int index, com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.set(index, builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.add(value); + onChanged(); + } else { + indexesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(int index, com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.add(index, value); + onChanged(); + } else { + indexesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes( + int index, com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(index, builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addAllIndexes( + java.lang.Iterable values) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, indexes_); + onChanged(); + } else { + indexesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder clearIndexes() { + if (indexesBuilder_ == null) { + indexes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + indexesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder removeIndexes(int index) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.remove(index); + onChanged(); + } else { + indexesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder getIndexesBuilder(int index) { + return internalGetIndexesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List + getIndexesOrBuilderList() { + if (indexesBuilder_ != null) { + return indexesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(indexes_); + } + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder addIndexesBuilder() { + return internalGetIndexesFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder addIndexesBuilder(int index) { + return internalGetIndexesFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+       * The indexes supported for this field.
+       * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List getIndexesBuilderList() { + return internalGetIndexesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + internalGetIndexesFieldBuilder() { + if (indexesBuilder_ == null) { + indexesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder>( + indexes_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexes_ = null; + } + return indexesBuilder_; + } + + private boolean usesAncestorConfig_; + + /** + * + * + *
+       * Output only. When true, the `Field`'s index configuration is set from the
+       * configuration specified by the `ancestor_field`.
+       * When false, the `Field`'s index configuration is defined explicitly.
+       * 
+ * + * bool uses_ancestor_config = 2; + * + * @return The usesAncestorConfig. + */ + @java.lang.Override + public boolean getUsesAncestorConfig() { + return usesAncestorConfig_; + } + + /** + * + * + *
+       * Output only. When true, the `Field`'s index configuration is set from the
+       * configuration specified by the `ancestor_field`.
+       * When false, the `Field`'s index configuration is defined explicitly.
+       * 
+ * + * bool uses_ancestor_config = 2; + * + * @param value The usesAncestorConfig to set. + * @return This builder for chaining. + */ + public Builder setUsesAncestorConfig(boolean value) { + + usesAncestorConfig_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. When true, the `Field`'s index configuration is set from the
+       * configuration specified by the `ancestor_field`.
+       * When false, the `Field`'s index configuration is defined explicitly.
+       * 
+ * + * bool uses_ancestor_config = 2; + * + * @return This builder for chaining. + */ + public Builder clearUsesAncestorConfig() { + bitField0_ = (bitField0_ & ~0x00000002); + usesAncestorConfig_ = false; + onChanged(); + return this; + } + + private java.lang.Object ancestorField_ = ""; + + /** + * + * + *
+       * Output only. Specifies the resource name of the `Field` from which this
+       * field's index configuration is set (when `uses_ancestor_config` is true),
+       * or from which it *would* be set if this field had no index configuration
+       * (when `uses_ancestor_config` is false).
+       * 
+ * + * string ancestor_field = 3; + * + * @return The ancestorField. + */ + public java.lang.String getAncestorField() { + java.lang.Object ref = ancestorField_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + ancestorField_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Output only. Specifies the resource name of the `Field` from which this
+       * field's index configuration is set (when `uses_ancestor_config` is true),
+       * or from which it *would* be set if this field had no index configuration
+       * (when `uses_ancestor_config` is false).
+       * 
+ * + * string ancestor_field = 3; + * + * @return The bytes for ancestorField. + */ + public com.google.protobuf.ByteString getAncestorFieldBytes() { + java.lang.Object ref = ancestorField_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + ancestorField_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Output only. Specifies the resource name of the `Field` from which this
+       * field's index configuration is set (when `uses_ancestor_config` is true),
+       * or from which it *would* be set if this field had no index configuration
+       * (when `uses_ancestor_config` is false).
+       * 
+ * + * string ancestor_field = 3; + * + * @param value The ancestorField to set. + * @return This builder for chaining. + */ + public Builder setAncestorField(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ancestorField_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Specifies the resource name of the `Field` from which this
+       * field's index configuration is set (when `uses_ancestor_config` is true),
+       * or from which it *would* be set if this field had no index configuration
+       * (when `uses_ancestor_config` is false).
+       * 
+ * + * string ancestor_field = 3; + * + * @return This builder for chaining. + */ + public Builder clearAncestorField() { + ancestorField_ = getDefaultInstance().getAncestorField(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Specifies the resource name of the `Field` from which this
+       * field's index configuration is set (when `uses_ancestor_config` is true),
+       * or from which it *would* be set if this field had no index configuration
+       * (when `uses_ancestor_config` is false).
+       * 
+ * + * string ancestor_field = 3; + * + * @param value The bytes for ancestorField to set. + * @return This builder for chaining. + */ + public Builder setAncestorFieldBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ancestorField_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private boolean reverting_; + + /** + * + * + *
+       * Output only
+       * When true, the `Field`'s index configuration is in the process of being
+       * reverted. Once complete, the index config will transition to the same
+       * state as the field specified by `ancestor_field`, at which point
+       * `uses_ancestor_config` will be `true` and `reverting` will be `false`.
+       * 
+ * + * bool reverting = 4; + * + * @return The reverting. + */ + @java.lang.Override + public boolean getReverting() { + return reverting_; + } + + /** + * + * + *
+       * Output only
+       * When true, the `Field`'s index configuration is in the process of being
+       * reverted. Once complete, the index config will transition to the same
+       * state as the field specified by `ancestor_field`, at which point
+       * `uses_ancestor_config` will be `true` and `reverting` will be `false`.
+       * 
+ * + * bool reverting = 4; + * + * @param value The reverting to set. + * @return This builder for chaining. + */ + public Builder setReverting(boolean value) { + + reverting_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only
+       * When true, the `Field`'s index configuration is in the process of being
+       * reverted. Once complete, the index config will transition to the same
+       * state as the field specified by `ancestor_field`, at which point
+       * `uses_ancestor_config` will be `true` and `reverting` will be `false`.
+       * 
+ * + * bool reverting = 4; + * + * @return This builder for chaining. + */ + public Builder clearReverting() { + bitField0_ = (bitField0_ & ~0x00000008); + reverting_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Field.IndexConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Field.IndexConfig) + private static final com.google.firestore.admin.v1.Field.IndexConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Field.IndexConfig(); + } + + public static com.google.firestore.admin.v1.Field.IndexConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface TtlConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Field.TtlConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.firestore.admin.v1.Field.TtlConfig.State getState(); + } + + /** + * + * + *
+   * The TTL (time-to-live) configuration for documents that have this `Field`
+   * set.
+   *
+   * Storing a timestamp value into a TTL-enabled field will be treated as
+   * the document's absolute expiration time. For Enterprise edition databases,
+   * the timestamp value may also be stored in an array value in the
+   * TTL-enabled field.
+   *
+   * Timestamp values in the past indicate that the document is eligible for
+   * immediate expiration. Using any other data type or leaving the field absent
+   * will disable expiration for the individual document.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field.TtlConfig} + */ + public static final class TtlConfig extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Field.TtlConfig) + TtlConfigOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "TtlConfig"); + } + + // Use TtlConfig.newBuilder() to construct. + private TtlConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private TtlConfig() { + state_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.TtlConfig.class, + com.google.firestore.admin.v1.Field.TtlConfig.Builder.class); + } + + /** + * + * + *
+     * The state of applying the TTL configuration to all documents.
+     * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Field.TtlConfig.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The state is unspecified or unknown.
+       * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+       * The TTL is being applied. There is an active long-running operation to
+       * track the change. Newly written documents will have TTLs applied as
+       * requested. Requested TTLs on existing documents are still being
+       * processed. When TTLs on all existing documents have been processed, the
+       * state will move to 'ACTIVE'.
+       * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+       * The TTL is active for all documents.
+       * 
+ * + * ACTIVE = 2; + */ + ACTIVE(2), + /** + * + * + *
+       * The TTL configuration could not be enabled for all existing documents.
+       * Newly written documents will continue to have their TTL applied.
+       * The LRO returned when last attempting to enable TTL for this `Field`
+       * has failed, and may have more details.
+       * 
+ * + * NEEDS_REPAIR = 3; + */ + NEEDS_REPAIR(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "State"); + } + + /** + * + * + *
+       * The state is unspecified or unknown.
+       * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The TTL is being applied. There is an active long-running operation to
+       * track the change. Newly written documents will have TTLs applied as
+       * requested. Requested TTLs on existing documents are still being
+       * processed. When TTLs on all existing documents have been processed, the
+       * state will move to 'ACTIVE'.
+       * 
+ * + * CREATING = 1; + */ + public static final int CREATING_VALUE = 1; + + /** + * + * + *
+       * The TTL is active for all documents.
+       * 
+ * + * ACTIVE = 2; + */ + public static final int ACTIVE_VALUE = 2; + + /** + * + * + *
+       * The TTL configuration could not be enabled for all existing documents.
+       * Newly written documents will continue to have their TTL applied.
+       * The LRO returned when last attempting to enable TTL for this `Field`
+       * has failed, and may have more details.
+       * 
+ * + * NEEDS_REPAIR = 3; + */ + public static final int NEEDS_REPAIR_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return CREATING; + case 2: + return ACTIVE; + case 3: + return NEEDS_REPAIR; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Field.TtlConfig.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Field.TtlConfig.State) + } + + public static final int STATE_FIELD_NUMBER = 1; + private int state_ = 0; + + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * Output only. The state of the TTL configuration.
+     * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig.State getState() { + com.google.firestore.admin.v1.Field.TtlConfig.State result = + com.google.firestore.admin.v1.Field.TtlConfig.State.forNumber(state_); + return result == null + ? com.google.firestore.admin.v1.Field.TtlConfig.State.UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (state_ + != com.google.firestore.admin.v1.Field.TtlConfig.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(1, state_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (state_ + != com.google.firestore.admin.v1.Field.TtlConfig.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, state_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Field.TtlConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Field.TtlConfig other = + (com.google.firestore.admin.v1.Field.TtlConfig) obj; + + if (state_ != other.state_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Field.TtlConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * The TTL (time-to-live) configuration for documents that have this `Field`
+     * set.
+     *
+     * Storing a timestamp value into a TTL-enabled field will be treated as
+     * the document's absolute expiration time. For Enterprise edition databases,
+     * the timestamp value may also be stored in an array value in the
+     * TTL-enabled field.
+     *
+     * Timestamp values in the past indicate that the document is eligible for
+     * immediate expiration. Using any other data type or leaving the field absent
+     * will disable expiration for the individual document.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field.TtlConfig} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Field.TtlConfig) + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.TtlConfig.class, + com.google.firestore.admin.v1.Field.TtlConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Field.TtlConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + state_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig build() { + com.google.firestore.admin.v1.Field.TtlConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig buildPartial() { + com.google.firestore.admin.v1.Field.TtlConfig result = + new com.google.firestore.admin.v1.Field.TtlConfig(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Field.TtlConfig result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.state_ = state_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Field.TtlConfig) { + return mergeFrom((com.google.firestore.admin.v1.Field.TtlConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Field.TtlConfig other) { + if (other == com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance()) + return this; + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int state_ = 0; + + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig.State getState() { + com.google.firestore.admin.v1.Field.TtlConfig.State result = + com.google.firestore.admin.v1.Field.TtlConfig.State.forNumber(state_); + return result == null + ? com.google.firestore.admin.v1.Field.TtlConfig.State.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.Field.TtlConfig.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. The state of the TTL configuration.
+       * 
+ * + * + * .google.firestore.admin.v1.Field.TtlConfig.State state = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000001); + state_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Field.TtlConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Field.TtlConfig) + private static final com.google.firestore.admin.v1.Field.TtlConfig DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Field.TtlConfig(); + } + + public static com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TtlConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A field name of the form:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   *
+   * A field path can be a simple field name, e.g. `address` or a path to fields
+   * within `map_value` , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   *
+   * Field paths can be quoted using `` ` `` (backtick). The only character that
+   * must be escaped within a quoted field path is the backtick character
+   * itself, escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   *
+   * Examples:
+   * `` `address.city` `` represents a field named `address.city`, not the map
+   * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+   * not any field.
+   *
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A field name of the form:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   *
+   * A field path can be a simple field name, e.g. `address` or a path to fields
+   * within `map_value` , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   *
+   * Field paths can be quoted using `` ` `` (backtick). The only character that
+   * must be escaped within a quoted field path is the backtick character
+   * itself, escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   *
+   * Examples:
+   * `` `address.city` `` represents a field named `address.city`, not the map
+   * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+   * not any field.
+   *
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_CONFIG_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.Field.IndexConfig indexConfig_; + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return Whether the indexConfig field is set. + */ + @java.lang.Override + public boolean hasIndexConfig() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return The indexConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfig getIndexConfig() { + return indexConfig_ == null + ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() + : indexConfig_; + } + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder() { + return indexConfig_ == null + ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() + : indexConfig_; + } + + public static final int TTL_CONFIG_FIELD_NUMBER = 3; + private com.google.firestore.admin.v1.Field.TtlConfig ttlConfig_; + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + @java.lang.Override + public boolean hasTtlConfig() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig() { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder() { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getIndexConfig()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getTtlConfig()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndexConfig()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getTtlConfig()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Field)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Field other = (com.google.firestore.admin.v1.Field) obj; + + if (!getName().equals(other.getName())) return false; + if (hasIndexConfig() != other.hasIndexConfig()) return false; + if (hasIndexConfig()) { + if (!getIndexConfig().equals(other.getIndexConfig())) return false; + } + if (hasTtlConfig() != other.hasTtlConfig()) return false; + if (hasTtlConfig()) { + if (!getTtlConfig().equals(other.getTtlConfig())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasIndexConfig()) { + hash = (37 * hash) + INDEX_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getIndexConfig().hashCode(); + } + if (hasTtlConfig()) { + hash = (37 * hash) + TTL_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getTtlConfig().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Field parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Field parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Field prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Represents a single field in the database.
+   *
+   * Fields are grouped by their "Collection Group", which represent all
+   * collections in the database with the same ID.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Field} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Field) + com.google.firestore.admin.v1.FieldOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Field.class, + com.google.firestore.admin.v1.Field.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Field.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetIndexConfigFieldBuilder(); + internalGetTtlConfigFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + indexConfig_ = null; + if (indexConfigBuilder_ != null) { + indexConfigBuilder_.dispose(); + indexConfigBuilder_ = null; + } + ttlConfig_ = null; + if (ttlConfigBuilder_ != null) { + ttlConfigBuilder_.dispose(); + ttlConfigBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FieldProto + .internal_static_google_firestore_admin_v1_Field_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Field.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field build() { + com.google.firestore.admin.v1.Field result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field buildPartial() { + com.google.firestore.admin.v1.Field result = new com.google.firestore.admin.v1.Field(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Field result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.indexConfig_ = + indexConfigBuilder_ == null ? indexConfig_ : indexConfigBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.ttlConfig_ = ttlConfigBuilder_ == null ? ttlConfig_ : ttlConfigBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Field) { + return mergeFrom((com.google.firestore.admin.v1.Field) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Field other) { + if (other == com.google.firestore.admin.v1.Field.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasIndexConfig()) { + mergeIndexConfig(other.getIndexConfig()); + } + if (other.hasTtlConfig()) { + mergeTtlConfig(other.getTtlConfig()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetIndexConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetTtlConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A field name of the form:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     *
+     * A field path can be a simple field name, e.g. `address` or a path to fields
+     * within `map_value` , e.g. `address.city`,
+     * or a special field path. The only valid special field is `*`, which
+     * represents any field.
+     *
+     * Field paths can be quoted using `` ` `` (backtick). The only character that
+     * must be escaped within a quoted field path is the backtick character
+     * itself, escaped using a backslash. Special characters in field paths that
+     * must be quoted include: `*`, `.`,
+     * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+     *
+     * Examples:
+     * `` `address.city` `` represents a field named `address.city`, not the map
+     * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+     * not any field.
+     *
+     * A special `Field` contains the default indexing settings for all fields.
+     * This field's resource name is:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+     * Indexes defined on this `Field` will be applied to all fields which do not
+     * have their own `Field` index configuration.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A field name of the form:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     *
+     * A field path can be a simple field name, e.g. `address` or a path to fields
+     * within `map_value` , e.g. `address.city`,
+     * or a special field path. The only valid special field is `*`, which
+     * represents any field.
+     *
+     * Field paths can be quoted using `` ` `` (backtick). The only character that
+     * must be escaped within a quoted field path is the backtick character
+     * itself, escaped using a backslash. Special characters in field paths that
+     * must be quoted include: `*`, `.`,
+     * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+     *
+     * Examples:
+     * `` `address.city` `` represents a field named `address.city`, not the map
+     * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+     * not any field.
+     *
+     * A special `Field` contains the default indexing settings for all fields.
+     * This field's resource name is:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+     * Indexes defined on this `Field` will be applied to all fields which do not
+     * have their own `Field` index configuration.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A field name of the form:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     *
+     * A field path can be a simple field name, e.g. `address` or a path to fields
+     * within `map_value` , e.g. `address.city`,
+     * or a special field path. The only valid special field is `*`, which
+     * represents any field.
+     *
+     * Field paths can be quoted using `` ` `` (backtick). The only character that
+     * must be escaped within a quoted field path is the backtick character
+     * itself, escaped using a backslash. Special characters in field paths that
+     * must be quoted include: `*`, `.`,
+     * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+     *
+     * Examples:
+     * `` `address.city` `` represents a field named `address.city`, not the map
+     * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+     * not any field.
+     *
+     * A special `Field` contains the default indexing settings for all fields.
+     * This field's resource name is:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+     * Indexes defined on this `Field` will be applied to all fields which do not
+     * have their own `Field` index configuration.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A field name of the form:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     *
+     * A field path can be a simple field name, e.g. `address` or a path to fields
+     * within `map_value` , e.g. `address.city`,
+     * or a special field path. The only valid special field is `*`, which
+     * represents any field.
+     *
+     * Field paths can be quoted using `` ` `` (backtick). The only character that
+     * must be escaped within a quoted field path is the backtick character
+     * itself, escaped using a backslash. Special characters in field paths that
+     * must be quoted include: `*`, `.`,
+     * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+     *
+     * Examples:
+     * `` `address.city` `` represents a field named `address.city`, not the map
+     * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+     * not any field.
+     *
+     * A special `Field` contains the default indexing settings for all fields.
+     * This field's resource name is:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+     * Indexes defined on this `Field` will be applied to all fields which do not
+     * have their own `Field` index configuration.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A field name of the form:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     *
+     * A field path can be a simple field name, e.g. `address` or a path to fields
+     * within `map_value` , e.g. `address.city`,
+     * or a special field path. The only valid special field is `*`, which
+     * represents any field.
+     *
+     * Field paths can be quoted using `` ` `` (backtick). The only character that
+     * must be escaped within a quoted field path is the backtick character
+     * itself, escaped using a backslash. Special characters in field paths that
+     * must be quoted include: `*`, `.`,
+     * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+     *
+     * Examples:
+     * `` `address.city` `` represents a field named `address.city`, not the map
+     * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+     * not any field.
+     *
+     * A special `Field` contains the default indexing settings for all fields.
+     * This field's resource name is:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+     * Indexes defined on this `Field` will be applied to all fields which do not
+     * have their own `Field` index configuration.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Field.IndexConfig indexConfig_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.IndexConfig, + com.google.firestore.admin.v1.Field.IndexConfig.Builder, + com.google.firestore.admin.v1.Field.IndexConfigOrBuilder> + indexConfigBuilder_; + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return Whether the indexConfig field is set. + */ + public boolean hasIndexConfig() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return The indexConfig. + */ + public com.google.firestore.admin.v1.Field.IndexConfig getIndexConfig() { + if (indexConfigBuilder_ == null) { + return indexConfig_ == null + ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() + : indexConfig_; + } else { + return indexConfigBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public Builder setIndexConfig(com.google.firestore.admin.v1.Field.IndexConfig value) { + if (indexConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + indexConfig_ = value; + } else { + indexConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public Builder setIndexConfig( + com.google.firestore.admin.v1.Field.IndexConfig.Builder builderForValue) { + if (indexConfigBuilder_ == null) { + indexConfig_ = builderForValue.build(); + } else { + indexConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public Builder mergeIndexConfig(com.google.firestore.admin.v1.Field.IndexConfig value) { + if (indexConfigBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && indexConfig_ != null + && indexConfig_ + != com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance()) { + getIndexConfigBuilder().mergeFrom(value); + } else { + indexConfig_ = value; + } + } else { + indexConfigBuilder_.mergeFrom(value); + } + if (indexConfig_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public Builder clearIndexConfig() { + bitField0_ = (bitField0_ & ~0x00000002); + indexConfig_ = null; + if (indexConfigBuilder_ != null) { + indexConfigBuilder_.dispose(); + indexConfigBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public com.google.firestore.admin.v1.Field.IndexConfig.Builder getIndexConfigBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetIndexConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + public com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder() { + if (indexConfigBuilder_ != null) { + return indexConfigBuilder_.getMessageOrBuilder(); + } else { + return indexConfig_ == null + ? com.google.firestore.admin.v1.Field.IndexConfig.getDefaultInstance() + : indexConfig_; + } + } + + /** + * + * + *
+     * The index configuration for this field. If unset, field indexing will
+     * revert to the configuration defined by the `ancestor_field`. To
+     * explicitly remove all indexes for this field, specify an index config
+     * with an empty list of indexes.
+     * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.IndexConfig, + com.google.firestore.admin.v1.Field.IndexConfig.Builder, + com.google.firestore.admin.v1.Field.IndexConfigOrBuilder> + internalGetIndexConfigFieldBuilder() { + if (indexConfigBuilder_ == null) { + indexConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.IndexConfig, + com.google.firestore.admin.v1.Field.IndexConfig.Builder, + com.google.firestore.admin.v1.Field.IndexConfigOrBuilder>( + getIndexConfig(), getParentForChildren(), isClean()); + indexConfig_ = null; + } + return indexConfigBuilder_; + } + + private com.google.firestore.admin.v1.Field.TtlConfig ttlConfig_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder> + ttlConfigBuilder_; + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + public boolean hasTtlConfig() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + public com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig() { + if (ttlConfigBuilder_ == null) { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } else { + return ttlConfigBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder setTtlConfig(com.google.firestore.admin.v1.Field.TtlConfig value) { + if (ttlConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ttlConfig_ = value; + } else { + ttlConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder setTtlConfig( + com.google.firestore.admin.v1.Field.TtlConfig.Builder builderForValue) { + if (ttlConfigBuilder_ == null) { + ttlConfig_ = builderForValue.build(); + } else { + ttlConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder mergeTtlConfig(com.google.firestore.admin.v1.Field.TtlConfig value) { + if (ttlConfigBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && ttlConfig_ != null + && ttlConfig_ != com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance()) { + getTtlConfigBuilder().mergeFrom(value); + } else { + ttlConfig_ = value; + } + } else { + ttlConfigBuilder_.mergeFrom(value); + } + if (ttlConfig_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public Builder clearTtlConfig() { + bitField0_ = (bitField0_ & ~0x00000004); + ttlConfig_ = null; + if (ttlConfigBuilder_ != null) { + ttlConfigBuilder_.dispose(); + ttlConfigBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public com.google.firestore.admin.v1.Field.TtlConfig.Builder getTtlConfigBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetTtlConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + public com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder() { + if (ttlConfigBuilder_ != null) { + return ttlConfigBuilder_.getMessageOrBuilder(); + } else { + return ttlConfig_ == null + ? com.google.firestore.admin.v1.Field.TtlConfig.getDefaultInstance() + : ttlConfig_; + } + } + + /** + * + * + *
+     * The TTL configuration for this `Field`.
+     * Setting or unsetting this will enable or disable the TTL for
+     * documents that have this `Field`.
+     * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder> + internalGetTtlConfigFieldBuilder() { + if (ttlConfigBuilder_ == null) { + ttlConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field.TtlConfig, + com.google.firestore.admin.v1.Field.TtlConfig.Builder, + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder>( + getTtlConfig(), getParentForChildren(), isClean()); + ttlConfig_ = null; + } + return ttlConfigBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Field) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Field) + private static final com.google.firestore.admin.v1.Field DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Field(); + } + + public static com.google.firestore.admin.v1.Field getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Field parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Field getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java new file mode 100644 index 000000000000..8458fce1e3ba --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldName.java @@ -0,0 +1,260 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class FieldName implements ResourceName { + 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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public String getField() { + return field; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static FieldName of(String project, String database, String collection, String field) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollection(collection) + .setField(field) + .build(); + } + + public static String format(String project, String database, String collection, String field) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollection(collection) + .setField(field) + .build() + .toString(); + } + + public static FieldName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_COLLECTION_FIELD.validatedMatch( + formattedString, "FieldName.parse: formattedString not in valid format"); + return of( + matchMap.get("project"), + matchMap.get("database"), + matchMap.get("collection"), + matchMap.get("field")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (FieldName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String 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(); + 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(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_COLLECTION_FIELD.instantiate( + "project", project, "database", database, "collection", collection, "field", field); + } + + @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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public String getField() { + return field; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setCollection(String collection) { + this.collection = collection; + return this; + } + + public Builder setField(String field) { + this.field = field; + return this; + } + + private Builder(FieldName fieldName) { + this.project = fieldName.project; + this.database = fieldName.database; + this.collection = fieldName.collection; + this.field = fieldName.field; + } + + public FieldName build() { + return new FieldName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java new file mode 100644 index 000000000000..3212dd41875f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadata.java @@ -0,0 +1,4761 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+ * results from
+ * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata} + */ +@com.google.protobuf.Generated +public final class FieldOperationMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.FieldOperationMetadata) + FieldOperationMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FieldOperationMetadata"); + } + + // Use FieldOperationMetadata.newBuilder() to construct. + private FieldOperationMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FieldOperationMetadata() { + field_ = ""; + indexConfigDeltas_ = java.util.Collections.emptyList(); + state_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.class, + com.google.firestore.admin.v1.FieldOperationMetadata.Builder.class); + } + + public interface IndexConfigDeltaOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Specifies how the index is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + int getChangeTypeValue(); + + /** + * + * + *
+     * Specifies how the index is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + getChangeType(); + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return Whether the index field is set. + */ + boolean hasIndex(); + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return The index. + */ + com.google.firestore.admin.v1.Index getIndex(); + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder(); + } + + /** + * + * + *
+   * Information about an index configuration change.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta} + */ + public static final class IndexConfigDelta extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + IndexConfigDeltaOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "IndexConfigDelta"); + } + + // Use IndexConfigDelta.newBuilder() to construct. + private IndexConfigDelta(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private IndexConfigDelta() { + changeType_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder.class); + } + + /** + * + * + *
+     * Specifies how the index is changing.
+     * 
+ * + * Protobuf enum {@code + * google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType} + */ + public enum ChangeType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + CHANGE_TYPE_UNSPECIFIED(0), + /** + * + * + *
+       * The single field index is being added.
+       * 
+ * + * ADD = 1; + */ + ADD(1), + /** + * + * + *
+       * The single field index is being removed.
+       * 
+ * + * REMOVE = 2; + */ + REMOVE(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ChangeType"); + } + + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + public static final int CHANGE_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The single field index is being added.
+       * 
+ * + * ADD = 1; + */ + public static final int ADD_VALUE = 1; + + /** + * + * + *
+       * The single field index is being removed.
+       * 
+ * + * REMOVE = 2; + */ + public static final int REMOVE_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ChangeType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ChangeType forNumber(int value) { + switch (value) { + case 0: + return CHANGE_TYPE_UNSPECIFIED; + case 1: + return ADD; + case 2: + return REMOVE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ChangeType findValueByNumber(int number) { + return ChangeType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final ChangeType[] VALUES = values(); + + public static ChangeType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ChangeType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType) + } + + private int bitField0_; + public static final int CHANGE_TYPE_FIELD_NUMBER = 1; + private int changeType_ = 0; + + /** + * + * + *
+     * Specifies how the index is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + + /** + * + * + *
+     * Specifies how the index is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + getChangeType() { + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .forNumber(changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .UNRECOGNIZED + : result; + } + + public static final int INDEX_FIELD_NUMBER = 2; + private com.google.firestore.admin.v1.Index index_; + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return Whether the index field is set. + */ + @java.lang.Override + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return The index. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index getIndex() { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + + /** + * + * + *
+     * The index being changed.
+     * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, changeType_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getIndex()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, changeType_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getIndex()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta other = + (com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) obj; + + if (changeType_ != other.changeType_) return false; + if (hasIndex() != other.hasIndex()) return false; + if (hasIndex()) { + if (!getIndex().equals(other.getIndex())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CHANGE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + changeType_; + if (hasIndex()) { + hash = (37 * hash) + INDEX_FIELD_NUMBER; + hash = (53 * hash) + getIndex().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Information about an index configuration change.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + .class); + } + + // Construct using + // com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetIndexFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + changeType_ = 0; + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta build() { + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta buildPartial() { + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta result = + new com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.changeType_ = changeType_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.index_ = indexBuilder_ == null ? index_ : indexBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) { + return mergeFrom( + (com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta other) { + if (other + == com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + .getDefaultInstance()) return this; + if (other.changeType_ != 0) { + setChangeTypeValue(other.getChangeTypeValue()); + } + if (other.hasIndex()) { + mergeIndex(other.getIndex()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + changeType_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + input.readMessage(internalGetIndexFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int changeType_ = 0; + + /** + * + * + *
+       * Specifies how the index is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + + /** + * + * + *
+       * Specifies how the index is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @param value The enum numeric value on the wire for changeType to set. + * @return This builder for chaining. + */ + public Builder setChangeTypeValue(int value) { + changeType_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Specifies how the index is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + getChangeType() { + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .forNumber(changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType + .UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * Specifies how the index is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @param value The changeType to set. + * @return This builder for chaining. + */ + public Builder setChangeType( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + changeType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Specifies how the index is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.ChangeType change_type = 1; + * + * + * @return This builder for chaining. + */ + public Builder clearChangeType() { + bitField0_ = (bitField0_ & ~0x00000001); + changeType_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Index index_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + indexBuilder_; + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return Whether the index field is set. + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + * + * @return The index. + */ + public com.google.firestore.admin.v1.Index getIndex() { + if (indexBuilder_ == null) { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } else { + return indexBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public Builder setIndex(com.google.firestore.admin.v1.Index value) { + if (indexBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + index_ = value; + } else { + indexBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public Builder setIndex(com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexBuilder_ == null) { + index_ = builderForValue.build(); + } else { + indexBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public Builder mergeIndex(com.google.firestore.admin.v1.Index value) { + if (indexBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && index_ != null + && index_ != com.google.firestore.admin.v1.Index.getDefaultInstance()) { + getIndexBuilder().mergeFrom(value); + } else { + index_ = value; + } + } else { + indexBuilder_.mergeFrom(value); + } + if (index_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000002); + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public com.google.firestore.admin.v1.Index.Builder getIndexBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetIndexFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + public com.google.firestore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + if (indexBuilder_ != null) { + return indexBuilder_.getMessageOrBuilder(); + } else { + return index_ == null ? com.google.firestore.admin.v1.Index.getDefaultInstance() : index_; + } + } + + /** + * + * + *
+       * The index being changed.
+       * 
+ * + * .google.firestore.admin.v1.Index index = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + internalGetIndexFieldBuilder() { + if (indexBuilder_ == null) { + indexBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder>( + getIndex(), getParentForChildren(), isClean()); + index_ = null; + } + return indexBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta) + private static final com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta(); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexConfigDelta parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface TtlConfigDeltaOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + int getChangeTypeValue(); + + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType getChangeType(); + } + + /** + * + * + *
+   * Information about a TTL configuration change.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta} + */ + public static final class TtlConfigDelta extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + TtlConfigDeltaOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "TtlConfigDelta"); + } + + // Use TtlConfigDelta.newBuilder() to construct. + private TtlConfigDelta(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private TtlConfigDelta() { + changeType_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder.class); + } + + /** + * + * + *
+     * Specifies how the TTL config is changing.
+     * 
+ * + * Protobuf enum {@code + * google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType} + */ + public enum ChangeType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + CHANGE_TYPE_UNSPECIFIED(0), + /** + * + * + *
+       * The TTL config is being added.
+       * 
+ * + * ADD = 1; + */ + ADD(1), + /** + * + * + *
+       * The TTL config is being removed.
+       * 
+ * + * REMOVE = 2; + */ + REMOVE(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ChangeType"); + } + + /** + * + * + *
+       * The type of change is not specified or known.
+       * 
+ * + * CHANGE_TYPE_UNSPECIFIED = 0; + */ + public static final int CHANGE_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The TTL config is being added.
+       * 
+ * + * ADD = 1; + */ + public static final int ADD_VALUE = 1; + + /** + * + * + *
+       * The TTL config is being removed.
+       * 
+ * + * REMOVE = 2; + */ + public static final int REMOVE_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ChangeType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ChangeType forNumber(int value) { + switch (value) { + case 0: + return CHANGE_TYPE_UNSPECIFIED; + case 1: + return ADD; + case 2: + return REMOVE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ChangeType findValueByNumber(int number) { + return ChangeType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final ChangeType[] VALUES = values(); + + public static ChangeType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ChangeType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType) + } + + public static final int CHANGE_TYPE_FIELD_NUMBER = 1; + private int changeType_ = 0; + + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + + /** + * + * + *
+     * Specifies how the TTL configuration is changing.
+     * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + getChangeType() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType.forNumber( + changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, changeType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (changeType_ + != com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .CHANGE_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, changeType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta other = + (com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) obj; + + if (changeType_ != other.changeType_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + CHANGE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + changeType_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Information about a TTL configuration change.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.class, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder.class); + } + + // Construct using + // com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + changeType_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta build() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta buildPartial() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta result = + new com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.changeType_ = changeType_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) { + return mergeFrom( + (com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta other) { + if (other + == com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance()) return this; + if (other.changeType_ != 0) { + setChangeTypeValue(other.getChangeTypeValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + changeType_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int changeType_ = 0; + + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The enum numeric value on the wire for changeType. + */ + @java.lang.Override + public int getChangeTypeValue() { + return changeType_; + } + + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @param value The enum numeric value on the wire for changeType to set. + * @return This builder for chaining. + */ + public Builder setChangeTypeValue(int value) { + changeType_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return The changeType. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + getChangeType() { + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType result = + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .forNumber(changeType_); + return result == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType + .UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @param value The changeType to set. + * @return This builder for chaining. + */ + public Builder setChangeType( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + changeType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Specifies how the TTL configuration is changing.
+       * 
+ * + * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType change_type = 1; + * + * + * @return This builder for chaining. + */ + public Builder clearChangeType() { + bitField0_ = (bitField0_ & ~0x00000001); + changeType_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta) + private static final com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta(); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TtlConfigDelta parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int FIELD_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object field_ = ""; + + /** + * + * + *
+   * The field resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * 
+ * + * string field = 3; + * + * @return The field. + */ + @java.lang.Override + public java.lang.String getField() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } + } + + /** + * + * + *
+   * The field resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * 
+ * + * string field = 3; + * + * @return The bytes for field. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_CONFIG_DELTAS_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private java.util.List + indexConfigDeltas_; + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + @java.lang.Override + public java.util.List + getIndexConfigDeltasList() { + return indexConfigDeltas_; + } + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + @java.lang.Override + public java.util.List< + ? extends com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder> + getIndexConfigDeltasOrBuilderList() { + return indexConfigDeltas_; + } + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + @java.lang.Override + public int getIndexConfigDeltasCount() { + return indexConfigDeltas_.size(); + } + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta getIndexConfigDeltas( + int index) { + return indexConfigDeltas_.get(index); + } + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder + getIndexConfigDeltasOrBuilder(int index) { + return indexConfigDeltas_.get(index); + } + + public static final int STATE_FIELD_NUMBER = 5; + private int state_ = 0; + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int PROGRESS_DOCUMENTS_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.Progress progressDocuments_; + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return Whether the progressDocuments field is set. + */ + @java.lang.Override + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return The progressDocuments. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 7; + private com.google.firestore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int TTL_CONFIG_DELTA_FIELD_NUMBER = 8; + private com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttlConfigDelta_; + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + @java.lang.Override + public boolean hasTtlConfigDelta() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta() { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.getDefaultInstance() + : ttlConfigDelta_; + } + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder() { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.getDefaultInstance() + : ttlConfigDelta_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(field_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, field_); + } + for (int i = 0; i < indexConfigDeltas_.size(); i++) { + output.writeMessage(4, indexConfigDeltas_.get(i)); + } + if (state_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(5, state_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(7, getProgressBytes()); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(8, getTtlConfigDelta()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(field_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, field_); + } + for (int i = 0; i < indexConfigDeltas_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(4, indexConfigDeltas_.get(i)); + } + if (state_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, state_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getProgressBytes()); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getTtlConfigDelta()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.FieldOperationMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.FieldOperationMetadata other = + (com.google.firestore.admin.v1.FieldOperationMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (!getField().equals(other.getField())) return false; + if (!getIndexConfigDeltasList().equals(other.getIndexConfigDeltasList())) return false; + if (state_ != other.state_) return false; + if (hasProgressDocuments() != other.hasProgressDocuments()) return false; + if (hasProgressDocuments()) { + if (!getProgressDocuments().equals(other.getProgressDocuments())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (hasTtlConfigDelta() != other.hasTtlConfigDelta()) return false; + if (hasTtlConfigDelta()) { + if (!getTtlConfigDelta().equals(other.getTtlConfigDelta())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + if (getIndexConfigDeltasCount() > 0) { + hash = (37 * hash) + INDEX_CONFIG_DELTAS_FIELD_NUMBER; + hash = (53 * hash) + getIndexConfigDeltasList().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + if (hasProgressDocuments()) { + hash = (37 * hash) + PROGRESS_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getProgressDocuments().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (hasTtlConfigDelta()) { + hash = (37 * hash) + TTL_CONFIG_DELTA_FIELD_NUMBER; + hash = (53 * hash) + getTtlConfigDelta().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.FieldOperationMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+   * results from
+   * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.FieldOperationMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.FieldOperationMetadata) + com.google.firestore.admin.v1.FieldOperationMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.FieldOperationMetadata.class, + com.google.firestore.admin.v1.FieldOperationMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.FieldOperationMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetIndexConfigDeltasFieldBuilder(); + internalGetProgressDocumentsFieldBuilder(); + internalGetProgressBytesFieldBuilder(); + internalGetTtlConfigDeltaFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + field_ = ""; + if (indexConfigDeltasBuilder_ == null) { + indexConfigDeltas_ = java.util.Collections.emptyList(); + } else { + indexConfigDeltas_ = null; + indexConfigDeltasBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + state_ = 0; + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + ttlConfigDelta_ = null; + if (ttlConfigDeltaBuilder_ != null) { + ttlConfigDeltaBuilder_.dispose(); + ttlConfigDeltaBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.FieldOperationMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata build() { + com.google.firestore.admin.v1.FieldOperationMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata buildPartial() { + com.google.firestore.admin.v1.FieldOperationMetadata result = + new com.google.firestore.admin.v1.FieldOperationMetadata(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.FieldOperationMetadata result) { + if (indexConfigDeltasBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + indexConfigDeltas_ = java.util.Collections.unmodifiableList(indexConfigDeltas_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.indexConfigDeltas_ = indexConfigDeltas_; + } else { + result.indexConfigDeltas_ = indexConfigDeltasBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.FieldOperationMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.field_ = field_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.state_ = state_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.progressDocuments_ = + progressDocumentsBuilder_ == null + ? progressDocuments_ + : progressDocumentsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.ttlConfigDelta_ = + ttlConfigDeltaBuilder_ == null ? ttlConfigDelta_ : ttlConfigDeltaBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.FieldOperationMetadata) { + return mergeFrom((com.google.firestore.admin.v1.FieldOperationMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.FieldOperationMetadata other) { + if (other == com.google.firestore.admin.v1.FieldOperationMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (!other.getField().isEmpty()) { + field_ = other.field_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (indexConfigDeltasBuilder_ == null) { + if (!other.indexConfigDeltas_.isEmpty()) { + if (indexConfigDeltas_.isEmpty()) { + indexConfigDeltas_ = other.indexConfigDeltas_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.addAll(other.indexConfigDeltas_); + } + onChanged(); + } + } else { + if (!other.indexConfigDeltas_.isEmpty()) { + if (indexConfigDeltasBuilder_.isEmpty()) { + indexConfigDeltasBuilder_.dispose(); + indexConfigDeltasBuilder_ = null; + indexConfigDeltas_ = other.indexConfigDeltas_; + bitField0_ = (bitField0_ & ~0x00000008); + indexConfigDeltasBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetIndexConfigDeltasFieldBuilder() + : null; + } else { + indexConfigDeltasBuilder_.addAllMessages(other.indexConfigDeltas_); + } + } + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + if (other.hasProgressDocuments()) { + mergeProgressDocuments(other.getProgressDocuments()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (other.hasTtlConfigDelta()) { + mergeTtlConfigDelta(other.getTtlConfigDelta()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + field_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta m = + input.readMessage( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + .parser(), + extensionRegistry); + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.add(m); + } else { + indexConfigDeltasBuilder_.addMessage(m); + } + break; + } // case 34 + case 40: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 50: + { + input.readMessage( + internalGetProgressDocumentsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 58 + case 66: + { + input.readMessage( + internalGetTtlConfigDeltaFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private java.lang.Object field_ = ""; + + /** + * + * + *
+     * The field resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     * 
+ * + * string field = 3; + * + * @return The field. + */ + public java.lang.String getField() { + java.lang.Object ref = field_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + field_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The field resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     * 
+ * + * string field = 3; + * + * @return The bytes for field. + */ + public com.google.protobuf.ByteString getFieldBytes() { + java.lang.Object ref = field_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + field_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The field resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     * 
+ * + * string field = 3; + * + * @param value The field to set. + * @return This builder for chaining. + */ + public Builder setField(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The field resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     * 
+ * + * string field = 3; + * + * @return This builder for chaining. + */ + public Builder clearField() { + field_ = getDefaultInstance().getField(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * The field resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+     * 
+ * + * string field = 3; + * + * @param value The bytes for field to set. + * @return This builder for chaining. + */ + public Builder setFieldBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + field_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private java.util.List + indexConfigDeltas_ = java.util.Collections.emptyList(); + + private void ensureIndexConfigDeltasIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + indexConfigDeltas_ = + new java.util.ArrayList< + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta>( + indexConfigDeltas_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder> + indexConfigDeltasBuilder_; + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public java.util.List + getIndexConfigDeltasList() { + if (indexConfigDeltasBuilder_ == null) { + return java.util.Collections.unmodifiableList(indexConfigDeltas_); + } else { + return indexConfigDeltasBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public int getIndexConfigDeltasCount() { + if (indexConfigDeltasBuilder_ == null) { + return indexConfigDeltas_.size(); + } else { + return indexConfigDeltasBuilder_.getCount(); + } + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + getIndexConfigDeltas(int index) { + if (indexConfigDeltasBuilder_ == null) { + return indexConfigDeltas_.get(index); + } else { + return indexConfigDeltasBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder setIndexConfigDeltas( + int index, com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta value) { + if (indexConfigDeltasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.set(index, value); + onChanged(); + } else { + indexConfigDeltasBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder setIndexConfigDeltas( + int index, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + builderForValue) { + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.set(index, builderForValue.build()); + onChanged(); + } else { + indexConfigDeltasBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder addIndexConfigDeltas( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta value) { + if (indexConfigDeltasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.add(value); + onChanged(); + } else { + indexConfigDeltasBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder addIndexConfigDeltas( + int index, com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta value) { + if (indexConfigDeltasBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.add(index, value); + onChanged(); + } else { + indexConfigDeltasBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder addIndexConfigDeltas( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + builderForValue) { + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.add(builderForValue.build()); + onChanged(); + } else { + indexConfigDeltasBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder addIndexConfigDeltas( + int index, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + builderForValue) { + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.add(index, builderForValue.build()); + onChanged(); + } else { + indexConfigDeltasBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder addAllIndexConfigDeltas( + java.lang.Iterable< + ? extends com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta> + values) { + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, indexConfigDeltas_); + onChanged(); + } else { + indexConfigDeltasBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder clearIndexConfigDeltas() { + if (indexConfigDeltasBuilder_ == null) { + indexConfigDeltas_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + indexConfigDeltasBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public Builder removeIndexConfigDeltas(int index) { + if (indexConfigDeltasBuilder_ == null) { + ensureIndexConfigDeltasIsMutable(); + indexConfigDeltas_.remove(index); + onChanged(); + } else { + indexConfigDeltasBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + getIndexConfigDeltasBuilder(int index) { + return internalGetIndexConfigDeltasFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder + getIndexConfigDeltasOrBuilder(int index) { + if (indexConfigDeltasBuilder_ == null) { + return indexConfigDeltas_.get(index); + } else { + return indexConfigDeltasBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public java.util.List< + ? extends + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder> + getIndexConfigDeltasOrBuilderList() { + if (indexConfigDeltasBuilder_ != null) { + return indexConfigDeltasBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(indexConfigDeltas_); + } + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + addIndexConfigDeltasBuilder() { + return internalGetIndexConfigDeltasFieldBuilder() + .addBuilder( + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + .getDefaultInstance()); + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder + addIndexConfigDeltasBuilder(int index) { + return internalGetIndexConfigDeltasFieldBuilder() + .addBuilder( + index, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta + .getDefaultInstance()); + } + + /** + * + * + *
+     * A list of
+     * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+     * which describe the intent of this operation.
+     * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + public java.util.List< + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder> + getIndexConfigDeltasBuilderList() { + return internalGetIndexConfigDeltasFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder> + internalGetIndexConfigDeltasFieldBuilder() { + if (indexConfigDeltasBuilder_ == null) { + indexConfigDeltasBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder>( + indexConfigDeltas_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + indexConfigDeltas_ = null; + } + return indexConfigDeltasBuilder_; + } + + private int state_ = 0; + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000010); + state_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressDocuments_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressDocumentsBuilder_; + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return Whether the progressDocuments field is set. + */ + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return The progressDocuments. + */ + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + if (progressDocumentsBuilder_ == null) { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } else { + return progressDocumentsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public Builder setProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressDocuments_ = value; + } else { + progressDocumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public Builder setProgressDocuments( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressDocumentsBuilder_ == null) { + progressDocuments_ = builderForValue.build(); + } else { + progressDocumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public Builder mergeProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && progressDocuments_ != null + && progressDocuments_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressDocumentsBuilder().mergeFrom(value); + } else { + progressDocuments_ = value; + } + } else { + progressDocumentsBuilder_.mergeFrom(value); + } + if (progressDocuments_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public Builder clearProgressDocuments() { + bitField0_ = (bitField0_ & ~0x00000020); + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressDocumentsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetProgressDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + if (progressDocumentsBuilder_ != null) { + return progressDocumentsBuilder_.getMessageOrBuilder(); + } else { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressDocumentsFieldBuilder() { + if (progressDocumentsBuilder_ == null) { + progressDocumentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressDocuments(), getParentForChildren(), isClean()); + progressDocuments_ = null; + } + return progressDocumentsBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return The progressBytes. + */ + public com.google.firestore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public Builder setProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public Builder setProgressBytes( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public Builder mergeProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000040); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return internalGetProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttlConfigDelta_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder> + ttlConfigDeltaBuilder_; + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + public boolean hasTtlConfigDelta() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta() { + if (ttlConfigDeltaBuilder_ == null) { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance() + : ttlConfigDelta_; + } else { + return ttlConfigDeltaBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder setTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta value) { + if (ttlConfigDeltaBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ttlConfigDelta_ = value; + } else { + ttlConfigDeltaBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder setTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder + builderForValue) { + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDelta_ = builderForValue.build(); + } else { + ttlConfigDeltaBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder mergeTtlConfigDelta( + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta value) { + if (ttlConfigDeltaBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && ttlConfigDelta_ != null + && ttlConfigDelta_ + != com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance()) { + getTtlConfigDeltaBuilder().mergeFrom(value); + } else { + ttlConfigDelta_ = value; + } + } else { + ttlConfigDeltaBuilder_.mergeFrom(value); + } + if (ttlConfigDelta_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public Builder clearTtlConfigDelta() { + bitField0_ = (bitField0_ & ~0x00000080); + ttlConfigDelta_ = null; + if (ttlConfigDeltaBuilder_ != null) { + ttlConfigDeltaBuilder_.dispose(); + ttlConfigDeltaBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder + getTtlConfigDeltaBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return internalGetTtlConfigDeltaFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + public com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder() { + if (ttlConfigDeltaBuilder_ != null) { + return ttlConfigDeltaBuilder_.getMessageOrBuilder(); + } else { + return ttlConfigDelta_ == null + ? com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta + .getDefaultInstance() + : ttlConfigDelta_; + } + } + + /** + * + * + *
+     * Describes the deltas of TTL configuration.
+     * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder> + internalGetTtlConfigDeltaFieldBuilder() { + if (ttlConfigDeltaBuilder_ == null) { + ttlConfigDeltaBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.Builder, + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder>( + getTtlConfigDelta(), getParentForChildren(), isClean()); + ttlConfigDelta_ = null; + } + return ttlConfigDeltaBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.FieldOperationMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.FieldOperationMetadata) + private static final com.google.firestore.admin.v1.FieldOperationMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.FieldOperationMetadata(); + } + + public static com.google.firestore.admin.v1.FieldOperationMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FieldOperationMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.FieldOperationMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java new file mode 100644 index 000000000000..1ea42aebac10 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOperationMetadataOrBuilder.java @@ -0,0 +1,354 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface FieldOperationMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.FieldOperationMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The field resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * 
+ * + * string field = 3; + * + * @return The field. + */ + java.lang.String getField(); + + /** + * + * + *
+   * The field resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   * 
+ * + * string field = 3; + * + * @return The bytes for field. + */ + com.google.protobuf.ByteString getFieldBytes(); + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + java.util.List + getIndexConfigDeltasList(); + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta getIndexConfigDeltas( + int index); + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + int getIndexConfigDeltasCount(); + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + java.util.List< + ? extends com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder> + getIndexConfigDeltasOrBuilderList(); + + /** + * + * + *
+   * A list of
+   * [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta],
+   * which describe the intent of this operation.
+   * 
+ * + * + * repeated .google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta index_config_deltas = 4; + * + */ + com.google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDeltaOrBuilder + getIndexConfigDeltasOrBuilder(int index); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 5; + * + * @return The state. + */ + com.google.firestore.admin.v1.OperationState getState(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return Whether the progressDocuments field is set. + */ + boolean hasProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + * + * @return The progressDocuments. + */ + com.google.firestore.admin.v1.Progress getProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 6; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + * + * @return The progressBytes. + */ + com.google.firestore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 7; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return Whether the ttlConfigDelta field is set. + */ + boolean hasTtlConfigDelta(); + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + * + * @return The ttlConfigDelta. + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta getTtlConfigDelta(); + + /** + * + * + *
+   * Describes the deltas of TTL configuration.
+   * 
+ * + * .google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta ttl_config_delta = 8; + * + */ + com.google.firestore.admin.v1.FieldOperationMetadata.TtlConfigDeltaOrBuilder + getTtlConfigDeltaOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java new file mode 100644 index 000000000000..141743b62146 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldOrBuilder.java @@ -0,0 +1,189 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/field.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface FieldOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Field) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A field name of the form:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   *
+   * A field path can be a simple field name, e.g. `address` or a path to fields
+   * within `map_value` , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   *
+   * Field paths can be quoted using `` ` `` (backtick). The only character that
+   * must be escaped within a quoted field path is the backtick character
+   * itself, escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   *
+   * Examples:
+   * `` `address.city` `` represents a field named `address.city`, not the map
+   * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+   * not any field.
+   *
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A field name of the form:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}`
+   *
+   * A field path can be a simple field name, e.g. `address` or a path to fields
+   * within `map_value` , e.g. `address.city`,
+   * or a special field path. The only valid special field is `*`, which
+   * represents any field.
+   *
+   * Field paths can be quoted using `` ` `` (backtick). The only character that
+   * must be escaped within a quoted field path is the backtick character
+   * itself, escaped using a backslash. Special characters in field paths that
+   * must be quoted include: `*`, `.`,
+   * `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters.
+   *
+   * Examples:
+   * `` `address.city` `` represents a field named `address.city`, not the map
+   * key `city` in the field `address`. `` `*` `` represents a field named `*`,
+   * not any field.
+   *
+   * A special `Field` contains the default indexing settings for all fields.
+   * This field's resource name is:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*`
+   * Indexes defined on this `Field` will be applied to all fields which do not
+   * have their own `Field` index configuration.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return Whether the indexConfig field is set. + */ + boolean hasIndexConfig(); + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + * + * @return The indexConfig. + */ + com.google.firestore.admin.v1.Field.IndexConfig getIndexConfig(); + + /** + * + * + *
+   * The index configuration for this field. If unset, field indexing will
+   * revert to the configuration defined by the `ancestor_field`. To
+   * explicitly remove all indexes for this field, specify an index config
+   * with an empty list of indexes.
+   * 
+ * + * .google.firestore.admin.v1.Field.IndexConfig index_config = 2; + */ + com.google.firestore.admin.v1.Field.IndexConfigOrBuilder getIndexConfigOrBuilder(); + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return Whether the ttlConfig field is set. + */ + boolean hasTtlConfig(); + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + * + * @return The ttlConfig. + */ + com.google.firestore.admin.v1.Field.TtlConfig getTtlConfig(); + + /** + * + * + *
+   * The TTL configuration for this `Field`.
+   * Setting or unsetting this will enable or disable the TTL for
+   * documents that have this `Field`.
+   * 
+ * + * .google.firestore.admin.v1.Field.TtlConfig ttl_config = 3; + */ + com.google.firestore.admin.v1.Field.TtlConfigOrBuilder getTtlConfigOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java new file mode 100644 index 000000000000..a7b3dcd7a174 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FieldProto.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/field.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class FieldProto extends com.google.protobuf.GeneratedFile { + private FieldProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FieldProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Field_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Field_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Field_IndexConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "%google/firestore/admin/v1/field.proto\022" + + "\031google.firestore.admin.v1\032\037google/api/f" + + "ield_behavior.proto\032\031google/api/resource" + + ".proto\032%google/firestore/admin/v1/index.proto\"\305\004\n" + + "\005Field\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022B\n" + + "\014index_config\030\002" + + " \001(\0132,.google.firestore.admin.v1.Field.IndexConfig\022>\n\n" + + "ttl_config\030\003 \001(\0132*.google.firestore.admin.v1.Field.TtlConfig\032\211\001\n" + + "\013IndexConfig\0221\n" + + "\007indexes\030\001 \003(\0132 .google.firestore.admin.v1.Index\022\034\n" + + "\024uses_ancestor_config\030\002 \001(\010\022\026\n" + + "\016ancestor_field\030\003 \001(\t\022\021\n" + + "\treverting\030\004 \001(\010\032\235\001\n" + + "\tTtlConfig\022D\n" + + "\005state\030\001" + + " \001(\01620.google.firestore.admin.v1.Field.TtlConfig.StateB\003\340A\003\"J\n" + + "\005State\022\025\n" + + "\021STATE_UNSPECIFIED\020\000\022\014\n" + + "\010CREATING\020\001\022\n\n" + + "\006ACTIVE\020\002\022\020\n" + + "\014NEEDS_REPAIR\020\003:y\352Av\n" + + "\036firestore.googleapis.com/Field\022Tprojects/{proje" + + "ct}/databases/{database}/collectionGroups/{collection}/fields/{field}B\331\001\n" + + "\035com.google.firestore.admin.v1B\n" + + "FieldProtoP\001Z9cloud.google.com/go/firestore/apiv1/admin" + + "/adminpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud.F" + + "irestore.Admin.V1\312\002\037Google\\Cloud\\Firesto" + + "re\\Admin\\V1\352\002#Google::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.firestore.admin.v1.IndexProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_Field_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_Field_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Field_descriptor, + new java.lang.String[] { + "Name", "IndexConfig", "TtlConfig", + }); + internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor = + internal_static_google_firestore_admin_v1_Field_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Field_IndexConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Field_IndexConfig_descriptor, + new java.lang.String[] { + "Indexes", "UsesAncestorConfig", "AncestorField", "Reverting", + }); + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor = + internal_static_google_firestore_admin_v1_Field_descriptor.getNestedType(1); + internal_static_google_firestore_admin_v1_Field_TtlConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Field_TtlConfig_descriptor, + new java.lang.String[] { + "State", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.firestore.admin.v1.IndexProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java new file mode 100644 index 000000000000..a134677a12ce --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/FirestoreAdminProto.java @@ -0,0 +1,940 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class FirestoreAdminProto extends com.google.protobuf.GeneratedFile { + private FirestoreAdminProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FirestoreAdminProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListDatabasesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListDatabasesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListUserCredsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_EnableUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DisableUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CreateIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListIndexesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListIndexesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UpdateFieldRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetFieldRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListFieldsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListFieldsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ExportDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n/google/firestore/admin/v1/firestore_ad" + + "min.proto\022\031google.firestore.admin.v1\032\034go" + + "ogle/api/annotations.proto\032\027google/api/c" + + "lient.proto\032\037google/api/field_behavior.p" + + "roto\032\031google/api/resource.proto\032\030google/" + + "api/routing.proto\032&google/firestore/admi" + + "n/v1/backup.proto\032(google/firestore/admi" + + "n/v1/database.proto\032%google/firestore/ad" + + "min/v1/field.proto\032%google/firestore/adm" + + "in/v1/index.proto\032)google/firestore/admi" + + "n/v1/operation.proto\032(google/firestore/a" + + "dmin/v1/schedule.proto\032(google/firestore" + + "/admin/v1/snapshot.proto\032*google/firesto" + + "re/admin/v1/user_creds.proto\032#google/lon" + + "grunning/operations.proto\032\033google/protob" + + "uf/empty.proto\032 google/protobuf/field_ma" + + "sk.proto\032\037google/protobuf/timestamp.prot" + + "o\"g\n\024ListDatabasesRequest\0229\n\006parent\030\001 \001(" + + "\tB)\340A\002\372A#\022!firestore.googleapis.com/Data" + + "base\022\024\n\014show_deleted\030\004 \001(\010\"\250\001\n\025CreateDat" + + "abaseRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\022!fi" + + "restore.googleapis.com/Database\022:\n\010datab" + + "ase\030\002 \001(\0132#.google.firestore.admin.v1.Da" + + "tabaseB\003\340A\002\022\030\n\013database_id\030\003 \001(\tB\003\340A\002\"\030\n" + + "\026CreateDatabaseMetadata\"d\n\025ListDatabases" + + "Response\0226\n\tdatabases\030\001 \003(\0132#.google.fir" + + "estore.admin.v1.Database\022\023\n\013unreachable\030" + + "\003 \003(\t\"M\n\022GetDatabaseRequest\0227\n\004name\030\001 \001(" + + "\tB)\340A\002\372A#\n!firestore.googleapis.com/Data" + + "base\"\204\001\n\025UpdateDatabaseRequest\022:\n\010databa" + + "se\030\001 \001(\0132#.google.firestore.admin.v1.Dat" + + "abaseB\003\340A\002\022/\n\013update_mask\030\002 \001(\0132\032.google" + + ".protobuf.FieldMask\"\030\n\026UpdateDatabaseMet" + + "adata\"^\n\025DeleteDatabaseRequest\0227\n\004name\030\001" + + " \001(\tB)\340A\002\372A#\n!firestore.googleapis.com/D" + + "atabase\022\014\n\004etag\030\003 \001(\t\"\030\n\026DeleteDatabaseM" + + "etadata\"\257\001\n\026CreateUserCredsRequest\022:\n\006pa" + + "rent\030\001 \001(\tB*\340A\002\372A$\022\"firestore.googleapis" + + ".com/UserCreds\022=\n\nuser_creds\030\002 \001(\0132$.goo" + + "gle.firestore.admin.v1.UserCredsB\003\340A\002\022\032\n" + + "\ruser_creds_id\030\003 \001(\tB\003\340A\002\"O\n\023GetUserCred" + + "sRequest\0228\n\004name\030\001 \001(\tB*\340A\002\372A$\n\"firestor" + + "e.googleapis.com/UserCreds\"R\n\024ListUserCr" + + "edsRequest\022:\n\006parent\030\001 \001(\tB*\340A\002\372A$\022\"fire" + + "store.googleapis.com/UserCreds\"Q\n\025ListUs" + + "erCredsResponse\0228\n\nuser_creds\030\001 \003(\0132$.go" + + "ogle.firestore.admin.v1.UserCreds\"R\n\026Ena" + + "bleUserCredsRequest\0228\n\004name\030\001 \001(\tB*\340A\002\372A" + + "$\n\"firestore.googleapis.com/UserCreds\"S\n" + + "\027DisableUserCredsRequest\0228\n\004name\030\001 \001(\tB*" + + "\340A\002\372A$\n\"firestore.googleapis.com/UserCre" + + "ds\"T\n\030ResetUserPasswordRequest\0228\n\004name\030\001" + + " \001(\tB*\340A\002\372A$\n\"firestore.googleapis.com/U" + + "serCreds\"R\n\026DeleteUserCredsRequest\0228\n\004na" + + "me\030\001 \001(\tB*\340A\002\372A$\n\"firestore.googleapis.c" + + "om/UserCreds\"\241\001\n\033CreateBackupScheduleReq" + + "uest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!firestore." + + "googleapis.com/Database\022G\n\017backup_schedu" + + "le\030\002 \001(\0132).google.firestore.admin.v1.Bac" + + "kupScheduleB\003\340A\002\"Y\n\030GetBackupScheduleReq" + + "uest\022=\n\004name\030\001 \001(\tB/\340A\002\372A)\n\'firestore.go" + + "ogleapis.com/BackupSchedule\"\227\001\n\033UpdateBa" + + "ckupScheduleRequest\022G\n\017backup_schedule\030\001" + + " \001(\0132).google.firestore.admin.v1.BackupS" + + "cheduleB\003\340A\002\022/\n\013update_mask\030\002 \001(\0132\032.goog" + + "le.protobuf.FieldMask\"W\n\032ListBackupSched" + + "ulesRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\n!fir" + + "estore.googleapis.com/Database\"b\n\033ListBa" + + "ckupSchedulesResponse\022C\n\020backup_schedule" + + "s\030\001 \003(\0132).google.firestore.admin.v1.Back" + + "upSchedule\"\\\n\033DeleteBackupScheduleReques" + + "t\022=\n\004name\030\001 \001(\tB/\340A\002\372A)\n\'firestore.googl" + + "eapis.com/BackupSchedule\"\214\001\n\022CreateIndex" + + "Request\022@\n\006parent\030\001 \001(\tB0\340A\002\372A*\n(firesto" + + "re.googleapis.com/CollectionGroup\0224\n\005ind" + + "ex\030\002 \001(\0132 .google.firestore.admin.v1.Ind" + + "exB\003\340A\002\"\215\001\n\022ListIndexesRequest\022@\n\006parent" + + "\030\001 \001(\tB0\340A\002\372A*\n(firestore.googleapis.com" + + "/CollectionGroup\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage" + + "_size\030\003 \001(\005\022\022\n\npage_token\030\004 \001(\t\"a\n\023ListI" + + "ndexesResponse\0221\n\007indexes\030\001 \003(\0132 .google" + + ".firestore.admin.v1.Index\022\027\n\017next_page_t" + + "oken\030\002 \001(\t\"G\n\017GetIndexRequest\0224\n\004name\030\001 " + + "\001(\tB&\340A\002\372A \n\036firestore.googleapis.com/In" + + "dex\"J\n\022DeleteIndexRequest\0224\n\004name\030\001 \001(\tB" + + "&\340A\002\372A \n\036firestore.googleapis.com/Index\"" + + "{\n\022UpdateFieldRequest\0224\n\005field\030\001 \001(\0132 .g" + + "oogle.firestore.admin.v1.FieldB\003\340A\002\022/\n\013u" + + "pdate_mask\030\002 \001(\0132\032.google.protobuf.Field" + + "Mask\"G\n\017GetFieldRequest\0224\n\004name\030\001 \001(\tB&\340" + + "A\002\372A \n\036firestore.googleapis.com/Field\"\214\001" + + "\n\021ListFieldsRequest\022@\n\006parent\030\001 \001(\tB0\340A\002" + + "\372A*\n(firestore.googleapis.com/Collection" + + "Group\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005" + + "\022\022\n\npage_token\030\004 \001(\t\"_\n\022ListFieldsRespon" + + "se\0220\n\006fields\030\001 \003(\0132 .google.firestore.ad" + + "min.v1.Field\022\027\n\017next_page_token\030\002 \001(\t\"\316\001" + + "\n\026ExportDocumentsRequest\0227\n\004name\030\001 \001(\tB)" + + "\340A\002\372A#\n!firestore.googleapis.com/Databas" + + "e\022\026\n\016collection_ids\030\002 \003(\t\022\031\n\021output_uri_" + + "prefix\030\003 \001(\t\022\025\n\rnamespace_ids\030\004 \003(\t\0221\n\rs" + + "napshot_time\030\005 \001(\0132\032.google.protobuf.Tim" + + "estamp\"\232\001\n\026ImportDocumentsRequest\0227\n\004nam" + + "e\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleapis.co" + + "m/Database\022\026\n\016collection_ids\030\002 \003(\t\022\030\n\020in" + + "put_uri_prefix\030\003 \001(\t\022\025\n\rnamespace_ids\030\004 " + + "\003(\t\"\216\001\n\032BulkDeleteDocumentsRequest\0227\n\004na" + + "me\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleapis.c" + + "om/Database\022\033\n\016collection_ids\030\002 \003(\tB\003\340A\001" + + "\022\032\n\rnamespace_ids\030\003 \003(\tB\003\340A\001\"\035\n\033BulkDele" + + "teDocumentsResponse\"I\n\020GetBackupRequest\022" + + "5\n\004name\030\001 \001(\tB\'\340A\002\372A!\n\037firestore.googlea" + + "pis.com/Backup\"_\n\022ListBackupsRequest\0229\n\006" + + "parent\030\001 \001(\tB)\340A\002\372A#\n!firestore.googleap" + + "is.com/Location\022\016\n\006filter\030\002 \001(\t\"^\n\023ListB" + + "ackupsResponse\0222\n\007backups\030\001 \003(\0132!.google" + + ".firestore.admin.v1.Backup\022\023\n\013unreachabl" + + "e\030\003 \003(\t\"L\n\023DeleteBackupRequest\0225\n\004name\030\001" + + " \001(\tB\'\340A\002\372A!\n\037firestore.googleapis.com/B" + + "ackup\"\374\002\n\026RestoreDatabaseRequest\0229\n\006pare" + + "nt\030\001 \001(\tB)\340A\002\372A#\022!firestore.googleapis.c" + + "om/Database\022\030\n\013database_id\030\002 \001(\tB\003\340A\002\0227\n" + + "\006backup\030\003 \001(\tB\'\340A\002\372A!\n\037firestore.googlea" + + "pis.com/Backup\022T\n\021encryption_config\030\t \001(" + + "\01324.google.firestore.admin.v1.Database.E" + + "ncryptionConfigB\003\340A\001\022Q\n\004tags\030\n \003(\0132;.goo" + + "gle.firestore.admin.v1.RestoreDatabaseRe" + + "quest.TagsEntryB\006\340A\005\340A\001\032+\n\tTagsEntry\022\013\n\003" + + "key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\"\204\003\n\024CloneDa" + + "tabaseRequest\0229\n\006parent\030\001 \001(\tB)\340A\002\372A#\022!f" + + "irestore.googleapis.com/Database\022\030\n\013data" + + "base_id\030\002 \001(\tB\003\340A\002\022C\n\rpitr_snapshot\030\006 \001(" + + "\0132\'.google.firestore.admin.v1.PitrSnapsh" + + "otB\003\340A\002\022T\n\021encryption_config\030\004 \001(\01324.goo" + + "gle.firestore.admin.v1.Database.Encrypti" + + "onConfigB\003\340A\001\022O\n\004tags\030\005 \003(\01329.google.fir" + + "estore.admin.v1.CloneDatabaseRequest.Tag" + + "sEntryB\006\340A\005\340A\001\032+\n\tTagsEntry\022\013\n\003key\030\001 \001(\t" + + "\022\r\n\005value\030\002 \001(\t:\0028\0012\3731\n\016FirestoreAdmin\022\333" + + "\001\n\013CreateIndex\022-.google.firestore.admin." + + "v1.CreateIndexRequest\032\035.google.longrunni" + + "ng.Operation\"~\312A\037\n\005Index\022\026IndexOperation" + + "Metadata\332A\014parent,index\202\323\344\223\002G\">/v1/{pare" + + "nt=projects/*/databases/*/collectionGrou" + + "ps/*}/indexes:\005index\022\275\001\n\013ListIndexes\022-.g" + + "oogle.firestore.admin.v1.ListIndexesRequ" + + "est\032..google.firestore.admin.v1.ListInde" + + "xesResponse\"O\332A\006parent\202\323\344\223\002@\022>/v1/{paren" + + "t=projects/*/databases/*/collectionGroup" + + "s/*}/indexes\022\247\001\n\010GetIndex\022*.google.fires" + + "tore.admin.v1.GetIndexRequest\032 .google.f" + + "irestore.admin.v1.Index\"M\332A\004name\202\323\344\223\002@\022>" + + "/v1/{name=projects/*/databases/*/collect" + + "ionGroups/*/indexes/*}\022\243\001\n\013DeleteIndex\022-" + + ".google.firestore.admin.v1.DeleteIndexRe" + + "quest\032\026.google.protobuf.Empty\"M\332A\004name\202\323" + + "\344\223\002@*>/v1/{name=projects/*/databases/*/c" + + "ollectionGroups/*/indexes/*}\022\246\001\n\010GetFiel" + + "d\022*.google.firestore.admin.v1.GetFieldRe" + + "quest\032 .google.firestore.admin.v1.Field\"" + + "L\332A\004name\202\323\344\223\002?\022=/v1/{name=projects/*/dat" + + "abases/*/collectionGroups/*/fields/*}\022\331\001" + + "\n\013UpdateField\022-.google.firestore.admin.v" + + "1.UpdateFieldRequest\032\035.google.longrunnin" + + "g.Operation\"|\312A\037\n\005Field\022\026FieldOperationM" + + "etadata\332A\005field\202\323\344\223\002L2C/v1/{field.name=p" + + "rojects/*/databases/*/collectionGroups/*" + + "/fields/*}:\005field\022\271\001\n\nListFields\022,.googl" + + "e.firestore.admin.v1.ListFieldsRequest\032-" + + ".google.firestore.admin.v1.ListFieldsRes" + + "ponse\"N\332A\006parent\202\323\344\223\002?\022=/v1/{parent=proj" + + "ects/*/databases/*/collectionGroups/*}/f" + + "ields\022\335\001\n\017ExportDocuments\0221.google.fires" + + "tore.admin.v1.ExportDocumentsRequest\032\035.g" + + "oogle.longrunning.Operation\"x\312A2\n\027Export" + + "DocumentsResponse\022\027ExportDocumentsMetada" + + "ta\332A\004name\202\323\344\223\0026\"1/v1/{name=projects/*/da" + + "tabases/*}:exportDocuments:\001*\022\333\001\n\017Import" + + "Documents\0221.google.firestore.admin.v1.Im" + + "portDocumentsRequest\032\035.google.longrunnin" + + "g.Operation\"v\312A0\n\025google.protobuf.Empty\022" + + "\027ImportDocumentsMetadata\332A\004name\202\323\344\223\0026\"1/" + + "v1/{name=projects/*/databases/*}:importD" + + "ocuments:\001*\022\362\001\n\023BulkDeleteDocuments\0225.go" + + "ogle.firestore.admin.v1.BulkDeleteDocume" + + "ntsRequest\032\035.google.longrunning.Operatio" + + "n\"\204\001\312A:\n\033BulkDeleteDocumentsResponse\022\033Bu" + + "lkDeleteDocumentsMetadata\332A\004name\202\323\344\223\002:\"5" + + "/v1/{name=projects/*/databases/*}:bulkDe" + + "leteDocuments:\001*\022\331\001\n\016CreateDatabase\0220.go" + + "ogle.firestore.admin.v1.CreateDatabaseRe" + + "quest\032\035.google.longrunning.Operation\"v\312A" + + "\"\n\010Database\022\026CreateDatabaseMetadata\332A\033pa" + + "rent,database,database_id\202\323\344\223\002-\"!/v1/{pa" + + "rent=projects/*}/databases:\010database\022\223\001\n" + + "\013GetDatabase\022-.google.firestore.admin.v1" + + ".GetDatabaseRequest\032#.google.firestore.a" + + "dmin.v1.Database\"0\332A\004name\202\323\344\223\002#\022!/v1/{na" + + "me=projects/*/databases/*}\022\246\001\n\rListDatab" + + "ases\022/.google.firestore.admin.v1.ListDat" + + "abasesRequest\0320.google.firestore.admin.v" + + "1.ListDatabasesResponse\"2\332A\006parent\202\323\344\223\002#" + + "\022!/v1/{parent=projects/*}/databases\022\333\001\n\016" + + "UpdateDatabase\0220.google.firestore.admin." + + "v1.UpdateDatabaseRequest\032\035.google.longru" + + "nning.Operation\"x\312A\"\n\010Database\022\026UpdateDa" + + "tabaseMetadata\332A\024database,update_mask\202\323\344" + + "\223\00262*/v1/{database.name=projects/*/datab" + + "ases/*}:\010database\022\270\001\n\016DeleteDatabase\0220.g" + + "oogle.firestore.admin.v1.DeleteDatabaseR" + + "equest\032\035.google.longrunning.Operation\"U\312" + + "A\"\n\010Database\022\026DeleteDatabaseMetadata\332A\004n" + + "ame\202\323\344\223\002#*!/v1/{name=projects/*/database" + + "s/*}\022\317\001\n\017CreateUserCreds\0221.google.firest" + + "ore.admin.v1.CreateUserCredsRequest\032$.go" + + "ogle.firestore.admin.v1.UserCreds\"c\332A\037pa" + + "rent,user_creds,user_creds_id\202\323\344\223\002;\"-/v1" + + "/{parent=projects/*/databases/*}/userCre" + + "ds:\nuser_creds\022\242\001\n\014GetUserCreds\022..google" + + ".firestore.admin.v1.GetUserCredsRequest\032" + + "$.google.firestore.admin.v1.UserCreds\"<\332" + + "A\004name\202\323\344\223\002/\022-/v1/{name=projects/*/datab" + + "ases/*/userCreds/*}\022\262\001\n\rListUserCreds\022/." + + "google.firestore.admin.v1.ListUserCredsR" + + "equest\0320.google.firestore.admin.v1.ListU" + + "serCredsResponse\">\332A\006parent\202\323\344\223\002/\022-/v1/{" + + "parent=projects/*/databases/*}/userCreds" + + "\022\262\001\n\017EnableUserCreds\0221.google.firestore." + + "admin.v1.EnableUserCredsRequest\032$.google" + + ".firestore.admin.v1.UserCreds\"F\332A\004name\202\323" + + "\344\223\0029\"4/v1/{name=projects/*/databases/*/u" + + "serCreds/*}:enable:\001*\022\265\001\n\020DisableUserCre" + + "ds\0222.google.firestore.admin.v1.DisableUs" + + "erCredsRequest\032$.google.firestore.admin." + + "v1.UserCreds\"G\332A\004name\202\323\344\223\002:\"5/v1/{name=p" + + "rojects/*/databases/*/userCreds/*}:disab" + + "le:\001*\022\275\001\n\021ResetUserPassword\0223.google.fir" + + "estore.admin.v1.ResetUserPasswordRequest" + + "\032$.google.firestore.admin.v1.UserCreds\"M" + + "\332A\004name\202\323\344\223\002@\";/v1/{name=projects/*/data" + + "bases/*/userCreds/*}:resetPassword:\001*\022\232\001" + + "\n\017DeleteUserCreds\0221.google.firestore.adm" + + "in.v1.DeleteUserCredsRequest\032\026.google.pr" + + "otobuf.Empty\"<\332A\004name\202\323\344\223\002/*-/v1/{name=p" + + "rojects/*/databases/*/userCreds/*}\022\227\001\n\tG" + + "etBackup\022+.google.firestore.admin.v1.Get" + + "BackupRequest\032!.google.firestore.admin.v" + + "1.Backup\":\332A\004name\202\323\344\223\002-\022+/v1/{name=proje" + + "cts/*/locations/*/backups/*}\022\252\001\n\013ListBac" + + "kups\022-.google.firestore.admin.v1.ListBac" + + "kupsRequest\032..google.firestore.admin.v1." + + "ListBackupsResponse\"<\332A\006parent\202\323\344\223\002-\022+/v" + + "1/{parent=projects/*/locations/*}/backup" + + "s\022\222\001\n\014DeleteBackup\022..google.firestore.ad" + + "min.v1.DeleteBackupRequest\032\026.google.prot" + + "obuf.Empty\":\332A\004name\202\323\344\223\002-*+/v1/{name=pro" + + "jects/*/locations/*/backups/*}\022\277\001\n\017Resto" + + "reDatabase\0221.google.firestore.admin.v1.R" + + "estoreDatabaseRequest\032\035.google.longrunni" + + "ng.Operation\"Z\312A#\n\010Database\022\027RestoreData" + + "baseMetadata\202\323\344\223\002.\")/v1/{parent=projects" + + "/*}/databases:restore:\001*\022\340\001\n\024CreateBacku" + + "pSchedule\0226.google.firestore.admin.v1.Cr" + + "eateBackupScheduleRequest\032).google.fires" + + "tore.admin.v1.BackupSchedule\"e\332A\026parent," + + "backup_schedule\202\323\344\223\002F\"3/v1/{parent=proje" + + "cts/*/databases/*}/backupSchedules:\017back" + + "up_schedule\022\267\001\n\021GetBackupSchedule\0223.goog" + + "le.firestore.admin.v1.GetBackupScheduleR" + + "equest\032).google.firestore.admin.v1.Backu" + + "pSchedule\"B\332A\004name\202\323\344\223\0025\0223/v1/{name=proj" + + "ects/*/databases/*/backupSchedules/*}\022\312\001" + + "\n\023ListBackupSchedules\0225.google.firestore" + + ".admin.v1.ListBackupSchedulesRequest\0326.g" + + "oogle.firestore.admin.v1.ListBackupSched" + + "ulesResponse\"D\332A\006parent\202\323\344\223\0025\0223/v1/{pare" + + "nt=projects/*/databases/*}/backupSchedul" + + "es\022\365\001\n\024UpdateBackupSchedule\0226.google.fir" + + "estore.admin.v1.UpdateBackupScheduleRequ" + + "est\032).google.firestore.admin.v1.BackupSc" + + "hedule\"z\332A\033backup_schedule,update_mask\202\323" + + "\344\223\002V2C/v1/{backup_schedule.name=projects" + + "/*/databases/*/backupSchedules/*}:\017backu" + + "p_schedule\022\252\001\n\024DeleteBackupSchedule\0226.go" + + "ogle.firestore.admin.v1.DeleteBackupSche" + + "duleRequest\032\026.google.protobuf.Empty\"B\332A\004" + + "name\202\323\344\223\0025*3/v1/{name=projects/*/databas" + + "es/*/backupSchedules/*}\022\267\002\n\rCloneDatabas" + + "e\022/.google.firestore.admin.v1.CloneDatab" + + "aseRequest\032\035.google.longrunning.Operatio" + + "n\"\325\001\312A!\n\010Database\022\025CloneDatabaseMetadata" + + "\202\323\344\223\002,\"\'/v1/{parent=projects/*}/database" + + "s:clone:\001*\212\323\344\223\002y\0224\n\026pitr_snapshot.databa" + + "se\022\032projects/{project_id=*}/**\022A\n\026pitr_s" + + "napshot.database\022\'projects/*/databases/{" + + "database_id=*}/**\032v\312A\030firestore.googleap" + + "is.com\322AXhttps://www.googleapis.com/auth" + + "/cloud-platform,https://www.googleapis.c" + + "om/auth/datastoreB\245\003\n\035com.google.firesto" + + "re.admin.v1B\023FirestoreAdminProtoP\001Z9clou" + + "d.google.com/go/firestore/apiv1/admin/ad" + + "minpb;adminpb\242\002\004GCFS\252\002\037Google.Cloud.Fire" + + "store.Admin.V1\312\002\037Google\\Cloud\\Firestore\\" + + "Admin\\V1\352\002#Google::Cloud::Firestore::Adm" + + "in::V1\352AL\n!firestore.googleapis.com/Loca" + + "tion\022\'projects/{project}/locations/{loca" + + "tion}\352Aq\n(firestore.googleapis.com/Colle" + + "ctionGroup\022Eprojects/{project}/databases" + + "/{database}/collectionGroups/{collection" + + "}b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.AnnotationsProto.getDescriptor(), + com.google.api.ClientProto.getDescriptor(), + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.api.RoutingProto.getDescriptor(), + com.google.firestore.admin.v1.BackupProto.getDescriptor(), + com.google.firestore.admin.v1.DatabaseProto.getDescriptor(), + com.google.firestore.admin.v1.FieldProto.getDescriptor(), + com.google.firestore.admin.v1.IndexProto.getDescriptor(), + com.google.firestore.admin.v1.OperationProto.getDescriptor(), + com.google.firestore.admin.v1.ScheduleProto.getDescriptor(), + com.google.firestore.admin.v1.PitrSnapshotProto.getDescriptor(), + com.google.firestore.admin.v1.UserCredsProto.getDescriptor(), + com.google.longrunning.OperationsProto.getDescriptor(), + com.google.protobuf.EmptyProto.getDescriptor(), + com.google.protobuf.FieldMaskProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_ListDatabasesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor, + new java.lang.String[] { + "Parent", "ShowDeleted", + }); + internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_admin_v1_CreateDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateDatabaseRequest_descriptor, + new java.lang.String[] { + "Parent", "Database", "DatabaseId", + }); + internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor = + getDescriptor().getMessageType(2); + internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateDatabaseMetadata_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor = + getDescriptor().getMessageType(3); + internal_static_google_firestore_admin_v1_ListDatabasesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor, + new java.lang.String[] { + "Databases", "Unreachable", + }); + internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor = + getDescriptor().getMessageType(4); + internal_static_google_firestore_admin_v1_GetDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor = + getDescriptor().getMessageType(5); + internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor, + new java.lang.String[] { + "Database", "UpdateMask", + }); + internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor = + getDescriptor().getMessageType(6); + internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor = + getDescriptor().getMessageType(7); + internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteDatabaseRequest_descriptor, + new java.lang.String[] { + "Name", "Etag", + }); + internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor = + getDescriptor().getMessageType(8); + internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteDatabaseMetadata_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor = + getDescriptor().getMessageType(9); + internal_static_google_firestore_admin_v1_CreateUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateUserCredsRequest_descriptor, + new java.lang.String[] { + "Parent", "UserCreds", "UserCredsId", + }); + internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor = + getDescriptor().getMessageType(10); + internal_static_google_firestore_admin_v1_GetUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor = + getDescriptor().getMessageType(11); + internal_static_google_firestore_admin_v1_ListUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor, + new java.lang.String[] { + "Parent", + }); + internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor = + getDescriptor().getMessageType(12); + internal_static_google_firestore_admin_v1_ListUserCredsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor, + new java.lang.String[] { + "UserCreds", + }); + internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor = + getDescriptor().getMessageType(13); + internal_static_google_firestore_admin_v1_EnableUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_EnableUserCredsRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor = + getDescriptor().getMessageType(14); + internal_static_google_firestore_admin_v1_DisableUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DisableUserCredsRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor = + getDescriptor().getMessageType(15); + internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor = + getDescriptor().getMessageType(16); + internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteUserCredsRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor = + getDescriptor().getMessageType(17); + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Parent", "BackupSchedule", + }); + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor = + getDescriptor().getMessageType(18); + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor = + getDescriptor().getMessageType(19); + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "BackupSchedule", "UpdateMask", + }); + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor = + getDescriptor().getMessageType(20); + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor, + new java.lang.String[] { + "Parent", + }); + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor = + getDescriptor().getMessageType(21); + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor, + new java.lang.String[] { + "BackupSchedules", + }); + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor = + getDescriptor().getMessageType(22); + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor = + getDescriptor().getMessageType(23); + internal_static_google_firestore_admin_v1_CreateIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CreateIndexRequest_descriptor, + new java.lang.String[] { + "Parent", "Index", + }); + internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor = + getDescriptor().getMessageType(24); + internal_static_google_firestore_admin_v1_ListIndexesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor, + new java.lang.String[] { + "Parent", "Filter", "PageSize", "PageToken", + }); + internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor = + getDescriptor().getMessageType(25); + internal_static_google_firestore_admin_v1_ListIndexesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor, + new java.lang.String[] { + "Indexes", "NextPageToken", + }); + internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor = + getDescriptor().getMessageType(26); + internal_static_google_firestore_admin_v1_GetIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor = + getDescriptor().getMessageType(27); + internal_static_google_firestore_admin_v1_DeleteIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteIndexRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor = + getDescriptor().getMessageType(28); + internal_static_google_firestore_admin_v1_UpdateFieldRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor, + new java.lang.String[] { + "Field", "UpdateMask", + }); + internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor = + getDescriptor().getMessageType(29); + internal_static_google_firestore_admin_v1_GetFieldRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor = + getDescriptor().getMessageType(30); + internal_static_google_firestore_admin_v1_ListFieldsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor, + new java.lang.String[] { + "Parent", "Filter", "PageSize", "PageToken", + }); + internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor = + getDescriptor().getMessageType(31); + internal_static_google_firestore_admin_v1_ListFieldsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor, + new java.lang.String[] { + "Fields", "NextPageToken", + }); + internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor = + getDescriptor().getMessageType(32); + internal_static_google_firestore_admin_v1_ExportDocumentsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ExportDocumentsRequest_descriptor, + new java.lang.String[] { + "Name", "CollectionIds", "OutputUriPrefix", "NamespaceIds", "SnapshotTime", + }); + internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor = + getDescriptor().getMessageType(33); + internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor, + new java.lang.String[] { + "Name", "CollectionIds", "InputUriPrefix", "NamespaceIds", + }); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor = + getDescriptor().getMessageType(34); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsRequest_descriptor, + new java.lang.String[] { + "Name", "CollectionIds", "NamespaceIds", + }); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor = + getDescriptor().getMessageType(35); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsResponse_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor = + getDescriptor().getMessageType(36); + internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor = + getDescriptor().getMessageType(37); + internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor, + new java.lang.String[] { + "Parent", "Filter", + }); + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor = + getDescriptor().getMessageType(38); + internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor, + new java.lang.String[] { + "Backups", "Unreachable", + }); + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor = + getDescriptor().getMessageType(39); + internal_static_google_firestore_admin_v1_DeleteBackupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DeleteBackupRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor = + getDescriptor().getMessageType(40); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor, + new java.lang.String[] { + "Parent", "DatabaseId", "Backup", "EncryptionConfig", "Tags", + }); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_descriptor = + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor.getNestedType( + 0); + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor = + getDescriptor().getMessageType(41); + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor, + new java.lang.String[] { + "Parent", "DatabaseId", "PitrSnapshot", "EncryptionConfig", "Tags", + }); + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_descriptor = + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CloneDatabaseRequest_TagsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.api.RoutingProto.getDescriptor(); + com.google.firestore.admin.v1.BackupProto.getDescriptor(); + com.google.firestore.admin.v1.DatabaseProto.getDescriptor(); + com.google.firestore.admin.v1.FieldProto.getDescriptor(); + com.google.firestore.admin.v1.IndexProto.getDescriptor(); + com.google.firestore.admin.v1.OperationProto.getDescriptor(); + com.google.firestore.admin.v1.ScheduleProto.getDescriptor(); + com.google.firestore.admin.v1.PitrSnapshotProto.getDescriptor(); + com.google.firestore.admin.v1.UserCredsProto.getDescriptor(); + com.google.longrunning.OperationsProto.getDescriptor(); + com.google.protobuf.EmptyProto.getDescriptor(); + com.google.protobuf.FieldMaskProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ClientProto.defaultHost); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.AnnotationsProto.http); + registry.add(com.google.api.ClientProto.methodSignature); + registry.add(com.google.api.ClientProto.oauthScopes); + registry.add(com.google.api.ResourceProto.resourceDefinition); + registry.add(com.google.api.ResourceProto.resourceReference); + registry.add(com.google.api.RoutingProto.routing); + registry.add(com.google.longrunning.OperationsProto.operationInfo); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java new file mode 100644 index 000000000000..fc2c5c4d154f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequest.java @@ -0,0 +1,625 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupRequest} + */ +@com.google.protobuf.Generated +public final class GetBackupRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetBackupRequest) + GetBackupRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetBackupRequest"); + } + + // Use GetBackupRequest.newBuilder() to construct. + private GetBackupRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetBackupRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupRequest.class, + com.google.firestore.admin.v1.GetBackupRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetBackupRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetBackupRequest other = + (com.google.firestore.admin.v1.GetBackupRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetBackupRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetBackupRequest) + com.google.firestore.admin.v1.GetBackupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupRequest.class, + com.google.firestore.admin.v1.GetBackupRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetBackupRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest build() { + com.google.firestore.admin.v1.GetBackupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest buildPartial() { + com.google.firestore.admin.v1.GetBackupRequest result = + new com.google.firestore.admin.v1.GetBackupRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetBackupRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetBackupRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetBackupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetBackupRequest other) { + if (other == com.google.firestore.admin.v1.GetBackupRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Name of the backup to fetch.
+     *
+     * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetBackupRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetBackupRequest) + private static final com.google.firestore.admin.v1.GetBackupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetBackupRequest(); + } + + public static com.google.firestore.admin.v1.GetBackupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetBackupRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java new file mode 100644 index 000000000000..ed1c866c7bd1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupRequestOrBuilder.java @@ -0,0 +1,62 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetBackupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetBackupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. Name of the backup to fetch.
+   *
+   * Format is `projects/{project}/locations/{location}/backups/{backup}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java new file mode 100644 index 000000000000..5a7843ac2ce2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequest.java @@ -0,0 +1,634 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupScheduleRequest} + */ +@com.google.protobuf.Generated +public final class GetBackupScheduleRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetBackupScheduleRequest) + GetBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetBackupScheduleRequest"); + } + + // Use GetBackupScheduleRequest.newBuilder() to construct. + private GetBackupScheduleRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetBackupScheduleRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + com.google.firestore.admin.v1.GetBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetBackupScheduleRequest other = + (com.google.firestore.admin.v1.GetBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.GetBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetBackupScheduleRequest) + com.google.firestore.admin.v1.GetBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetBackupScheduleRequest.class, + com.google.firestore.admin.v1.GetBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetBackupScheduleRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest build() { + com.google.firestore.admin.v1.GetBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.GetBackupScheduleRequest result = + new com.google.firestore.admin.v1.GetBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.GetBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the backup schedule.
+     *
+     * Format
+     * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetBackupScheduleRequest) + private static final com.google.firestore.admin.v1.GetBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000000..3c7855fa2513 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetBackupScheduleRequestOrBuilder.java @@ -0,0 +1,64 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. The name of the backup schedule.
+   *
+   * Format
+   * `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequest.java new file mode 100644 index 000000000000..2004e28cbee6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetDatabase][google.firestore.admin.v1.FirestoreAdmin.GetDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class GetDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetDatabaseRequest) + GetDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetDatabaseRequest"); + } + + // Use GetDatabaseRequest.newBuilder() to construct. + private GetDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetDatabaseRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetDatabaseRequest.class, + com.google.firestore.admin.v1.GetDatabaseRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetDatabaseRequest other = + (com.google.firestore.admin.v1.GetDatabaseRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetDatabase][google.firestore.admin.v1.FirestoreAdmin.GetDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetDatabaseRequest) + com.google.firestore.admin.v1.GetDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetDatabaseRequest.class, + com.google.firestore.admin.v1.GetDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetDatabaseRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetDatabaseRequest build() { + com.google.firestore.admin.v1.GetDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.GetDatabaseRequest result = + new com.google.firestore.admin.v1.GetDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.GetDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetDatabaseRequest) + private static final com.google.firestore.admin.v1.GetDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.GetDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..c9893f0b1dad --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetDatabaseRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequest.java new file mode 100644 index 000000000000..f2a1da52b19e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequest.java @@ -0,0 +1,618 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetFieldRequest} + */ +@com.google.protobuf.Generated +public final class GetFieldRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetFieldRequest) + GetFieldRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetFieldRequest"); + } + + // Use GetFieldRequest.newBuilder() to construct. + private GetFieldRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetFieldRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetFieldRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetFieldRequest.class, + com.google.firestore.admin.v1.GetFieldRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetFieldRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetFieldRequest other = + (com.google.firestore.admin.v1.GetFieldRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetFieldRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetFieldRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetFieldRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetFieldRequest) + com.google.firestore.admin.v1.GetFieldRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetFieldRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetFieldRequest.class, + com.google.firestore.admin.v1.GetFieldRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetFieldRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetFieldRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetFieldRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetFieldRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetFieldRequest build() { + com.google.firestore.admin.v1.GetFieldRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetFieldRequest buildPartial() { + com.google.firestore.admin.v1.GetFieldRequest result = + new com.google.firestore.admin.v1.GetFieldRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetFieldRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetFieldRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetFieldRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetFieldRequest other) { + if (other == com.google.firestore.admin.v1.GetFieldRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetFieldRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetFieldRequest) + private static final com.google.firestore.admin.v1.GetFieldRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetFieldRequest(); + } + + public static com.google.firestore.admin.v1.GetFieldRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetFieldRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetFieldRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequestOrBuilder.java new file mode 100644 index 000000000000..945dd513b93c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetFieldRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetFieldRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetFieldRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequest.java new file mode 100644 index 000000000000..72a9c7131607 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequest.java @@ -0,0 +1,618 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetIndexRequest} + */ +@com.google.protobuf.Generated +public final class GetIndexRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetIndexRequest) + GetIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetIndexRequest"); + } + + // Use GetIndexRequest.newBuilder() to construct. + private GetIndexRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetIndexRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetIndexRequest.class, + com.google.firestore.admin.v1.GetIndexRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetIndexRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetIndexRequest other = + (com.google.firestore.admin.v1.GetIndexRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetIndexRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetIndexRequest) + com.google.firestore.admin.v1.GetIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetIndexRequest.class, + com.google.firestore.admin.v1.GetIndexRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetIndexRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetIndexRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetIndexRequest build() { + com.google.firestore.admin.v1.GetIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetIndexRequest buildPartial() { + com.google.firestore.admin.v1.GetIndexRequest result = + new com.google.firestore.admin.v1.GetIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetIndexRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetIndexRequest other) { + if (other == com.google.firestore.admin.v1.GetIndexRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetIndexRequest) + private static final com.google.firestore.admin.v1.GetIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetIndexRequest(); + } + + public static com.google.firestore.admin.v1.GetIndexRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetIndexRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequestOrBuilder.java new file mode 100644 index 000000000000..c7392133df9d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetIndexRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequest.java new file mode 100644 index 000000000000..5b1f29a0831c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.GetUserCreds][google.firestore.admin.v1.FirestoreAdmin.GetUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class GetUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.GetUserCredsRequest) + GetUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetUserCredsRequest"); + } + + // Use GetUserCredsRequest.newBuilder() to construct. + private GetUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetUserCredsRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetUserCredsRequest.class, + com.google.firestore.admin.v1.GetUserCredsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.GetUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.GetUserCredsRequest other = + (com.google.firestore.admin.v1.GetUserCredsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.GetUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.GetUserCreds][google.firestore.admin.v1.FirestoreAdmin.GetUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.GetUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.GetUserCredsRequest) + com.google.firestore.admin.v1.GetUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.GetUserCredsRequest.class, + com.google.firestore.admin.v1.GetUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.GetUserCredsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_GetUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.GetUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetUserCredsRequest build() { + com.google.firestore.admin.v1.GetUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.GetUserCredsRequest result = + new com.google.firestore.admin.v1.GetUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.GetUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.GetUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.GetUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.GetUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.GetUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.GetUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.GetUserCredsRequest) + private static final com.google.firestore.admin.v1.GetUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.GetUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.GetUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.GetUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..19b7c2b1b1e2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/GetUserCredsRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface GetUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.GetUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadata.java new file mode 100644 index 000000000000..81a71b4b4ffc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadata.java @@ -0,0 +1,2474 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+ * results from
+ * [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ImportDocumentsMetadata} + */ +@com.google.protobuf.Generated +public final class ImportDocumentsMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ImportDocumentsMetadata) + ImportDocumentsMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ImportDocumentsMetadata"); + } + + // Use ImportDocumentsMetadata.newBuilder() to construct. + private ImportDocumentsMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ImportDocumentsMetadata() { + operationState_ = 0; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + inputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ImportDocumentsMetadata.class, + com.google.firestore.admin.v1.ImportDocumentsMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + + /** + * + * + *
+   * The state of the import operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+   * The state of the import operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int PROGRESS_DOCUMENTS_FIELD_NUMBER = 4; + private com.google.firestore.admin.v1.Progress progressDocuments_; + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + @java.lang.Override + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 5; + private com.google.firestore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int INPUT_URI_PREFIX_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object inputUriPrefix_ = ""; + + /** + * + * + *
+   * The location of the documents being imported.
+   * 
+ * + * string input_uri_prefix = 7; + * + * @return The inputUriPrefix. + */ + @java.lang.Override + public java.lang.String getInputUriPrefix() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUriPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * The location of the documents being imported.
+   * 
+ * + * string input_uri_prefix = 7; + * + * @return The bytes for inputUriPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getInputUriPrefixBytes() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(5, getProgressBytes()); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, collectionIds_.getRaw(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(inputUriPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, inputUriPrefix_); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 8, namespaceIds_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getProgressBytes()); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(inputUriPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(7, inputUriPrefix_); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ImportDocumentsMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ImportDocumentsMetadata other = + (com.google.firestore.admin.v1.ImportDocumentsMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (hasProgressDocuments() != other.hasProgressDocuments()) return false; + if (hasProgressDocuments()) { + if (!getProgressDocuments().equals(other.getProgressDocuments())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getInputUriPrefix().equals(other.getInputUriPrefix())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + if (hasProgressDocuments()) { + hash = (37 * hash) + PROGRESS_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getProgressDocuments().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + hash = (37 * hash) + INPUT_URI_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getInputUriPrefix().hashCode(); + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ImportDocumentsMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+   * results from
+   * [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ImportDocumentsMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ImportDocumentsMetadata) + com.google.firestore.admin.v1.ImportDocumentsMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ImportDocumentsMetadata.class, + com.google.firestore.admin.v1.ImportDocumentsMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ImportDocumentsMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetProgressDocumentsFieldBuilder(); + internalGetProgressBytesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + inputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ImportDocumentsMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsMetadata build() { + com.google.firestore.admin.v1.ImportDocumentsMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsMetadata buildPartial() { + com.google.firestore.admin.v1.ImportDocumentsMetadata result = + new com.google.firestore.admin.v1.ImportDocumentsMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ImportDocumentsMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.progressDocuments_ = + progressDocumentsBuilder_ == null + ? progressDocuments_ + : progressDocumentsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.inputUriPrefix_ = inputUriPrefix_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ImportDocumentsMetadata) { + return mergeFrom((com.google.firestore.admin.v1.ImportDocumentsMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ImportDocumentsMetadata other) { + if (other == com.google.firestore.admin.v1.ImportDocumentsMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (other.hasProgressDocuments()) { + mergeProgressDocuments(other.getProgressDocuments()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000020; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.getInputUriPrefix().isEmpty()) { + inputUriPrefix_ = other.inputUriPrefix_; + bitField0_ |= 0x00000040; + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000080; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage( + internalGetProgressDocumentsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 50 + case 58: + { + inputUriPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000040; + break; + } // case 58 + case 66: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + + /** + * + * + *
+     * The state of the import operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+     * The state of the import operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the import operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The state of the import operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the import operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressDocuments_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressDocumentsBuilder_; + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + if (progressDocumentsBuilder_ == null) { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } else { + return progressDocumentsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressDocuments_ = value; + } else { + progressDocumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder setProgressDocuments( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressDocumentsBuilder_ == null) { + progressDocuments_ = builderForValue.build(); + } else { + progressDocumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder mergeProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && progressDocuments_ != null + && progressDocuments_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressDocumentsBuilder().mergeFrom(value); + } else { + progressDocuments_ = value; + } + } else { + progressDocumentsBuilder_.mergeFrom(value); + } + if (progressDocuments_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public Builder clearProgressDocuments() { + bitField0_ = (bitField0_ & ~0x00000008); + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressDocumentsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetProgressDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + if (progressDocumentsBuilder_ != null) { + return progressDocumentsBuilder_.getMessageOrBuilder(); + } else { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressDocumentsFieldBuilder() { + if (progressDocumentsBuilder_ == null) { + progressDocumentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressDocuments(), getParentForChildren(), isClean()); + progressDocuments_ = null; + } + return progressDocumentsBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + public com.google.firestore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder setProgressBytes( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder mergeProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000010); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000020; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which collection IDs are being imported.
+     * 
+ * + * repeated string collection_ids = 6; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + private java.lang.Object inputUriPrefix_ = ""; + + /** + * + * + *
+     * The location of the documents being imported.
+     * 
+ * + * string input_uri_prefix = 7; + * + * @return The inputUriPrefix. + */ + public java.lang.String getInputUriPrefix() { + java.lang.Object ref = inputUriPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUriPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The location of the documents being imported.
+     * 
+ * + * string input_uri_prefix = 7; + * + * @return The bytes for inputUriPrefix. + */ + public com.google.protobuf.ByteString getInputUriPrefixBytes() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The location of the documents being imported.
+     * 
+ * + * string input_uri_prefix = 7; + * + * @param value The inputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setInputUriPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + inputUriPrefix_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the documents being imported.
+     * 
+ * + * string input_uri_prefix = 7; + * + * @return This builder for chaining. + */ + public Builder clearInputUriPrefix() { + inputUriPrefix_ = getDefaultInstance().getInputUriPrefix(); + bitField0_ = (bitField0_ & ~0x00000040); + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the documents being imported.
+     * 
+ * + * string input_uri_prefix = 7; + * + * @param value The bytes for inputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setInputUriPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + inputUriPrefix_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000080; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000080); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * Which namespace IDs are being imported.
+     * 
+ * + * repeated string namespace_ids = 8; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ImportDocumentsMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ImportDocumentsMetadata) + private static final com.google.firestore.admin.v1.ImportDocumentsMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ImportDocumentsMetadata(); + } + + public static com.google.firestore.admin.v1.ImportDocumentsMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ImportDocumentsMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadataOrBuilder.java new file mode 100644 index 000000000000..4716c795d54b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsMetadataOrBuilder.java @@ -0,0 +1,339 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ImportDocumentsMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ImportDocumentsMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The state of the import operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + + /** + * + * + *
+   * The state of the import operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return Whether the progressDocuments field is set. + */ + boolean hasProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + * + * @return The progressDocuments. + */ + com.google.firestore.admin.v1.Progress getProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 4; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + * + * @return The progressBytes. + */ + com.google.firestore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 5; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * Which collection IDs are being imported.
+   * 
+ * + * repeated string collection_ids = 6; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * The location of the documents being imported.
+   * 
+ * + * string input_uri_prefix = 7; + * + * @return The inputUriPrefix. + */ + java.lang.String getInputUriPrefix(); + + /** + * + * + *
+   * The location of the documents being imported.
+   * 
+ * + * string input_uri_prefix = 7; + * + * @return The bytes for inputUriPrefix. + */ + com.google.protobuf.ByteString getInputUriPrefixBytes(); + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * Which namespace IDs are being imported.
+   * 
+ * + * repeated string namespace_ids = 8; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequest.java new file mode 100644 index 000000000000..96ef6bb43628 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequest.java @@ -0,0 +1,1507 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ImportDocumentsRequest} + */ +@com.google.protobuf.Generated +public final class ImportDocumentsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ImportDocumentsRequest) + ImportDocumentsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ImportDocumentsRequest"); + } + + // Use ImportDocumentsRequest.newBuilder() to construct. + private ImportDocumentsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ImportDocumentsRequest() { + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + inputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ImportDocumentsRequest.class, + com.google.firestore.admin.v1.ImportDocumentsRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. Database to import into. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Database to import into. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int INPUT_URI_PREFIX_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object inputUriPrefix_ = ""; + + /** + * + * + *
+   * Location of the exported files.
+   * This must match the output_uri_prefix of an ExportDocumentsResponse from
+   * an export that has completed successfully.
+   * See:
+   * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+   * 
+ * + * string input_uri_prefix = 3; + * + * @return The inputUriPrefix. + */ + @java.lang.Override + public java.lang.String getInputUriPrefix() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUriPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Location of the exported files.
+   * This must match the output_uri_prefix of an ExportDocumentsResponse from
+   * an export that has completed successfully.
+   * See:
+   * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+   * 
+ * + * string input_uri_prefix = 3; + * + * @return The bytes for inputUriPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getInputUriPrefixBytes() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + return namespaceIds_; + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionIds_.getRaw(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(inputUriPrefix_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, inputUriPrefix_); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, namespaceIds_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(inputUriPrefix_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, inputUriPrefix_); + } + { + int dataSize = 0; + for (int i = 0; i < namespaceIds_.size(); i++) { + dataSize += computeStringSizeNoTag(namespaceIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getNamespaceIdsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ImportDocumentsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ImportDocumentsRequest other = + (com.google.firestore.admin.v1.ImportDocumentsRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getInputUriPrefix().equals(other.getInputUriPrefix())) return false; + if (!getNamespaceIdsList().equals(other.getNamespaceIdsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + hash = (37 * hash) + INPUT_URI_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getInputUriPrefix().hashCode(); + if (getNamespaceIdsCount() > 0) { + hash = (37 * hash) + NAMESPACE_IDS_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceIdsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ImportDocumentsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ImportDocumentsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ImportDocumentsRequest) + com.google.firestore.admin.v1.ImportDocumentsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ImportDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ImportDocumentsRequest.class, + com.google.firestore.admin.v1.ImportDocumentsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ImportDocumentsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + inputUriPrefix_ = ""; + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ImportDocumentsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ImportDocumentsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsRequest build() { + com.google.firestore.admin.v1.ImportDocumentsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsRequest buildPartial() { + com.google.firestore.admin.v1.ImportDocumentsRequest result = + new com.google.firestore.admin.v1.ImportDocumentsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ImportDocumentsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.inputUriPrefix_ = inputUriPrefix_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ImportDocumentsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ImportDocumentsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ImportDocumentsRequest other) { + if (other == com.google.firestore.admin.v1.ImportDocumentsRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000002; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.getInputUriPrefix().isEmpty()) { + inputUriPrefix_ = other.inputUriPrefix_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000008; + } else { + ensureNamespaceIdsIsMutable(); + namespaceIds_.addAll(other.namespaceIds_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 18 + case 26: + { + inputUriPrefix_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(s); + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. Database to import into. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Database to import into. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Database to import into. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to import into. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database to import into. Should be of the form:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * IDs of the collection groups to import. Unspecified means all collection
+     * groups that were included in the export. Each collection group in this list
+     * must be unique.
+     * 
+ * + * repeated string collection_ids = 2; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object inputUriPrefix_ = ""; + + /** + * + * + *
+     * Location of the exported files.
+     * This must match the output_uri_prefix of an ExportDocumentsResponse from
+     * an export that has completed successfully.
+     * See:
+     * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+     * 
+ * + * string input_uri_prefix = 3; + * + * @return The inputUriPrefix. + */ + public java.lang.String getInputUriPrefix() { + java.lang.Object ref = inputUriPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUriPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Location of the exported files.
+     * This must match the output_uri_prefix of an ExportDocumentsResponse from
+     * an export that has completed successfully.
+     * See:
+     * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+     * 
+ * + * string input_uri_prefix = 3; + * + * @return The bytes for inputUriPrefix. + */ + public com.google.protobuf.ByteString getInputUriPrefixBytes() { + java.lang.Object ref = inputUriPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUriPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Location of the exported files.
+     * This must match the output_uri_prefix of an ExportDocumentsResponse from
+     * an export that has completed successfully.
+     * See:
+     * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+     * 
+ * + * string input_uri_prefix = 3; + * + * @param value The inputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setInputUriPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + inputUriPrefix_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the exported files.
+     * This must match the output_uri_prefix of an ExportDocumentsResponse from
+     * an export that has completed successfully.
+     * See:
+     * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+     * 
+ * + * string input_uri_prefix = 3; + * + * @return This builder for chaining. + */ + public Builder clearInputUriPrefix() { + inputUriPrefix_ = getDefaultInstance().getInputUriPrefix(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the exported files.
+     * This must match the output_uri_prefix of an ExportDocumentsResponse from
+     * an export that has completed successfully.
+     * See:
+     * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+     * 
+ * + * string input_uri_prefix = 3; + * + * @param value The bytes for inputUriPrefix to set. + * @return This builder for chaining. + */ + public Builder setInputUriPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + inputUriPrefix_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList namespaceIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureNamespaceIdsIsMutable() { + if (!namespaceIds_.isModifiable()) { + namespaceIds_ = new com.google.protobuf.LazyStringArrayList(namespaceIds_); + } + bitField0_ |= 0x00000008; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + public com.google.protobuf.ProtocolStringList getNamespaceIdsList() { + namespaceIds_.makeImmutable(); + return namespaceIds_; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + public java.lang.String getNamespaceIds(int index) { + return namespaceIds_.get(index); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + public com.google.protobuf.ByteString getNamespaceIdsBytes(int index) { + return namespaceIds_.getByteString(index); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index to set the value at. + * @param value The namespaceIds to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.set(index, value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param value The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param values The namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addAllNamespaceIds(java.lang.Iterable values) { + ensureNamespaceIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, namespaceIds_); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for databases that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the database has data in non-default namespaces, but doesn't want
+     * to include them. Each namespace in this list must be unique.
+     * 
+ * + * repeated string namespace_ids = 4; + * + * @param value The bytes of the namespaceIds to add. + * @return This builder for chaining. + */ + public Builder addNamespaceIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureNamespaceIdsIsMutable(); + namespaceIds_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ImportDocumentsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ImportDocumentsRequest) + private static final com.google.firestore.admin.v1.ImportDocumentsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ImportDocumentsRequest(); + } + + public static com.google.firestore.admin.v1.ImportDocumentsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ImportDocumentsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ImportDocumentsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequestOrBuilder.java new file mode 100644 index 000000000000..bca37430e364 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ImportDocumentsRequestOrBuilder.java @@ -0,0 +1,230 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ImportDocumentsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ImportDocumentsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Database to import into. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. Database to import into. Should be of the form:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * IDs of the collection groups to import. Unspecified means all collection
+   * groups that were included in the export. Each collection group in this list
+   * must be unique.
+   * 
+ * + * repeated string collection_ids = 2; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * Location of the exported files.
+   * This must match the output_uri_prefix of an ExportDocumentsResponse from
+   * an export that has completed successfully.
+   * See:
+   * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+   * 
+ * + * string input_uri_prefix = 3; + * + * @return The inputUriPrefix. + */ + java.lang.String getInputUriPrefix(); + + /** + * + * + *
+   * Location of the exported files.
+   * This must match the output_uri_prefix of an ExportDocumentsResponse from
+   * an export that has completed successfully.
+   * See:
+   * [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix].
+   * 
+ * + * string input_uri_prefix = 3; + * + * @return The bytes for inputUriPrefix. + */ + com.google.protobuf.ByteString getInputUriPrefixBytes(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the element to return. + * @return The namespaceIds at the given index. + */ + java.lang.String getNamespaceIds(int index); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for databases that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the database has data in non-default namespaces, but doesn't want
+   * to include them. Each namespace in this list must be unique.
+   * 
+ * + * repeated string namespace_ids = 4; + * + * @param index The index of the value to return. + * @return The bytes of the namespaceIds at the given index. + */ + com.google.protobuf.ByteString getNamespaceIdsBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java new file mode 100644 index 000000000000..a584a05c5aad --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Index.java @@ -0,0 +1,6540 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/index.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Cloud Firestore indexes enable simple and complex queries against
+ * documents in a database.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index} + */ +@com.google.protobuf.Generated +public final class Index extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index) + IndexOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Index"); + } + + // Use Index.newBuilder() to construct. + private Index(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Index() { + name_ = ""; + queryScope_ = 0; + apiScope_ = 0; + fields_ = java.util.Collections.emptyList(); + state_ = 0; + density_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.class, + com.google.firestore.admin.v1.Index.Builder.class); + } + + /** + * + * + *
+   * Query Scope defines the scope at which a query is run. This is specified on
+   * a StructuredQuery's `from` field.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.QueryScope} + */ + public enum QueryScope implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The query scope is unspecified. Not a valid option.
+     * 
+ * + * QUERY_SCOPE_UNSPECIFIED = 0; + */ + QUERY_SCOPE_UNSPECIFIED(0), + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified
+     * at query time, and that has the collection ID specified by the index.
+     * 
+ * + * COLLECTION = 1; + */ + COLLECTION(1), + /** + * + * + *
+     * Indexes with a collection group query scope specified allow queries
+     * against all collections that has the collection ID specified by the
+     * index.
+     * 
+ * + * COLLECTION_GROUP = 2; + */ + COLLECTION_GROUP(2), + /** + * + * + *
+     * Include all the collections's ancestor in the index. Only available for
+     * Datastore Mode databases.
+     * 
+ * + * COLLECTION_RECURSIVE = 3; + */ + COLLECTION_RECURSIVE(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "QueryScope"); + } + + /** + * + * + *
+     * The query scope is unspecified. Not a valid option.
+     * 
+ * + * QUERY_SCOPE_UNSPECIFIED = 0; + */ + public static final int QUERY_SCOPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified
+     * at query time, and that has the collection ID specified by the index.
+     * 
+ * + * COLLECTION = 1; + */ + public static final int COLLECTION_VALUE = 1; + + /** + * + * + *
+     * Indexes with a collection group query scope specified allow queries
+     * against all collections that has the collection ID specified by the
+     * index.
+     * 
+ * + * COLLECTION_GROUP = 2; + */ + public static final int COLLECTION_GROUP_VALUE = 2; + + /** + * + * + *
+     * Include all the collections's ancestor in the index. Only available for
+     * Datastore Mode databases.
+     * 
+ * + * COLLECTION_RECURSIVE = 3; + */ + public static final int COLLECTION_RECURSIVE_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryScope valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static QueryScope forNumber(int value) { + switch (value) { + case 0: + return QUERY_SCOPE_UNSPECIFIED; + case 1: + return COLLECTION; + case 2: + return COLLECTION_GROUP; + case 3: + return COLLECTION_RECURSIVE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public QueryScope findValueByNumber(int number) { + return QueryScope.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.getDescriptor().getEnumTypes().get(0); + } + + private static final QueryScope[] VALUES = values(); + + public static QueryScope valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private QueryScope(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.QueryScope) + } + + /** + * + * + *
+   * API Scope defines the APIs (Firestore Native, or Firestore in
+   * Datastore Mode) that are supported for queries.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.ApiScope} + */ + public enum ApiScope implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The index can only be used by the Firestore Native query API.
+     * This is the default.
+     * 
+ * + * ANY_API = 0; + */ + ANY_API(0), + /** + * + * + *
+     * The index can only be used by the Firestore in Datastore Mode query API.
+     * 
+ * + * DATASTORE_MODE_API = 1; + */ + DATASTORE_MODE_API(1), + /** + * + * + *
+     * The index can only be used by the MONGODB_COMPATIBLE_API.
+     * 
+ * + * MONGODB_COMPATIBLE_API = 2; + */ + MONGODB_COMPATIBLE_API(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ApiScope"); + } + + /** + * + * + *
+     * The index can only be used by the Firestore Native query API.
+     * This is the default.
+     * 
+ * + * ANY_API = 0; + */ + public static final int ANY_API_VALUE = 0; + + /** + * + * + *
+     * The index can only be used by the Firestore in Datastore Mode query API.
+     * 
+ * + * DATASTORE_MODE_API = 1; + */ + public static final int DATASTORE_MODE_API_VALUE = 1; + + /** + * + * + *
+     * The index can only be used by the MONGODB_COMPATIBLE_API.
+     * 
+ * + * MONGODB_COMPATIBLE_API = 2; + */ + public static final int MONGODB_COMPATIBLE_API_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ApiScope valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ApiScope forNumber(int value) { + switch (value) { + case 0: + return ANY_API; + case 1: + return DATASTORE_MODE_API; + case 2: + return MONGODB_COMPATIBLE_API; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ApiScope findValueByNumber(int number) { + return ApiScope.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.getDescriptor().getEnumTypes().get(1); + } + + private static final ApiScope[] VALUES = values(); + + public static ApiScope valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ApiScope(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.ApiScope) + } + + /** + * + * + *
+   * The state of an index. During index creation, an index will be in the
+   * `CREATING` state. If the index is created successfully, it will transition
+   * to the `READY` state. If the index creation encounters a problem, the index
+   * will transition to the `NEEDS_REPAIR` state.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+     * The index is being created.
+     * There is an active long-running operation for the index.
+     * The index is updated when writing a document.
+     * Some index data may exist.
+     * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+     * The index is ready to be used.
+     * The index is updated when writing a document.
+     * The index is fully populated from all stored documents it applies to.
+     * 
+ * + * READY = 2; + */ + READY(2), + /** + * + * + *
+     * The index was being created, but something went wrong.
+     * There is no active long-running operation for the index,
+     * and the most recently finished long-running operation failed.
+     * The index is not updated when writing a document.
+     * Some index data may exist.
+     * Use the google.longrunning.Operations API to determine why the operation
+     * that last attempted to create this index failed, then re-create the
+     * index.
+     * 
+ * + * NEEDS_REPAIR = 3; + */ + NEEDS_REPAIR(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "State"); + } + + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The index is being created.
+     * There is an active long-running operation for the index.
+     * The index is updated when writing a document.
+     * Some index data may exist.
+     * 
+ * + * CREATING = 1; + */ + public static final int CREATING_VALUE = 1; + + /** + * + * + *
+     * The index is ready to be used.
+     * The index is updated when writing a document.
+     * The index is fully populated from all stored documents it applies to.
+     * 
+ * + * READY = 2; + */ + public static final int READY_VALUE = 2; + + /** + * + * + *
+     * The index was being created, but something went wrong.
+     * There is no active long-running operation for the index,
+     * and the most recently finished long-running operation failed.
+     * The index is not updated when writing a document.
+     * Some index data may exist.
+     * Use the google.longrunning.Operations API to determine why the operation
+     * that last attempted to create this index failed, then re-create the
+     * index.
+     * 
+ * + * NEEDS_REPAIR = 3; + */ + public static final int NEEDS_REPAIR_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return CREATING; + case 2: + return READY; + case 3: + return NEEDS_REPAIR; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.getDescriptor().getEnumTypes().get(2); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.State) + } + + /** + * + * + *
+   * The density configuration for the index.
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.Density} + */ + public enum Density implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. It will use database default setting. This value is input
+     * only.
+     * 
+ * + * DENSITY_UNSPECIFIED = 0; + */ + DENSITY_UNSPECIFIED(0), + /** + * + * + *
+     * An index entry will only exist if ALL fields are present in the document.
+     *
+     * This is both the default and only allowed value for Standard Edition
+     * databases (for both Cloud Firestore `ANY_API` and Cloud Datastore
+     * `DATASTORE_MODE_API`).
+     *
+     * Take for example the following document:
+     *
+     * ```
+     * {
+     * "__name__": "...",
+     * "a": 1,
+     * "b": 2,
+     * "c": 3
+     * }
+     * ```
+     *
+     * an index on `(a ASC, b ASC, c ASC, __name__ ASC)` will generate an index
+     * entry for this document since `a`, 'b', `c`, and `__name__` are all
+     * present but an index of `(a ASC, d ASC, __name__ ASC)` will not generate
+     * an index entry for this document since `d` is missing.
+     *
+     * This means that such indexes can only be used to serve a query when the
+     * query has either implicit or explicit requirements that all fields from
+     * the index are present.
+     * 
+ * + * SPARSE_ALL = 1; + */ + SPARSE_ALL(1), + /** + * + * + *
+     * An index entry will exist if ANY field are present in the document.
+     *
+     * This is used as the definition of a sparse index for Enterprise Edition
+     * databases.
+     *
+     * Take for example the following document:
+     *
+     * ```
+     * {
+     * "__name__": "...",
+     * "a": 1,
+     * "b": 2,
+     * "c": 3
+     * }
+     * ```
+     *
+     * an index on `(a ASC, d ASC)` will generate an index entry for this
+     * document since `a` is present, and will fill in an `unset` value for `d`.
+     * An index on `(d ASC, e ASC)` will not generate any index entry as neither
+     * `d` nor `e` are present.
+     *
+     * An index that contains `__name__` will generate an index entry for all
+     * documents since Firestore guarantees that all documents have a `__name__`
+     * field.
+     * 
+ * + * SPARSE_ANY = 2; + */ + SPARSE_ANY(2), + /** + * + * + *
+     * An index entry will exist regardless of if the fields are present or not.
+     *
+     * This is the default density for an Enterprise Edition database.
+     *
+     * The index will store `unset` values for fields that are not present in
+     * the document.
+     * 
+ * + * DENSE = 3; + */ + DENSE(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Density"); + } + + /** + * + * + *
+     * Unspecified. It will use database default setting. This value is input
+     * only.
+     * 
+ * + * DENSITY_UNSPECIFIED = 0; + */ + public static final int DENSITY_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * An index entry will only exist if ALL fields are present in the document.
+     *
+     * This is both the default and only allowed value for Standard Edition
+     * databases (for both Cloud Firestore `ANY_API` and Cloud Datastore
+     * `DATASTORE_MODE_API`).
+     *
+     * Take for example the following document:
+     *
+     * ```
+     * {
+     * "__name__": "...",
+     * "a": 1,
+     * "b": 2,
+     * "c": 3
+     * }
+     * ```
+     *
+     * an index on `(a ASC, b ASC, c ASC, __name__ ASC)` will generate an index
+     * entry for this document since `a`, 'b', `c`, and `__name__` are all
+     * present but an index of `(a ASC, d ASC, __name__ ASC)` will not generate
+     * an index entry for this document since `d` is missing.
+     *
+     * This means that such indexes can only be used to serve a query when the
+     * query has either implicit or explicit requirements that all fields from
+     * the index are present.
+     * 
+ * + * SPARSE_ALL = 1; + */ + public static final int SPARSE_ALL_VALUE = 1; + + /** + * + * + *
+     * An index entry will exist if ANY field are present in the document.
+     *
+     * This is used as the definition of a sparse index for Enterprise Edition
+     * databases.
+     *
+     * Take for example the following document:
+     *
+     * ```
+     * {
+     * "__name__": "...",
+     * "a": 1,
+     * "b": 2,
+     * "c": 3
+     * }
+     * ```
+     *
+     * an index on `(a ASC, d ASC)` will generate an index entry for this
+     * document since `a` is present, and will fill in an `unset` value for `d`.
+     * An index on `(d ASC, e ASC)` will not generate any index entry as neither
+     * `d` nor `e` are present.
+     *
+     * An index that contains `__name__` will generate an index entry for all
+     * documents since Firestore guarantees that all documents have a `__name__`
+     * field.
+     * 
+ * + * SPARSE_ANY = 2; + */ + public static final int SPARSE_ANY_VALUE = 2; + + /** + * + * + *
+     * An index entry will exist regardless of if the fields are present or not.
+     *
+     * This is the default density for an Enterprise Edition database.
+     *
+     * The index will store `unset` values for fields that are not present in
+     * the document.
+     * 
+ * + * DENSE = 3; + */ + public static final int DENSE_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Density valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Density forNumber(int value) { + switch (value) { + case 0: + return DENSITY_UNSPECIFIED; + case 1: + return SPARSE_ALL; + case 2: + return SPARSE_ANY; + case 3: + return DENSE; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Density findValueByNumber(int number) { + return Density.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.getDescriptor().getEnumTypes().get(3); + } + + private static final Density[] VALUES = values(); + + public static Density valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Density(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.Density) + } + + public interface IndexFieldOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index.IndexField) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Can be __name__.
+     * For single field indexes, this must match the name of the field or may
+     * be omitted.
+     * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + java.lang.String getFieldPath(); + + /** + * + * + *
+     * Can be __name__.
+     * For single field indexes, this must match the name of the field or may
+     * be omitted.
+     * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + 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(); + + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, !=, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return The enum numeric value on the wire for order. + */ + int getOrderValue(); + + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, !=, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return The order. + */ + 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(); + + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The enum numeric value on the wire for arrayConfig. + */ + int getArrayConfigValue(); + + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The arrayConfig. + */ + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig getArrayConfig(); + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + boolean hasVectorConfig(); + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig(); + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder getVectorConfigOrBuilder(); + + com.google.firestore.admin.v1.Index.IndexField.ValueModeCase getValueModeCase(); + } + + /** + * + * + *
+   * A field in an index.
+   * The field_path describes which field is indexed, the value_mode describes
+   * how the field value is indexed.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField} + */ + public static final class IndexField extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index.IndexField) + IndexFieldOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "IndexField"); + } + + // Use IndexField.newBuilder() to construct. + private IndexField(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private IndexField() { + fieldPath_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.class, + com.google.firestore.admin.v1.Index.IndexField.Builder.class); + } + + /** + * + * + *
+     * The supported orderings.
+     * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.IndexField.Order} + */ + public enum Order implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The ordering is unspecified. Not a valid option.
+       * 
+ * + * ORDER_UNSPECIFIED = 0; + */ + ORDER_UNSPECIFIED(0), + /** + * + * + *
+       * The field is ordered by ascending field value.
+       * 
+ * + * ASCENDING = 1; + */ + ASCENDING(1), + /** + * + * + *
+       * The field is ordered by descending field value.
+       * 
+ * + * DESCENDING = 2; + */ + DESCENDING(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Order"); + } + + /** + * + * + *
+       * The ordering is unspecified. Not a valid option.
+       * 
+ * + * ORDER_UNSPECIFIED = 0; + */ + public static final int ORDER_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The field is ordered by ascending field value.
+       * 
+ * + * ASCENDING = 1; + */ + public static final int ASCENDING_VALUE = 1; + + /** + * + * + *
+       * The field is ordered by descending field value.
+       * 
+ * + * DESCENDING = 2; + */ + public static final int DESCENDING_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Order valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Order forNumber(int value) { + switch (value) { + case 0: + return ORDER_UNSPECIFIED; + case 1: + return ASCENDING; + case 2: + return DESCENDING; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Order findValueByNumber(int number) { + return Order.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.IndexField.getDescriptor().getEnumTypes().get(0); + } + + private static final Order[] VALUES = values(); + + public static Order valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Order(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.IndexField.Order) + } + + /** + * + * + *
+     * The supported array value configurations.
+     * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.Index.IndexField.ArrayConfig} + */ + public enum ArrayConfig implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * The index does not support additional array queries.
+       * 
+ * + * ARRAY_CONFIG_UNSPECIFIED = 0; + */ + ARRAY_CONFIG_UNSPECIFIED(0), + /** + * + * + *
+       * The index supports array containment queries.
+       * 
+ * + * CONTAINS = 1; + */ + CONTAINS(1), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ArrayConfig"); + } + + /** + * + * + *
+       * The index does not support additional array queries.
+       * 
+ * + * ARRAY_CONFIG_UNSPECIFIED = 0; + */ + public static final int ARRAY_CONFIG_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The index supports array containment queries.
+       * 
+ * + * CONTAINS = 1; + */ + public static final int CONTAINS_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ArrayConfig valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ArrayConfig forNumber(int value) { + switch (value) { + case 0: + return ARRAY_CONFIG_UNSPECIFIED; + case 1: + return CONTAINS; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ArrayConfig findValueByNumber(int number) { + return ArrayConfig.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.Index.IndexField.getDescriptor().getEnumTypes().get(1); + } + + private static final ArrayConfig[] VALUES = values(); + + public static ArrayConfig valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ArrayConfig(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.Index.IndexField.ArrayConfig) + } + + public interface VectorConfigOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index.IndexField.VectorConfig) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * Required. The vector dimension this configuration applies to.
+       *
+       * The resulting index will only include vectors of this dimension, and
+       * can be used for vector search with the same dimension.
+       * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + int getDimension(); + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + boolean hasFlat(); + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat(); + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder(); + + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.TypeCase getTypeCase(); + } + + /** + * + * + *
+     * The index configuration to support vector search operations
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig} + */ + public static final class VectorConfig extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig) + VectorConfigOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "VectorConfig"); + } + + // Use VectorConfig.newBuilder() to construct. + private VectorConfig(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private VectorConfig() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder.class); + } + + public interface FlatIndexOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + com.google.protobuf.MessageOrBuilder {} + + /** + * + * + *
+       * An index that stores vectors in a flat data structure, and supports
+       * exhaustive search.
+       * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex} + */ + public static final class FlatIndex extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + FlatIndexOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FlatIndex"); + } + + // Use FlatIndex.newBuilder() to construct. + private FlatIndex(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FlatIndex() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + .class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex other = + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+         * An index that stores vectors in a flat data structure, and supports
+         * exhaustive search.
+         * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + .class); + } + + // Construct using + // com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex build() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + buildPartial() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex result = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) { + return mergeFrom( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex other) { + if (other + == com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + private static final com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex(); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FlatIndex parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int typeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object type_; + + public enum TypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + FLAT(2), + TYPE_NOT_SET(0); + private final int value; + + private TypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TypeCase valueOf(int value) { + return forNumber(value); + } + + public static TypeCase forNumber(int value) { + switch (value) { + case 2: + return FLAT; + case 0: + return TYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TypeCase getTypeCase() { + return TypeCase.forNumber(typeCase_); + } + + public static final int DIMENSION_FIELD_NUMBER = 1; + private int dimension_ = 0; + + /** + * + * + *
+       * Required. The vector dimension this configuration applies to.
+       *
+       * The resulting index will only include vectors of this dimension, and
+       * can be used for vector search with the same dimension.
+       * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + @java.lang.Override + public int getDimension() { + return dimension_; + } + + public static final int FLAT_FIELD_NUMBER = 2; + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + @java.lang.Override + public boolean hasFlat() { + return typeCase_ == 2; + } + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat() { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + + /** + * + * + *
+       * Indicates the vector index is a flat index.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder() { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (dimension_ != 0) { + output.writeInt32(1, dimension_); + } + if (typeCase_ == 2) { + output.writeMessage( + 2, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (dimension_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, dimension_); + } + if (typeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index.IndexField.VectorConfig other = + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) obj; + + if (getDimension() != other.getDimension()) return false; + if (!getTypeCase().equals(other.getTypeCase())) return false; + switch (typeCase_) { + case 2: + if (!getFlat().equals(other.getFlat())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DIMENSION_FIELD_NUMBER; + hash = (53 * hash) + getDimension(); + switch (typeCase_) { + case 2: + hash = (37 * hash) + FLAT_FIELD_NUMBER; + hash = (53 * hash) + getFlat().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * The index configuration to support vector search operations
+       * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField.VectorConfig} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index.IndexField.VectorConfig) + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.class, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Index.IndexField.VectorConfig.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + dimension_ = 0; + if (flatBuilder_ != null) { + flatBuilder_.clear(); + } + typeCase_ = 0; + type_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig build() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig buildPartial() { + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result = + new com.google.firestore.admin.v1.Index.IndexField.VectorConfig(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.dimension_ = dimension_; + } + } + + private void buildPartialOneofs( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig result) { + result.typeCase_ = typeCase_; + result.type_ = this.type_; + if (typeCase_ == 2 && flatBuilder_ != null) { + result.type_ = flatBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Index.IndexField.VectorConfig) { + return mergeFrom((com.google.firestore.admin.v1.Index.IndexField.VectorConfig) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig other) { + if (other + == com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance()) + return this; + if (other.getDimension() != 0) { + setDimension(other.getDimension()); + } + switch (other.getTypeCase()) { + case FLAT: + { + mergeFlat(other.getFlat()); + break; + } + case TYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + dimension_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + input.readMessage( + internalGetFlatFieldBuilder().getBuilder(), extensionRegistry); + typeCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int typeCase_ = 0; + private java.lang.Object type_; + + public TypeCase getTypeCase() { + return TypeCase.forNumber(typeCase_); + } + + public Builder clearType() { + typeCase_ = 0; + type_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private int dimension_; + + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The dimension. + */ + @java.lang.Override + public int getDimension() { + return dimension_; + } + + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The dimension to set. + * @return This builder for chaining. + */ + public Builder setDimension(int value) { + + dimension_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * Required. The vector dimension this configuration applies to.
+         *
+         * The resulting index will only include vectors of this dimension, and
+         * can be used for vector search with the same dimension.
+         * 
+ * + * int32 dimension = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDimension() { + bitField0_ = (bitField0_ & ~0x00000001); + dimension_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder> + flatBuilder_; + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return Whether the flat field is set. + */ + @java.lang.Override + public boolean hasFlat() { + return typeCase_ == 2; + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + * + * @return The flat. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex getFlat() { + if (flatBuilder_ == null) { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } else { + if (typeCase_ == 2) { + return flatBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder setFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex value) { + if (flatBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + type_ = value; + onChanged(); + } else { + flatBuilder_.setMessage(value); + } + typeCase_ = 2; + return this; + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder setFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + builderForValue) { + if (flatBuilder_ == null) { + type_ = builderForValue.build(); + onChanged(); + } else { + flatBuilder_.setMessage(builderForValue.build()); + } + typeCase_ = 2; + return this; + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder mergeFlat( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex value) { + if (flatBuilder_ == null) { + if (typeCase_ == 2 + && type_ + != com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance()) { + type_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.newBuilder( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) + type_) + .mergeFrom(value) + .buildPartial(); + } else { + type_ = value; + } + onChanged(); + } else { + if (typeCase_ == 2) { + flatBuilder_.mergeFrom(value); + } else { + flatBuilder_.setMessage(value); + } + } + typeCase_ = 2; + return this; + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public Builder clearFlat() { + if (flatBuilder_ == null) { + if (typeCase_ == 2) { + typeCase_ = 0; + type_ = null; + onChanged(); + } + } else { + if (typeCase_ == 2) { + typeCase_ = 0; + type_ = null; + } + flatBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder + getFlatBuilder() { + return internalGetFlatFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder + getFlatOrBuilder() { + if ((typeCase_ == 2) && (flatBuilder_ != null)) { + return flatBuilder_.getMessageOrBuilder(); + } else { + if (typeCase_ == 2) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + } + + /** + * + * + *
+         * Indicates the vector index is a flat index.
+         * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex flat = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder> + internalGetFlatFieldBuilder() { + if (flatBuilder_ == null) { + if (!(typeCase_ == 2)) { + type_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex + .getDefaultInstance(); + } + flatBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndexOrBuilder>( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig.FlatIndex) type_, + getParentForChildren(), + isClean()); + type_ = null; + } + typeCase_ = 2; + onChanged(); + return flatBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index.IndexField.VectorConfig) + private static final com.google.firestore.admin.v1.Index.IndexField.VectorConfig + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Index.IndexField.VectorConfig(); + } + + public static com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public VectorConfig parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int valueModeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object valueMode_; + + public enum ValueModeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + ORDER(2), + ARRAY_CONFIG(3), + VECTOR_CONFIG(4), + VALUEMODE_NOT_SET(0); + private final int value; + + private ValueModeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ValueModeCase valueOf(int value) { + return forNumber(value); + } + + public static ValueModeCase forNumber(int value) { + switch (value) { + case 2: + return ORDER; + case 3: + return ARRAY_CONFIG; + case 4: + return VECTOR_CONFIG; + case 0: + return VALUEMODE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ValueModeCase getValueModeCase() { + return ValueModeCase.forNumber(valueModeCase_); + } + + public static final int FIELD_PATH_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+     * Can be __name__.
+     * For single field indexes, this must match the name of the field or may
+     * be omitted.
+     * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + @java.lang.Override + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } + } + + /** + * + * + *
+     * Can be __name__.
+     * For single field indexes, this must match the name of the field or may
+     * be omitted.
+     * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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; + } + + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, !=, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return The enum numeric value on the wire for order. + */ + public int getOrderValue() { + if (valueModeCase_ == 2) { + return (java.lang.Integer) valueMode_; + } + return 0; + } + + /** + * + * + *
+     * Indicates that this field supports ordering by the specified order or
+     * comparing using =, !=, <, <=, >, >=.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return The order. + */ + public com.google.firestore.admin.v1.Index.IndexField.Order getOrder() { + if (valueModeCase_ == 2) { + com.google.firestore.admin.v1.Index.IndexField.Order result = + com.google.firestore.admin.v1.Index.IndexField.Order.forNumber( + (java.lang.Integer) valueMode_); + return result == null + ? com.google.firestore.admin.v1.Index.IndexField.Order.UNRECOGNIZED + : result; + } + return com.google.firestore.admin.v1.Index.IndexField.Order.ORDER_UNSPECIFIED; + } + + 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; + } + + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The enum numeric value on the wire for arrayConfig. + */ + public int getArrayConfigValue() { + if (valueModeCase_ == 3) { + return (java.lang.Integer) valueMode_; + } + return 0; + } + + /** + * + * + *
+     * Indicates that this field supports operations on `array_value`s.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The arrayConfig. + */ + public com.google.firestore.admin.v1.Index.IndexField.ArrayConfig getArrayConfig() { + if (valueModeCase_ == 3) { + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig result = + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.forNumber( + (java.lang.Integer) valueMode_); + return result == null + ? com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.UNRECOGNIZED + : result; + } + return com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.ARRAY_CONFIG_UNSPECIFIED; + } + + public static final int VECTOR_CONFIG_FIELD_NUMBER = 4; + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + @java.lang.Override + public boolean hasVectorConfig() { + return valueModeCase_ == 4; + } + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig() { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + + /** + * + * + *
+     * Indicates that this field supports nearest neighbor and distance
+     * operations on vector.
+     * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder + getVectorConfigOrBuilder() { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, fieldPath_); + } + if (valueModeCase_ == 2) { + output.writeEnum(2, ((java.lang.Integer) valueMode_)); + } + if (valueModeCase_ == 3) { + output.writeEnum(3, ((java.lang.Integer) valueMode_)); + } + if (valueModeCase_ == 4) { + output.writeMessage( + 4, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, fieldPath_); + } + if (valueModeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 2, ((java.lang.Integer) valueMode_)); + } + if (valueModeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 3, ((java.lang.Integer) valueMode_)); + } + if (valueModeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Index.IndexField)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index.IndexField other = + (com.google.firestore.admin.v1.Index.IndexField) obj; + + if (!getFieldPath().equals(other.getFieldPath())) return false; + if (!getValueModeCase().equals(other.getValueModeCase())) return false; + switch (valueModeCase_) { + case 2: + if (getOrderValue() != other.getOrderValue()) return false; + break; + case 3: + if (getArrayConfigValue() != other.getArrayConfigValue()) return false; + break; + case 4: + if (!getVectorConfig().equals(other.getVectorConfig())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FIELD_PATH_FIELD_NUMBER; + hash = (53 * hash) + getFieldPath().hashCode(); + switch (valueModeCase_) { + case 2: + hash = (37 * hash) + ORDER_FIELD_NUMBER; + hash = (53 * hash) + getOrderValue(); + break; + case 3: + hash = (37 * hash) + ARRAY_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getArrayConfigValue(); + break; + case 4: + hash = (37 * hash) + VECTOR_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getVectorConfig().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index.IndexField parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Index.IndexField prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A field in an index.
+     * The field_path describes which field is indexed, the value_mode describes
+     * how the field value is indexed.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index.IndexField} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index.IndexField) + com.google.firestore.admin.v1.Index.IndexFieldOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.IndexField.class, + com.google.firestore.admin.v1.Index.IndexField.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Index.IndexField.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + fieldPath_ = ""; + if (vectorConfigBuilder_ != null) { + vectorConfigBuilder_.clear(); + } + valueModeCase_ = 0; + valueMode_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_IndexField_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.IndexField.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField build() { + com.google.firestore.admin.v1.Index.IndexField result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField buildPartial() { + com.google.firestore.admin.v1.Index.IndexField result = + new com.google.firestore.admin.v1.Index.IndexField(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Index.IndexField result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.fieldPath_ = fieldPath_; + } + } + + private void buildPartialOneofs(com.google.firestore.admin.v1.Index.IndexField result) { + result.valueModeCase_ = valueModeCase_; + result.valueMode_ = this.valueMode_; + if (valueModeCase_ == 4 && vectorConfigBuilder_ != null) { + result.valueMode_ = vectorConfigBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Index.IndexField) { + return mergeFrom((com.google.firestore.admin.v1.Index.IndexField) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Index.IndexField other) { + if (other == com.google.firestore.admin.v1.Index.IndexField.getDefaultInstance()) + return this; + if (!other.getFieldPath().isEmpty()) { + fieldPath_ = other.fieldPath_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getValueModeCase()) { + case ORDER: + { + setOrderValue(other.getOrderValue()); + break; + } + case ARRAY_CONFIG: + { + setArrayConfigValue(other.getArrayConfigValue()); + break; + } + case VECTOR_CONFIG: + { + mergeVectorConfig(other.getVectorConfig()); + break; + } + case VALUEMODE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + fieldPath_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + int rawValue = input.readEnum(); + valueModeCase_ = 2; + valueMode_ = rawValue; + break; + } // case 16 + case 24: + { + int rawValue = input.readEnum(); + valueModeCase_ = 3; + valueMode_ = rawValue; + break; + } // case 24 + case 34: + { + input.readMessage( + internalGetVectorConfigFieldBuilder().getBuilder(), extensionRegistry); + valueModeCase_ = 4; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int valueModeCase_ = 0; + private java.lang.Object valueMode_; + + public ValueModeCase getValueModeCase() { + return ValueModeCase.forNumber(valueModeCase_); + } + + public Builder clearValueMode() { + valueModeCase_ = 0; + valueMode_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+       * Can be __name__.
+       * For single field indexes, this must match the name of the field or may
+       * be omitted.
+       * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Can be __name__.
+       * For single field indexes, this must match the name of the field or may
+       * be omitted.
+       * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Can be __name__.
+       * For single field indexes, this must match the name of the field or may
+       * be omitted.
+       * 
+ * + * string field_path = 1; + * + * @param value The fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPath(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Can be __name__.
+       * For single field indexes, this must match the name of the field or may
+       * be omitted.
+       * 
+ * + * string field_path = 1; + * + * @return This builder for chaining. + */ + public Builder clearFieldPath() { + fieldPath_ = getDefaultInstance().getFieldPath(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * Can be __name__.
+       * For single field indexes, this must match the name of the field or may
+       * be omitted.
+       * 
+ * + * string field_path = 1; + * + * @param value The bytes for fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPathBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + 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; + } + + /** + * + * + *
+       * Indicates that this field supports ordering by the specified order or
+       * comparing using =, !=, <, <=, >, >=.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @return The enum numeric value on the wire for order. + */ + @java.lang.Override + public int getOrderValue() { + if (valueModeCase_ == 2) { + return ((java.lang.Integer) valueMode_).intValue(); + } + return 0; + } + + /** + * + * + *
+       * Indicates that this field supports ordering by the specified order or
+       * comparing using =, !=, <, <=, >, >=.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @param value The enum numeric value on the wire for order to set. + * @return This builder for chaining. + */ + public Builder setOrderValue(int value) { + valueModeCase_ = 2; + valueMode_ = value; + onChanged(); + 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 The order. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.Order getOrder() { + if (valueModeCase_ == 2) { + com.google.firestore.admin.v1.Index.IndexField.Order result = + com.google.firestore.admin.v1.Index.IndexField.Order.forNumber( + (java.lang.Integer) valueMode_); + return result == null + ? com.google.firestore.admin.v1.Index.IndexField.Order.UNRECOGNIZED + : result; + } + return com.google.firestore.admin.v1.Index.IndexField.Order.ORDER_UNSPECIFIED; + } + + /** + * + * + *
+       * Indicates that this field supports ordering by the specified order or
+       * comparing using =, !=, <, <=, >, >=.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.Order order = 2; + * + * @param value The order to set. + * @return This builder for chaining. + */ + public Builder setOrder(com.google.firestore.admin.v1.Index.IndexField.Order value) { + if (value == null) { + throw new NullPointerException(); + } + valueModeCase_ = 2; + valueMode_ = value.getNumber(); + onChanged(); + 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 This builder for chaining. + */ + public Builder clearOrder() { + if (valueModeCase_ == 2) { + valueModeCase_ = 0; + valueMode_ = null; + onChanged(); + } + 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; + } + + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The enum numeric value on the wire for arrayConfig. + */ + @java.lang.Override + public int getArrayConfigValue() { + if (valueModeCase_ == 3) { + return ((java.lang.Integer) valueMode_).intValue(); + } + return 0; + } + + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @param value The enum numeric value on the wire for arrayConfig to set. + * @return This builder for chaining. + */ + public Builder setArrayConfigValue(int value) { + valueModeCase_ = 3; + valueMode_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return The arrayConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.ArrayConfig getArrayConfig() { + if (valueModeCase_ == 3) { + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig result = + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.forNumber( + (java.lang.Integer) valueMode_); + return result == null + ? com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.UNRECOGNIZED + : result; + } + return com.google.firestore.admin.v1.Index.IndexField.ArrayConfig.ARRAY_CONFIG_UNSPECIFIED; + } + + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @param value The arrayConfig to set. + * @return This builder for chaining. + */ + public Builder setArrayConfig( + com.google.firestore.admin.v1.Index.IndexField.ArrayConfig value) { + if (value == null) { + throw new NullPointerException(); + } + valueModeCase_ = 3; + valueMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Indicates that this field supports operations on `array_value`s.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.ArrayConfig array_config = 3; + * + * @return This builder for chaining. + */ + public Builder clearArrayConfig() { + if (valueModeCase_ == 3) { + valueModeCase_ = 0; + valueMode_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder> + vectorConfigBuilder_; + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return Whether the vectorConfig field is set. + */ + @java.lang.Override + public boolean hasVectorConfig() { + return valueModeCase_ == 4; + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + * + * @return The vectorConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig getVectorConfig() { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } else { + if (valueModeCase_ == 4) { + return vectorConfigBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder setVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig value) { + if (vectorConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueMode_ = value; + onChanged(); + } else { + vectorConfigBuilder_.setMessage(value); + } + valueModeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder setVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder builderForValue) { + if (vectorConfigBuilder_ == null) { + valueMode_ = builderForValue.build(); + onChanged(); + } else { + vectorConfigBuilder_.setMessage(builderForValue.build()); + } + valueModeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder mergeVectorConfig( + com.google.firestore.admin.v1.Index.IndexField.VectorConfig value) { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4 + && valueMode_ + != com.google.firestore.admin.v1.Index.IndexField.VectorConfig + .getDefaultInstance()) { + valueMode_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.newBuilder( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_) + .mergeFrom(value) + .buildPartial(); + } else { + valueMode_ = value; + } + onChanged(); + } else { + if (valueModeCase_ == 4) { + vectorConfigBuilder_.mergeFrom(value); + } else { + vectorConfigBuilder_.setMessage(value); + } + } + valueModeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public Builder clearVectorConfig() { + if (vectorConfigBuilder_ == null) { + if (valueModeCase_ == 4) { + valueModeCase_ = 0; + valueMode_ = null; + onChanged(); + } + } else { + if (valueModeCase_ == 4) { + valueModeCase_ = 0; + valueMode_ = null; + } + vectorConfigBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + public com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder + getVectorConfigBuilder() { + return internalGetVectorConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder + getVectorConfigOrBuilder() { + if ((valueModeCase_ == 4) && (vectorConfigBuilder_ != null)) { + return vectorConfigBuilder_.getMessageOrBuilder(); + } else { + if (valueModeCase_ == 4) { + return (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_; + } + return com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Indicates that this field supports nearest neighbor and distance
+       * operations on vector.
+       * 
+ * + * .google.firestore.admin.v1.Index.IndexField.VectorConfig vector_config = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder> + internalGetVectorConfigFieldBuilder() { + if (vectorConfigBuilder_ == null) { + if (!(valueModeCase_ == 4)) { + valueMode_ = + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.getDefaultInstance(); + } + vectorConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField.VectorConfig, + com.google.firestore.admin.v1.Index.IndexField.VectorConfig.Builder, + com.google.firestore.admin.v1.Index.IndexField.VectorConfigOrBuilder>( + (com.google.firestore.admin.v1.Index.IndexField.VectorConfig) valueMode_, + getParentForChildren(), + isClean()); + valueMode_ = null; + } + valueModeCase_ = 4; + onChanged(); + return vectorConfigBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index.IndexField) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index.IndexField) + private static final com.google.firestore.admin.v1.Index.IndexField DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Index.IndexField(); + } + + public static com.google.firestore.admin.v1.Index.IndexField getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexField parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Output only. A server defined name for this index.
+   * The form of this name for composite indexes will be:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+   * For single field indexes, this field will be empty.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. A server defined name for this index.
+   * The form of this name for composite indexes will be:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+   * For single field indexes, this field will be empty.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int QUERY_SCOPE_FIELD_NUMBER = 2; + private int queryScope_ = 0; + + /** + * + * + *
+   * Indexes with a collection query scope specified allow queries
+   * against a collection that is the child of a specific document, specified at
+   * query time, and that has the same collection ID.
+   *
+   * Indexes with a collection group query scope specified allow queries against
+   * all collections descended from a specific document, specified at query
+   * time, and that have the same collection ID as this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The enum numeric value on the wire for queryScope. + */ + @java.lang.Override + public int getQueryScopeValue() { + return queryScope_; + } + + /** + * + * + *
+   * Indexes with a collection query scope specified allow queries
+   * against a collection that is the child of a specific document, specified at
+   * query time, and that has the same collection ID.
+   *
+   * Indexes with a collection group query scope specified allow queries against
+   * all collections descended from a specific document, specified at query
+   * time, and that have the same collection ID as this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The queryScope. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.QueryScope getQueryScope() { + com.google.firestore.admin.v1.Index.QueryScope result = + com.google.firestore.admin.v1.Index.QueryScope.forNumber(queryScope_); + return result == null ? com.google.firestore.admin.v1.Index.QueryScope.UNRECOGNIZED : result; + } + + public static final int API_SCOPE_FIELD_NUMBER = 5; + private int apiScope_ = 0; + + /** + * + * + *
+   * The API scope supported by this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The enum numeric value on the wire for apiScope. + */ + @java.lang.Override + public int getApiScopeValue() { + return apiScope_; + } + + /** + * + * + *
+   * The API scope supported by this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The apiScope. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.ApiScope getApiScope() { + com.google.firestore.admin.v1.Index.ApiScope result = + com.google.firestore.admin.v1.Index.ApiScope.forNumber(apiScope_); + return result == null ? com.google.firestore.admin.v1.Index.ApiScope.UNRECOGNIZED : result; + } + + public static final int FIELDS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List fields_; + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + @java.lang.Override + public java.util.List getFieldsList() { + return fields_; + } + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + @java.lang.Override + public java.util.List + getFieldsOrBuilderList() { + return fields_; + } + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + @java.lang.Override + public int getFieldsCount() { + return fields_.size(); + } + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexField getFields(int index) { + return fields_.get(index); + } + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.IndexFieldOrBuilder getFieldsOrBuilder(int index) { + return fields_.get(index); + } + + public static final int STATE_FIELD_NUMBER = 4; + private int state_ = 0; + + /** + * + * + *
+   * Output only. The serving state of the index.
+   * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * Output only. The serving state of the index.
+   * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.State getState() { + com.google.firestore.admin.v1.Index.State result = + com.google.firestore.admin.v1.Index.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Index.State.UNRECOGNIZED : result; + } + + public static final int DENSITY_FIELD_NUMBER = 6; + private int density_ = 0; + + /** + * + * + *
+   * Immutable. The density configuration of the index.
+   * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for density. + */ + @java.lang.Override + public int getDensityValue() { + return density_; + } + + /** + * + * + *
+   * Immutable. The density configuration of the index.
+   * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The density. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.Density getDensity() { + com.google.firestore.admin.v1.Index.Density result = + com.google.firestore.admin.v1.Index.Density.forNumber(density_); + return result == null ? com.google.firestore.admin.v1.Index.Density.UNRECOGNIZED : result; + } + + public static final int MULTIKEY_FIELD_NUMBER = 7; + private boolean multikey_ = false; + + /** + * + * + *
+   * Optional. Whether the index is multikey. By default, the index is not
+   * multikey. For non-multikey indexes, none of the paths in the index
+   * definition reach or traverse an array, except via an explicit array index.
+   * For multikey indexes, at most one of the paths in the index definition
+   * reach or traverse an array, except via an explicit array index. Violations
+   * will result in errors.
+   *
+   * Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
+   * 
+ * + * bool multikey = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The multikey. + */ + @java.lang.Override + public boolean getMultikey() { + return multikey_; + } + + public static final int SHARD_COUNT_FIELD_NUMBER = 8; + private int shardCount_ = 0; + + /** + * + * + *
+   * Optional. The number of shards for the index.
+   * 
+ * + * int32 shard_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The shardCount. + */ + @java.lang.Override + public int getShardCount() { + return shardCount_; + } + + public static final int UNIQUE_FIELD_NUMBER = 10; + private boolean unique_ = false; + + /** + * + * + *
+   * Optional. Whether it is an unique index. Unique index ensures all values
+   * for the indexed field(s) are unique across documents.
+   * 
+ * + * bool unique = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The unique. + */ + @java.lang.Override + public boolean getUnique() { + return unique_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (queryScope_ + != com.google.firestore.admin.v1.Index.QueryScope.QUERY_SCOPE_UNSPECIFIED.getNumber()) { + output.writeEnum(2, queryScope_); + } + for (int i = 0; i < fields_.size(); i++) { + output.writeMessage(3, fields_.get(i)); + } + if (state_ != com.google.firestore.admin.v1.Index.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(4, state_); + } + if (apiScope_ != com.google.firestore.admin.v1.Index.ApiScope.ANY_API.getNumber()) { + output.writeEnum(5, apiScope_); + } + if (density_ != com.google.firestore.admin.v1.Index.Density.DENSITY_UNSPECIFIED.getNumber()) { + output.writeEnum(6, density_); + } + if (multikey_ != false) { + output.writeBool(7, multikey_); + } + if (shardCount_ != 0) { + output.writeInt32(8, shardCount_); + } + if (unique_ != false) { + output.writeBool(10, unique_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (queryScope_ + != com.google.firestore.admin.v1.Index.QueryScope.QUERY_SCOPE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, queryScope_); + } + for (int i = 0; i < fields_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, fields_.get(i)); + } + if (state_ != com.google.firestore.admin.v1.Index.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, state_); + } + if (apiScope_ != com.google.firestore.admin.v1.Index.ApiScope.ANY_API.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, apiScope_); + } + if (density_ != com.google.firestore.admin.v1.Index.Density.DENSITY_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(6, density_); + } + if (multikey_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(7, multikey_); + } + if (shardCount_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(8, shardCount_); + } + if (unique_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(10, unique_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Index)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Index other = (com.google.firestore.admin.v1.Index) obj; + + if (!getName().equals(other.getName())) return false; + if (queryScope_ != other.queryScope_) return false; + if (apiScope_ != other.apiScope_) return false; + if (!getFieldsList().equals(other.getFieldsList())) return false; + if (state_ != other.state_) return false; + if (density_ != other.density_) return false; + if (getMultikey() != other.getMultikey()) return false; + if (getShardCount() != other.getShardCount()) return false; + if (getUnique() != other.getUnique()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + QUERY_SCOPE_FIELD_NUMBER; + hash = (53 * hash) + queryScope_; + hash = (37 * hash) + API_SCOPE_FIELD_NUMBER; + hash = (53 * hash) + apiScope_; + if (getFieldsCount() > 0) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + getFieldsList().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (37 * hash) + DENSITY_FIELD_NUMBER; + hash = (53 * hash) + density_; + hash = (37 * hash) + MULTIKEY_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getMultikey()); + hash = (37 * hash) + SHARD_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getShardCount(); + hash = (37 * hash) + UNIQUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getUnique()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Index parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Index parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Index prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Cloud Firestore indexes enable simple and complex queries against
+   * documents in a database.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Index} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Index) + com.google.firestore.admin.v1.IndexOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Index.class, + com.google.firestore.admin.v1.Index.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Index.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + queryScope_ = 0; + apiScope_ = 0; + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + } else { + fields_ = null; + fieldsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + state_ = 0; + density_ = 0; + multikey_ = false; + shardCount_ = 0; + unique_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.IndexProto + .internal_static_google_firestore_admin_v1_Index_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Index.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index build() { + com.google.firestore.admin.v1.Index result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index buildPartial() { + com.google.firestore.admin.v1.Index result = new com.google.firestore.admin.v1.Index(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.admin.v1.Index result) { + if (fieldsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + fields_ = java.util.Collections.unmodifiableList(fields_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.fields_ = fields_; + } else { + result.fields_ = fieldsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.Index result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.queryScope_ = queryScope_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.apiScope_ = apiScope_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.state_ = state_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.density_ = density_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.multikey_ = multikey_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.shardCount_ = shardCount_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.unique_ = unique_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Index) { + return mergeFrom((com.google.firestore.admin.v1.Index) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Index other) { + if (other == com.google.firestore.admin.v1.Index.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.queryScope_ != 0) { + setQueryScopeValue(other.getQueryScopeValue()); + } + if (other.apiScope_ != 0) { + setApiScopeValue(other.getApiScopeValue()); + } + if (fieldsBuilder_ == null) { + if (!other.fields_.isEmpty()) { + if (fields_.isEmpty()) { + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureFieldsIsMutable(); + fields_.addAll(other.fields_); + } + onChanged(); + } + } else { + if (!other.fields_.isEmpty()) { + if (fieldsBuilder_.isEmpty()) { + fieldsBuilder_.dispose(); + fieldsBuilder_ = null; + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000008); + fieldsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFieldsFieldBuilder() + : null; + } else { + fieldsBuilder_.addAllMessages(other.fields_); + } + } + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + if (other.density_ != 0) { + setDensityValue(other.getDensityValue()); + } + if (other.getMultikey() != false) { + setMultikey(other.getMultikey()); + } + if (other.getShardCount() != 0) { + setShardCount(other.getShardCount()); + } + if (other.getUnique() != false) { + setUnique(other.getUnique()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + queryScope_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + com.google.firestore.admin.v1.Index.IndexField m = + input.readMessage( + com.google.firestore.admin.v1.Index.IndexField.parser(), extensionRegistry); + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(m); + } else { + fieldsBuilder_.addMessage(m); + } + break; + } // case 26 + case 32: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000010; + break; + } // case 32 + case 40: + { + apiScope_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 40 + case 48: + { + density_ = input.readEnum(); + bitField0_ |= 0x00000020; + break; + } // case 48 + case 56: + { + multikey_ = input.readBool(); + bitField0_ |= 0x00000040; + break; + } // case 56 + case 64: + { + shardCount_ = input.readInt32(); + bitField0_ |= 0x00000080; + break; + } // case 64 + case 80: + { + unique_ = input.readBool(); + bitField0_ |= 0x00000100; + break; + } // case 80 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Output only. A server defined name for this index.
+     * The form of this name for composite indexes will be:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+     * For single field indexes, this field will be empty.
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. A server defined name for this index.
+     * The form of this name for composite indexes will be:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+     * For single field indexes, this field will be empty.
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. A server defined name for this index.
+     * The form of this name for composite indexes will be:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+     * For single field indexes, this field will be empty.
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. A server defined name for this index.
+     * The form of this name for composite indexes will be:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+     * For single field indexes, this field will be empty.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. A server defined name for this index.
+     * The form of this name for composite indexes will be:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+     * For single field indexes, this field will be empty.
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private int queryScope_ = 0; + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified at
+     * query time, and that has the same collection ID.
+     *
+     * Indexes with a collection group query scope specified allow queries against
+     * all collections descended from a specific document, specified at query
+     * time, and that have the same collection ID as this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The enum numeric value on the wire for queryScope. + */ + @java.lang.Override + public int getQueryScopeValue() { + return queryScope_; + } + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified at
+     * query time, and that has the same collection ID.
+     *
+     * Indexes with a collection group query scope specified allow queries against
+     * all collections descended from a specific document, specified at query
+     * time, and that have the same collection ID as this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @param value The enum numeric value on the wire for queryScope to set. + * @return This builder for chaining. + */ + public Builder setQueryScopeValue(int value) { + queryScope_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified at
+     * query time, and that has the same collection ID.
+     *
+     * Indexes with a collection group query scope specified allow queries against
+     * all collections descended from a specific document, specified at query
+     * time, and that have the same collection ID as this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The queryScope. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.QueryScope getQueryScope() { + com.google.firestore.admin.v1.Index.QueryScope result = + com.google.firestore.admin.v1.Index.QueryScope.forNumber(queryScope_); + return result == null ? com.google.firestore.admin.v1.Index.QueryScope.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified at
+     * query time, and that has the same collection ID.
+     *
+     * Indexes with a collection group query scope specified allow queries against
+     * all collections descended from a specific document, specified at query
+     * time, and that have the same collection ID as this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @param value The queryScope to set. + * @return This builder for chaining. + */ + public Builder setQueryScope(com.google.firestore.admin.v1.Index.QueryScope value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + queryScope_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Indexes with a collection query scope specified allow queries
+     * against a collection that is the child of a specific document, specified at
+     * query time, and that has the same collection ID.
+     *
+     * Indexes with a collection group query scope specified allow queries against
+     * all collections descended from a specific document, specified at query
+     * time, and that have the same collection ID as this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return This builder for chaining. + */ + public Builder clearQueryScope() { + bitField0_ = (bitField0_ & ~0x00000002); + queryScope_ = 0; + onChanged(); + return this; + } + + private int apiScope_ = 0; + + /** + * + * + *
+     * The API scope supported by this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The enum numeric value on the wire for apiScope. + */ + @java.lang.Override + public int getApiScopeValue() { + return apiScope_; + } + + /** + * + * + *
+     * The API scope supported by this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @param value The enum numeric value on the wire for apiScope to set. + * @return This builder for chaining. + */ + public Builder setApiScopeValue(int value) { + apiScope_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The API scope supported by this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The apiScope. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.ApiScope getApiScope() { + com.google.firestore.admin.v1.Index.ApiScope result = + com.google.firestore.admin.v1.Index.ApiScope.forNumber(apiScope_); + return result == null ? com.google.firestore.admin.v1.Index.ApiScope.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The API scope supported by this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @param value The apiScope to set. + * @return This builder for chaining. + */ + public Builder setApiScope(com.google.firestore.admin.v1.Index.ApiScope value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + apiScope_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The API scope supported by this index.
+     * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return This builder for chaining. + */ + public Builder clearApiScope() { + bitField0_ = (bitField0_ & ~0x00000004); + apiScope_ = 0; + onChanged(); + return this; + } + + private java.util.List fields_ = + java.util.Collections.emptyList(); + + private void ensureFieldsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + fields_ = new java.util.ArrayList(fields_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField, + com.google.firestore.admin.v1.Index.IndexField.Builder, + com.google.firestore.admin.v1.Index.IndexFieldOrBuilder> + fieldsBuilder_; + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public java.util.List getFieldsList() { + if (fieldsBuilder_ == null) { + return java.util.Collections.unmodifiableList(fields_); + } else { + return fieldsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public int getFieldsCount() { + if (fieldsBuilder_ == null) { + return fields_.size(); + } else { + return fieldsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public com.google.firestore.admin.v1.Index.IndexField getFields(int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder setFields(int index, com.google.firestore.admin.v1.Index.IndexField value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.set(index, value); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder setFields( + int index, com.google.firestore.admin.v1.Index.IndexField.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.set(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder addFields(com.google.firestore.admin.v1.Index.IndexField value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(value); + onChanged(); + } else { + fieldsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder addFields(int index, com.google.firestore.admin.v1.Index.IndexField value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(index, value); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder addFields( + com.google.firestore.admin.v1.Index.IndexField.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder addFields( + int index, com.google.firestore.admin.v1.Index.IndexField.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder addAllFields( + java.lang.Iterable values) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, fields_); + onChanged(); + } else { + fieldsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder clearFields() { + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + fieldsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public Builder removeFields(int index) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.remove(index); + onChanged(); + } else { + fieldsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public com.google.firestore.admin.v1.Index.IndexField.Builder getFieldsBuilder(int index) { + return internalGetFieldsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public com.google.firestore.admin.v1.Index.IndexFieldOrBuilder getFieldsOrBuilder(int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public java.util.List + getFieldsOrBuilderList() { + if (fieldsBuilder_ != null) { + return fieldsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(fields_); + } + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public com.google.firestore.admin.v1.Index.IndexField.Builder addFieldsBuilder() { + return internalGetFieldsFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Index.IndexField.getDefaultInstance()); + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public com.google.firestore.admin.v1.Index.IndexField.Builder addFieldsBuilder(int index) { + return internalGetFieldsFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Index.IndexField.getDefaultInstance()); + } + + /** + * + * + *
+     * The fields supported by this index.
+     *
+     * For composite indexes, this requires a minimum of 2 and a maximum of 100
+     * fields. The last field entry is always for the field path `__name__`. If,
+     * on creation, `__name__` was not specified as the last field, it will be
+     * added automatically with the same direction as that of the last field
+     * defined. If the final field in a composite index is not directional, the
+     * `__name__` will be ordered ASCENDING (unless explicitly specified).
+     *
+     * For single field indexes, this will always be exactly one entry with a
+     * field path equal to the field path of the associated field.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + public java.util.List + getFieldsBuilderList() { + return internalGetFieldsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField, + com.google.firestore.admin.v1.Index.IndexField.Builder, + com.google.firestore.admin.v1.Index.IndexFieldOrBuilder> + internalGetFieldsFieldBuilder() { + if (fieldsBuilder_ == null) { + fieldsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index.IndexField, + com.google.firestore.admin.v1.Index.IndexField.Builder, + com.google.firestore.admin.v1.Index.IndexFieldOrBuilder>( + fields_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + fields_ = null; + } + return fieldsBuilder_; + } + + private int state_ = 0; + + /** + * + * + *
+     * Output only. The serving state of the index.
+     * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * Output only. The serving state of the index.
+     * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The serving state of the index.
+     * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.State getState() { + com.google.firestore.admin.v1.Index.State result = + com.google.firestore.admin.v1.Index.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.Index.State.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Output only. The serving state of the index.
+     * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.Index.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The serving state of the index.
+     * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000010); + state_ = 0; + onChanged(); + return this; + } + + private int density_ = 0; + + /** + * + * + *
+     * Immutable. The density configuration of the index.
+     * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for density. + */ + @java.lang.Override + public int getDensityValue() { + return density_; + } + + /** + * + * + *
+     * Immutable. The density configuration of the index.
+     * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The enum numeric value on the wire for density to set. + * @return This builder for chaining. + */ + public Builder setDensityValue(int value) { + density_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The density configuration of the index.
+     * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The density. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index.Density getDensity() { + com.google.firestore.admin.v1.Index.Density result = + com.google.firestore.admin.v1.Index.Density.forNumber(density_); + return result == null ? com.google.firestore.admin.v1.Index.Density.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Immutable. The density configuration of the index.
+     * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @param value The density to set. + * @return This builder for chaining. + */ + public Builder setDensity(com.google.firestore.admin.v1.Index.Density value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + density_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Immutable. The density configuration of the index.
+     * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return This builder for chaining. + */ + public Builder clearDensity() { + bitField0_ = (bitField0_ & ~0x00000020); + density_ = 0; + onChanged(); + return this; + } + + private boolean multikey_; + + /** + * + * + *
+     * Optional. Whether the index is multikey. By default, the index is not
+     * multikey. For non-multikey indexes, none of the paths in the index
+     * definition reach or traverse an array, except via an explicit array index.
+     * For multikey indexes, at most one of the paths in the index definition
+     * reach or traverse an array, except via an explicit array index. Violations
+     * will result in errors.
+     *
+     * Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
+     * 
+ * + * bool multikey = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The multikey. + */ + @java.lang.Override + public boolean getMultikey() { + return multikey_; + } + + /** + * + * + *
+     * Optional. Whether the index is multikey. By default, the index is not
+     * multikey. For non-multikey indexes, none of the paths in the index
+     * definition reach or traverse an array, except via an explicit array index.
+     * For multikey indexes, at most one of the paths in the index definition
+     * reach or traverse an array, except via an explicit array index. Violations
+     * will result in errors.
+     *
+     * Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
+     * 
+ * + * bool multikey = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The multikey to set. + * @return This builder for chaining. + */ + public Builder setMultikey(boolean value) { + + multikey_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Whether the index is multikey. By default, the index is not
+     * multikey. For non-multikey indexes, none of the paths in the index
+     * definition reach or traverse an array, except via an explicit array index.
+     * For multikey indexes, at most one of the paths in the index definition
+     * reach or traverse an array, except via an explicit array index. Violations
+     * will result in errors.
+     *
+     * Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
+     * 
+ * + * bool multikey = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearMultikey() { + bitField0_ = (bitField0_ & ~0x00000040); + multikey_ = false; + onChanged(); + return this; + } + + private int shardCount_; + + /** + * + * + *
+     * Optional. The number of shards for the index.
+     * 
+ * + * int32 shard_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The shardCount. + */ + @java.lang.Override + public int getShardCount() { + return shardCount_; + } + + /** + * + * + *
+     * Optional. The number of shards for the index.
+     * 
+ * + * int32 shard_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The shardCount to set. + * @return This builder for chaining. + */ + public Builder setShardCount(int value) { + + shardCount_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The number of shards for the index.
+     * 
+ * + * int32 shard_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearShardCount() { + bitField0_ = (bitField0_ & ~0x00000080); + shardCount_ = 0; + onChanged(); + return this; + } + + private boolean unique_; + + /** + * + * + *
+     * Optional. Whether it is an unique index. Unique index ensures all values
+     * for the indexed field(s) are unique across documents.
+     * 
+ * + * bool unique = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The unique. + */ + @java.lang.Override + public boolean getUnique() { + return unique_; + } + + /** + * + * + *
+     * Optional. Whether it is an unique index. Unique index ensures all values
+     * for the indexed field(s) are unique across documents.
+     * 
+ * + * bool unique = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The unique to set. + * @return This builder for chaining. + */ + public Builder setUnique(boolean value) { + + unique_ = value; + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Whether it is an unique index. Unique index ensures all values
+     * for the indexed field(s) are unique across documents.
+     * 
+ * + * bool unique = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearUnique() { + bitField0_ = (bitField0_ & ~0x00000100); + unique_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Index) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Index) + private static final com.google.firestore.admin.v1.Index DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Index(); + } + + public static com.google.firestore.admin.v1.Index getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Index parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Index getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java new file mode 100644 index 000000000000..4ed08a62b4fd --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexName.java @@ -0,0 +1,260 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class IndexName implements ResourceName { + 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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public String getIndex() { + return index; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static IndexName of(String project, String database, String collection, String index) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollection(collection) + .setIndex(index) + .build(); + } + + public static String format(String project, String database, String collection, String index) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollection(collection) + .setIndex(index) + .build() + .toString(); + } + + public static IndexName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_COLLECTION_INDEX.validatedMatch( + formattedString, "IndexName.parse: formattedString not in valid format"); + return of( + matchMap.get("project"), + matchMap.get("database"), + matchMap.get("collection"), + matchMap.get("index")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (IndexName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String 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(); + 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(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_COLLECTION_INDEX.instantiate( + "project", project, "database", database, "collection", collection, "index", index); + } + + @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; + } + + public String getDatabase() { + return database; + } + + public String getCollection() { + return collection; + } + + public String getIndex() { + return index; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setCollection(String collection) { + this.collection = collection; + return this; + } + + public Builder setIndex(String index) { + this.index = index; + return this; + } + + private Builder(IndexName indexName) { + this.project = indexName.project; + this.database = indexName.database; + this.collection = indexName.collection; + this.index = indexName.index; + } + + public IndexName build() { + return new IndexName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadata.java new file mode 100644 index 000000000000..5dd4acd593e0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadata.java @@ -0,0 +1,1900 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+ * results from
+ * [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.IndexOperationMetadata} + */ +@com.google.protobuf.Generated +public final class IndexOperationMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.IndexOperationMetadata) + IndexOperationMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "IndexOperationMetadata"); + } + + // Use IndexOperationMetadata.newBuilder() to construct. + private IndexOperationMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private IndexOperationMetadata() { + index_ = ""; + state_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_IndexOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.IndexOperationMetadata.class, + com.google.firestore.admin.v1.IndexOperationMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int INDEX_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object index_ = ""; + + /** + * + * + *
+   * The index resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * string index = 3; + * + * @return The index. + */ + @java.lang.Override + public java.lang.String getIndex() { + java.lang.Object ref = index_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + index_ = s; + return s; + } + } + + /** + * + * + *
+   * The index resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * string index = 3; + * + * @return The bytes for index. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIndexBytes() { + java.lang.Object ref = index_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + index_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STATE_FIELD_NUMBER = 4; + private int state_ = 0; + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int PROGRESS_DOCUMENTS_FIELD_NUMBER = 5; + private com.google.firestore.admin.v1.Progress progressDocuments_; + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return Whether the progressDocuments field is set. + */ + @java.lang.Override + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return The progressDocuments. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 6; + private com.google.firestore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(index_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, index_); + } + if (state_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(4, state_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(5, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(6, getProgressBytes()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(index_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, index_); + } + if (state_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, state_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getProgressDocuments()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getProgressBytes()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.IndexOperationMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.IndexOperationMetadata other = + (com.google.firestore.admin.v1.IndexOperationMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (!getIndex().equals(other.getIndex())) return false; + if (state_ != other.state_) return false; + if (hasProgressDocuments() != other.hasProgressDocuments()) return false; + if (hasProgressDocuments()) { + if (!getProgressDocuments().equals(other.getProgressDocuments())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + INDEX_FIELD_NUMBER; + hash = (53 * hash) + getIndex().hashCode(); + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + if (hasProgressDocuments()) { + hash = (37 * hash) + PROGRESS_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getProgressDocuments().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.IndexOperationMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for [google.longrunning.Operation][google.longrunning.Operation]
+   * results from
+   * [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.IndexOperationMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.IndexOperationMetadata) + com.google.firestore.admin.v1.IndexOperationMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_IndexOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.IndexOperationMetadata.class, + com.google.firestore.admin.v1.IndexOperationMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.IndexOperationMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetProgressDocumentsFieldBuilder(); + internalGetProgressBytesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + index_ = ""; + state_ = 0; + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.IndexOperationMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.IndexOperationMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.IndexOperationMetadata build() { + com.google.firestore.admin.v1.IndexOperationMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.IndexOperationMetadata buildPartial() { + com.google.firestore.admin.v1.IndexOperationMetadata result = + new com.google.firestore.admin.v1.IndexOperationMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.IndexOperationMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.index_ = index_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.state_ = state_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.progressDocuments_ = + progressDocumentsBuilder_ == null + ? progressDocuments_ + : progressDocumentsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.IndexOperationMetadata) { + return mergeFrom((com.google.firestore.admin.v1.IndexOperationMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.IndexOperationMetadata other) { + if (other == com.google.firestore.admin.v1.IndexOperationMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (!other.getIndex().isEmpty()) { + index_ = other.index_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + if (other.hasProgressDocuments()) { + mergeProgressDocuments(other.getProgressDocuments()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + index_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 42: + { + input.readMessage( + internalGetProgressDocumentsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time this operation started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time this operation completed. Will be unset if operation still in
+     * progress.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private java.lang.Object index_ = ""; + + /** + * + * + *
+     * The index resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * string index = 3; + * + * @return The index. + */ + public java.lang.String getIndex() { + java.lang.Object ref = index_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + index_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The index resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * string index = 3; + * + * @return The bytes for index. + */ + public com.google.protobuf.ByteString getIndexBytes() { + java.lang.Object ref = index_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + index_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The index resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * string index = 3; + * + * @param value The index to set. + * @return This builder for chaining. + */ + public Builder setIndex(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + index_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The index resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * string index = 3; + * + * @return This builder for chaining. + */ + public Builder clearIndex() { + index_ = getDefaultInstance().getIndex(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * The index resource that this operation is acting on. For example:
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+     * 
+ * + * string index = 3; + * + * @param value The bytes for index to set. + * @return This builder for chaining. + */ + public Builder setIndexBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + index_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private int state_ = 0; + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the operation.
+     * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000008); + state_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressDocuments_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressDocumentsBuilder_; + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return Whether the progressDocuments field is set. + */ + public boolean hasProgressDocuments() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return The progressDocuments. + */ + public com.google.firestore.admin.v1.Progress getProgressDocuments() { + if (progressDocumentsBuilder_ == null) { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } else { + return progressDocumentsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public Builder setProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressDocuments_ = value; + } else { + progressDocumentsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public Builder setProgressDocuments( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressDocumentsBuilder_ == null) { + progressDocuments_ = builderForValue.build(); + } else { + progressDocumentsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public Builder mergeProgressDocuments(com.google.firestore.admin.v1.Progress value) { + if (progressDocumentsBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && progressDocuments_ != null + && progressDocuments_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressDocumentsBuilder().mergeFrom(value); + } else { + progressDocuments_ = value; + } + } else { + progressDocumentsBuilder_.mergeFrom(value); + } + if (progressDocuments_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public Builder clearProgressDocuments() { + bitField0_ = (bitField0_ & ~0x00000010); + progressDocuments_ = null; + if (progressDocumentsBuilder_ != null) { + progressDocumentsBuilder_.dispose(); + progressDocumentsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressDocumentsBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetProgressDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder() { + if (progressDocumentsBuilder_ != null) { + return progressDocumentsBuilder_.getMessageOrBuilder(); + } else { + return progressDocuments_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressDocuments_; + } + } + + /** + * + * + *
+     * The progress, in documents, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressDocumentsFieldBuilder() { + if (progressDocumentsBuilder_ == null) { + progressDocumentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressDocuments(), getParentForChildren(), isClean()); + progressDocuments_ = null; + } + return progressDocumentsBuilder_; + } + + private com.google.firestore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return The progressBytes. + */ + public com.google.firestore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public Builder setProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public Builder setProgressBytes( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public Builder mergeProgressBytes(com.google.firestore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000020); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * The progress, in bytes, of this operation.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.IndexOperationMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.IndexOperationMetadata) + private static final com.google.firestore.admin.v1.IndexOperationMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.IndexOperationMetadata(); + } + + public static com.google.firestore.admin.v1.IndexOperationMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexOperationMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.IndexOperationMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadataOrBuilder.java new file mode 100644 index 000000000000..c4db6185bf7b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOperationMetadataOrBuilder.java @@ -0,0 +1,233 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface IndexOperationMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.IndexOperationMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time this operation started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time this operation completed. Will be unset if operation still in
+   * progress.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The index resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * string index = 3; + * + * @return The index. + */ + java.lang.String getIndex(); + + /** + * + * + *
+   * The index resource that this operation is acting on. For example:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}`
+   * 
+ * + * string index = 3; + * + * @return The bytes for index. + */ + com.google.protobuf.ByteString getIndexBytes(); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * The state of the operation.
+   * 
+ * + * .google.firestore.admin.v1.OperationState state = 4; + * + * @return The state. + */ + com.google.firestore.admin.v1.OperationState getState(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return Whether the progressDocuments field is set. + */ + boolean hasProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + * + * @return The progressDocuments. + */ + com.google.firestore.admin.v1.Progress getProgressDocuments(); + + /** + * + * + *
+   * The progress, in documents, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_documents = 5; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressDocumentsOrBuilder(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + * + * @return The progressBytes. + */ + com.google.firestore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * The progress, in bytes, of this operation.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_bytes = 6; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOrBuilder.java new file mode 100644 index 000000000000..ac40f5d48391 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexOrBuilder.java @@ -0,0 +1,333 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/index.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface IndexOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Index) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. A server defined name for this index.
+   * The form of this name for composite indexes will be:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+   * For single field indexes, this field will be empty.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Output only. A server defined name for this index.
+   * The form of this name for composite indexes will be:
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}`
+   * For single field indexes, this field will be empty.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Indexes with a collection query scope specified allow queries
+   * against a collection that is the child of a specific document, specified at
+   * query time, and that has the same collection ID.
+   *
+   * Indexes with a collection group query scope specified allow queries against
+   * all collections descended from a specific document, specified at query
+   * time, and that have the same collection ID as this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The enum numeric value on the wire for queryScope. + */ + int getQueryScopeValue(); + + /** + * + * + *
+   * Indexes with a collection query scope specified allow queries
+   * against a collection that is the child of a specific document, specified at
+   * query time, and that has the same collection ID.
+   *
+   * Indexes with a collection group query scope specified allow queries against
+   * all collections descended from a specific document, specified at query
+   * time, and that have the same collection ID as this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.QueryScope query_scope = 2; + * + * @return The queryScope. + */ + com.google.firestore.admin.v1.Index.QueryScope getQueryScope(); + + /** + * + * + *
+   * The API scope supported by this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The enum numeric value on the wire for apiScope. + */ + int getApiScopeValue(); + + /** + * + * + *
+   * The API scope supported by this index.
+   * 
+ * + * .google.firestore.admin.v1.Index.ApiScope api_scope = 5; + * + * @return The apiScope. + */ + com.google.firestore.admin.v1.Index.ApiScope getApiScope(); + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + java.util.List getFieldsList(); + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + com.google.firestore.admin.v1.Index.IndexField getFields(int index); + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + int getFieldsCount(); + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + java.util.List + getFieldsOrBuilderList(); + + /** + * + * + *
+   * The fields supported by this index.
+   *
+   * For composite indexes, this requires a minimum of 2 and a maximum of 100
+   * fields. The last field entry is always for the field path `__name__`. If,
+   * on creation, `__name__` was not specified as the last field, it will be
+   * added automatically with the same direction as that of the last field
+   * defined. If the final field in a composite index is not directional, the
+   * `__name__` will be ordered ASCENDING (unless explicitly specified).
+   *
+   * For single field indexes, this will always be exactly one entry with a
+   * field path equal to the field path of the associated field.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index.IndexField fields = 3; + */ + com.google.firestore.admin.v1.Index.IndexFieldOrBuilder getFieldsOrBuilder(int index); + + /** + * + * + *
+   * Output only. The serving state of the index.
+   * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * Output only. The serving state of the index.
+   * 
+ * + * .google.firestore.admin.v1.Index.State state = 4; + * + * @return The state. + */ + com.google.firestore.admin.v1.Index.State getState(); + + /** + * + * + *
+   * Immutable. The density configuration of the index.
+   * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The enum numeric value on the wire for density. + */ + int getDensityValue(); + + /** + * + * + *
+   * Immutable. The density configuration of the index.
+   * 
+ * + * + * .google.firestore.admin.v1.Index.Density density = 6 [(.google.api.field_behavior) = IMMUTABLE]; + * + * + * @return The density. + */ + com.google.firestore.admin.v1.Index.Density getDensity(); + + /** + * + * + *
+   * Optional. Whether the index is multikey. By default, the index is not
+   * multikey. For non-multikey indexes, none of the paths in the index
+   * definition reach or traverse an array, except via an explicit array index.
+   * For multikey indexes, at most one of the paths in the index definition
+   * reach or traverse an array, except via an explicit array index. Violations
+   * will result in errors.
+   *
+   * Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope.
+   * 
+ * + * bool multikey = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The multikey. + */ + boolean getMultikey(); + + /** + * + * + *
+   * Optional. The number of shards for the index.
+   * 
+ * + * int32 shard_count = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The shardCount. + */ + int getShardCount(); + + /** + * + * + *
+   * Optional. Whether it is an unique index. Unique index ensures all values
+   * for the indexed field(s) are unique across documents.
+   * 
+ * + * bool unique = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The unique. + */ + boolean getUnique(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java new file mode 100644 index 000000000000..2f23955b7da8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/IndexProto.java @@ -0,0 +1,191 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/index.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class IndexProto extends com.google.protobuf.GeneratedFile { + private IndexProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "IndexProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_IndexField_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_IndexField_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "%google/firestore/admin/v1/index.proto\022" + + "\031google.firestore.admin.v1\032\037google/api/f" + + "ield_behavior.proto\032\031google/api/resource.proto\"\202\013\n" + + "\005Index\022\014\n" + + "\004name\030\001 \001(\t\022@\n" + + "\013query_scope\030\002 \001(\0162+.google.firestore.admin.v1.Index.QueryScope\022<\n" + + "\tapi_scope\030\005 \001(\0162).google.firestore.admin.v1.Index.ApiScope\022;\n" + + "\006fields\030\003 \003(\0132+.google.firestore.admin.v1.Index.IndexField\0225\n" + + "\005state\030\004 \001(\0162&.google.firestore.admin.v1.Index.State\022>\n" + + "\007density\030\006" + + " \001(\0162(.google.firestore.admin.v1.Index.DensityB\003\340A\005\022\025\n" + + "\010multikey\030\007 \001(\010B\003\340A\001\022\030\n" + + "\013shard_count\030\010 \001(\005B\003\340A\001\022\023\n" + + "\006unique\030\n" + + " \001(\010B\003\340A\001\032\242\004\n\n" + + "IndexField\022\022\n\n" + + "field_path\030\001 \001(\t\022B\n" + + "\005order\030\002" + + " \001(\01621.google.firestore.admin.v1.Index.IndexField.OrderH\000\022O\n" + + "\014array_config\030\003" + + " \001(\01627.google.firestore.admin.v1.Index.IndexField.ArrayConfigH\000\022Q\n\r" + + "vector_config\030\004" + + " \001(\01328.google.firestore.admin.v1.Index.IndexField.VectorConfigH\000\032\217\001\n" + + "\014VectorConfig\022\026\n" + + "\tdimension\030\001 \001(\005B\003\340A\002\022R\n" + + "\004flat\030\002 \001(\0132B.google.firestore.admin.v1.I" + + "ndex.IndexField.VectorConfig.FlatIndexH\000\032\013\n" + + "\tFlatIndexB\006\n" + + "\004type\"=\n" + + "\005Order\022\025\n" + + "\021ORDER_UNSPECIFIED\020\000\022\r\n" + + "\tASCENDING\020\001\022\016\n\n" + + "DESCENDING\020\002\"9\n" + + "\013ArrayConfig\022\034\n" + + "\030ARRAY_CONFIG_UNSPECIFIED\020\000\022\014\n" + + "\010CONTAINS\020\001B\014\n\n" + + "value_mode\"i\n" + + "\n" + + "QueryScope\022\033\n" + + "\027QUERY_SCOPE_UNSPECIFIED\020\000\022\016\n\n" + + "COLLECTION\020\001\022\024\n" + + "\020COLLECTION_GROUP\020\002\022\030\n" + + "\024COLLECTION_RECURSIVE\020\003\"K\n" + + "\010ApiScope\022\013\n" + + "\007ANY_API\020\000\022\026\n" + + "\022DATASTORE_MODE_API\020\001\022\032\n" + + "\026MONGODB_COMPATIBLE_API\020\002\"I\n" + + "\005State\022\025\n" + + "\021STATE_UNSPECIFIED\020\000\022\014\n" + + "\010CREATING\020\001\022\t\n" + + "\005READY\020\002\022\020\n" + + "\014NEEDS_REPAIR\020\003\"M\n" + + "\007Density\022\027\n" + + "\023DENSITY_UNSPECIFIED\020\000\022\016\n\n" + + "SPARSE_ALL\020\001\022\016\n\n" + + "SPARSE_ANY\020\002\022\t\n" + + "\005DENSE\020\003:z\352Aw\n" + + "\036firestore.googleapis.com/Index\022Uprojects/{project}/databas" + + "es/{database}/collectionGroups/{collection}/indexes/{index}B\331\001\n" + + "\035com.google.firestore.admin.v1B\n" + + "IndexProtoP\001Z9cloud.google.com/go/firestore/apiv1/admin/adminpb;a" + + "dminpb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.A" + + "dmin.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V" + + "1\352\002#Google::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_Index_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_Index_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_descriptor, + new java.lang.String[] { + "Name", + "QueryScope", + "ApiScope", + "Fields", + "State", + "Density", + "Multikey", + "ShardCount", + "Unique", + }); + internal_static_google_firestore_admin_v1_Index_IndexField_descriptor = + internal_static_google_firestore_admin_v1_Index_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Index_IndexField_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_IndexField_descriptor, + new java.lang.String[] { + "FieldPath", "Order", "ArrayConfig", "VectorConfig", "ValueMode", + }); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor = + internal_static_google_firestore_admin_v1_Index_IndexField_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor, + new java.lang.String[] { + "Dimension", "Flat", "Type", + }); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor = + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_descriptor + .getNestedType(0); + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Index_IndexField_VectorConfig_FlatIndex_descriptor, + new java.lang.String[] {}); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java new file mode 100644 index 000000000000..4be3527701b1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequest.java @@ -0,0 +1,627 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesRequest} + */ +@com.google.protobuf.Generated +public final class ListBackupSchedulesRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupSchedulesRequest) + ListBackupSchedulesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListBackupSchedulesRequest"); + } + + // Use ListBackupSchedulesRequest.newBuilder() to construct. + private ListBackupSchedulesRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListBackupSchedulesRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + com.google.firestore.admin.v1.ListBackupSchedulesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupSchedulesRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupSchedulesRequest other = + (com.google.firestore.admin.v1.ListBackupSchedulesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ListBackupSchedulesRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupSchedulesRequest) + com.google.firestore.admin.v1.ListBackupSchedulesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesRequest.class, + com.google.firestore.admin.v1.ListBackupSchedulesRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupSchedulesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupSchedulesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest build() { + com.google.firestore.admin.v1.ListBackupSchedulesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest buildPartial() { + com.google.firestore.admin.v1.ListBackupSchedulesRequest result = + new com.google.firestore.admin.v1.ListBackupSchedulesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupSchedulesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupSchedulesRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupSchedulesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupSchedulesRequest other) { + if (other == com.google.firestore.admin.v1.ListBackupSchedulesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent database.
+     *
+     * Format is `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupSchedulesRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupSchedulesRequest) + private static final com.google.firestore.admin.v1.ListBackupSchedulesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupSchedulesRequest(); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java new file mode 100644 index 000000000000..02ac98b03607 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesRequestOrBuilder.java @@ -0,0 +1,62 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListBackupSchedulesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupSchedulesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent database.
+   *
+   * Format is `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java new file mode 100644 index 000000000000..59b6eaf1da5a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponse.java @@ -0,0 +1,936 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesResponse} + */ +@com.google.protobuf.Generated +public final class ListBackupSchedulesResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupSchedulesResponse) + ListBackupSchedulesResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListBackupSchedulesResponse"); + } + + // Use ListBackupSchedulesResponse.newBuilder() to construct. + private ListBackupSchedulesResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListBackupSchedulesResponse() { + backupSchedules_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + com.google.firestore.admin.v1.ListBackupSchedulesResponse.Builder.class); + } + + public static final int BACKUP_SCHEDULES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List backupSchedules_; + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List getBackupSchedulesList() { + return backupSchedules_; + } + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List + getBackupSchedulesOrBuilderList() { + return backupSchedules_; + } + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public int getBackupSchedulesCount() { + return backupSchedules_.size(); + } + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index) { + return backupSchedules_.get(index); + } + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + return backupSchedules_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < backupSchedules_.size(); i++) { + output.writeMessage(1, backupSchedules_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < backupSchedules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, backupSchedules_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupSchedulesResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupSchedulesResponse other = + (com.google.firestore.admin.v1.ListBackupSchedulesResponse) obj; + + if (!getBackupSchedulesList().equals(other.getBackupSchedulesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBackupSchedulesCount() > 0) { + hash = (37 * hash) + BACKUP_SCHEDULES_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedulesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ListBackupSchedulesResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupSchedulesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupSchedulesResponse) + com.google.firestore.admin.v1.ListBackupSchedulesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupSchedulesResponse.class, + com.google.firestore.admin.v1.ListBackupSchedulesResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupSchedulesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + } else { + backupSchedules_ = null; + backupSchedulesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupSchedulesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse build() { + com.google.firestore.admin.v1.ListBackupSchedulesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse buildPartial() { + com.google.firestore.admin.v1.ListBackupSchedulesResponse result = + new com.google.firestore.admin.v1.ListBackupSchedulesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListBackupSchedulesResponse result) { + if (backupSchedulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = java.util.Collections.unmodifiableList(backupSchedules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.backupSchedules_ = backupSchedules_; + } else { + result.backupSchedules_ = backupSchedulesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupSchedulesResponse result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupSchedulesResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupSchedulesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupSchedulesResponse other) { + if (other == com.google.firestore.admin.v1.ListBackupSchedulesResponse.getDefaultInstance()) + return this; + if (backupSchedulesBuilder_ == null) { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedules_.isEmpty()) { + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBackupSchedulesIsMutable(); + backupSchedules_.addAll(other.backupSchedules_); + } + onChanged(); + } + } else { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedulesBuilder_.isEmpty()) { + backupSchedulesBuilder_.dispose(); + backupSchedulesBuilder_ = null; + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedulesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetBackupSchedulesFieldBuilder() + : null; + } else { + backupSchedulesBuilder_.addAllMessages(other.backupSchedules_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.BackupSchedule m = + input.readMessage( + com.google.firestore.admin.v1.BackupSchedule.parser(), extensionRegistry); + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(m); + } else { + backupSchedulesBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List backupSchedules_ = + java.util.Collections.emptyList(); + + private void ensureBackupSchedulesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = + new java.util.ArrayList(backupSchedules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupSchedulesBuilder_; + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List getBackupSchedulesList() { + if (backupSchedulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(backupSchedules_); + } else { + return backupSchedulesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public int getBackupSchedulesCount() { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.size(); + } else { + return backupSchedulesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addAllBackupSchedules( + java.lang.Iterable values) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backupSchedules_); + onChanged(); + } else { + backupSchedulesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder clearBackupSchedules() { + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + backupSchedulesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public Builder removeBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.remove(index); + onChanged(); + } else { + backupSchedulesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupSchedulesBuilder( + int index) { + return internalGetBackupSchedulesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesOrBuilderList() { + if (backupSchedulesBuilder_ != null) { + return backupSchedulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(backupSchedules_); + } + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder addBackupSchedulesBuilder() { + return internalGetBackupSchedulesFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()); + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder addBackupSchedulesBuilder( + int index) { + return internalGetBackupSchedulesFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()); + } + + /** + * + * + *
+     * List of all backup schedules.
+     * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesBuilderList() { + return internalGetBackupSchedulesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + internalGetBackupSchedulesFieldBuilder() { + if (backupSchedulesBuilder_ == null) { + backupSchedulesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + backupSchedules_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + backupSchedules_ = null; + } + return backupSchedulesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupSchedulesResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupSchedulesResponse) + private static final com.google.firestore.admin.v1.ListBackupSchedulesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupSchedulesResponse(); + } + + public static com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupSchedulesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java new file mode 100644 index 000000000000..0aa8a24fb739 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupSchedulesResponseOrBuilder.java @@ -0,0 +1,84 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListBackupSchedulesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupSchedulesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List getBackupSchedulesList(); + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedules(int index); + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + int getBackupSchedulesCount(); + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List + getBackupSchedulesOrBuilderList(); + + /** + * + * + *
+   * List of all backup schedules.
+   * 
+ * + * repeated .google.firestore.admin.v1.BackupSchedule backup_schedules = 1; + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java new file mode 100644 index 000000000000..d492d3fb7d27 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequest.java @@ -0,0 +1,913 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsRequest} + */ +@com.google.protobuf.Generated +public final class ListBackupsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupsRequest) + ListBackupsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListBackupsRequest"); + } + + // Use ListBackupsRequest.newBuilder() to construct. + private ListBackupsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListBackupsRequest() { + parent_ = ""; + filter_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsRequest.class, + com.google.firestore.admin.v1.ListBackupsRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILTER_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object filter_ = ""; + + /** + * + * + *
+   * An expression that filters the list of returned backups.
+   *
+   * A filter expression consists of a field name, a comparison operator, and a
+   * value for filtering.
+   * The value must be a string, a number, or a boolean. The comparison operator
+   * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+   * Colon `:` is the contains operator. Filter rules are not case sensitive.
+   *
+   * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+   * eligible for filtering:
+   *
+   * * `database_uid` (supports `=` only)
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + @java.lang.Override + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } + } + + /** + * + * + *
+   * An expression that filters the list of returned backups.
+   *
+   * A filter expression consists of a field name, a comparison operator, and a
+   * value for filtering.
+   * The value must be a string, a number, or a boolean. The comparison operator
+   * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+   * Colon `:` is the contains operator. Filter rules are not case sensitive.
+   *
+   * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+   * eligible for filtering:
+   *
+   * * `database_uid` (supports `=` only)
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, filter_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, filter_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupsRequest other = + (com.google.firestore.admin.v1.ListBackupsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getFilter().equals(other.getFilter())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListBackupsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupsRequest) + com.google.firestore.admin.v1.ListBackupsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsRequest.class, + com.google.firestore.admin.v1.ListBackupsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + filter_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest build() { + com.google.firestore.admin.v1.ListBackupsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest buildPartial() { + com.google.firestore.admin.v1.ListBackupsRequest result = + new com.google.firestore.admin.v1.ListBackupsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.filter_ = filter_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupsRequest other) { + if (other == com.google.firestore.admin.v1.ListBackupsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getFilter().isEmpty()) { + filter_ = other.filter_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + filter_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The location to list backups from.
+     *
+     * Format is `projects/{project}/locations/{location}`.
+     * Use `{location} = '-'` to list backups from all locations for the given
+     * project. This allows listing backups from a single location or from all
+     * locations.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object filter_ = ""; + + /** + * + * + *
+     * An expression that filters the list of returned backups.
+     *
+     * A filter expression consists of a field name, a comparison operator, and a
+     * value for filtering.
+     * The value must be a string, a number, or a boolean. The comparison operator
+     * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+     * Colon `:` is the contains operator. Filter rules are not case sensitive.
+     *
+     * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+     * eligible for filtering:
+     *
+     * * `database_uid` (supports `=` only)
+     * 
+ * + * string filter = 2; + * + * @return The filter. + */ + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * An expression that filters the list of returned backups.
+     *
+     * A filter expression consists of a field name, a comparison operator, and a
+     * value for filtering.
+     * The value must be a string, a number, or a boolean. The comparison operator
+     * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+     * Colon `:` is the contains operator. Filter rules are not case sensitive.
+     *
+     * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+     * eligible for filtering:
+     *
+     * * `database_uid` (supports `=` only)
+     * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * An expression that filters the list of returned backups.
+     *
+     * A filter expression consists of a field name, a comparison operator, and a
+     * value for filtering.
+     * The value must be a string, a number, or a boolean. The comparison operator
+     * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+     * Colon `:` is the contains operator. Filter rules are not case sensitive.
+     *
+     * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+     * eligible for filtering:
+     *
+     * * `database_uid` (supports `=` only)
+     * 
+ * + * string filter = 2; + * + * @param value The filter to set. + * @return This builder for chaining. + */ + public Builder setFilter(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An expression that filters the list of returned backups.
+     *
+     * A filter expression consists of a field name, a comparison operator, and a
+     * value for filtering.
+     * The value must be a string, a number, or a boolean. The comparison operator
+     * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+     * Colon `:` is the contains operator. Filter rules are not case sensitive.
+     *
+     * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+     * eligible for filtering:
+     *
+     * * `database_uid` (supports `=` only)
+     * 
+ * + * string filter = 2; + * + * @return This builder for chaining. + */ + public Builder clearFilter() { + filter_ = getDefaultInstance().getFilter(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * An expression that filters the list of returned backups.
+     *
+     * A filter expression consists of a field name, a comparison operator, and a
+     * value for filtering.
+     * The value must be a string, a number, or a boolean. The comparison operator
+     * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+     * Colon `:` is the contains operator. Filter rules are not case sensitive.
+     *
+     * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+     * eligible for filtering:
+     *
+     * * `database_uid` (supports `=` only)
+     * 
+ * + * string filter = 2; + * + * @param value The bytes for filter to set. + * @return This builder for chaining. + */ + public Builder setFilterBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupsRequest) + private static final com.google.firestore.admin.v1.ListBackupsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupsRequest(); + } + + public static com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java new file mode 100644 index 000000000000..940ae503744e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsRequestOrBuilder.java @@ -0,0 +1,116 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListBackupsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The location to list backups from.
+   *
+   * Format is `projects/{project}/locations/{location}`.
+   * Use `{location} = '-'` to list backups from all locations for the given
+   * project. This allows listing backups from a single location or from all
+   * locations.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * An expression that filters the list of returned backups.
+   *
+   * A filter expression consists of a field name, a comparison operator, and a
+   * value for filtering.
+   * The value must be a string, a number, or a boolean. The comparison operator
+   * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+   * Colon `:` is the contains operator. Filter rules are not case sensitive.
+   *
+   * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+   * eligible for filtering:
+   *
+   * * `database_uid` (supports `=` only)
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + java.lang.String getFilter(); + + /** + * + * + *
+   * An expression that filters the list of returned backups.
+   *
+   * A filter expression consists of a field name, a comparison operator, and a
+   * value for filtering.
+   * The value must be a string, a number, or a boolean. The comparison operator
+   * must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`.
+   * Colon `:` is the contains operator. Filter rules are not case sensitive.
+   *
+   * The following fields in the [Backup][google.firestore.admin.v1.Backup] are
+   * eligible for filtering:
+   *
+   * * `database_uid` (supports `=` only)
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + com.google.protobuf.ByteString getFilterBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java new file mode 100644 index 000000000000..af0f6c8c9064 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponse.java @@ -0,0 +1,1278 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsResponse} + */ +@com.google.protobuf.Generated +public final class ListBackupsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListBackupsResponse) + ListBackupsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListBackupsResponse"); + } + + // Use ListBackupsResponse.newBuilder() to construct. + private ListBackupsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListBackupsResponse() { + backups_ = java.util.Collections.emptyList(); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsResponse.class, + com.google.firestore.admin.v1.ListBackupsResponse.Builder.class); + } + + public static final int BACKUPS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List backups_; + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public java.util.List getBackupsList() { + return backups_; + } + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public java.util.List + getBackupsOrBuilderList() { + return backups_; + } + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public int getBackupsCount() { + return backups_.size(); + } + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Backup getBackups(int index) { + return backups_.get(index); + } + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index) { + return backups_.get(index); + } + + public static final int UNREACHABLE_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + return unreachable_; + } + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < backups_.size(); i++) { + output.writeMessage(1, backups_.get(i)); + } + for (int i = 0; i < unreachable_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, unreachable_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < backups_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, backups_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < unreachable_.size(); i++) { + dataSize += computeStringSizeNoTag(unreachable_.getRaw(i)); + } + size += dataSize; + size += 1 * getUnreachableList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListBackupsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListBackupsResponse other = + (com.google.firestore.admin.v1.ListBackupsResponse) obj; + + if (!getBackupsList().equals(other.getBackupsList())) return false; + if (!getUnreachableList().equals(other.getUnreachableList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getBackupsCount() > 0) { + hash = (37 * hash) + BACKUPS_FIELD_NUMBER; + hash = (53 * hash) + getBackupsList().hashCode(); + } + if (getUnreachableCount() > 0) { + hash = (37 * hash) + UNREACHABLE_FIELD_NUMBER; + hash = (53 * hash) + getUnreachableList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListBackupsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListBackupsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListBackupsResponse) + com.google.firestore.admin.v1.ListBackupsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListBackupsResponse.class, + com.google.firestore.admin.v1.ListBackupsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListBackupsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupsBuilder_ == null) { + backups_ = java.util.Collections.emptyList(); + } else { + backups_ = null; + backupsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListBackupsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListBackupsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse build() { + com.google.firestore.admin.v1.ListBackupsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse buildPartial() { + com.google.firestore.admin.v1.ListBackupsResponse result = + new com.google.firestore.admin.v1.ListBackupsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListBackupsResponse result) { + if (backupsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + backups_ = java.util.Collections.unmodifiableList(backups_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.backups_ = backups_; + } else { + result.backups_ = backupsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListBackupsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + unreachable_.makeImmutable(); + result.unreachable_ = unreachable_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListBackupsResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListBackupsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListBackupsResponse other) { + if (other == com.google.firestore.admin.v1.ListBackupsResponse.getDefaultInstance()) + return this; + if (backupsBuilder_ == null) { + if (!other.backups_.isEmpty()) { + if (backups_.isEmpty()) { + backups_ = other.backups_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBackupsIsMutable(); + backups_.addAll(other.backups_); + } + onChanged(); + } + } else { + if (!other.backups_.isEmpty()) { + if (backupsBuilder_.isEmpty()) { + backupsBuilder_.dispose(); + backupsBuilder_ = null; + backups_ = other.backups_; + bitField0_ = (bitField0_ & ~0x00000001); + backupsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetBackupsFieldBuilder() + : null; + } else { + backupsBuilder_.addAllMessages(other.backups_); + } + } + } + if (!other.unreachable_.isEmpty()) { + if (unreachable_.isEmpty()) { + unreachable_ = other.unreachable_; + bitField0_ |= 0x00000002; + } else { + ensureUnreachableIsMutable(); + unreachable_.addAll(other.unreachable_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Backup m = + input.readMessage( + com.google.firestore.admin.v1.Backup.parser(), extensionRegistry); + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(m); + } else { + backupsBuilder_.addMessage(m); + } + break; + } // case 10 + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureUnreachableIsMutable(); + unreachable_.add(s); + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List backups_ = + java.util.Collections.emptyList(); + + private void ensureBackupsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + backups_ = new java.util.ArrayList(backups_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder> + backupsBuilder_; + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List getBackupsList() { + if (backupsBuilder_ == null) { + return java.util.Collections.unmodifiableList(backups_); + } else { + return backupsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public int getBackupsCount() { + if (backupsBuilder_ == null) { + return backups_.size(); + } else { + return backupsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup getBackups(int index) { + if (backupsBuilder_ == null) { + return backups_.get(index); + } else { + return backupsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder setBackups(int index, com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.set(index, value); + onChanged(); + } else { + backupsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder setBackups( + int index, com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.set(index, builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.add(value); + onChanged(); + } else { + backupsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(int index, com.google.firestore.admin.v1.Backup value) { + if (backupsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupsIsMutable(); + backups_.add(index, value); + onChanged(); + } else { + backupsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups(com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addBackups( + int index, com.google.firestore.admin.v1.Backup.Builder builderForValue) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.add(index, builderForValue.build()); + onChanged(); + } else { + backupsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder addAllBackups( + java.lang.Iterable values) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backups_); + onChanged(); + } else { + backupsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder clearBackups() { + if (backupsBuilder_ == null) { + backups_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + backupsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public Builder removeBackups(int index) { + if (backupsBuilder_ == null) { + ensureBackupsIsMutable(); + backups_.remove(index); + onChanged(); + } else { + backupsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder getBackupsBuilder(int index) { + return internalGetBackupsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index) { + if (backupsBuilder_ == null) { + return backups_.get(index); + } else { + return backupsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List + getBackupsOrBuilderList() { + if (backupsBuilder_ != null) { + return backupsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(backups_); + } + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder addBackupsBuilder() { + return internalGetBackupsFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Backup.getDefaultInstance()); + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public com.google.firestore.admin.v1.Backup.Builder addBackupsBuilder(int index) { + return internalGetBackupsFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Backup.getDefaultInstance()); + } + + /** + * + * + *
+     * List of all backups for the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + public java.util.List getBackupsBuilderList() { + return internalGetBackupsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder> + internalGetBackupsFieldBuilder() { + if (backupsBuilder_ == null) { + backupsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Backup, + com.google.firestore.admin.v1.Backup.Builder, + com.google.firestore.admin.v1.BackupOrBuilder>( + backups_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + backups_ = null; + } + return backupsBuilder_; + } + + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureUnreachableIsMutable() { + if (!unreachable_.isModifiable()) { + unreachable_ = new com.google.protobuf.LazyStringArrayList(unreachable_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + unreachable_.makeImmutable(); + return unreachable_; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index to set the value at. + * @param value The unreachable to set. + * @return This builder for chaining. + */ + public Builder setUnreachable(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachable(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param values The unreachable to add. + * @return This builder for chaining. + */ + public Builder addAllUnreachable(java.lang.Iterable values) { + ensureUnreachableIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, unreachable_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return This builder for chaining. + */ + public Builder clearUnreachable() { + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * List of locations that existing backups were not able to be fetched from.
+     *
+     * Instead of failing the entire requests when a single location is
+     * unreachable, this response returns a partial result set and list of
+     * locations unable to be reached here. The request can be retried against a
+     * single location to get a concrete error.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The bytes of the unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachableBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListBackupsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListBackupsResponse) + private static final com.google.firestore.admin.v1.ListBackupsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListBackupsResponse(); + } + + public static com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListBackupsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java new file mode 100644 index 000000000000..4a3a85b6c818 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListBackupsResponseOrBuilder.java @@ -0,0 +1,157 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListBackupsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListBackupsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + java.util.List getBackupsList(); + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + com.google.firestore.admin.v1.Backup getBackups(int index); + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + int getBackupsCount(); + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + java.util.List getBackupsOrBuilderList(); + + /** + * + * + *
+   * List of all backups for the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Backup backups = 1; + */ + com.google.firestore.admin.v1.BackupOrBuilder getBackupsOrBuilder(int index); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + java.util.List getUnreachableList(); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + int getUnreachableCount(); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + java.lang.String getUnreachable(int index); + + /** + * + * + *
+   * List of locations that existing backups were not able to be fetched from.
+   *
+   * Instead of failing the entire requests when a single location is
+   * unreachable, this response returns a partial result set and list of
+   * locations unable to be reached here. The request can be retried against a
+   * single location to get a concrete error.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + com.google.protobuf.ByteString getUnreachableBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequest.java new file mode 100644 index 000000000000..edf0f8347943 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequest.java @@ -0,0 +1,714 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A request to list the Firestore Databases in all locations for a project.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListDatabasesRequest} + */ +@com.google.protobuf.Generated +public final class ListDatabasesRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListDatabasesRequest) + ListDatabasesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListDatabasesRequest"); + } + + // Use ListDatabasesRequest.newBuilder() to construct. + private ListDatabasesRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListDatabasesRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListDatabasesRequest.class, + com.google.firestore.admin.v1.ListDatabasesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SHOW_DELETED_FIELD_NUMBER = 4; + private boolean showDeleted_ = false; + + /** + * + * + *
+   * If true, also returns deleted resources.
+   * 
+ * + * bool show_deleted = 4; + * + * @return The showDeleted. + */ + @java.lang.Override + public boolean getShowDeleted() { + return showDeleted_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (showDeleted_ != false) { + output.writeBool(4, showDeleted_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (showDeleted_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(4, showDeleted_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListDatabasesRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListDatabasesRequest other = + (com.google.firestore.admin.v1.ListDatabasesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getShowDeleted() != other.getShowDeleted()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + SHOW_DELETED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getShowDeleted()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListDatabasesRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A request to list the Firestore Databases in all locations for a project.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListDatabasesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListDatabasesRequest) + com.google.firestore.admin.v1.ListDatabasesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListDatabasesRequest.class, + com.google.firestore.admin.v1.ListDatabasesRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListDatabasesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + showDeleted_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListDatabasesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesRequest build() { + com.google.firestore.admin.v1.ListDatabasesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesRequest buildPartial() { + com.google.firestore.admin.v1.ListDatabasesRequest result = + new com.google.firestore.admin.v1.ListDatabasesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListDatabasesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.showDeleted_ = showDeleted_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListDatabasesRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListDatabasesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListDatabasesRequest other) { + if (other == com.google.firestore.admin.v1.ListDatabasesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getShowDeleted() != false) { + setShowDeleted(other.getShowDeleted()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 32: + { + showDeleted_ = input.readBool(); + bitField0_ |= 0x00000002; + break; + } // case 32 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private boolean showDeleted_; + + /** + * + * + *
+     * If true, also returns deleted resources.
+     * 
+ * + * bool show_deleted = 4; + * + * @return The showDeleted. + */ + @java.lang.Override + public boolean getShowDeleted() { + return showDeleted_; + } + + /** + * + * + *
+     * If true, also returns deleted resources.
+     * 
+ * + * bool show_deleted = 4; + * + * @param value The showDeleted to set. + * @return This builder for chaining. + */ + public Builder setShowDeleted(boolean value) { + + showDeleted_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * If true, also returns deleted resources.
+     * 
+ * + * bool show_deleted = 4; + * + * @return This builder for chaining. + */ + public Builder clearShowDeleted() { + bitField0_ = (bitField0_ & ~0x00000002); + showDeleted_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListDatabasesRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListDatabasesRequest) + private static final com.google.firestore.admin.v1.ListDatabasesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListDatabasesRequest(); + } + + public static com.google.firestore.admin.v1.ListDatabasesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListDatabasesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequestOrBuilder.java new file mode 100644 index 000000000000..a417f9cd39d1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesRequestOrBuilder.java @@ -0,0 +1,73 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListDatabasesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListDatabasesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * If true, also returns deleted resources.
+   * 
+ * + * bool show_deleted = 4; + * + * @return The showDeleted. + */ + boolean getShowDeleted(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponse.java new file mode 100644 index 000000000000..aca31bb35bcf --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponse.java @@ -0,0 +1,1316 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The list of databases for a project.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListDatabasesResponse} + */ +@com.google.protobuf.Generated +public final class ListDatabasesResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListDatabasesResponse) + ListDatabasesResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListDatabasesResponse"); + } + + // Use ListDatabasesResponse.newBuilder() to construct. + private ListDatabasesResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListDatabasesResponse() { + databases_ = java.util.Collections.emptyList(); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListDatabasesResponse.class, + com.google.firestore.admin.v1.ListDatabasesResponse.Builder.class); + } + + public static final int DATABASES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List databases_; + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + @java.lang.Override + public java.util.List getDatabasesList() { + return databases_; + } + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + @java.lang.Override + public java.util.List + getDatabasesOrBuilderList() { + return databases_; + } + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + @java.lang.Override + public int getDatabasesCount() { + return databases_.size(); + } + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database getDatabases(int index) { + return databases_.get(index); + } + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabasesOrBuilder(int index) { + return databases_.get(index); + } + + public static final int UNREACHABLE_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + return unreachable_; + } + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < databases_.size(); i++) { + output.writeMessage(1, databases_.get(i)); + } + for (int i = 0; i < unreachable_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, unreachable_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < databases_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, databases_.get(i)); + } + { + int dataSize = 0; + for (int i = 0; i < unreachable_.size(); i++) { + dataSize += computeStringSizeNoTag(unreachable_.getRaw(i)); + } + size += dataSize; + size += 1 * getUnreachableList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListDatabasesResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListDatabasesResponse other = + (com.google.firestore.admin.v1.ListDatabasesResponse) obj; + + if (!getDatabasesList().equals(other.getDatabasesList())) return false; + if (!getUnreachableList().equals(other.getUnreachableList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDatabasesCount() > 0) { + hash = (37 * hash) + DATABASES_FIELD_NUMBER; + hash = (53 * hash) + getDatabasesList().hashCode(); + } + if (getUnreachableCount() > 0) { + hash = (37 * hash) + UNREACHABLE_FIELD_NUMBER; + hash = (53 * hash) + getUnreachableList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListDatabasesResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The list of databases for a project.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListDatabasesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListDatabasesResponse) + com.google.firestore.admin.v1.ListDatabasesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListDatabasesResponse.class, + com.google.firestore.admin.v1.ListDatabasesResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListDatabasesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (databasesBuilder_ == null) { + databases_ = java.util.Collections.emptyList(); + } else { + databases_ = null; + databasesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListDatabasesResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListDatabasesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesResponse build() { + com.google.firestore.admin.v1.ListDatabasesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesResponse buildPartial() { + com.google.firestore.admin.v1.ListDatabasesResponse result = + new com.google.firestore.admin.v1.ListDatabasesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListDatabasesResponse result) { + if (databasesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + databases_ = java.util.Collections.unmodifiableList(databases_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.databases_ = databases_; + } else { + result.databases_ = databasesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListDatabasesResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + unreachable_.makeImmutable(); + result.unreachable_ = unreachable_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListDatabasesResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListDatabasesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListDatabasesResponse other) { + if (other == com.google.firestore.admin.v1.ListDatabasesResponse.getDefaultInstance()) + return this; + if (databasesBuilder_ == null) { + if (!other.databases_.isEmpty()) { + if (databases_.isEmpty()) { + databases_ = other.databases_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDatabasesIsMutable(); + databases_.addAll(other.databases_); + } + onChanged(); + } + } else { + if (!other.databases_.isEmpty()) { + if (databasesBuilder_.isEmpty()) { + databasesBuilder_.dispose(); + databasesBuilder_ = null; + databases_ = other.databases_; + bitField0_ = (bitField0_ & ~0x00000001); + databasesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetDatabasesFieldBuilder() + : null; + } else { + databasesBuilder_.addAllMessages(other.databases_); + } + } + } + if (!other.unreachable_.isEmpty()) { + if (unreachable_.isEmpty()) { + unreachable_ = other.unreachable_; + bitField0_ |= 0x00000002; + } else { + ensureUnreachableIsMutable(); + unreachable_.addAll(other.unreachable_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Database m = + input.readMessage( + com.google.firestore.admin.v1.Database.parser(), extensionRegistry); + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + databases_.add(m); + } else { + databasesBuilder_.addMessage(m); + } + break; + } // case 10 + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureUnreachableIsMutable(); + unreachable_.add(s); + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List databases_ = + java.util.Collections.emptyList(); + + private void ensureDatabasesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + databases_ = new java.util.ArrayList(databases_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + databasesBuilder_; + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public java.util.List getDatabasesList() { + if (databasesBuilder_ == null) { + return java.util.Collections.unmodifiableList(databases_); + } else { + return databasesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public int getDatabasesCount() { + if (databasesBuilder_ == null) { + return databases_.size(); + } else { + return databasesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public com.google.firestore.admin.v1.Database getDatabases(int index) { + if (databasesBuilder_ == null) { + return databases_.get(index); + } else { + return databasesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder setDatabases(int index, com.google.firestore.admin.v1.Database value) { + if (databasesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDatabasesIsMutable(); + databases_.set(index, value); + onChanged(); + } else { + databasesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder setDatabases( + int index, com.google.firestore.admin.v1.Database.Builder builderForValue) { + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + databases_.set(index, builderForValue.build()); + onChanged(); + } else { + databasesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder addDatabases(com.google.firestore.admin.v1.Database value) { + if (databasesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDatabasesIsMutable(); + databases_.add(value); + onChanged(); + } else { + databasesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder addDatabases(int index, com.google.firestore.admin.v1.Database value) { + if (databasesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDatabasesIsMutable(); + databases_.add(index, value); + onChanged(); + } else { + databasesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder addDatabases(com.google.firestore.admin.v1.Database.Builder builderForValue) { + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + databases_.add(builderForValue.build()); + onChanged(); + } else { + databasesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder addDatabases( + int index, com.google.firestore.admin.v1.Database.Builder builderForValue) { + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + databases_.add(index, builderForValue.build()); + onChanged(); + } else { + databasesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder addAllDatabases( + java.lang.Iterable values) { + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, databases_); + onChanged(); + } else { + databasesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder clearDatabases() { + if (databasesBuilder_ == null) { + databases_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + databasesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public Builder removeDatabases(int index) { + if (databasesBuilder_ == null) { + ensureDatabasesIsMutable(); + databases_.remove(index); + onChanged(); + } else { + databasesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public com.google.firestore.admin.v1.Database.Builder getDatabasesBuilder(int index) { + return internalGetDatabasesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabasesOrBuilder(int index) { + if (databasesBuilder_ == null) { + return databases_.get(index); + } else { + return databasesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public java.util.List + getDatabasesOrBuilderList() { + if (databasesBuilder_ != null) { + return databasesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(databases_); + } + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public com.google.firestore.admin.v1.Database.Builder addDatabasesBuilder() { + return internalGetDatabasesFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Database.getDefaultInstance()); + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public com.google.firestore.admin.v1.Database.Builder addDatabasesBuilder(int index) { + return internalGetDatabasesFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Database.getDefaultInstance()); + } + + /** + * + * + *
+     * The databases in the project.
+     * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + public java.util.List + getDatabasesBuilderList() { + return internalGetDatabasesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + internalGetDatabasesFieldBuilder() { + if (databasesBuilder_ == null) { + databasesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder>( + databases_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + databases_ = null; + } + return databasesBuilder_; + } + + private com.google.protobuf.LazyStringArrayList unreachable_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureUnreachableIsMutable() { + if (!unreachable_.isModifiable()) { + unreachable_ = new com.google.protobuf.LazyStringArrayList(unreachable_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + public com.google.protobuf.ProtocolStringList getUnreachableList() { + unreachable_.makeImmutable(); + return unreachable_; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + public int getUnreachableCount() { + return unreachable_.size(); + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + public java.lang.String getUnreachable(int index) { + return unreachable_.get(index); + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + public com.google.protobuf.ByteString getUnreachableBytes(int index) { + return unreachable_.getByteString(index); + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param index The index to set the value at. + * @param value The unreachable to set. + * @return This builder for chaining. + */ + public Builder setUnreachable(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachable(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param values The unreachable to add. + * @return This builder for chaining. + */ + public Builder addAllUnreachable(java.lang.Iterable values) { + ensureUnreachableIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, unreachable_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @return This builder for chaining. + */ + public Builder clearUnreachable() { + unreachable_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * In the event that data about individual databases cannot be listed they
+     * will be recorded here.
+     *
+     * An example entry might be: projects/some_project/locations/some_location
+     * This can happen if the Cloud Region that the Database resides in is
+     * currently unavailable.  In this case we can't fetch all the details about
+     * the database. You may be able to get a more detailed error message
+     * (or possibly fetch the resource) by sending a 'Get' request for the
+     * resource or a 'List' request for the specific location.
+     * 
+ * + * repeated string unreachable = 3; + * + * @param value The bytes of the unreachable to add. + * @return This builder for chaining. + */ + public Builder addUnreachableBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureUnreachableIsMutable(); + unreachable_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListDatabasesResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListDatabasesResponse) + private static final com.google.firestore.admin.v1.ListDatabasesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListDatabasesResponse(); + } + + public static com.google.firestore.admin.v1.ListDatabasesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListDatabasesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListDatabasesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponseOrBuilder.java new file mode 100644 index 000000000000..48effad3d4ea --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListDatabasesResponseOrBuilder.java @@ -0,0 +1,170 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListDatabasesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListDatabasesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + java.util.List getDatabasesList(); + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + com.google.firestore.admin.v1.Database getDatabases(int index); + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + int getDatabasesCount(); + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + java.util.List + getDatabasesOrBuilderList(); + + /** + * + * + *
+   * The databases in the project.
+   * 
+ * + * repeated .google.firestore.admin.v1.Database databases = 1; + */ + com.google.firestore.admin.v1.DatabaseOrBuilder getDatabasesOrBuilder(int index); + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return A list containing the unreachable. + */ + java.util.List getUnreachableList(); + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @return The count of unreachable. + */ + int getUnreachableCount(); + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the element to return. + * @return The unreachable at the given index. + */ + java.lang.String getUnreachable(int index); + + /** + * + * + *
+   * In the event that data about individual databases cannot be listed they
+   * will be recorded here.
+   *
+   * An example entry might be: projects/some_project/locations/some_location
+   * This can happen if the Cloud Region that the Database resides in is
+   * currently unavailable.  In this case we can't fetch all the details about
+   * the database. You may be able to get a more detailed error message
+   * (or possibly fetch the resource) by sending a 'Get' request for the
+   * resource or a 'List' request for the specific location.
+   * 
+ * + * repeated string unreachable = 3; + * + * @param index The index of the value to return. + * @return The bytes of the unreachable at the given index. + */ + com.google.protobuf.ByteString getUnreachableBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequest.java new file mode 100644 index 000000000000..e518b681926e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequest.java @@ -0,0 +1,1150 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListFieldsRequest} + */ +@com.google.protobuf.Generated +public final class ListFieldsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListFieldsRequest) + ListFieldsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListFieldsRequest"); + } + + // Use ListFieldsRequest.newBuilder() to construct. + private ListFieldsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListFieldsRequest() { + parent_ = ""; + filter_ = ""; + pageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListFieldsRequest.class, + com.google.firestore.admin.v1.ListFieldsRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILTER_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object filter_ = ""; + + /** + * + * + *
+   * The filter to apply to list results. Currently,
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * only supports listing fields that have been explicitly overridden. To issue
+   * this query, call
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+   * `ttlConfig:*`.
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + @java.lang.Override + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } + } + + /** + * + * + *
+   * The filter to apply to list results. Currently,
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * only supports listing fields that have been explicitly overridden. To issue
+   * this query, call
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+   * `ttlConfig:*`.
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 3; + private int pageSize_ = 0; + + /** + * + * + *
+   * The number of results to return.
+   * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, filter_); + } + if (pageSize_ != 0) { + output.writeInt32(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, pageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, filter_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListFieldsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListFieldsRequest other = + (com.google.firestore.admin.v1.ListFieldsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getFilter().equals(other.getFilter())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListFieldsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListFieldsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListFieldsRequest) + com.google.firestore.admin.v1.ListFieldsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListFieldsRequest.class, + com.google.firestore.admin.v1.ListFieldsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListFieldsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + filter_ = ""; + pageSize_ = 0; + pageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListFieldsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsRequest build() { + com.google.firestore.admin.v1.ListFieldsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsRequest buildPartial() { + com.google.firestore.admin.v1.ListFieldsRequest result = + new com.google.firestore.admin.v1.ListFieldsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListFieldsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.filter_ = filter_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.pageToken_ = pageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListFieldsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListFieldsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListFieldsRequest other) { + if (other == com.google.firestore.admin.v1.ListFieldsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getFilter().isEmpty()) { + filter_ = other.filter_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000008; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + filter_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + pageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object filter_ = ""; + + /** + * + * + *
+     * The filter to apply to list results. Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ * + * string filter = 2; + * + * @return The filter. + */ + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The filter to apply to list results. Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The filter to apply to list results. Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ * + * string filter = 2; + * + * @param value The filter to set. + * @return This builder for chaining. + */ + public Builder setFilter(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply to list results. Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ * + * string filter = 2; + * + * @return This builder for chaining. + */ + public Builder clearFilter() { + filter_ = getDefaultInstance().getFilter(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply to list results. Currently,
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * only supports listing fields that have been explicitly overridden. To issue
+     * this query, call
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+     * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+     * `ttlConfig:*`.
+     * 
+ * + * string filter = 2; + * + * @param value The bytes for filter to set. + * @return This builder for chaining. + */ + public Builder setFilterBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private int pageSize_; + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000004); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListFieldsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListFieldsRequest) + private static final com.google.firestore.admin.v1.ListFieldsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListFieldsRequest(); + } + + public static com.google.firestore.admin.v1.ListFieldsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListFieldsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequestOrBuilder.java new file mode 100644 index 000000000000..b26a124c0355 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsRequestOrBuilder.java @@ -0,0 +1,141 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListFieldsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListFieldsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * The filter to apply to list results. Currently,
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * only supports listing fields that have been explicitly overridden. To issue
+   * this query, call
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+   * `ttlConfig:*`.
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + java.lang.String getFilter(); + + /** + * + * + *
+   * The filter to apply to list results. Currently,
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * only supports listing fields that have been explicitly overridden. To issue
+   * this query, call
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]
+   * with a filter that includes `indexConfig.usesAncestorConfig:false` or
+   * `ttlConfig:*`.
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + com.google.protobuf.ByteString getFilterBytes(); + + /** + * + * + *
+   * The number of results to return.
+   * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponse.java new file mode 100644 index 000000000000..58e1bbccb3a1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponse.java @@ -0,0 +1,1119 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListFieldsResponse} + */ +@com.google.protobuf.Generated +public final class ListFieldsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListFieldsResponse) + ListFieldsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListFieldsResponse"); + } + + // Use ListFieldsResponse.newBuilder() to construct. + private ListFieldsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListFieldsResponse() { + fields_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListFieldsResponse.class, + com.google.firestore.admin.v1.ListFieldsResponse.Builder.class); + } + + public static final int FIELDS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List fields_; + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + @java.lang.Override + public java.util.List getFieldsList() { + return fields_; + } + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + @java.lang.Override + public java.util.List + getFieldsOrBuilderList() { + return fields_; + } + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + @java.lang.Override + public int getFieldsCount() { + return fields_.size(); + } + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field getFields(int index) { + return fields_.get(index); + } + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOrBuilder getFieldsOrBuilder(int index) { + return fields_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < fields_.size(); i++) { + output.writeMessage(1, fields_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < fields_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, fields_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListFieldsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListFieldsResponse other = + (com.google.firestore.admin.v1.ListFieldsResponse) obj; + + if (!getFieldsList().equals(other.getFieldsList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getFieldsCount() > 0) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + getFieldsList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListFieldsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListFieldsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListFieldsResponse) + com.google.firestore.admin.v1.ListFieldsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListFieldsResponse.class, + com.google.firestore.admin.v1.ListFieldsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListFieldsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + } else { + fields_ = null; + fieldsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListFieldsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListFieldsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsResponse build() { + com.google.firestore.admin.v1.ListFieldsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsResponse buildPartial() { + com.google.firestore.admin.v1.ListFieldsResponse result = + new com.google.firestore.admin.v1.ListFieldsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListFieldsResponse result) { + if (fieldsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + fields_ = java.util.Collections.unmodifiableList(fields_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.fields_ = fields_; + } else { + result.fields_ = fieldsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListFieldsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListFieldsResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListFieldsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListFieldsResponse other) { + if (other == com.google.firestore.admin.v1.ListFieldsResponse.getDefaultInstance()) + return this; + if (fieldsBuilder_ == null) { + if (!other.fields_.isEmpty()) { + if (fields_.isEmpty()) { + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFieldsIsMutable(); + fields_.addAll(other.fields_); + } + onChanged(); + } + } else { + if (!other.fields_.isEmpty()) { + if (fieldsBuilder_.isEmpty()) { + fieldsBuilder_.dispose(); + fieldsBuilder_ = null; + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000001); + fieldsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFieldsFieldBuilder() + : null; + } else { + fieldsBuilder_.addAllMessages(other.fields_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Field m = + input.readMessage( + com.google.firestore.admin.v1.Field.parser(), extensionRegistry); + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(m); + } else { + fieldsBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List fields_ = + java.util.Collections.emptyList(); + + private void ensureFieldsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + fields_ = new java.util.ArrayList(fields_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder> + fieldsBuilder_; + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public java.util.List getFieldsList() { + if (fieldsBuilder_ == null) { + return java.util.Collections.unmodifiableList(fields_); + } else { + return fieldsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public int getFieldsCount() { + if (fieldsBuilder_ == null) { + return fields_.size(); + } else { + return fieldsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public com.google.firestore.admin.v1.Field getFields(int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder setFields(int index, com.google.firestore.admin.v1.Field value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.set(index, value); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder setFields( + int index, com.google.firestore.admin.v1.Field.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.set(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder addFields(com.google.firestore.admin.v1.Field value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(value); + onChanged(); + } else { + fieldsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder addFields(int index, com.google.firestore.admin.v1.Field value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(index, value); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder addFields(com.google.firestore.admin.v1.Field.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder addFields( + int index, com.google.firestore.admin.v1.Field.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder addAllFields( + java.lang.Iterable values) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, fields_); + onChanged(); + } else { + fieldsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder clearFields() { + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + fieldsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public Builder removeFields(int index) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.remove(index); + onChanged(); + } else { + fieldsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public com.google.firestore.admin.v1.Field.Builder getFieldsBuilder(int index) { + return internalGetFieldsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public com.google.firestore.admin.v1.FieldOrBuilder getFieldsOrBuilder(int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public java.util.List + getFieldsOrBuilderList() { + if (fieldsBuilder_ != null) { + return fieldsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(fields_); + } + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public com.google.firestore.admin.v1.Field.Builder addFieldsBuilder() { + return internalGetFieldsFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Field.getDefaultInstance()); + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public com.google.firestore.admin.v1.Field.Builder addFieldsBuilder(int index) { + return internalGetFieldsFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Field.getDefaultInstance()); + } + + /** + * + * + *
+     * The requested fields.
+     * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + public java.util.List getFieldsBuilderList() { + return internalGetFieldsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder> + internalGetFieldsFieldBuilder() { + if (fieldsBuilder_ == null) { + fieldsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder>( + fields_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + fields_ = null; + } + return fieldsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListFieldsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListFieldsResponse) + private static final com.google.firestore.admin.v1.ListFieldsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListFieldsResponse(); + } + + public static com.google.firestore.admin.v1.ListFieldsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListFieldsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListFieldsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponseOrBuilder.java new file mode 100644 index 000000000000..8fdcdfe68eaf --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListFieldsResponseOrBuilder.java @@ -0,0 +1,111 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListFieldsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListFieldsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + java.util.List getFieldsList(); + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + com.google.firestore.admin.v1.Field getFields(int index); + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + int getFieldsCount(); + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + java.util.List getFieldsOrBuilderList(); + + /** + * + * + *
+   * The requested fields.
+   * 
+ * + * repeated .google.firestore.admin.v1.Field fields = 1; + */ + com.google.firestore.admin.v1.FieldOrBuilder getFieldsOrBuilder(int index); + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequest.java new file mode 100644 index 000000000000..d37a9d48f65c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequest.java @@ -0,0 +1,1108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListIndexesRequest} + */ +@com.google.protobuf.Generated +public final class ListIndexesRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListIndexesRequest) + ListIndexesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListIndexesRequest"); + } + + // Use ListIndexesRequest.newBuilder() to construct. + private ListIndexesRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListIndexesRequest() { + parent_ = ""; + filter_ = ""; + pageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListIndexesRequest.class, + com.google.firestore.admin.v1.ListIndexesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILTER_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object filter_ = ""; + + /** + * + * + *
+   * The filter to apply to list results.
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + @java.lang.Override + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } + } + + /** + * + * + *
+   * The filter to apply to list results.
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 3; + private int pageSize_ = 0; + + /** + * + * + *
+   * The number of results to return.
+   * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, filter_); + } + if (pageSize_ != 0) { + output.writeInt32(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, pageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(filter_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, filter_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListIndexesRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListIndexesRequest other = + (com.google.firestore.admin.v1.ListIndexesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getFilter().equals(other.getFilter())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListIndexesRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListIndexesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListIndexesRequest) + com.google.firestore.admin.v1.ListIndexesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListIndexesRequest.class, + com.google.firestore.admin.v1.ListIndexesRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListIndexesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + filter_ = ""; + pageSize_ = 0; + pageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListIndexesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesRequest build() { + com.google.firestore.admin.v1.ListIndexesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesRequest buildPartial() { + com.google.firestore.admin.v1.ListIndexesRequest result = + new com.google.firestore.admin.v1.ListIndexesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListIndexesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.filter_ = filter_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.pageToken_ = pageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListIndexesRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListIndexesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListIndexesRequest other) { + if (other == com.google.firestore.admin.v1.ListIndexesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getFilter().isEmpty()) { + filter_ = other.filter_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000008; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + filter_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + pageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent name of the form
+     * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object filter_ = ""; + + /** + * + * + *
+     * The filter to apply to list results.
+     * 
+ * + * string filter = 2; + * + * @return The filter. + */ + public java.lang.String getFilter() { + java.lang.Object ref = filter_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + filter_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The filter to apply to list results.
+     * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + public com.google.protobuf.ByteString getFilterBytes() { + java.lang.Object ref = filter_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + filter_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The filter to apply to list results.
+     * 
+ * + * string filter = 2; + * + * @param value The filter to set. + * @return This builder for chaining. + */ + public Builder setFilter(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply to list results.
+     * 
+ * + * string filter = 2; + * + * @return This builder for chaining. + */ + public Builder clearFilter() { + filter_ = getDefaultInstance().getFilter(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply to list results.
+     * 
+ * + * string filter = 2; + * + * @param value The bytes for filter to set. + * @return This builder for chaining. + */ + public Builder setFilterBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + filter_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private int pageSize_; + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of results to return.
+     * 
+ * + * int32 page_size = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000004); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token, returned from a previous call to
+     * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+     * that may be used to get the next page of results.
+     * 
+ * + * string page_token = 4; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListIndexesRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListIndexesRequest) + private static final com.google.firestore.admin.v1.ListIndexesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListIndexesRequest(); + } + + public static com.google.firestore.admin.v1.ListIndexesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListIndexesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequestOrBuilder.java new file mode 100644 index 000000000000..ecf0016c9248 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesRequestOrBuilder.java @@ -0,0 +1,129 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListIndexesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListIndexesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent name of the form
+   * `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * The filter to apply to list results.
+   * 
+ * + * string filter = 2; + * + * @return The filter. + */ + java.lang.String getFilter(); + + /** + * + * + *
+   * The filter to apply to list results.
+   * 
+ * + * string filter = 2; + * + * @return The bytes for filter. + */ + com.google.protobuf.ByteString getFilterBytes(); + + /** + * + * + *
+   * The number of results to return.
+   * 
+ * + * int32 page_size = 3; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * A page token, returned from a previous call to
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes],
+   * that may be used to get the next page of results.
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponse.java new file mode 100644 index 000000000000..9805971cb3c3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponse.java @@ -0,0 +1,1119 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListIndexesResponse} + */ +@com.google.protobuf.Generated +public final class ListIndexesResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListIndexesResponse) + ListIndexesResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListIndexesResponse"); + } + + // Use ListIndexesResponse.newBuilder() to construct. + private ListIndexesResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListIndexesResponse() { + indexes_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListIndexesResponse.class, + com.google.firestore.admin.v1.ListIndexesResponse.Builder.class); + } + + public static final int INDEXES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List indexes_; + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List getIndexesList() { + return indexes_; + } + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List + getIndexesOrBuilderList() { + return indexes_; + } + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public int getIndexesCount() { + return indexes_.size(); + } + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.Index getIndexes(int index) { + return indexes_.get(index); + } + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index) { + return indexes_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < indexes_.size(); i++) { + output.writeMessage(1, indexes_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < indexes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, indexes_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListIndexesResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListIndexesResponse other = + (com.google.firestore.admin.v1.ListIndexesResponse) obj; + + if (!getIndexesList().equals(other.getIndexesList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIndexesCount() > 0) { + hash = (37 * hash) + INDEXES_FIELD_NUMBER; + hash = (53 * hash) + getIndexesList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListIndexesResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListIndexesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListIndexesResponse) + com.google.firestore.admin.v1.ListIndexesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListIndexesResponse.class, + com.google.firestore.admin.v1.ListIndexesResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListIndexesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (indexesBuilder_ == null) { + indexes_ = java.util.Collections.emptyList(); + } else { + indexes_ = null; + indexesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListIndexesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesResponse build() { + com.google.firestore.admin.v1.ListIndexesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesResponse buildPartial() { + com.google.firestore.admin.v1.ListIndexesResponse result = + new com.google.firestore.admin.v1.ListIndexesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListIndexesResponse result) { + if (indexesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + indexes_ = java.util.Collections.unmodifiableList(indexes_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.indexes_ = indexes_; + } else { + result.indexes_ = indexesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListIndexesResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListIndexesResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListIndexesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListIndexesResponse other) { + if (other == com.google.firestore.admin.v1.ListIndexesResponse.getDefaultInstance()) + return this; + if (indexesBuilder_ == null) { + if (!other.indexes_.isEmpty()) { + if (indexes_.isEmpty()) { + indexes_ = other.indexes_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIndexesIsMutable(); + indexes_.addAll(other.indexes_); + } + onChanged(); + } + } else { + if (!other.indexes_.isEmpty()) { + if (indexesBuilder_.isEmpty()) { + indexesBuilder_.dispose(); + indexesBuilder_ = null; + indexes_ = other.indexes_; + bitField0_ = (bitField0_ & ~0x00000001); + indexesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetIndexesFieldBuilder() + : null; + } else { + indexesBuilder_.addAllMessages(other.indexes_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.Index m = + input.readMessage( + com.google.firestore.admin.v1.Index.parser(), extensionRegistry); + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(m); + } else { + indexesBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List indexes_ = + java.util.Collections.emptyList(); + + private void ensureIndexesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + indexes_ = new java.util.ArrayList(indexes_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + indexesBuilder_; + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List getIndexesList() { + if (indexesBuilder_ == null) { + return java.util.Collections.unmodifiableList(indexes_); + } else { + return indexesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public int getIndexesCount() { + if (indexesBuilder_ == null) { + return indexes_.size(); + } else { + return indexesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index getIndexes(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes(int index, com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.set(index, value); + onChanged(); + } else { + indexesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes( + int index, com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.set(index, builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.add(value); + onChanged(); + } else { + indexesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(int index, com.google.firestore.admin.v1.Index value) { + if (indexesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesIsMutable(); + indexes_.add(index, value); + onChanged(); + } else { + indexesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes( + int index, com.google.firestore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(index, builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder addAllIndexes( + java.lang.Iterable values) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, indexes_); + onChanged(); + } else { + indexesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder clearIndexes() { + if (indexesBuilder_ == null) { + indexes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + indexesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public Builder removeIndexes(int index) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.remove(index); + onChanged(); + } else { + indexesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder getIndexesBuilder(int index) { + return internalGetIndexesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List + getIndexesOrBuilderList() { + if (indexesBuilder_ != null) { + return indexesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(indexes_); + } + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder addIndexesBuilder() { + return internalGetIndexesFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public com.google.firestore.admin.v1.Index.Builder addIndexesBuilder(int index) { + return internalGetIndexesFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+     * The requested indexes.
+     * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + public java.util.List getIndexesBuilderList() { + return internalGetIndexesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder> + internalGetIndexesFieldBuilder() { + if (indexesBuilder_ == null) { + indexesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.Index, + com.google.firestore.admin.v1.Index.Builder, + com.google.firestore.admin.v1.IndexOrBuilder>( + indexes_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexes_ = null; + } + return indexesBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request another page of results. If blank,
+     * this is the last page.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListIndexesResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListIndexesResponse) + private static final com.google.firestore.admin.v1.ListIndexesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListIndexesResponse(); + } + + public static com.google.firestore.admin.v1.ListIndexesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListIndexesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListIndexesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponseOrBuilder.java new file mode 100644 index 000000000000..c16e9413abce --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListIndexesResponseOrBuilder.java @@ -0,0 +1,111 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListIndexesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListIndexesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + java.util.List getIndexesList(); + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + com.google.firestore.admin.v1.Index getIndexes(int index); + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + int getIndexesCount(); + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + java.util.List getIndexesOrBuilderList(); + + /** + * + * + *
+   * The requested indexes.
+   * 
+ * + * repeated .google.firestore.admin.v1.Index indexes = 1; + */ + com.google.firestore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index); + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * A page token that may be used to request another page of results. If blank,
+   * this is the last page.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequest.java new file mode 100644 index 000000000000..f89eb6ce0b1e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequest.java @@ -0,0 +1,619 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListUserCredsRequest} + */ +@com.google.protobuf.Generated +public final class ListUserCredsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListUserCredsRequest) + ListUserCredsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListUserCredsRequest"); + } + + // Use ListUserCredsRequest.newBuilder() to construct. + private ListUserCredsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListUserCredsRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListUserCredsRequest.class, + com.google.firestore.admin.v1.ListUserCredsRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. A parent database name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A parent database name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListUserCredsRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListUserCredsRequest other = + (com.google.firestore.admin.v1.ListUserCredsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListUserCredsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListUserCredsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListUserCredsRequest) + com.google.firestore.admin.v1.ListUserCredsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListUserCredsRequest.class, + com.google.firestore.admin.v1.ListUserCredsRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListUserCredsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListUserCredsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsRequest build() { + com.google.firestore.admin.v1.ListUserCredsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsRequest buildPartial() { + com.google.firestore.admin.v1.ListUserCredsRequest result = + new com.google.firestore.admin.v1.ListUserCredsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ListUserCredsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListUserCredsRequest) { + return mergeFrom((com.google.firestore.admin.v1.ListUserCredsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListUserCredsRequest other) { + if (other == com.google.firestore.admin.v1.ListUserCredsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. A parent database name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A parent database name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A parent database name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent database name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A parent database name of the form
+     * `projects/{project_id}/databases/{database_id}`
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListUserCredsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListUserCredsRequest) + private static final com.google.firestore.admin.v1.ListUserCredsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListUserCredsRequest(); + } + + public static com.google.firestore.admin.v1.ListUserCredsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListUserCredsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequestOrBuilder.java new file mode 100644 index 000000000000..04602e9ba056 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListUserCredsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListUserCredsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A parent database name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. A parent database name of the form
+   * `projects/{project_id}/databases/{database_id}`
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponse.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponse.java new file mode 100644 index 000000000000..d838e6933d54 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponse.java @@ -0,0 +1,924 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListUserCredsResponse} + */ +@com.google.protobuf.Generated +public final class ListUserCredsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ListUserCredsResponse) + ListUserCredsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListUserCredsResponse"); + } + + // Use ListUserCredsResponse.newBuilder() to construct. + private ListUserCredsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListUserCredsResponse() { + userCreds_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListUserCredsResponse.class, + com.google.firestore.admin.v1.ListUserCredsResponse.Builder.class); + } + + public static final int USER_CREDS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List userCreds_; + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + @java.lang.Override + public java.util.List getUserCredsList() { + return userCreds_; + } + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + @java.lang.Override + public java.util.List + getUserCredsOrBuilderList() { + return userCreds_; + } + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + @java.lang.Override + public int getUserCredsCount() { + return userCreds_.size(); + } + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds getUserCreds(int index) { + return userCreds_.get(index); + } + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder(int index) { + return userCreds_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < userCreds_.size(); i++) { + output.writeMessage(1, userCreds_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < userCreds_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, userCreds_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ListUserCredsResponse)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ListUserCredsResponse other = + (com.google.firestore.admin.v1.ListUserCredsResponse) obj; + + if (!getUserCredsList().equals(other.getUserCredsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getUserCredsCount() > 0) { + hash = (37 * hash) + USER_CREDS_FIELD_NUMBER; + hash = (53 * hash) + getUserCredsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.ListUserCredsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ListUserCredsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ListUserCredsResponse) + com.google.firestore.admin.v1.ListUserCredsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ListUserCredsResponse.class, + com.google.firestore.admin.v1.ListUserCredsResponse.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ListUserCredsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (userCredsBuilder_ == null) { + userCreds_ = java.util.Collections.emptyList(); + } else { + userCreds_ = null; + userCredsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ListUserCredsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsResponse getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ListUserCredsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsResponse build() { + com.google.firestore.admin.v1.ListUserCredsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsResponse buildPartial() { + com.google.firestore.admin.v1.ListUserCredsResponse result = + new com.google.firestore.admin.v1.ListUserCredsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.admin.v1.ListUserCredsResponse result) { + if (userCredsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + userCreds_ = java.util.Collections.unmodifiableList(userCreds_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.userCreds_ = userCreds_; + } else { + result.userCreds_ = userCredsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.admin.v1.ListUserCredsResponse result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ListUserCredsResponse) { + return mergeFrom((com.google.firestore.admin.v1.ListUserCredsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ListUserCredsResponse other) { + if (other == com.google.firestore.admin.v1.ListUserCredsResponse.getDefaultInstance()) + return this; + if (userCredsBuilder_ == null) { + if (!other.userCreds_.isEmpty()) { + if (userCreds_.isEmpty()) { + userCreds_ = other.userCreds_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureUserCredsIsMutable(); + userCreds_.addAll(other.userCreds_); + } + onChanged(); + } + } else { + if (!other.userCreds_.isEmpty()) { + if (userCredsBuilder_.isEmpty()) { + userCredsBuilder_.dispose(); + userCredsBuilder_ = null; + userCreds_ = other.userCreds_; + bitField0_ = (bitField0_ & ~0x00000001); + userCredsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetUserCredsFieldBuilder() + : null; + } else { + userCredsBuilder_.addAllMessages(other.userCreds_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.admin.v1.UserCreds m = + input.readMessage( + com.google.firestore.admin.v1.UserCreds.parser(), extensionRegistry); + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + userCreds_.add(m); + } else { + userCredsBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List userCreds_ = + java.util.Collections.emptyList(); + + private void ensureUserCredsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + userCreds_ = new java.util.ArrayList(userCreds_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder> + userCredsBuilder_; + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public java.util.List getUserCredsList() { + if (userCredsBuilder_ == null) { + return java.util.Collections.unmodifiableList(userCreds_); + } else { + return userCredsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public int getUserCredsCount() { + if (userCredsBuilder_ == null) { + return userCreds_.size(); + } else { + return userCredsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public com.google.firestore.admin.v1.UserCreds getUserCreds(int index) { + if (userCredsBuilder_ == null) { + return userCreds_.get(index); + } else { + return userCredsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder setUserCreds(int index, com.google.firestore.admin.v1.UserCreds value) { + if (userCredsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUserCredsIsMutable(); + userCreds_.set(index, value); + onChanged(); + } else { + userCredsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder setUserCreds( + int index, com.google.firestore.admin.v1.UserCreds.Builder builderForValue) { + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + userCreds_.set(index, builderForValue.build()); + onChanged(); + } else { + userCredsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder addUserCreds(com.google.firestore.admin.v1.UserCreds value) { + if (userCredsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUserCredsIsMutable(); + userCreds_.add(value); + onChanged(); + } else { + userCredsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder addUserCreds(int index, com.google.firestore.admin.v1.UserCreds value) { + if (userCredsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUserCredsIsMutable(); + userCreds_.add(index, value); + onChanged(); + } else { + userCredsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder addUserCreds(com.google.firestore.admin.v1.UserCreds.Builder builderForValue) { + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + userCreds_.add(builderForValue.build()); + onChanged(); + } else { + userCredsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder addUserCreds( + int index, com.google.firestore.admin.v1.UserCreds.Builder builderForValue) { + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + userCreds_.add(index, builderForValue.build()); + onChanged(); + } else { + userCredsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder addAllUserCreds( + java.lang.Iterable values) { + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, userCreds_); + onChanged(); + } else { + userCredsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder clearUserCreds() { + if (userCredsBuilder_ == null) { + userCreds_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + userCredsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public Builder removeUserCreds(int index) { + if (userCredsBuilder_ == null) { + ensureUserCredsIsMutable(); + userCreds_.remove(index); + onChanged(); + } else { + userCredsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public com.google.firestore.admin.v1.UserCreds.Builder getUserCredsBuilder(int index) { + return internalGetUserCredsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder(int index) { + if (userCredsBuilder_ == null) { + return userCreds_.get(index); + } else { + return userCredsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public java.util.List + getUserCredsOrBuilderList() { + if (userCredsBuilder_ != null) { + return userCredsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(userCreds_); + } + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public com.google.firestore.admin.v1.UserCreds.Builder addUserCredsBuilder() { + return internalGetUserCredsFieldBuilder() + .addBuilder(com.google.firestore.admin.v1.UserCreds.getDefaultInstance()); + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public com.google.firestore.admin.v1.UserCreds.Builder addUserCredsBuilder(int index) { + return internalGetUserCredsFieldBuilder() + .addBuilder(index, com.google.firestore.admin.v1.UserCreds.getDefaultInstance()); + } + + /** + * + * + *
+     * The user creds for the database.
+     * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + public java.util.List + getUserCredsBuilderList() { + return internalGetUserCredsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder> + internalGetUserCredsFieldBuilder() { + if (userCredsBuilder_ == null) { + userCredsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.admin.v1.UserCreds, + com.google.firestore.admin.v1.UserCreds.Builder, + com.google.firestore.admin.v1.UserCredsOrBuilder>( + userCreds_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + userCreds_ = null; + } + return userCredsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ListUserCredsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ListUserCredsResponse) + private static final com.google.firestore.admin.v1.ListUserCredsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ListUserCredsResponse(); + } + + public static com.google.firestore.admin.v1.ListUserCredsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListUserCredsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ListUserCredsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponseOrBuilder.java new file mode 100644 index 000000000000..6af0ee63ead5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ListUserCredsResponseOrBuilder.java @@ -0,0 +1,84 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ListUserCredsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ListUserCredsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + java.util.List getUserCredsList(); + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + com.google.firestore.admin.v1.UserCreds getUserCreds(int index); + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + int getUserCredsCount(); + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + java.util.List + getUserCredsOrBuilderList(); + + /** + * + * + *
+   * The user creds for the database.
+   * 
+ * + * repeated .google.firestore.admin.v1.UserCreds user_creds = 1; + */ + com.google.firestore.admin.v1.UserCredsOrBuilder getUserCredsOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadata.java new file mode 100644 index 000000000000..fa1f6e02177c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadata.java @@ -0,0 +1,397 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/location.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The metadata message for
+ * [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.LocationMetadata} + */ +@com.google.protobuf.Generated +public final class LocationMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.LocationMetadata) + LocationMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "LocationMetadata"); + } + + // Use LocationMetadata.newBuilder() to construct. + private LocationMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private LocationMetadata() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.LocationProto + .internal_static_google_firestore_admin_v1_LocationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.LocationProto + .internal_static_google_firestore_admin_v1_LocationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.LocationMetadata.class, + com.google.firestore.admin.v1.LocationMetadata.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.LocationMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.LocationMetadata other = + (com.google.firestore.admin.v1.LocationMetadata) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.LocationMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.LocationMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The metadata message for
+   * [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.LocationMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.LocationMetadata) + com.google.firestore.admin.v1.LocationMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.LocationProto + .internal_static_google_firestore_admin_v1_LocationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.LocationProto + .internal_static_google_firestore_admin_v1_LocationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.LocationMetadata.class, + com.google.firestore.admin.v1.LocationMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.LocationMetadata.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.LocationProto + .internal_static_google_firestore_admin_v1_LocationMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.LocationMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.LocationMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.LocationMetadata build() { + com.google.firestore.admin.v1.LocationMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.LocationMetadata buildPartial() { + com.google.firestore.admin.v1.LocationMetadata result = + new com.google.firestore.admin.v1.LocationMetadata(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.LocationMetadata) { + return mergeFrom((com.google.firestore.admin.v1.LocationMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.LocationMetadata other) { + if (other == com.google.firestore.admin.v1.LocationMetadata.getDefaultInstance()) return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.LocationMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.LocationMetadata) + private static final com.google.firestore.admin.v1.LocationMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.LocationMetadata(); + } + + public static com.google.firestore.admin.v1.LocationMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LocationMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.LocationMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadataOrBuilder.java new file mode 100644 index 000000000000..0c6fce7126b7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationMetadataOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/location.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface LocationMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.LocationMetadata) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java new file mode 100644 index 000000000000..6b0e73acfbf1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationName.java @@ -0,0 +1,192 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class LocationName implements ResourceName { + private static final PathTemplate PROJECT_LOCATION = + PathTemplate.createWithoutUrlEncoding("projects/{project}/locations/{location}"); + private volatile Map fieldValuesMap; + private final String project; + private final String location; + + @Deprecated + protected LocationName() { + project = null; + location = null; + } + + private LocationName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + location = Preconditions.checkNotNull(builder.getLocation()); + } + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static LocationName of(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build(); + } + + public static String format(String project, String location) { + return newBuilder().setProject(project).setLocation(location).build().toString(); + } + + public static LocationName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_LOCATION.validatedMatch( + formattedString, "LocationName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("location")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (LocationName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_LOCATION.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (location != null) { + fieldMapBuilder.put("location", location); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_LOCATION.instantiate("project", project, "location", location); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + LocationName that = ((LocationName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.location, that.location); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(location); + return h; + } + + /** Builder for projects/{project}/locations/{location}. */ + public static class Builder { + private String project; + private String location; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getLocation() { + return location; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setLocation(String location) { + this.location = location; + return this; + } + + private Builder(LocationName locationName) { + this.project = locationName.project; + this.location = locationName.location; + } + + public LocationName build() { + return new LocationName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java new file mode 100644 index 000000000000..e688826361b3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/LocationProto.java @@ -0,0 +1,78 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/location.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class LocationProto extends com.google.protobuf.GeneratedFile { + private LocationProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "LocationProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_LocationMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_LocationMetadata_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n(google/firestore/admin/v1/location.pro" + + "to\022\031google.firestore.admin.v1\"\022\n\020Locatio" + + "nMetadataB\334\001\n\035com.google.firestore.admin" + + ".v1B\rLocationProtoP\001Z9cloud.google.com/g" + + "o/firestore/apiv1/admin/adminpb;adminpb\242" + + "\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin.V1" + + "\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Goo" + + "gle::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_firestore_admin_v1_LocationMetadata_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_LocationMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_LocationMetadata_descriptor, + new java.lang.String[] {}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java new file mode 100644 index 000000000000..99fd03f313cd --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationProto.java @@ -0,0 +1,352 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class OperationProto extends com.google.protobuf.GeneratedFile { + private OperationProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "OperationProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_IndexOperationMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_FieldOperationMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_ExportDocumentsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_Progress_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_Progress_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + ")google/firestore/admin/v1/operation.pr" + + "oto\022\031google.firestore.admin.v1\032\031google/a" + + "pi/resource.proto\032%google/firestore/admin/v1/index.proto\032(google/firestore/admin" + + "/v1/snapshot.proto\032\037google/protobuf/timestamp.proto\"\275\002\n" + + "\026IndexOperationMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022\r\n" + + "\005index\030\003 \001(\t\0228\n" + + "\005state\030\004 \001(\0162).google.firestore.admin.v1.OperationState\022?\n" + + "\022progress_documents\030\005 \001(\0132#.google.firestore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\006 \001(\0132#.google.firestore.admin.v1.Progress\"\231\007\n" + + "\026FieldOperationMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022\r\n" + + "\005field\030\003 \001(\t\022_\n" + + "\023index_config_deltas\030\004 \003(\0132B.google.firestore.admi" + + "n.v1.FieldOperationMetadata.IndexConfigDelta\0228\n" + + "\005state\030\005 \001(\0162).google.firestore.admin.v1.OperationState\022?\n" + + "\022progress_documents\030\006 \001(\0132#.google.firestore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\007 \001(\0132#.google.firestore.admin.v1.Progress\022Z\n" + + "\020ttl_config_delta\030\010 \001(\0132@.google.firestore.admin." + + "v1.FieldOperationMetadata.TtlConfigDelta\032\347\001\n" + + "\020IndexConfigDelta\022b\n" + + "\013change_type\030\001 \001(\0162M.google.firestore.admin.v1.FieldOper" + + "ationMetadata.IndexConfigDelta.ChangeType\022/\n" + + "\005index\030\002 \001(\0132 .google.firestore.admin.v1.Index\">\n\n" + + "ChangeType\022\033\n" + + "\027CHANGE_TYPE_UNSPECIFIED\020\000\022\007\n" + + "\003ADD\020\001\022\n\n" + + "\006REMOVE\020\002\032\262\001\n" + + "\016TtlConfigDelta\022`\n" + + "\013change_type\030\001 \001(\0162K.goo" + + "gle.firestore.admin.v1.FieldOperationMetadata.TtlConfigDelta.ChangeType\">\n\n" + + "ChangeType\022\033\n" + + "\027CHANGE_TYPE_UNSPECIFIED\020\000\022\007\n" + + "\003ADD\020\001\022\n\n" + + "\006REMOVE\020\002\"\266\003\n" + + "\027ExportDocumentsMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n" + + "\017operation_state\030\003 \001" + + "(\0162).google.firestore.admin.v1.OperationState\022?\n" + + "\022progress_documents\030\004 \001(\0132#.google.firestore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\005 \001(\0132#.google.firestore.admin.v1.Progress\022\026\n" + + "\016collection_ids\030\006 \003(\t\022\031\n" + + "\021output_uri_prefix\030\007 \001(\t\022\025\n\r" + + "namespace_ids\030\010 \003(\t\0221\n\r" + + "snapshot_time\030\t \001(\0132\032.google.protobuf.Timestamp\"\202\003\n" + + "\027ImportDocumentsMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n" + + "\017operation_state\030\003 " + + "\001(\0162).google.firestore.admin.v1.OperationState\022?\n" + + "\022progress_documents\030\004 \001(\0132#.google.firestore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\005 \001(\0132#.google.firestore.admin.v1.Progress\022\026\n" + + "\016collection_ids\030\006 \003(\t\022\030\n" + + "\020input_uri_prefix\030\007 \001(\t\022\025\n\r" + + "namespace_ids\030\010 \003(\t\"\237\003\n" + + "\033BulkDeleteDocumentsMetadata\022.\n" + + "\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n" + + "\017operation_state\030\003 \001(\0162).g" + + "oogle.firestore.admin.v1.OperationState\022?\n" + + "\022progress_documents\030\004 \001(\0132#.google.firestore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\005 \001(\0132#.google.firestore.admin.v1.Progress\022\026\n" + + "\016collection_ids\030\006 \003(\t\022\025\n\r" + + "namespace_ids\030\007 \003(\t\0221\n\r" + + "snapshot_time\030\010 \001(\0132\032.google.protobuf.Timestamp\"4\n" + + "\027ExportDocumentsResponse\022\031\n" + + "\021output_uri_prefix\030\001 \001(\t\"\355\002\n" + + "\027RestoreDatabaseMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n" + + "\017operation_state\030\003" + + " \001(\0162).google.firestore.admin.v1.OperationState\0228\n" + + "\010database\030\004 \001(\tB&\372A#\n" + + "!firestore.googleapis.com/Database\0224\n" + + "\006backup\030\005 \001(\tB$\372A!\n" + + "\037firestore.googleapis.com/Backup\022@\n" + + "\023progress_percentage\030\010" + + " \001(\0132#.google.firestore.admin.v1.Progress\"\365\002\n" + + "\025CloneDatabaseMetadata\022.\n\n" + + "start_time\030\001 \001(\0132\032.google.protobuf.Timestamp\022,\n" + + "\010end_time\030\002 \001(\0132\032.google.protobuf.Timestamp\022B\n" + + "\017operation_state\030\003" + + " \001(\0162).google.firestore.admin.v1.OperationState\0228\n" + + "\010database\030\004 \001(\tB&\372A#\n" + + "!firestore.googleapis.com/Database\022>\n\r" + + "pitr_snapshot\030\007 \001(\0132\'.google.firestore.admin.v1.PitrSnapshot\022@\n" + + "\023progress_percentage\030\006 \001(\0132#.google.firestore.admin.v1.Progress\":\n" + + "\010Progress\022\026\n" + + "\016estimated_work\030\001 \001(\003\022\026\n" + + "\016completed_work\030\002 \001(\003*\236\001\n" + + "\016OperationState\022\037\n" + + "\033OPERATION_STATE_UNSPECIFIED\020\000\022\020\n" + + "\014INITIALIZING\020\001\022\016\n\n" + + "PROCESSING\020\002\022\016\n\n" + + "CANCELLING\020\003\022\016\n\n" + + "FINALIZING\020\004\022\016\n\n" + + "SUCCESSFUL\020\005\022\n\n" + + "\006FAILED\020\006\022\r\n" + + "\tCANCELLED\020\007B\335\001\n" + + "\035com.google.firestore.admin.v1B\016OperationProtoP\001Z9cloud.google.com/go/fire" + + "store/apiv1/admin/adminpb;adminpb\242\002\004GCFS" + + "\252\002\037Google.Cloud.Firestore.Admin.V1\312\002\037Goo" + + "gle\\Cloud\\Firestore\\Admin\\V1\352\002#Google::C" + + "loud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.ResourceProto.getDescriptor(), + com.google.firestore.admin.v1.IndexProto.getDescriptor(), + com.google.firestore.admin.v1.PitrSnapshotProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_IndexOperationMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_IndexOperationMetadata_descriptor, + new java.lang.String[] { + "StartTime", "EndTime", "Index", "State", "ProgressDocuments", "ProgressBytes", + }); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor, + new java.lang.String[] { + "StartTime", + "EndTime", + "Field", + "IndexConfigDeltas", + "State", + "ProgressDocuments", + "ProgressBytes", + "TtlConfigDelta", + }); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor = + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor.getNestedType( + 0); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_FieldOperationMetadata_IndexConfigDelta_descriptor, + new java.lang.String[] { + "ChangeType", "Index", + }); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor = + internal_static_google_firestore_admin_v1_FieldOperationMetadata_descriptor.getNestedType( + 1); + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_FieldOperationMetadata_TtlConfigDelta_descriptor, + new java.lang.String[] { + "ChangeType", + }); + internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor = + getDescriptor().getMessageType(2); + internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ExportDocumentsMetadata_descriptor, + new java.lang.String[] { + "StartTime", + "EndTime", + "OperationState", + "ProgressDocuments", + "ProgressBytes", + "CollectionIds", + "OutputUriPrefix", + "NamespaceIds", + "SnapshotTime", + }); + internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor = + getDescriptor().getMessageType(3); + internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ImportDocumentsMetadata_descriptor, + new java.lang.String[] { + "StartTime", + "EndTime", + "OperationState", + "ProgressDocuments", + "ProgressBytes", + "CollectionIds", + "InputUriPrefix", + "NamespaceIds", + }); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor = + getDescriptor().getMessageType(4); + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_BulkDeleteDocumentsMetadata_descriptor, + new java.lang.String[] { + "StartTime", + "EndTime", + "OperationState", + "ProgressDocuments", + "ProgressBytes", + "CollectionIds", + "NamespaceIds", + "SnapshotTime", + }); + internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor = + getDescriptor().getMessageType(5); + internal_static_google_firestore_admin_v1_ExportDocumentsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_ExportDocumentsResponse_descriptor, + new java.lang.String[] { + "OutputUriPrefix", + }); + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor = + getDescriptor().getMessageType(6); + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor, + new java.lang.String[] { + "StartTime", "EndTime", "OperationState", "Database", "Backup", "ProgressPercentage", + }); + internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor = + getDescriptor().getMessageType(7); + internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_CloneDatabaseMetadata_descriptor, + new java.lang.String[] { + "StartTime", + "EndTime", + "OperationState", + "Database", + "PitrSnapshot", + "ProgressPercentage", + }); + internal_static_google_firestore_admin_v1_Progress_descriptor = + getDescriptor().getMessageType(8); + internal_static_google_firestore_admin_v1_Progress_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_Progress_descriptor, + new java.lang.String[] { + "EstimatedWork", "CompletedWork", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.ResourceProto.getDescriptor(); + com.google.firestore.admin.v1.IndexProto.getDescriptor(); + com.google.firestore.admin.v1.PitrSnapshotProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationState.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationState.java new file mode 100644 index 000000000000..4a10404b1330 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/OperationState.java @@ -0,0 +1,310 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Describes the state of the operation.
+ * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.OperationState} + */ +@com.google.protobuf.Generated +public enum OperationState implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * OPERATION_STATE_UNSPECIFIED = 0; + */ + OPERATION_STATE_UNSPECIFIED(0), + /** + * + * + *
+   * Request is being prepared for processing.
+   * 
+ * + * INITIALIZING = 1; + */ + INITIALIZING(1), + /** + * + * + *
+   * Request is actively being processed.
+   * 
+ * + * PROCESSING = 2; + */ + PROCESSING(2), + /** + * + * + *
+   * Request is in the process of being cancelled after user called
+   * google.longrunning.Operations.CancelOperation on the operation.
+   * 
+ * + * CANCELLING = 3; + */ + CANCELLING(3), + /** + * + * + *
+   * Request has been processed and is in its finalization stage.
+   * 
+ * + * FINALIZING = 4; + */ + FINALIZING(4), + /** + * + * + *
+   * Request has completed successfully.
+   * 
+ * + * SUCCESSFUL = 5; + */ + SUCCESSFUL(5), + /** + * + * + *
+   * Request has finished being processed, but encountered an error.
+   * 
+ * + * FAILED = 6; + */ + FAILED(6), + /** + * + * + *
+   * Request has finished being cancelled after user called
+   * google.longrunning.Operations.CancelOperation.
+   * 
+ * + * CANCELLED = 7; + */ + CANCELLED(7), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "OperationState"); + } + + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * OPERATION_STATE_UNSPECIFIED = 0; + */ + public static final int OPERATION_STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+   * Request is being prepared for processing.
+   * 
+ * + * INITIALIZING = 1; + */ + public static final int INITIALIZING_VALUE = 1; + + /** + * + * + *
+   * Request is actively being processed.
+   * 
+ * + * PROCESSING = 2; + */ + public static final int PROCESSING_VALUE = 2; + + /** + * + * + *
+   * Request is in the process of being cancelled after user called
+   * google.longrunning.Operations.CancelOperation on the operation.
+   * 
+ * + * CANCELLING = 3; + */ + public static final int CANCELLING_VALUE = 3; + + /** + * + * + *
+   * Request has been processed and is in its finalization stage.
+   * 
+ * + * FINALIZING = 4; + */ + public static final int FINALIZING_VALUE = 4; + + /** + * + * + *
+   * Request has completed successfully.
+   * 
+ * + * SUCCESSFUL = 5; + */ + public static final int SUCCESSFUL_VALUE = 5; + + /** + * + * + *
+   * Request has finished being processed, but encountered an error.
+   * 
+ * + * FAILED = 6; + */ + public static final int FAILED_VALUE = 6; + + /** + * + * + *
+   * Request has finished being cancelled after user called
+   * google.longrunning.Operations.CancelOperation.
+   * 
+ * + * CANCELLED = 7; + */ + public static final int CANCELLED_VALUE = 7; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static OperationState valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static OperationState forNumber(int value) { + switch (value) { + case 0: + return OPERATION_STATE_UNSPECIFIED; + case 1: + return INITIALIZING; + case 2: + return PROCESSING; + case 3: + return CANCELLING; + case 4: + return FINALIZING; + case 5: + return SUCCESSFUL; + case 6: + return FAILED; + case 7: + return CANCELLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public OperationState findValueByNumber(int number) { + return OperationState.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto.getDescriptor().getEnumTypes().get(0); + } + + private static final OperationState[] VALUES = values(); + + public static OperationState valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private OperationState(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.OperationState) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ParentName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ParentName.java new file mode 100644 index 000000000000..5ddf42950787 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ParentName.java @@ -0,0 +1,215 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") +public class ParentName implements ResourceName { + + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/collectionGroups/{collection_id}"); + + private volatile Map fieldValuesMap; + + private final String project; + private final String database; + private final String collectionId; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getCollectionId() { + return collectionId; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private ParentName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + collectionId = Preconditions.checkNotNull(builder.getCollectionId()); + } + + public static ParentName of(String project, String database, String collectionId) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollectionId(collectionId) + .build(); + } + + public static String format(String project, String database, String collectionId) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setCollectionId(collectionId) + .build() + .toString(); + } + + public static ParentName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, "ParentName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("collection_id")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList(values.size()); + for (ParentName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + 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("collectionId", collectionId); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate( + "project", project, "database", database, "collection_id", collectionId); + } + + /** Builder for ParentName. */ + public static class Builder { + + private String project; + private String database; + private String collectionId; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getCollectionId() { + return collectionId; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setCollectionId(String collectionId) { + this.collectionId = collectionId; + return this; + } + + private Builder() {} + + private Builder(ParentName parentName) { + project = parentName.project; + database = parentName.database; + collectionId = parentName.collectionId; + } + + public ParentName build() { + return new ParentName(this); + } + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof ParentName) { + ParentName that = (ParentName) o; + return (this.project.equals(that.project)) + && (this.database.equals(that.database)) + && (this.collectionId.equals(that.collectionId)); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= project.hashCode(); + h *= 1000003; + h ^= database.hashCode(); + h *= 1000003; + h ^= collectionId.hashCode(); + return h; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshot.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshot.java new file mode 100644 index 000000000000..dd9cc0ab5140 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshot.java @@ -0,0 +1,1029 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/snapshot.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A consistent snapshot of a database at a specific point in time.
+ * A PITR (Point-in-time recovery) snapshot with previous versions of a
+ * database's data is available for every minute up to the associated database's
+ * data retention period. If the PITR feature is enabled, the retention period
+ * is 7 days; otherwise, it is one hour.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.PitrSnapshot} + */ +@com.google.protobuf.Generated +public final class PitrSnapshot extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.PitrSnapshot) + PitrSnapshotOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PitrSnapshot"); + } + + // Use PitrSnapshot.newBuilder() to construct. + private PitrSnapshot(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private PitrSnapshot() { + database_ = ""; + databaseUid_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.PitrSnapshotProto + .internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.PitrSnapshotProto + .internal_static_google_firestore_admin_v1_PitrSnapshot_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.PitrSnapshot.class, + com.google.firestore.admin.v1.PitrSnapshot.Builder.class); + } + + private int bitField0_; + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The name of the database that this was a snapshot of. Format:
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The name of the database that this was a snapshot of. Format:
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_UID_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString databaseUid_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * Output only. Public UUID of the database the snapshot was associated with.
+   * 
+ * + * bytes database_uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseUid() { + return databaseUid_; + } + + public static final int SNAPSHOT_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp snapshotTime_; + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the snapshotTime field is set. + */ + @java.lang.Override + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The snapshotTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getSnapshotTime() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (!databaseUid_.isEmpty()) { + output.writeBytes(2, databaseUid_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getSnapshotTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (!databaseUid_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, databaseUid_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getSnapshotTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.PitrSnapshot)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.PitrSnapshot other = + (com.google.firestore.admin.v1.PitrSnapshot) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getDatabaseUid().equals(other.getDatabaseUid())) return false; + if (hasSnapshotTime() != other.hasSnapshotTime()) return false; + if (hasSnapshotTime()) { + if (!getSnapshotTime().equals(other.getSnapshotTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + DATABASE_UID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseUid().hashCode(); + if (hasSnapshotTime()) { + hash = (37 * hash) + SNAPSHOT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getSnapshotTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.PitrSnapshot parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.PitrSnapshot prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A consistent snapshot of a database at a specific point in time.
+   * A PITR (Point-in-time recovery) snapshot with previous versions of a
+   * database's data is available for every minute up to the associated database's
+   * data retention period. If the PITR feature is enabled, the retention period
+   * is 7 days; otherwise, it is one hour.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.PitrSnapshot} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.PitrSnapshot) + com.google.firestore.admin.v1.PitrSnapshotOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.PitrSnapshotProto + .internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.PitrSnapshotProto + .internal_static_google_firestore_admin_v1_PitrSnapshot_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.PitrSnapshot.class, + com.google.firestore.admin.v1.PitrSnapshot.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.PitrSnapshot.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetSnapshotTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + databaseUid_ = com.google.protobuf.ByteString.EMPTY; + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.PitrSnapshotProto + .internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot getDefaultInstanceForType() { + return com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot build() { + com.google.firestore.admin.v1.PitrSnapshot result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot buildPartial() { + com.google.firestore.admin.v1.PitrSnapshot result = + new com.google.firestore.admin.v1.PitrSnapshot(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.PitrSnapshot result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseUid_ = databaseUid_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.snapshotTime_ = + snapshotTimeBuilder_ == null ? snapshotTime_ : snapshotTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.PitrSnapshot) { + return mergeFrom((com.google.firestore.admin.v1.PitrSnapshot) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.PitrSnapshot other) { + if (other == com.google.firestore.admin.v1.PitrSnapshot.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseUid().isEmpty()) { + setDatabaseUid(other.getDatabaseUid()); + } + if (other.hasSnapshotTime()) { + mergeSnapshotTime(other.getSnapshotTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + databaseUid_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetSnapshotTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The name of the database that this was a snapshot of. Format:
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The name of the database that this was a snapshot of. Format:
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The name of the database that this was a snapshot of. Format:
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the database that this was a snapshot of. Format:
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the database that this was a snapshot of. Format:
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString databaseUid_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * Output only. Public UUID of the database the snapshot was associated with.
+     * 
+ * + * bytes database_uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseUid() { + return databaseUid_; + } + + /** + * + * + *
+     * Output only. Public UUID of the database the snapshot was associated with.
+     * 
+ * + * bytes database_uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The databaseUid to set. + * @return This builder for chaining. + */ + public Builder setDatabaseUid(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + databaseUid_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Public UUID of the database the snapshot was associated with.
+     * 
+ * + * bytes database_uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseUid() { + bitField0_ = (bitField0_ & ~0x00000002); + databaseUid_ = getDefaultInstance().getDatabaseUid(); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp snapshotTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + snapshotTimeBuilder_; + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the snapshotTime field is set. + */ + public boolean hasSnapshotTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The snapshotTime. + */ + public com.google.protobuf.Timestamp getSnapshotTime() { + if (snapshotTimeBuilder_ == null) { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } else { + return snapshotTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + snapshotTime_ = value; + } else { + snapshotTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setSnapshotTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (snapshotTimeBuilder_ == null) { + snapshotTime_ = builderForValue.build(); + } else { + snapshotTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeSnapshotTime(com.google.protobuf.Timestamp value) { + if (snapshotTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && snapshotTime_ != null + && snapshotTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getSnapshotTimeBuilder().mergeFrom(value); + } else { + snapshotTime_ = value; + } + } else { + snapshotTimeBuilder_.mergeFrom(value); + } + if (snapshotTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearSnapshotTime() { + bitField0_ = (bitField0_ & ~0x00000004); + snapshotTime_ = null; + if (snapshotTimeBuilder_ != null) { + snapshotTimeBuilder_.dispose(); + snapshotTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Timestamp.Builder getSnapshotTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetSnapshotTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder() { + if (snapshotTimeBuilder_ != null) { + return snapshotTimeBuilder_.getMessageOrBuilder(); + } else { + return snapshotTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : snapshotTime_; + } + } + + /** + * + * + *
+     * Required. Snapshot time of the database.
+     * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetSnapshotTimeFieldBuilder() { + if (snapshotTimeBuilder_ == null) { + snapshotTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getSnapshotTime(), getParentForChildren(), isClean()); + snapshotTime_ = null; + } + return snapshotTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.PitrSnapshot) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.PitrSnapshot) + private static final com.google.firestore.admin.v1.PitrSnapshot DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.PitrSnapshot(); + } + + public static com.google.firestore.admin.v1.PitrSnapshot getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PitrSnapshot parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.PitrSnapshot getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotOrBuilder.java new file mode 100644 index 000000000000..a11b224f9d5b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotOrBuilder.java @@ -0,0 +1,113 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/snapshot.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface PitrSnapshotOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.PitrSnapshot) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the database that this was a snapshot of. Format:
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The name of the database that this was a snapshot of. Format:
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * + * string database = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * Output only. Public UUID of the database the snapshot was associated with.
+   * 
+ * + * bytes database_uid = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The databaseUid. + */ + com.google.protobuf.ByteString getDatabaseUid(); + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the snapshotTime field is set. + */ + boolean hasSnapshotTime(); + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The snapshotTime. + */ + com.google.protobuf.Timestamp getSnapshotTime(); + + /** + * + * + *
+   * Required. Snapshot time of the database.
+   * 
+ * + * .google.protobuf.Timestamp snapshot_time = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.protobuf.TimestampOrBuilder getSnapshotTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotProto.java new file mode 100644 index 000000000000..62c19e5953b6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/PitrSnapshotProto.java @@ -0,0 +1,100 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/snapshot.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class PitrSnapshotProto extends com.google.protobuf.GeneratedFile { + private PitrSnapshotProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PitrSnapshotProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_PitrSnapshot_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n(google/firestore/admin/v1/snapshot.pro" + + "to\022\031google.firestore.admin.v1\032\037google/ap" + + "i/field_behavior.proto\032\031google/api/resou" + + "rce.proto\032\037google/protobuf/timestamp.pro" + + "to\"\236\001\n\014PitrSnapshot\022;\n\010database\030\001 \001(\tB)\340" + + "A\002\372A#\n!firestore.googleapis.com/Database" + + "\022\031\n\014database_uid\030\002 \001(\014B\003\340A\003\0226\n\rsnapshot_" + + "time\030\003 \001(\0132\032.google.protobuf.TimestampB\003" + + "\340A\002B\340\001\n\035com.google.firestore.admin.v1B\021P" + + "itrSnapshotProtoP\001Z9cloud.google.com/go/" + + "firestore/apiv1/admin/adminpb;adminpb\242\002\004" + + "GCFS\252\002\037Google.Cloud.Firestore.Admin.V1\312\002" + + "\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#Googl" + + "e::Cloud::Firestore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_PitrSnapshot_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_PitrSnapshot_descriptor, + new java.lang.String[] { + "Database", "DatabaseUid", "SnapshotTime", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Progress.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Progress.java new file mode 100644 index 000000000000..b7586313c273 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/Progress.java @@ -0,0 +1,602 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Describes the progress of the operation.
+ * Unit of work is generic and must be interpreted based on where
+ * [Progress][google.firestore.admin.v1.Progress] is used.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Progress} + */ +@com.google.protobuf.Generated +public final class Progress extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.Progress) + ProgressOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Progress"); + } + + // Use Progress.newBuilder() to construct. + private Progress(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Progress() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_Progress_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Progress.class, + com.google.firestore.admin.v1.Progress.Builder.class); + } + + public static final int ESTIMATED_WORK_FIELD_NUMBER = 1; + private long estimatedWork_ = 0L; + + /** + * + * + *
+   * The amount of work estimated.
+   * 
+ * + * int64 estimated_work = 1; + * + * @return The estimatedWork. + */ + @java.lang.Override + public long getEstimatedWork() { + return estimatedWork_; + } + + public static final int COMPLETED_WORK_FIELD_NUMBER = 2; + private long completedWork_ = 0L; + + /** + * + * + *
+   * The amount of work completed.
+   * 
+ * + * int64 completed_work = 2; + * + * @return The completedWork. + */ + @java.lang.Override + public long getCompletedWork() { + return completedWork_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (estimatedWork_ != 0L) { + output.writeInt64(1, estimatedWork_); + } + if (completedWork_ != 0L) { + output.writeInt64(2, completedWork_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (estimatedWork_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, estimatedWork_); + } + if (completedWork_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, completedWork_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.Progress)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.Progress other = (com.google.firestore.admin.v1.Progress) obj; + + if (getEstimatedWork() != other.getEstimatedWork()) return false; + if (getCompletedWork() != other.getCompletedWork()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ESTIMATED_WORK_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getEstimatedWork()); + hash = (37 * hash) + COMPLETED_WORK_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getCompletedWork()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.Progress parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Progress parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Progress parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Progress parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Progress parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.Progress parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.Progress prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Describes the progress of the operation.
+   * Unit of work is generic and must be interpreted based on where
+   * [Progress][google.firestore.admin.v1.Progress] is used.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.Progress} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.Progress) + com.google.firestore.admin.v1.ProgressOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_Progress_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.Progress.class, + com.google.firestore.admin.v1.Progress.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.Progress.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + estimatedWork_ = 0L; + completedWork_ = 0L; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Progress getDefaultInstanceForType() { + return com.google.firestore.admin.v1.Progress.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.Progress build() { + com.google.firestore.admin.v1.Progress result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Progress buildPartial() { + com.google.firestore.admin.v1.Progress result = + new com.google.firestore.admin.v1.Progress(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.Progress result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.estimatedWork_ = estimatedWork_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.completedWork_ = completedWork_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.Progress) { + return mergeFrom((com.google.firestore.admin.v1.Progress) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.Progress other) { + if (other == com.google.firestore.admin.v1.Progress.getDefaultInstance()) return this; + if (other.getEstimatedWork() != 0L) { + setEstimatedWork(other.getEstimatedWork()); + } + if (other.getCompletedWork() != 0L) { + setCompletedWork(other.getCompletedWork()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + estimatedWork_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + completedWork_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long estimatedWork_; + + /** + * + * + *
+     * The amount of work estimated.
+     * 
+ * + * int64 estimated_work = 1; + * + * @return The estimatedWork. + */ + @java.lang.Override + public long getEstimatedWork() { + return estimatedWork_; + } + + /** + * + * + *
+     * The amount of work estimated.
+     * 
+ * + * int64 estimated_work = 1; + * + * @param value The estimatedWork to set. + * @return This builder for chaining. + */ + public Builder setEstimatedWork(long value) { + + estimatedWork_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The amount of work estimated.
+     * 
+ * + * int64 estimated_work = 1; + * + * @return This builder for chaining. + */ + public Builder clearEstimatedWork() { + bitField0_ = (bitField0_ & ~0x00000001); + estimatedWork_ = 0L; + onChanged(); + return this; + } + + private long completedWork_; + + /** + * + * + *
+     * The amount of work completed.
+     * 
+ * + * int64 completed_work = 2; + * + * @return The completedWork. + */ + @java.lang.Override + public long getCompletedWork() { + return completedWork_; + } + + /** + * + * + *
+     * The amount of work completed.
+     * 
+ * + * int64 completed_work = 2; + * + * @param value The completedWork to set. + * @return This builder for chaining. + */ + public Builder setCompletedWork(long value) { + + completedWork_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The amount of work completed.
+     * 
+ * + * int64 completed_work = 2; + * + * @return This builder for chaining. + */ + public Builder clearCompletedWork() { + bitField0_ = (bitField0_ & ~0x00000002); + completedWork_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.Progress) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.Progress) + private static final com.google.firestore.admin.v1.Progress DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.Progress(); + } + + public static com.google.firestore.admin.v1.Progress getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Progress parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.Progress getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProgressOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProgressOrBuilder.java new file mode 100644 index 000000000000..a91a73e3a2aa --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProgressOrBuilder.java @@ -0,0 +1,54 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ProgressOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.Progress) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The amount of work estimated.
+   * 
+ * + * int64 estimated_work = 1; + * + * @return The estimatedWork. + */ + long getEstimatedWork(); + + /** + * + * + *
+   * The amount of work completed.
+   * 
+ * + * int64 completed_work = 2; + * + * @return The completedWork. + */ + long getCompletedWork(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java new file mode 100644 index 000000000000..d5a9e503c54b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ProjectName.java @@ -0,0 +1,168 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class ProjectName implements ResourceName { + private static final PathTemplate PROJECT = + PathTemplate.createWithoutUrlEncoding("projects/{project}"); + private volatile Map fieldValuesMap; + private final String project; + + @Deprecated + protected ProjectName() { + project = null; + } + + private ProjectName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + } + + public String getProject() { + return project; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static ProjectName of(String project) { + return newBuilder().setProject(project).build(); + } + + public static String format(String project) { + return newBuilder().setProject(project).build().toString(); + } + + public static ProjectName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT.validatedMatch( + formattedString, "ProjectName.parse: formattedString not in valid format"); + return of(matchMap.get("project")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (ProjectName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT.instantiate("project", project); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + ProjectName that = ((ProjectName) o); + return Objects.equals(this.project, that.project); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + return h; + } + + /** Builder for projects/{project}. */ + public static class Builder { + private String project; + + protected Builder() {} + + public String getProject() { + return project; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + private Builder(ProjectName projectName) { + this.project = projectName.project; + } + + public ProjectName build() { + return new ProjectName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesMode.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesMode.java new file mode 100644 index 000000000000..5108f10eff5e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesMode.java @@ -0,0 +1,198 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/realtime_updates.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The Realtime Updates mode.
+ * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.RealtimeUpdatesMode} + */ +@com.google.protobuf.Generated +public enum RealtimeUpdatesMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+   * The Realtime Updates feature is not specified.
+   * 
+ * + * REALTIME_UPDATES_MODE_UNSPECIFIED = 0; + */ + REALTIME_UPDATES_MODE_UNSPECIFIED(0), + /** + * + * + *
+   * The Realtime Updates feature is enabled by default.
+   *
+   * This could potentially degrade write performance for the database.
+   * 
+ * + * REALTIME_UPDATES_MODE_ENABLED = 1; + */ + REALTIME_UPDATES_MODE_ENABLED(1), + /** + * + * + *
+   * The Realtime Updates feature is disabled by default.
+   * 
+ * + * REALTIME_UPDATES_MODE_DISABLED = 2; + */ + REALTIME_UPDATES_MODE_DISABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RealtimeUpdatesMode"); + } + + /** + * + * + *
+   * The Realtime Updates feature is not specified.
+   * 
+ * + * REALTIME_UPDATES_MODE_UNSPECIFIED = 0; + */ + public static final int REALTIME_UPDATES_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+   * The Realtime Updates feature is enabled by default.
+   *
+   * This could potentially degrade write performance for the database.
+   * 
+ * + * REALTIME_UPDATES_MODE_ENABLED = 1; + */ + public static final int REALTIME_UPDATES_MODE_ENABLED_VALUE = 1; + + /** + * + * + *
+   * The Realtime Updates feature is disabled by default.
+   * 
+ * + * REALTIME_UPDATES_MODE_DISABLED = 2; + */ + public static final int REALTIME_UPDATES_MODE_DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static RealtimeUpdatesMode valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static RealtimeUpdatesMode forNumber(int value) { + switch (value) { + case 0: + return REALTIME_UPDATES_MODE_UNSPECIFIED; + case 1: + return REALTIME_UPDATES_MODE_ENABLED; + case 2: + return REALTIME_UPDATES_MODE_DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public RealtimeUpdatesMode findValueByNumber(int number) { + return RealtimeUpdatesMode.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.RealtimeUpdatesProto.getDescriptor().getEnumTypes().get(0); + } + + private static final RealtimeUpdatesMode[] VALUES = values(); + + public static RealtimeUpdatesMode valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private RealtimeUpdatesMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.RealtimeUpdatesMode) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesProto.java new file mode 100644 index 000000000000..a181576d3ceb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RealtimeUpdatesProto.java @@ -0,0 +1,71 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/realtime_updates.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class RealtimeUpdatesProto extends com.google.protobuf.GeneratedFile { + private RealtimeUpdatesProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RealtimeUpdatesProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n0google/firestore/admin/v1/realtime_upd" + + "ates.proto\022\031google.firestore.admin.v1*\203\001" + + "\n\023RealtimeUpdatesMode\022%\n!REALTIME_UPDATE" + + "S_MODE_UNSPECIFIED\020\000\022!\n\035REALTIME_UPDATES" + + "_MODE_ENABLED\020\001\022\"\n\036REALTIME_UPDATES_MODE" + + "_DISABLED\020\002B\343\001\n\035com.google.firestore.adm" + + "in.v1B\024RealtimeUpdatesProtoP\001Z9cloud.goo" + + "gle.com/go/firestore/apiv1/admin/adminpb" + + ";adminpb\242\002\004GCFS\252\002\037Google.Cloud.Firestore" + + ".Admin.V1\312\002\037Google\\Cloud\\Firestore\\Admin" + + "\\V1\352\002#Google::Cloud::Firestore::Admin::V" + + "1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequest.java new file mode 100644 index 000000000000..e9d169da325e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequest.java @@ -0,0 +1,620 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.ResetUserPassword][google.firestore.admin.v1.FirestoreAdmin.ResetUserPassword].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ResetUserPasswordRequest} + */ +@com.google.protobuf.Generated +public final class ResetUserPasswordRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.ResetUserPasswordRequest) + ResetUserPasswordRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ResetUserPasswordRequest"); + } + + // Use ResetUserPasswordRequest.newBuilder() to construct. + private ResetUserPasswordRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ResetUserPasswordRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ResetUserPasswordRequest.class, + com.google.firestore.admin.v1.ResetUserPasswordRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.ResetUserPasswordRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.ResetUserPasswordRequest other = + (com.google.firestore.admin.v1.ResetUserPasswordRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.ResetUserPasswordRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.ResetUserPassword][google.firestore.admin.v1.FirestoreAdmin.ResetUserPassword].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.ResetUserPasswordRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.ResetUserPasswordRequest) + com.google.firestore.admin.v1.ResetUserPasswordRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.ResetUserPasswordRequest.class, + com.google.firestore.admin.v1.ResetUserPasswordRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.ResetUserPasswordRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_ResetUserPasswordRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ResetUserPasswordRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.ResetUserPasswordRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.ResetUserPasswordRequest build() { + com.google.firestore.admin.v1.ResetUserPasswordRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ResetUserPasswordRequest buildPartial() { + com.google.firestore.admin.v1.ResetUserPasswordRequest result = + new com.google.firestore.admin.v1.ResetUserPasswordRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.ResetUserPasswordRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.ResetUserPasswordRequest) { + return mergeFrom((com.google.firestore.admin.v1.ResetUserPasswordRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.ResetUserPasswordRequest other) { + if (other == com.google.firestore.admin.v1.ResetUserPasswordRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. A name of the form
+     * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.ResetUserPasswordRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.ResetUserPasswordRequest) + private static final com.google.firestore.admin.v1.ResetUserPasswordRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.ResetUserPasswordRequest(); + } + + public static com.google.firestore.admin.v1.ResetUserPasswordRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ResetUserPasswordRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.ResetUserPasswordRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequestOrBuilder.java new file mode 100644 index 000000000000..f4c036c370e4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ResetUserPasswordRequestOrBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface ResetUserPasswordRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.ResetUserPasswordRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. A name of the form
+   * `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}`
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java new file mode 100644 index 000000000000..3cf0677209a2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadata.java @@ -0,0 +1,1786 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata for the [long-running operation][google.longrunning.Operation] from
+ * the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseMetadata} + */ +@com.google.protobuf.Generated +public final class RestoreDatabaseMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.RestoreDatabaseMetadata) + RestoreDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RestoreDatabaseMetadata"); + } + + // Use RestoreDatabaseMetadata.newBuilder() to construct. + private RestoreDatabaseMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RestoreDatabaseMetadata() { + operationState_ = 0; + database_ = ""; + backup_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseMetadata.class, + com.google.firestore.admin.v1.RestoreDatabaseMetadata.Builder.class); + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + @java.lang.Override + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getStartTime() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + + public static final int END_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp endTime_; + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + @java.lang.Override + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getEndTime() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + + public static final int OPERATION_STATE_FIELD_NUMBER = 3; + private int operationState_ = 0; + + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + public static final int DATABASE_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object backup_ = ""; + + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + @java.lang.Override + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } + } + + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PROGRESS_PERCENTAGE_FIELD_NUMBER = 8; + private com.google.firestore.admin.v1.Progress progressPercentage_; + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + @java.lang.Override + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + @java.lang.Override + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, database_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, backup_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(8, getProgressPercentage()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getEndTime()); + } + if (operationState_ + != com.google.firestore.admin.v1.OperationState.OPERATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationState_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, database_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, backup_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getProgressPercentage()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.RestoreDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.RestoreDatabaseMetadata other = + (com.google.firestore.admin.v1.RestoreDatabaseMetadata) obj; + + if (hasStartTime() != other.hasStartTime()) return false; + if (hasStartTime()) { + if (!getStartTime().equals(other.getStartTime())) return false; + } + if (hasEndTime() != other.hasEndTime()) return false; + if (hasEndTime()) { + if (!getEndTime().equals(other.getEndTime())) return false; + } + if (operationState_ != other.operationState_) return false; + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getBackup().equals(other.getBackup())) return false; + if (hasProgressPercentage() != other.hasProgressPercentage()) return false; + if (hasProgressPercentage()) { + if (!getProgressPercentage().equals(other.getProgressPercentage())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasStartTime()) { + hash = (37 * hash) + START_TIME_FIELD_NUMBER; + hash = (53 * hash) + getStartTime().hashCode(); + } + if (hasEndTime()) { + hash = (37 * hash) + END_TIME_FIELD_NUMBER; + hash = (53 * hash) + getEndTime().hashCode(); + } + hash = (37 * hash) + OPERATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + operationState_; + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + if (hasProgressPercentage()) { + hash = (37 * hash) + PROGRESS_PERCENTAGE_FIELD_NUMBER; + hash = (53 * hash) + getProgressPercentage().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.RestoreDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for the [long-running operation][google.longrunning.Operation] from
+   * the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.RestoreDatabaseMetadata) + com.google.firestore.admin.v1.RestoreDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseMetadata.class, + com.google.firestore.admin.v1.RestoreDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.RestoreDatabaseMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetStartTimeFieldBuilder(); + internalGetEndTimeFieldBuilder(); + internalGetProgressPercentageFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + operationState_ = 0; + database_ = ""; + backup_ = ""; + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.OperationProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.RestoreDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata build() { + com.google.firestore.admin.v1.RestoreDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.RestoreDatabaseMetadata result = + new com.google.firestore.admin.v1.RestoreDatabaseMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.RestoreDatabaseMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.startTime_ = startTimeBuilder_ == null ? startTime_ : startTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.endTime_ = endTimeBuilder_ == null ? endTime_ : endTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.operationState_ = operationState_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.backup_ = backup_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.progressPercentage_ = + progressPercentageBuilder_ == null + ? progressPercentage_ + : progressPercentageBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.RestoreDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.RestoreDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.RestoreDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.RestoreDatabaseMetadata.getDefaultInstance()) + return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationState_ != 0) { + setOperationStateValue(other.getOperationStateValue()); + } + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (!other.getBackup().isEmpty()) { + backup_ = other.backup_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (other.hasProgressPercentage()) { + mergeProgressPercentage(other.getProgressPercentage()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationState_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + backup_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 66: + { + input.readMessage( + internalGetProgressPercentageFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + public com.google.protobuf.Timestamp getStartTime() { + if (startTimeBuilder_ == null) { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } else { + return startTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startTime_ = value; + } else { + startTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder setStartTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (startTimeBuilder_ == null) { + startTime_ = builderForValue.build(); + } else { + startTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder mergeStartTime(com.google.protobuf.Timestamp value) { + if (startTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && startTime_ != null + && startTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getStartTimeBuilder().mergeFrom(value); + } else { + startTime_ = value; + } + } else { + startTimeBuilder_.mergeFrom(value); + } + if (startTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public Builder clearStartTime() { + bitField0_ = (bitField0_ & ~0x00000001); + startTime_ = null; + if (startTimeBuilder_ != null) { + startTimeBuilder_.dispose(); + startTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder() { + if (startTimeBuilder_ != null) { + return startTimeBuilder_.getMessageOrBuilder(); + } else { + return startTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : startTime_; + } + } + + /** + * + * + *
+     * The time the restore was started.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getStartTime(), getParentForChildren(), isClean()); + startTime_ = null; + } + return startTimeBuilder_; + } + + private com.google.protobuf.Timestamp endTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + public com.google.protobuf.Timestamp getEndTime() { + if (endTimeBuilder_ == null) { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } else { + return endTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endTime_ = value; + } else { + endTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder setEndTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (endTimeBuilder_ == null) { + endTime_ = builderForValue.build(); + } else { + endTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder mergeEndTime(com.google.protobuf.Timestamp value) { + if (endTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && endTime_ != null + && endTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getEndTimeBuilder().mergeFrom(value); + } else { + endTime_ = value; + } + } else { + endTimeBuilder_.mergeFrom(value); + } + if (endTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public Builder clearEndTime() { + bitField0_ = (bitField0_ & ~0x00000002); + endTime_ = null; + if (endTimeBuilder_ != null) { + endTimeBuilder_.dispose(); + endTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder() { + if (endTimeBuilder_ != null) { + return endTimeBuilder_.getMessageOrBuilder(); + } else { + return endTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : endTime_; + } + } + + /** + * + * + *
+     * The time the restore finished, unset for ongoing restores.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationState_ = 0; + + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + @java.lang.Override + public int getOperationStateValue() { + return operationState_; + } + + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The enum numeric value on the wire for operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationStateValue(int value) { + operationState_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + @java.lang.Override + public com.google.firestore.admin.v1.OperationState getOperationState() { + com.google.firestore.admin.v1.OperationState result = + com.google.firestore.admin.v1.OperationState.forNumber(operationState_); + return result == null ? com.google.firestore.admin.v1.OperationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @param value The operationState to set. + * @return This builder for chaining. + */ + public Builder setOperationState(com.google.firestore.admin.v1.OperationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The operation state of the restore.
+     * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationState() { + bitField0_ = (bitField0_ & ~0x00000004); + operationState_ = 0; + onChanged(); + return this; + } + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the database being restored to.
+     * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private java.lang.Object backup_ = ""; + + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @param value The backup to set. + * @return This builder for chaining. + */ + public Builder setBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backup_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return This builder for chaining. + */ + public Builder clearBackup() { + backup_ = getDefaultInstance().getBackup(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the backup restoring from.
+     * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @param value The bytes for backup to set. + * @return This builder for chaining. + */ + public Builder setBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backup_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Progress progressPercentage_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + progressPercentageBuilder_; + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + public boolean hasProgressPercentage() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + public com.google.firestore.admin.v1.Progress getProgressPercentage() { + if (progressPercentageBuilder_ == null) { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } else { + return progressPercentageBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder setProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressPercentage_ = value; + } else { + progressPercentageBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder setProgressPercentage( + com.google.firestore.admin.v1.Progress.Builder builderForValue) { + if (progressPercentageBuilder_ == null) { + progressPercentage_ = builderForValue.build(); + } else { + progressPercentageBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder mergeProgressPercentage(com.google.firestore.admin.v1.Progress value) { + if (progressPercentageBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && progressPercentage_ != null + && progressPercentage_ != com.google.firestore.admin.v1.Progress.getDefaultInstance()) { + getProgressPercentageBuilder().mergeFrom(value); + } else { + progressPercentage_ = value; + } + } else { + progressPercentageBuilder_.mergeFrom(value); + } + if (progressPercentage_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public Builder clearProgressPercentage() { + bitField0_ = (bitField0_ & ~0x00000020); + progressPercentage_ = null; + if (progressPercentageBuilder_ != null) { + progressPercentageBuilder_.dispose(); + progressPercentageBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public com.google.firestore.admin.v1.Progress.Builder getProgressPercentageBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetProgressPercentageFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + public com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder() { + if (progressPercentageBuilder_ != null) { + return progressPercentageBuilder_.getMessageOrBuilder(); + } else { + return progressPercentage_ == null + ? com.google.firestore.admin.v1.Progress.getDefaultInstance() + : progressPercentage_; + } + } + + /** + * + * + *
+     * How far along the restore is as an estimated percentage of remaining time.
+     * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder> + internalGetProgressPercentageFieldBuilder() { + if (progressPercentageBuilder_ == null) { + progressPercentageBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Progress, + com.google.firestore.admin.v1.Progress.Builder, + com.google.firestore.admin.v1.ProgressOrBuilder>( + getProgressPercentage(), getParentForChildren(), isClean()); + progressPercentage_ = null; + } + return progressPercentageBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.RestoreDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.RestoreDatabaseMetadata) + private static final com.google.firestore.admin.v1.RestoreDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.RestoreDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RestoreDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000000..95d0c9eba398 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseMetadataOrBuilder.java @@ -0,0 +1,217 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/operation.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface RestoreDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.RestoreDatabaseMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time the restore was started.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time the restore finished, unset for ongoing restores.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The enum numeric value on the wire for operationState. + */ + int getOperationStateValue(); + + /** + * + * + *
+   * The operation state of the restore.
+   * 
+ * + * .google.firestore.admin.v1.OperationState operation_state = 3; + * + * @return The operationState. + */ + com.google.firestore.admin.v1.OperationState getOperationState(); + + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * The name of the database being restored to.
+   * 
+ * + * string database = 4 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The backup. + */ + java.lang.String getBackup(); + + /** + * + * + *
+   * The name of the backup restoring from.
+   * 
+ * + * string backup = 5 [(.google.api.resource_reference) = { ... } + * + * @return The bytes for backup. + */ + com.google.protobuf.ByteString getBackupBytes(); + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return Whether the progressPercentage field is set. + */ + boolean hasProgressPercentage(); + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + * + * @return The progressPercentage. + */ + com.google.firestore.admin.v1.Progress getProgressPercentage(); + + /** + * + * + *
+   * How far along the restore is as an estimated percentage of remaining time.
+   * 
+ * + * .google.firestore.admin.v1.Progress progress_percentage = 8; + */ + com.google.firestore.admin.v1.ProgressOrBuilder getProgressPercentageOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java new file mode 100644 index 000000000000..ba471d36b3e0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequest.java @@ -0,0 +1,1882 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request message for
+ * [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.FirestoreAdmin.RestoreDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class RestoreDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.RestoreDatabaseRequest) + RestoreDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RestoreDatabaseRequest"); + } + + // Use RestoreDatabaseRequest.newBuilder() to construct. + private RestoreDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RestoreDatabaseRequest() { + parent_ = ""; + databaseId_ = ""; + backup_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 10: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + com.google.firestore.admin.v1.RestoreDatabaseRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + @java.lang.Override + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object backup_ = ""; + + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * The restored database will be created in the same location as the source
+   * backup.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + @java.lang.Override + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * The restored database will be created in the same location as the source
+   * backup.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ENCRYPTION_CONFIG_FIELD_NUMBER = 9; + private com.google.firestore.admin.v1.Database.EncryptionConfig encryptionConfig_; + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + @java.lang.Override + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig() { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + + public static final int TAGS_FIELD_NUMBER = 10; + + private static final class TagsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_TagsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, databaseId_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, backup_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(9, getEncryptionConfig()); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetTags(), TagsDefaultEntryHolder.defaultEntry, 10); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, databaseId_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(backup_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, backup_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getEncryptionConfig()); + } + for (java.util.Map.Entry entry : + internalGetTags().getMap().entrySet()) { + com.google.protobuf.MapEntry tags__ = + TagsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, tags__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.RestoreDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.RestoreDatabaseRequest other = + (com.google.firestore.admin.v1.RestoreDatabaseRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getBackup().equals(other.getBackup())) return false; + if (hasEncryptionConfig() != other.hasEncryptionConfig()) return false; + if (hasEncryptionConfig()) { + if (!getEncryptionConfig().equals(other.getEncryptionConfig())) return false; + } + if (!internalGetTags().equals(other.internalGetTags())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + hash = (37 * hash) + BACKUP_FIELD_NUMBER; + hash = (53 * hash) + getBackup().hashCode(); + if (hasEncryptionConfig()) { + hash = (37 * hash) + ENCRYPTION_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getEncryptionConfig().hashCode(); + } + if (!internalGetTags().getMap().isEmpty()) { + hash = (37 * hash) + TAGS_FIELD_NUMBER; + hash = (53 * hash) + internalGetTags().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.RestoreDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request message for
+   * [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.FirestoreAdmin.RestoreDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.RestoreDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.RestoreDatabaseRequest) + com.google.firestore.admin.v1.RestoreDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 10: + return internalGetTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 10: + return internalGetMutableTags(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.RestoreDatabaseRequest.class, + com.google.firestore.admin.v1.RestoreDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.RestoreDatabaseRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetEncryptionConfigFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + databaseId_ = ""; + backup_ = ""; + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + internalGetMutableTags().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_RestoreDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.RestoreDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest build() { + com.google.firestore.admin.v1.RestoreDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.RestoreDatabaseRequest result = + new com.google.firestore.admin.v1.RestoreDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.RestoreDatabaseRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.backup_ = backup_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.encryptionConfig_ = + encryptionConfigBuilder_ == null ? encryptionConfig_ : encryptionConfigBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.tags_ = internalGetTags(); + result.tags_.makeImmutable(); + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.RestoreDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.RestoreDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.RestoreDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.RestoreDatabaseRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getBackup().isEmpty()) { + backup_ = other.backup_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.hasEncryptionConfig()) { + mergeEncryptionConfig(other.getEncryptionConfig()); + } + internalGetMutableTags().mergeFrom(other.internalGetTags()); + bitField0_ |= 0x00000010; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + backup_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 74: + { + input.readMessage( + internalGetEncryptionConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 74 + case 82: + { + com.google.protobuf.MapEntry tags__ = + input.readMessage( + TagsDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + internalGetMutableTags().getMutableMap().put(tags__.getKey(), tags__.getValue()); + bitField0_ |= 0x00000010; + break; + } // case 82 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The project to restore the database in. Format is
+     * `projects/{project_id}`.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + public java.lang.String getDatabaseId() { + java.lang.Object ref = databaseId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + databaseId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + public com.google.protobuf.ByteString getDatabaseIdBytes() { + java.lang.Object ref = databaseId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + databaseId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID to use for the database, which will become the final
+     * component of the database's resource name. This database ID must not be
+     * associated with an existing database.
+     *
+     * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+     * with first character a letter and the last a letter or a number. Must not
+     * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+     *
+     * "(default)" database ID is also valid if the database is Standard edition.
+     * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for databaseId to set. + * @return This builder for chaining. + */ + public Builder setDatabaseIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + databaseId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object backup_ = ""; + + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * The restored database will be created in the same location as the source
+     * backup.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + public java.lang.String getBackup() { + java.lang.Object ref = backup_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backup_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * The restored database will be created in the same location as the source
+     * backup.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + public com.google.protobuf.ByteString getBackupBytes() { + java.lang.Object ref = backup_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backup_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * The restored database will be created in the same location as the source
+     * backup.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The backup to set. + * @return This builder for chaining. + */ + public Builder setBackup(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backup_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * The restored database will be created in the same location as the source
+     * backup.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearBackup() { + backup_ = getDefaultInstance().getBackup(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Backup to restore from. Must be from the same project as the
+     * parent.
+     *
+     * The restored database will be created in the same location as the source
+     * backup.
+     *
+     * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+     * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for backup to set. + * @return This builder for chaining. + */ + public Builder setBackupBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backup_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.firestore.admin.v1.Database.EncryptionConfig encryptionConfig_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder> + encryptionConfigBuilder_; + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig() { + if (encryptionConfigBuilder_ == null) { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } else { + return encryptionConfigBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionConfig_ = value; + } else { + encryptionConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder builderForValue) { + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = builderForValue.build(); + } else { + encryptionConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeEncryptionConfig( + com.google.firestore.admin.v1.Database.EncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && encryptionConfig_ != null + && encryptionConfig_ + != com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance()) { + getEncryptionConfigBuilder().mergeFrom(value); + } else { + encryptionConfig_ = value; + } + } else { + encryptionConfigBuilder_.mergeFrom(value); + } + if (encryptionConfig_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearEncryptionConfig() { + bitField0_ = (bitField0_ & ~0x00000008); + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfig.Builder + getEncryptionConfigBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetEncryptionConfigFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + if (encryptionConfigBuilder_ != null) { + return encryptionConfigBuilder_.getMessageOrBuilder(); + } else { + return encryptionConfig_ == null + ? com.google.firestore.admin.v1.Database.EncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + } + + /** + * + * + *
+     * Optional. Encryption configuration for the restored database.
+     *
+     * If this field is not specified, the restored database will use
+     * the same encryption configuration as the backup, namely
+     * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+     * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder> + internalGetEncryptionConfigFieldBuilder() { + if (encryptionConfigBuilder_ == null) { + encryptionConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database.EncryptionConfig, + com.google.firestore.admin.v1.Database.EncryptionConfig.Builder, + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder>( + getEncryptionConfig(), getParentForChildren(), isClean()); + encryptionConfig_ = null; + } + return encryptionConfigBuilder_; + } + + private com.google.protobuf.MapField tags_; + + private com.google.protobuf.MapField internalGetTags() { + if (tags_ == null) { + return com.google.protobuf.MapField.emptyMapField(TagsDefaultEntryHolder.defaultEntry); + } + return tags_; + } + + private com.google.protobuf.MapField + internalGetMutableTags() { + if (tags_ == null) { + tags_ = com.google.protobuf.MapField.newMapField(TagsDefaultEntryHolder.defaultEntry); + } + if (!tags_.isMutable()) { + tags_ = tags_.copy(); + } + bitField0_ |= 0x00000010; + onChanged(); + return tags_; + } + + public int getTagsCount() { + return internalGetTags().getMap().size(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetTags().getMap().containsKey(key); + } + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTags() { + return getTagsMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getTagsMap() { + return internalGetTags().getMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.lang.String getTagsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetTags().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearTags() { + bitField0_ = (bitField0_ & ~0x00000010); + internalGetMutableTags().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeTags(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableTags().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableTags() { + bitField0_ |= 0x00000010; + return internalGetMutableTags().getMutableMap(); + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putTags(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableTags().getMutableMap().put(key, value); + bitField0_ |= 0x00000010; + return this; + } + + /** + * + * + *
+     * Optional. Immutable. Tags to be bound to the restored database.
+     *
+     * The tags should be provided in the format of
+     * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+     * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllTags(java.util.Map values) { + internalGetMutableTags().getMutableMap().putAll(values); + bitField0_ |= 0x00000010; + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.RestoreDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.RestoreDatabaseRequest) + private static final com.google.firestore.admin.v1.RestoreDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.RestoreDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RestoreDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.RestoreDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..6fe3b6dc3daa --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/RestoreDatabaseRequestOrBuilder.java @@ -0,0 +1,287 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface RestoreDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.RestoreDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The project to restore the database in. Format is
+   * `projects/{project_id}`.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * Required. The ID to use for the database, which will become the final
+   * component of the database's resource name. This database ID must not be
+   * associated with an existing database.
+   *
+   * This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/
+   * with first character a letter and the last a letter or a number. Must not
+   * be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/.
+   *
+   * "(default)" database ID is also valid if the database is Standard edition.
+   * 
+ * + * string database_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * The restored database will be created in the same location as the source
+   * backup.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The backup. + */ + java.lang.String getBackup(); + + /** + * + * + *
+   * Required. Backup to restore from. Must be from the same project as the
+   * parent.
+   *
+   * The restored database will be created in the same location as the source
+   * backup.
+   *
+   * Format is: `projects/{project_id}/locations/{location}/backups/{backup}`
+   * 
+ * + * + * string backup = 3 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for backup. + */ + com.google.protobuf.ByteString getBackupBytes(); + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + boolean hasEncryptionConfig(); + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + com.google.firestore.admin.v1.Database.EncryptionConfig getEncryptionConfig(); + + /** + * + * + *
+   * Optional. Encryption configuration for the restored database.
+   *
+   * If this field is not specified, the restored database will use
+   * the same encryption configuration as the backup, namely
+   * [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption].
+   * 
+ * + * + * .google.firestore.admin.v1.Database.EncryptionConfig encryption_config = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.admin.v1.Database.EncryptionConfigOrBuilder getEncryptionConfigOrBuilder(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + int getTagsCount(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsTags(java.lang.String key); + + /** Use {@link #getTagsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getTags(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getTagsMap(); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + java.lang.String getTagsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Optional. Immutable. Tags to be bound to the restored database.
+   *
+   * The tags should be provided in the format of
+   * `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`.
+   * 
+ * + * + * map<string, string> tags = 10 [(.google.api.field_behavior) = IMMUTABLE, (.google.api.field_behavior) = OPTIONAL]; + * + */ + java.lang.String getTagsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java new file mode 100644 index 000000000000..75e74d249e1c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/ScheduleProto.java @@ -0,0 +1,144 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class ScheduleProto extends com.google.protobuf.GeneratedFile { + private ScheduleProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ScheduleProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n(google/firestore/admin/v1/schedule.pro" + + "to\022\031google.firestore.admin.v1\032\037google/ap" + + "i/field_behavior.proto\032\031google/api/resou" + + "rce.proto\032\036google/protobuf/duration.prot" + + "o\032\037google/protobuf/timestamp.proto\032\033goog" + + "le/type/dayofweek.proto\"\326\003\n\016BackupSchedu" + + "le\022\021\n\004name\030\001 \001(\tB\003\340A\003\0224\n\013create_time\030\003 \001" + + "(\0132\032.google.protobuf.TimestampB\003\340A\003\0224\n\013u" + + "pdate_time\030\n \001(\0132\032.google.protobuf.Times" + + "tampB\003\340A\003\022,\n\tretention\030\006 \001(\0132\031.google.pr" + + "otobuf.Duration\022F\n\020daily_recurrence\030\007 \001(" + + "\0132*.google.firestore.admin.v1.DailyRecur" + + "renceH\000\022H\n\021weekly_recurrence\030\010 \001(\0132+.goo" + + "gle.firestore.admin.v1.WeeklyRecurrenceH" + + "\000:w\352At\n\'firestore.googleapis.com/BackupS" + + "chedule\022Iprojects/{project}/databases/{d" + + "atabase}/backupSchedules/{backup_schedul" + + "e}B\014\n\nrecurrence\"\021\n\017DailyRecurrence\"7\n\020W" + + "eeklyRecurrence\022#\n\003day\030\002 \001(\0162\026.google.ty" + + "pe.DayOfWeekB\334\001\n\035com.google.firestore.ad" + + "min.v1B\rScheduleProtoP\001Z9cloud.google.co" + + "m/go/firestore/apiv1/admin/adminpb;admin" + + "pb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Admin" + + ".V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1\352\002#" + + "Google::Cloud::Firestore::Admin::V1b\006pro" + + "to3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.type.DayOfWeekProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_BackupSchedule_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_BackupSchedule_descriptor, + new java.lang.String[] { + "Name", + "CreateTime", + "UpdateTime", + "Retention", + "DailyRecurrence", + "WeeklyRecurrence", + "Recurrence", + }); + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_admin_v1_DailyRecurrence_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_DailyRecurrence_descriptor, + new java.lang.String[] {}); + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor = + getDescriptor().getMessageType(2); + internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor, + new java.lang.String[] { + "Day", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.type.DayOfWeekProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java new file mode 100644 index 000000000000..0b488f20caea --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequest.java @@ -0,0 +1,1005 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateBackupScheduleRequest} + */ +@com.google.protobuf.Generated +public final class UpdateBackupScheduleRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UpdateBackupScheduleRequest) + UpdateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UpdateBackupScheduleRequest"); + } + + // Use UpdateBackupScheduleRequest.newBuilder() to construct. + private UpdateBackupScheduleRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UpdateBackupScheduleRequest() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 1; + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.protobuf.FieldMask updateMask_; + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.protobuf.FieldMask getUpdateMask() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + @java.lang.Override + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UpdateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UpdateBackupScheduleRequest other = + (com.google.firestore.admin.v1.UpdateBackupScheduleRequest) obj; + + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UpdateBackupScheduleRequest) + com.google.firestore.admin.v1.UpdateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.class, + com.google.firestore.admin.v1.UpdateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UpdateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetBackupScheduleFieldBuilder(); + internalGetUpdateMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UpdateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest build() { + com.google.firestore.admin.v1.UpdateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest buildPartial() { + com.google.firestore.admin.v1.UpdateBackupScheduleRequest result = + new com.google.firestore.admin.v1.UpdateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UpdateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UpdateBackupScheduleRequest) { + return mergeFrom((com.google.firestore.admin.v1.UpdateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UpdateBackupScheduleRequest other) { + if (other == com.google.firestore.admin.v1.UpdateBackupScheduleRequest.getDefaultInstance()) + return this; + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.admin.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.firestore.admin.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.firestore.admin.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.firestore.admin.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetBackupScheduleFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.firestore.admin.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + + /** + * + * + *
+     * Required. The backup schedule to update.
+     * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder> + internalGetBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.BackupSchedule, + com.google.firestore.admin.v1.BackupSchedule.Builder, + com.google.firestore.admin.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + private com.google.protobuf.FieldMask updateMask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + updateMaskBuilder_; + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + public com.google.protobuf.FieldMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetUpdateMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + internalGetUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UpdateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UpdateBackupScheduleRequest) + private static final com.google.firestore.admin.v1.UpdateBackupScheduleRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UpdateBackupScheduleRequest(); + } + + public static com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java new file mode 100644 index 000000000000..2211e1627b99 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface UpdateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UpdateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.firestore.admin.v1.BackupSchedule getBackupSchedule(); + + /** + * + * + *
+   * Required. The backup schedule to update.
+   * 
+ * + * + * .google.firestore.admin.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + com.google.protobuf.FieldMask getUpdateMask(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadata.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadata.java new file mode 100644 index 000000000000..54b1d0d58f41 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadata.java @@ -0,0 +1,396 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Metadata related to the update database operation.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateDatabaseMetadata} + */ +@com.google.protobuf.Generated +public final class UpdateDatabaseMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UpdateDatabaseMetadata) + UpdateDatabaseMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UpdateDatabaseMetadata"); + } + + // Use UpdateDatabaseMetadata.newBuilder() to construct. + private UpdateDatabaseMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UpdateDatabaseMetadata() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateDatabaseMetadata.class, + com.google.firestore.admin.v1.UpdateDatabaseMetadata.Builder.class); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UpdateDatabaseMetadata)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UpdateDatabaseMetadata other = + (com.google.firestore.admin.v1.UpdateDatabaseMetadata) obj; + + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.UpdateDatabaseMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata related to the update database operation.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateDatabaseMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UpdateDatabaseMetadata) + com.google.firestore.admin.v1.UpdateDatabaseMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateDatabaseMetadata.class, + com.google.firestore.admin.v1.UpdateDatabaseMetadata.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UpdateDatabaseMetadata.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseMetadata getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UpdateDatabaseMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseMetadata build() { + com.google.firestore.admin.v1.UpdateDatabaseMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseMetadata buildPartial() { + com.google.firestore.admin.v1.UpdateDatabaseMetadata result = + new com.google.firestore.admin.v1.UpdateDatabaseMetadata(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UpdateDatabaseMetadata) { + return mergeFrom((com.google.firestore.admin.v1.UpdateDatabaseMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UpdateDatabaseMetadata other) { + if (other == com.google.firestore.admin.v1.UpdateDatabaseMetadata.getDefaultInstance()) + return this; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UpdateDatabaseMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UpdateDatabaseMetadata) + private static final com.google.firestore.admin.v1.UpdateDatabaseMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UpdateDatabaseMetadata(); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateDatabaseMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadataOrBuilder.java new file mode 100644 index 000000000000..2b0e5389c10d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseMetadataOrBuilder.java @@ -0,0 +1,27 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface UpdateDatabaseMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UpdateDatabaseMetadata) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequest.java new file mode 100644 index 000000000000..abe8e0a3c409 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequest.java @@ -0,0 +1,1001 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.UpdateDatabase][google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateDatabaseRequest} + */ +@com.google.protobuf.Generated +public final class UpdateDatabaseRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UpdateDatabaseRequest) + UpdateDatabaseRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UpdateDatabaseRequest"); + } + + // Use UpdateDatabaseRequest.newBuilder() to construct. + private UpdateDatabaseRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UpdateDatabaseRequest() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateDatabaseRequest.class, + com.google.firestore.admin.v1.UpdateDatabaseRequest.Builder.class); + } + + private int bitField0_; + public static final int DATABASE_FIELD_NUMBER = 1; + private com.google.firestore.admin.v1.Database database_; + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + @java.lang.Override + public boolean hasDatabase() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Database getDatabase() { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder() { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.protobuf.FieldMask updateMask_; + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.protobuf.FieldMask getUpdateMask() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + @java.lang.Override + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getDatabase()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDatabase()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UpdateDatabaseRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UpdateDatabaseRequest other = + (com.google.firestore.admin.v1.UpdateDatabaseRequest) obj; + + if (hasDatabase() != other.hasDatabase()) return false; + if (hasDatabase()) { + if (!getDatabase().equals(other.getDatabase())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasDatabase()) { + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.UpdateDatabaseRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.UpdateDatabase][google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateDatabaseRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UpdateDatabaseRequest) + com.google.firestore.admin.v1.UpdateDatabaseRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateDatabaseRequest.class, + com.google.firestore.admin.v1.UpdateDatabaseRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UpdateDatabaseRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDatabaseFieldBuilder(); + internalGetUpdateMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = null; + if (databaseBuilder_ != null) { + databaseBuilder_.dispose(); + databaseBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateDatabaseRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UpdateDatabaseRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseRequest build() { + com.google.firestore.admin.v1.UpdateDatabaseRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseRequest buildPartial() { + com.google.firestore.admin.v1.UpdateDatabaseRequest result = + new com.google.firestore.admin.v1.UpdateDatabaseRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UpdateDatabaseRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = databaseBuilder_ == null ? database_ : databaseBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UpdateDatabaseRequest) { + return mergeFrom((com.google.firestore.admin.v1.UpdateDatabaseRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UpdateDatabaseRequest other) { + if (other == com.google.firestore.admin.v1.UpdateDatabaseRequest.getDefaultInstance()) + return this; + if (other.hasDatabase()) { + mergeDatabase(other.getDatabase()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetDatabaseFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.admin.v1.Database database_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + databaseBuilder_; + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + public boolean hasDatabase() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + public com.google.firestore.admin.v1.Database getDatabase() { + if (databaseBuilder_ == null) { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } else { + return databaseBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDatabase(com.google.firestore.admin.v1.Database value) { + if (databaseBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + } else { + databaseBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDatabase(com.google.firestore.admin.v1.Database.Builder builderForValue) { + if (databaseBuilder_ == null) { + database_ = builderForValue.build(); + } else { + databaseBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeDatabase(com.google.firestore.admin.v1.Database value) { + if (databaseBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && database_ != null + && database_ != com.google.firestore.admin.v1.Database.getDefaultInstance()) { + getDatabaseBuilder().mergeFrom(value); + } else { + database_ = value; + } + } else { + databaseBuilder_.mergeFrom(value); + } + if (database_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearDatabase() { + bitField0_ = (bitField0_ & ~0x00000001); + database_ = null; + if (databaseBuilder_ != null) { + databaseBuilder_.dispose(); + databaseBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.Database.Builder getDatabaseBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetDatabaseFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder() { + if (databaseBuilder_ != null) { + return databaseBuilder_.getMessageOrBuilder(); + } else { + return database_ == null + ? com.google.firestore.admin.v1.Database.getDefaultInstance() + : database_; + } + } + + /** + * + * + *
+     * Required. The database to update.
+     * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder> + internalGetDatabaseFieldBuilder() { + if (databaseBuilder_ == null) { + databaseBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Database, + com.google.firestore.admin.v1.Database.Builder, + com.google.firestore.admin.v1.DatabaseOrBuilder>( + getDatabase(), getParentForChildren(), isClean()); + database_ = null; + } + return databaseBuilder_; + } + + private com.google.protobuf.FieldMask updateMask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + updateMaskBuilder_; + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + public com.google.protobuf.FieldMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetUpdateMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } + } + + /** + * + * + *
+     * The list of fields to be updated.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + internalGetUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UpdateDatabaseRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UpdateDatabaseRequest) + private static final com.google.firestore.admin.v1.UpdateDatabaseRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UpdateDatabaseRequest(); + } + + public static com.google.firestore.admin.v1.UpdateDatabaseRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateDatabaseRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateDatabaseRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequestOrBuilder.java new file mode 100644 index 000000000000..2d65fee2d765 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateDatabaseRequestOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface UpdateDatabaseRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UpdateDatabaseRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the database field is set. + */ + boolean hasDatabase(); + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The database. + */ + com.google.firestore.admin.v1.Database getDatabase(); + + /** + * + * + *
+   * Required. The database to update.
+   * 
+ * + * + * .google.firestore.admin.v1.Database database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.DatabaseOrBuilder getDatabaseOrBuilder(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + com.google.protobuf.FieldMask getUpdateMask(); + + /** + * + * + *
+   * The list of fields to be updated.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequest.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequest.java new file mode 100644 index 000000000000..8ebf47d1b749 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequest.java @@ -0,0 +1,992 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField].
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateFieldRequest} + */ +@com.google.protobuf.Generated +public final class UpdateFieldRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UpdateFieldRequest) + UpdateFieldRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UpdateFieldRequest"); + } + + // Use UpdateFieldRequest.newBuilder() to construct. + private UpdateFieldRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UpdateFieldRequest() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateFieldRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateFieldRequest.class, + com.google.firestore.admin.v1.UpdateFieldRequest.Builder.class); + } + + private int bitField0_; + public static final int FIELD_FIELD_NUMBER = 1; + private com.google.firestore.admin.v1.Field field_; + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.admin.v1.Field getField() { + return field_ == null ? com.google.firestore.admin.v1.Field.getDefaultInstance() : field_; + } + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.admin.v1.FieldOrBuilder getFieldOrBuilder() { + return field_ == null ? com.google.firestore.admin.v1.Field.getDefaultInstance() : field_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.protobuf.FieldMask updateMask_; + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.protobuf.FieldMask getUpdateMask() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + @java.lang.Override + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UpdateFieldRequest)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UpdateFieldRequest other = + (com.google.firestore.admin.v1.UpdateFieldRequest) obj; + + if (hasField() != other.hasField()) return false; + if (hasField()) { + if (!getField().equals(other.getField())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasField()) { + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.UpdateFieldRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField].
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UpdateFieldRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UpdateFieldRequest) + com.google.firestore.admin.v1.UpdateFieldRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateFieldRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UpdateFieldRequest.class, + com.google.firestore.admin.v1.UpdateFieldRequest.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UpdateFieldRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetFieldFieldBuilder(); + internalGetUpdateMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.FirestoreAdminProto + .internal_static_google_firestore_admin_v1_UpdateFieldRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateFieldRequest getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UpdateFieldRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateFieldRequest build() { + com.google.firestore.admin.v1.UpdateFieldRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateFieldRequest buildPartial() { + com.google.firestore.admin.v1.UpdateFieldRequest result = + new com.google.firestore.admin.v1.UpdateFieldRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UpdateFieldRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = fieldBuilder_ == null ? field_ : fieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UpdateFieldRequest) { + return mergeFrom((com.google.firestore.admin.v1.UpdateFieldRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UpdateFieldRequest other) { + if (other == com.google.firestore.admin.v1.UpdateFieldRequest.getDefaultInstance()) + return this; + if (other.hasField()) { + mergeField(other.getField()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.admin.v1.Field field_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder> + fieldBuilder_; + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the field field is set. + */ + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The field. + */ + public com.google.firestore.admin.v1.Field getField() { + if (fieldBuilder_ == null) { + return field_ == null ? com.google.firestore.admin.v1.Field.getDefaultInstance() : field_; + } else { + return fieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setField(com.google.firestore.admin.v1.Field value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + } else { + fieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setField(com.google.firestore.admin.v1.Field.Builder builderForValue) { + if (fieldBuilder_ == null) { + field_ = builderForValue.build(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeField(com.google.firestore.admin.v1.Field value) { + if (fieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && field_ != null + && field_ != com.google.firestore.admin.v1.Field.getDefaultInstance()) { + getFieldBuilder().mergeFrom(value); + } else { + field_ = value; + } + } else { + fieldBuilder_.mergeFrom(value); + } + if (field_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearField() { + bitField0_ = (bitField0_ & ~0x00000001); + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.Field.Builder getFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.admin.v1.FieldOrBuilder getFieldOrBuilder() { + if (fieldBuilder_ != null) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + return field_ == null ? com.google.firestore.admin.v1.Field.getDefaultInstance() : field_; + } + } + + /** + * + * + *
+     * Required. The field to be updated.
+     * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.Field, + com.google.firestore.admin.v1.Field.Builder, + com.google.firestore.admin.v1.FieldOrBuilder>( + getField(), getParentForChildren(), isClean()); + field_ = null; + } + return fieldBuilder_; + } + + private com.google.protobuf.FieldMask updateMask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + updateMaskBuilder_; + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + public com.google.protobuf.FieldMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetUpdateMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } + } + + /** + * + * + *
+     * A mask, relative to the field. If specified, only configuration specified
+     * by this field_mask will be updated in the field.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + internalGetUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UpdateFieldRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UpdateFieldRequest) + private static final com.google.firestore.admin.v1.UpdateFieldRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UpdateFieldRequest(); + } + + public static com.google.firestore.admin.v1.UpdateFieldRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateFieldRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UpdateFieldRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequestOrBuilder.java new file mode 100644 index 000000000000..923572e5edc3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UpdateFieldRequestOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/firestore_admin.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface UpdateFieldRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UpdateFieldRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The field. + */ + com.google.firestore.admin.v1.Field getField(); + + /** + * + * + *
+   * Required. The field to be updated.
+   * 
+ * + * .google.firestore.admin.v1.Field field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.admin.v1.FieldOrBuilder getFieldOrBuilder(); + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + * + * @return The updateMask. + */ + com.google.protobuf.FieldMask getUpdateMask(); + + /** + * + * + *
+   * A mask, relative to the field. If specified, only configuration specified
+   * by this field_mask will be updated in the field.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2; + */ + com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCreds.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCreds.java new file mode 100644 index 000000000000..90af1c644b27 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCreds.java @@ -0,0 +1,2770 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/user_creds.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * A Cloud Firestore User Creds.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UserCreds} + */ +@com.google.protobuf.Generated +public final class UserCreds extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UserCreds) + UserCredsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UserCreds"); + } + + // Use UserCreds.newBuilder() to construct. + private UserCreds(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UserCreds() { + name_ = ""; + state_ = 0; + securePassword_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UserCreds.class, + com.google.firestore.admin.v1.UserCreds.Builder.class); + } + + /** + * + * + *
+   * The state of the user creds (ENABLED or DISABLED).
+   * 
+ * + * Protobuf enum {@code google.firestore.admin.v1.UserCreds.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The default value. Should not be used.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + STATE_UNSPECIFIED(0), + /** + * + * + *
+     * The user creds are enabled.
+     * 
+ * + * ENABLED = 1; + */ + ENABLED(1), + /** + * + * + *
+     * The user creds are disabled.
+     * 
+ * + * DISABLED = 2; + */ + DISABLED(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "State"); + } + + /** + * + * + *
+     * The default value. Should not be used.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The user creds are enabled.
+     * 
+ * + * ENABLED = 1; + */ + public static final int ENABLED_VALUE = 1; + + /** + * + * + *
+     * The user creds are disabled.
+     * 
+ * + * DISABLED = 2; + */ + public static final int DISABLED_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static State valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static State forNumber(int value) { + switch (value) { + case 0: + return STATE_UNSPECIFIED; + case 1: + return ENABLED; + case 2: + return DISABLED; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public State findValueByNumber(int number) { + return State.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.admin.v1.UserCreds.getDescriptor().getEnumTypes().get(0); + } + + private static final State[] VALUES = values(); + + public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private State(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.admin.v1.UserCreds.State) + } + + public interface ResourceIdentityOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UserCreds.ResourceIdentity) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Output only. Principal identifier string.
+     * See: https://cloud.google.com/iam/docs/principal-identifiers
+     * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The principal. + */ + java.lang.String getPrincipal(); + + /** + * + * + *
+     * Output only. Principal identifier string.
+     * See: https://cloud.google.com/iam/docs/principal-identifiers
+     * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for principal. + */ + com.google.protobuf.ByteString getPrincipalBytes(); + } + + /** + * + * + *
+   * Describes a Resource Identity principal.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UserCreds.ResourceIdentity} + */ + public static final class ResourceIdentity extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.UserCreds.ResourceIdentity) + ResourceIdentityOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ResourceIdentity"); + } + + // Use ResourceIdentity.newBuilder() to construct. + private ResourceIdentity(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ResourceIdentity() { + principal_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.class, + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder.class); + } + + public static final int PRINCIPAL_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object principal_ = ""; + + /** + * + * + *
+     * Output only. Principal identifier string.
+     * See: https://cloud.google.com/iam/docs/principal-identifiers
+     * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The principal. + */ + @java.lang.Override + public java.lang.String getPrincipal() { + java.lang.Object ref = principal_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + principal_ = s; + return s; + } + } + + /** + * + * + *
+     * Output only. Principal identifier string.
+     * See: https://cloud.google.com/iam/docs/principal-identifiers
+     * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for principal. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPrincipalBytes() { + java.lang.Object ref = principal_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + principal_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(principal_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, principal_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(principal_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, principal_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UserCreds.ResourceIdentity)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UserCreds.ResourceIdentity other = + (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) obj; + + if (!getPrincipal().equals(other.getPrincipal())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PRINCIPAL_FIELD_NUMBER; + hash = (53 * hash) + getPrincipal().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Describes a Resource Identity principal.
+     * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UserCreds.ResourceIdentity} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UserCreds.ResourceIdentity) + com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.class, + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UserCreds.ResourceIdentity.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + principal_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity build() { + com.google.firestore.admin.v1.UserCreds.ResourceIdentity result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity buildPartial() { + com.google.firestore.admin.v1.UserCreds.ResourceIdentity result = + new com.google.firestore.admin.v1.UserCreds.ResourceIdentity(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UserCreds.ResourceIdentity result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.principal_ = principal_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UserCreds.ResourceIdentity) { + return mergeFrom((com.google.firestore.admin.v1.UserCreds.ResourceIdentity) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UserCreds.ResourceIdentity other) { + if (other == com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance()) + return this; + if (!other.getPrincipal().isEmpty()) { + principal_ = other.principal_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + principal_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object principal_ = ""; + + /** + * + * + *
+       * Output only. Principal identifier string.
+       * See: https://cloud.google.com/iam/docs/principal-identifiers
+       * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The principal. + */ + public java.lang.String getPrincipal() { + java.lang.Object ref = principal_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + principal_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Output only. Principal identifier string.
+       * See: https://cloud.google.com/iam/docs/principal-identifiers
+       * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for principal. + */ + public com.google.protobuf.ByteString getPrincipalBytes() { + java.lang.Object ref = principal_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + principal_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Output only. Principal identifier string.
+       * See: https://cloud.google.com/iam/docs/principal-identifiers
+       * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The principal to set. + * @return This builder for chaining. + */ + public Builder setPrincipal(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + principal_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Principal identifier string.
+       * See: https://cloud.google.com/iam/docs/principal-identifiers
+       * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearPrincipal() { + principal_ = getDefaultInstance().getPrincipal(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * Output only. Principal identifier string.
+       * See: https://cloud.google.com/iam/docs/principal-identifiers
+       * 
+ * + * string principal = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for principal to set. + * @return This builder for chaining. + */ + public Builder setPrincipalBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + principal_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UserCreds.ResourceIdentity) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UserCreds.ResourceIdentity) + private static final com.google.firestore.admin.v1.UserCreds.ResourceIdentity DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UserCreds.ResourceIdentity(); + } + + public static com.google.firestore.admin.v1.UserCreds.ResourceIdentity getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ResourceIdentity parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + private int userCredsIdentityCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object userCredsIdentity_; + + public enum UserCredsIdentityCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + RESOURCE_IDENTITY(6), + USERCREDSIDENTITY_NOT_SET(0); + private final int value; + + private UserCredsIdentityCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static UserCredsIdentityCase valueOf(int value) { + return forNumber(value); + } + + public static UserCredsIdentityCase forNumber(int value) { + switch (value) { + case 6: + return RESOURCE_IDENTITY; + case 0: + return USERCREDSIDENTITY_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public UserCredsIdentityCase getUserCredsIdentityCase() { + return UserCredsIdentityCase.forNumber(userCredsIdentityCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Identifier. The resource name of the UserCreds.
+   * Format:
+   * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Identifier. The resource name of the UserCreds.
+   * Format:
+   * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int STATE_FIELD_NUMBER = 4; + private int state_ = 0; + + /** + * + * + *
+   * Output only. Whether the user creds are enabled or disabled. Defaults to
+   * ENABLED on creation.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * Output only. Whether the user creds are enabled or disabled. Defaults to
+   * ENABLED on creation.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.State getState() { + com.google.firestore.admin.v1.UserCreds.State result = + com.google.firestore.admin.v1.UserCreds.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.UserCreds.State.UNRECOGNIZED : result; + } + + public static final int SECURE_PASSWORD_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object securePassword_ = ""; + + /** + * + * + *
+   * Output only. The plaintext server-generated password for the user creds.
+   * Only populated in responses for CreateUserCreds and ResetUserPassword.
+   * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The securePassword. + */ + @java.lang.Override + public java.lang.String getSecurePassword() { + java.lang.Object ref = securePassword_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + securePassword_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The plaintext server-generated password for the user creds.
+   * Only populated in responses for CreateUserCreds and ResetUserPassword.
+   * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for securePassword. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSecurePasswordBytes() { + java.lang.Object ref = securePassword_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + securePassword_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int RESOURCE_IDENTITY_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return Whether the resourceIdentity field is set. + */ + @java.lang.Override + public boolean hasResourceIdentity() { + return userCredsIdentityCase_ == 6; + } + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return The resourceIdentity. + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity getResourceIdentity() { + if (userCredsIdentityCase_ == 6) { + return (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_; + } + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder + getResourceIdentityOrBuilder() { + if (userCredsIdentityCase_ == 6) { + return (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_; + } + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getUpdateTime()); + } + if (state_ != com.google.firestore.admin.v1.UserCreds.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(4, state_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(securePassword_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, securePassword_); + } + if (userCredsIdentityCase_ == 6) { + output.writeMessage( + 6, (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getUpdateTime()); + } + if (state_ != com.google.firestore.admin.v1.UserCreds.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(4, state_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(securePassword_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, securePassword_); + } + if (userCredsIdentityCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.UserCreds)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.UserCreds other = (com.google.firestore.admin.v1.UserCreds) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (state_ != other.state_) return false; + if (!getSecurePassword().equals(other.getSecurePassword())) return false; + if (!getUserCredsIdentityCase().equals(other.getUserCredsIdentityCase())) return false; + switch (userCredsIdentityCase_) { + case 6: + if (!getResourceIdentity().equals(other.getResourceIdentity())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (37 * hash) + SECURE_PASSWORD_FIELD_NUMBER; + hash = (53 * hash) + getSecurePassword().hashCode(); + switch (userCredsIdentityCase_) { + case 6: + hash = (37 * hash) + RESOURCE_IDENTITY_FIELD_NUMBER; + hash = (53 * hash) + getResourceIdentity().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.UserCreds parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.UserCreds prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Cloud Firestore User Creds.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.UserCreds} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.UserCreds) + com.google.firestore.admin.v1.UserCredsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.UserCreds.class, + com.google.firestore.admin.v1.UserCreds.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.UserCreds.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCreateTimeFieldBuilder(); + internalGetUpdateTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + state_ = 0; + securePassword_ = ""; + if (resourceIdentityBuilder_ != null) { + resourceIdentityBuilder_.clear(); + } + userCredsIdentityCase_ = 0; + userCredsIdentity_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.UserCredsProto + .internal_static_google_firestore_admin_v1_UserCreds_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds getDefaultInstanceForType() { + return com.google.firestore.admin.v1.UserCreds.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds build() { + com.google.firestore.admin.v1.UserCreds result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds buildPartial() { + com.google.firestore.admin.v1.UserCreds result = + new com.google.firestore.admin.v1.UserCreds(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.UserCreds result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.state_ = state_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.securePassword_ = securePassword_; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.admin.v1.UserCreds result) { + result.userCredsIdentityCase_ = userCredsIdentityCase_; + result.userCredsIdentity_ = this.userCredsIdentity_; + if (userCredsIdentityCase_ == 6 && resourceIdentityBuilder_ != null) { + result.userCredsIdentity_ = resourceIdentityBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.UserCreds) { + return mergeFrom((com.google.firestore.admin.v1.UserCreds) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.UserCreds other) { + if (other == com.google.firestore.admin.v1.UserCreds.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.state_ != 0) { + setStateValue(other.getStateValue()); + } + if (!other.getSecurePassword().isEmpty()) { + securePassword_ = other.securePassword_; + bitField0_ |= 0x00000010; + onChanged(); + } + switch (other.getUserCredsIdentityCase()) { + case RESOURCE_IDENTITY: + { + mergeResourceIdentity(other.getResourceIdentity()); + break; + } + case USERCREDSIDENTITY_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 42: + { + securePassword_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetResourceIdentityFieldBuilder().getBuilder(), extensionRegistry); + userCredsIdentityCase_ = 6; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int userCredsIdentityCase_ = 0; + private java.lang.Object userCredsIdentity_; + + public UserCredsIdentityCase getUserCredsIdentityCase() { + return UserCredsIdentityCase.forNumber(userCredsIdentityCase_); + } + + public Builder clearUserCredsIdentity() { + userCredsIdentityCase_ = 0; + userCredsIdentity_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Identifier. The resource name of the UserCreds.
+     * Format:
+     * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Identifier. The resource name of the UserCreds.
+     * Format:
+     * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Identifier. The resource name of the UserCreds.
+     * Format:
+     * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Identifier. The resource name of the UserCreds.
+     * Format:
+     * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Identifier. The resource name of the UserCreds.
+     * Format:
+     * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * Output only. The time the user creds were created.
+     * 
+ * + * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * Output only. The time the user creds were last updated.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private int state_ = 0; + + /** + * + * + *
+     * Output only. Whether the user creds are enabled or disabled. Defaults to
+     * ENABLED on creation.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * Output only. Whether the user creds are enabled or disabled. Defaults to
+     * ENABLED on creation.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The enum numeric value on the wire for state to set. + * @return This builder for chaining. + */ + public Builder setStateValue(int value) { + state_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Whether the user creds are enabled or disabled. Defaults to
+     * ENABLED on creation.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.State getState() { + com.google.firestore.admin.v1.UserCreds.State result = + com.google.firestore.admin.v1.UserCreds.State.forNumber(state_); + return result == null ? com.google.firestore.admin.v1.UserCreds.State.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Output only. Whether the user creds are enabled or disabled. Defaults to
+     * ENABLED on creation.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.firestore.admin.v1.UserCreds.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Whether the user creds are enabled or disabled. Defaults to
+     * ENABLED on creation.
+     * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000008); + state_ = 0; + onChanged(); + return this; + } + + private java.lang.Object securePassword_ = ""; + + /** + * + * + *
+     * Output only. The plaintext server-generated password for the user creds.
+     * Only populated in responses for CreateUserCreds and ResetUserPassword.
+     * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The securePassword. + */ + public java.lang.String getSecurePassword() { + java.lang.Object ref = securePassword_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + securePassword_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The plaintext server-generated password for the user creds.
+     * Only populated in responses for CreateUserCreds and ResetUserPassword.
+     * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for securePassword. + */ + public com.google.protobuf.ByteString getSecurePasswordBytes() { + java.lang.Object ref = securePassword_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + securePassword_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The plaintext server-generated password for the user creds.
+     * Only populated in responses for CreateUserCreds and ResetUserPassword.
+     * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The securePassword to set. + * @return This builder for chaining. + */ + public Builder setSecurePassword(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + securePassword_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The plaintext server-generated password for the user creds.
+     * Only populated in responses for CreateUserCreds and ResetUserPassword.
+     * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearSecurePassword() { + securePassword_ = getDefaultInstance().getSecurePassword(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The plaintext server-generated password for the user creds.
+     * Only populated in responses for CreateUserCreds and ResetUserPassword.
+     * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for securePassword to set. + * @return This builder for chaining. + */ + public Builder setSecurePasswordBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + securePassword_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds.ResourceIdentity, + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder, + com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder> + resourceIdentityBuilder_; + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return Whether the resourceIdentity field is set. + */ + @java.lang.Override + public boolean hasResourceIdentity() { + return userCredsIdentityCase_ == 6; + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return The resourceIdentity. + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity getResourceIdentity() { + if (resourceIdentityBuilder_ == null) { + if (userCredsIdentityCase_ == 6) { + return (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_; + } + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } else { + if (userCredsIdentityCase_ == 6) { + return resourceIdentityBuilder_.getMessage(); + } + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + public Builder setResourceIdentity( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity value) { + if (resourceIdentityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + userCredsIdentity_ = value; + onChanged(); + } else { + resourceIdentityBuilder_.setMessage(value); + } + userCredsIdentityCase_ = 6; + return this; + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + public Builder setResourceIdentity( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder builderForValue) { + if (resourceIdentityBuilder_ == null) { + userCredsIdentity_ = builderForValue.build(); + onChanged(); + } else { + resourceIdentityBuilder_.setMessage(builderForValue.build()); + } + userCredsIdentityCase_ = 6; + return this; + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + public Builder mergeResourceIdentity( + com.google.firestore.admin.v1.UserCreds.ResourceIdentity value) { + if (resourceIdentityBuilder_ == null) { + if (userCredsIdentityCase_ == 6 + && userCredsIdentity_ + != com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance()) { + userCredsIdentity_ = + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.newBuilder( + (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_) + .mergeFrom(value) + .buildPartial(); + } else { + userCredsIdentity_ = value; + } + onChanged(); + } else { + if (userCredsIdentityCase_ == 6) { + resourceIdentityBuilder_.mergeFrom(value); + } else { + resourceIdentityBuilder_.setMessage(value); + } + } + userCredsIdentityCase_ = 6; + return this; + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + public Builder clearResourceIdentity() { + if (resourceIdentityBuilder_ == null) { + if (userCredsIdentityCase_ == 6) { + userCredsIdentityCase_ = 0; + userCredsIdentity_ = null; + onChanged(); + } + } else { + if (userCredsIdentityCase_ == 6) { + userCredsIdentityCase_ = 0; + userCredsIdentity_ = null; + } + resourceIdentityBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + public com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder + getResourceIdentityBuilder() { + return internalGetResourceIdentityFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder + getResourceIdentityOrBuilder() { + if ((userCredsIdentityCase_ == 6) && (resourceIdentityBuilder_ != null)) { + return resourceIdentityBuilder_.getMessageOrBuilder(); + } else { + if (userCredsIdentityCase_ == 6) { + return (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_; + } + return com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Resource Identity descriptor.
+     * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds.ResourceIdentity, + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder, + com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder> + internalGetResourceIdentityFieldBuilder() { + if (resourceIdentityBuilder_ == null) { + if (!(userCredsIdentityCase_ == 6)) { + userCredsIdentity_ = + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.getDefaultInstance(); + } + resourceIdentityBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.admin.v1.UserCreds.ResourceIdentity, + com.google.firestore.admin.v1.UserCreds.ResourceIdentity.Builder, + com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder>( + (com.google.firestore.admin.v1.UserCreds.ResourceIdentity) userCredsIdentity_, + getParentForChildren(), + isClean()); + userCredsIdentity_ = null; + } + userCredsIdentityCase_ = 6; + onChanged(); + return resourceIdentityBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.UserCreds) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.UserCreds) + private static final com.google.firestore.admin.v1.UserCreds DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.UserCreds(); + } + + public static com.google.firestore.admin.v1.UserCreds getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UserCreds parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.UserCreds getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsName.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsName.java new file mode 100644 index 000000000000..fdd08532a0b9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsName.java @@ -0,0 +1,223 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.admin.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +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. +@Generated("by gapic-generator-java") +public class UserCredsName implements ResourceName { + private static final PathTemplate PROJECT_DATABASE_USER_CREDS = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/userCreds/{user_creds}"); + private volatile Map fieldValuesMap; + private final String project; + private final String database; + private final String userCreds; + + @Deprecated + protected UserCredsName() { + project = null; + database = null; + userCreds = null; + } + + private UserCredsName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + userCreds = Preconditions.checkNotNull(builder.getUserCreds()); + } + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getUserCreds() { + return userCreds; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static UserCredsName of(String project, String database, String userCreds) { + return newBuilder().setProject(project).setDatabase(database).setUserCreds(userCreds).build(); + } + + public static String format(String project, String database, String userCreds) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setUserCreds(userCreds) + .build() + .toString(); + } + + public static UserCredsName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_DATABASE_USER_CREDS.validatedMatch( + formattedString, "UserCredsName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("user_creds")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (UserCredsName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_DATABASE_USER_CREDS.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (userCreds != null) { + fieldMapBuilder.put("user_creds", userCreds); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_DATABASE_USER_CREDS.instantiate( + "project", project, "database", database, "user_creds", userCreds); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + UserCredsName that = ((UserCredsName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.database, that.database) + && Objects.equals(this.userCreds, that.userCreds); + } + 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(userCreds); + return h; + } + + /** Builder for projects/{project}/databases/{database}/userCreds/{user_creds}. */ + public static class Builder { + private String project; + private String database; + private String userCreds; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getUserCreds() { + return userCreds; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setUserCreds(String userCreds) { + this.userCreds = userCreds; + return this; + } + + private Builder(UserCredsName userCredsName) { + this.project = userCredsName.project; + this.database = userCredsName.database; + this.userCreds = userCredsName.userCreds; + } + + public UserCredsName build() { + return new UserCredsName(this); + } + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsOrBuilder.java new file mode 100644 index 000000000000..38d063e65ddf --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsOrBuilder.java @@ -0,0 +1,237 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/user_creds.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface UserCredsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.UserCreds) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Identifier. The resource name of the UserCreds.
+   * Format:
+   * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Identifier. The resource name of the UserCreds.
+   * Format:
+   * `projects/{project}/databases/{database}/userCreds/{user_creds}`
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * Output only. The time the user creds were created.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * Output only. The time the user creds were last updated.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. Whether the user creds are enabled or disabled. Defaults to
+   * ENABLED on creation.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * Output only. Whether the user creds are enabled or disabled. Defaults to
+   * ENABLED on creation.
+   * 
+ * + * + * .google.firestore.admin.v1.UserCreds.State state = 4 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.firestore.admin.v1.UserCreds.State getState(); + + /** + * + * + *
+   * Output only. The plaintext server-generated password for the user creds.
+   * Only populated in responses for CreateUserCreds and ResetUserPassword.
+   * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The securePassword. + */ + java.lang.String getSecurePassword(); + + /** + * + * + *
+   * Output only. The plaintext server-generated password for the user creds.
+   * Only populated in responses for CreateUserCreds and ResetUserPassword.
+   * 
+ * + * string secure_password = 5 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for securePassword. + */ + com.google.protobuf.ByteString getSecurePasswordBytes(); + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return Whether the resourceIdentity field is set. + */ + boolean hasResourceIdentity(); + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + * + * @return The resourceIdentity. + */ + com.google.firestore.admin.v1.UserCreds.ResourceIdentity getResourceIdentity(); + + /** + * + * + *
+   * Resource Identity descriptor.
+   * 
+ * + * .google.firestore.admin.v1.UserCreds.ResourceIdentity resource_identity = 6; + */ + com.google.firestore.admin.v1.UserCreds.ResourceIdentityOrBuilder getResourceIdentityOrBuilder(); + + com.google.firestore.admin.v1.UserCreds.UserCredsIdentityCase getUserCredsIdentityCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsProto.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsProto.java new file mode 100644 index 000000000000..dbacdf04cda1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/UserCredsProto.java @@ -0,0 +1,129 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/user_creds.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public final class UserCredsProto extends com.google.protobuf.GeneratedFile { + private UserCredsProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UserCredsProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UserCreds_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UserCreds_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n*google/firestore/admin/v1/user_creds.p" + + "roto\022\031google.firestore.admin.v1\032\037google/" + + "api/field_behavior.proto\032\031google/api/res" + + "ource.proto\032\037google/protobuf/timestamp.p" + + "roto\"\267\004\n\tUserCreds\022\021\n\004name\030\001 \001(\tB\003\340A\010\0224\n" + + "\013create_time\030\002 \001(\0132\032.google.protobuf.Tim" + + "estampB\003\340A\003\0224\n\013update_time\030\003 \001(\0132\032.googl" + + "e.protobuf.TimestampB\003\340A\003\022>\n\005state\030\004 \001(\016" + + "2*.google.firestore.admin.v1.UserCreds.S" + + "tateB\003\340A\003\022\034\n\017secure_password\030\005 \001(\tB\003\340A\003\022" + + "R\n\021resource_identity\030\006 \001(\01325.google.fire" + + "store.admin.v1.UserCreds.ResourceIdentit" + + "yH\000\032*\n\020ResourceIdentity\022\026\n\tprincipal\030\001 \001" + + "(\tB\003\340A\003\"9\n\005State\022\025\n\021STATE_UNSPECIFIED\020\000\022" + + "\013\n\007ENABLED\020\001\022\014\n\010DISABLED\020\002:}\352Az\n\"firesto" + + "re.googleapis.com/UserCreds\022>projects/{p" + + "roject}/databases/{database}/userCreds/{" + + "user_creds}*\tuserCreds2\tuserCredsB\023\n\021Use" + + "rCredsIdentityB\335\001\n\035com.google.firestore." + + "admin.v1B\016UserCredsProtoP\001Z9cloud.google" + + ".com/go/firestore/apiv1/admin/adminpb;ad" + + "minpb\242\002\004GCFS\252\002\037Google.Cloud.Firestore.Ad" + + "min.V1\312\002\037Google\\Cloud\\Firestore\\Admin\\V1" + + "\352\002#Google::Cloud::Firestore::Admin::V1b\006" + + "proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_admin_v1_UserCreds_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_admin_v1_UserCreds_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UserCreds_descriptor, + new java.lang.String[] { + "Name", + "CreateTime", + "UpdateTime", + "State", + "SecurePassword", + "ResourceIdentity", + "UserCredsIdentity", + }); + internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor = + internal_static_google_firestore_admin_v1_UserCreds_descriptor.getNestedType(0); + internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_admin_v1_UserCreds_ResourceIdentity_descriptor, + new java.lang.String[] { + "Principal", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java new file mode 100644 index 000000000000..c0b72ca001eb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrence.java @@ -0,0 +1,577 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +/** + * + * + *
+ * Represents a recurring schedule that runs on a specified day of the week.
+ *
+ * The time zone is UTC.
+ * 
+ * + * Protobuf type {@code google.firestore.admin.v1.WeeklyRecurrence} + */ +@com.google.protobuf.Generated +public final class WeeklyRecurrence extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.admin.v1.WeeklyRecurrence) + WeeklyRecurrenceOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "WeeklyRecurrence"); + } + + // Use WeeklyRecurrence.newBuilder() to construct. + private WeeklyRecurrence(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private WeeklyRecurrence() { + day_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.WeeklyRecurrence.class, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder.class); + } + + public static final int DAY_FIELD_NUMBER = 2; + private int day_ = 0; + + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + @java.lang.Override + public int getDayValue() { + return day_; + } + + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + @java.lang.Override + public com.google.type.DayOfWeek getDay() { + com.google.type.DayOfWeek result = com.google.type.DayOfWeek.forNumber(day_); + return result == null ? com.google.type.DayOfWeek.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (day_ != com.google.type.DayOfWeek.DAY_OF_WEEK_UNSPECIFIED.getNumber()) { + output.writeEnum(2, day_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (day_ != com.google.type.DayOfWeek.DAY_OF_WEEK_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, day_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.admin.v1.WeeklyRecurrence)) { + return super.equals(obj); + } + com.google.firestore.admin.v1.WeeklyRecurrence other = + (com.google.firestore.admin.v1.WeeklyRecurrence) obj; + + if (day_ != other.day_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DAY_FIELD_NUMBER; + hash = (53 * hash) + day_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.admin.v1.WeeklyRecurrence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Represents a recurring schedule that runs on a specified day of the week.
+   *
+   * The time zone is UTC.
+   * 
+ * + * Protobuf type {@code google.firestore.admin.v1.WeeklyRecurrence} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.admin.v1.WeeklyRecurrence) + com.google.firestore.admin.v1.WeeklyRecurrenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.admin.v1.WeeklyRecurrence.class, + com.google.firestore.admin.v1.WeeklyRecurrence.Builder.class); + } + + // Construct using com.google.firestore.admin.v1.WeeklyRecurrence.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + day_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.admin.v1.ScheduleProto + .internal_static_google_firestore_admin_v1_WeeklyRecurrence_descriptor; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstanceForType() { + return com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence build() { + com.google.firestore.admin.v1.WeeklyRecurrence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence buildPartial() { + com.google.firestore.admin.v1.WeeklyRecurrence result = + new com.google.firestore.admin.v1.WeeklyRecurrence(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.admin.v1.WeeklyRecurrence result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.day_ = day_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.admin.v1.WeeklyRecurrence) { + return mergeFrom((com.google.firestore.admin.v1.WeeklyRecurrence) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.admin.v1.WeeklyRecurrence other) { + if (other == com.google.firestore.admin.v1.WeeklyRecurrence.getDefaultInstance()) return this; + if (other.day_ != 0) { + setDayValue(other.getDayValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 16: + { + day_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int day_ = 0; + + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + @java.lang.Override + public int getDayValue() { + return day_; + } + + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @param value The enum numeric value on the wire for day to set. + * @return This builder for chaining. + */ + public Builder setDayValue(int value) { + day_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + @java.lang.Override + public com.google.type.DayOfWeek getDay() { + com.google.type.DayOfWeek result = com.google.type.DayOfWeek.forNumber(day_); + return result == null ? com.google.type.DayOfWeek.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @param value The day to set. + * @return This builder for chaining. + */ + public Builder setDay(com.google.type.DayOfWeek value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + day_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The day of week to run.
+     *
+     * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+     * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return This builder for chaining. + */ + public Builder clearDay() { + bitField0_ = (bitField0_ & ~0x00000001); + day_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.admin.v1.WeeklyRecurrence) + } + + // @@protoc_insertion_point(class_scope:google.firestore.admin.v1.WeeklyRecurrence) + private static final com.google.firestore.admin.v1.WeeklyRecurrence DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.admin.v1.WeeklyRecurrence(); + } + + public static com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public WeeklyRecurrence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.admin.v1.WeeklyRecurrence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java new file mode 100644 index 000000000000..71ce49c0b860 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/java/com/google/firestore/admin/v1/WeeklyRecurrenceOrBuilder.java @@ -0,0 +1,58 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/admin/v1/schedule.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.admin.v1; + +@com.google.protobuf.Generated +public interface WeeklyRecurrenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.admin.v1.WeeklyRecurrence) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The enum numeric value on the wire for day. + */ + int getDayValue(); + + /** + * + * + *
+   * The day of week to run.
+   *
+   * DAY_OF_WEEK_UNSPECIFIED is not allowed.
+   * 
+ * + * .google.type.DayOfWeek day = 2; + * + * @return The day. + */ + com.google.type.DayOfWeek getDay(); +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto new file mode 100644 index 000000000000..613eb1184b6d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/backup.proto @@ -0,0 +1,107 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "BackupProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A Backup of a Cloud Firestore Database. +// +// The backup contains all documents and index configurations for the given +// database at a specific point in time. +message Backup { + option (google.api.resource) = { + type: "firestore.googleapis.com/Backup" + pattern: "projects/{project}/locations/{location}/backups/{backup}" + }; + + // Backup specific statistics. + message Stats { + // Output only. Summation of the size of all documents and index entries in + // the backup, measured in bytes. + int64 size_bytes = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The total number of documents contained in the backup. + int64 document_count = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The total number of index entries contained in the backup. + int64 index_count = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Indicate the current state of the backup. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The pending backup is still being created. Operations on the + // backup will be rejected in this state. + CREATING = 1; + + // The backup is complete and ready to use. + READY = 2; + + // The backup is not available at this moment. + NOT_AVAILABLE = 3; + } + + // Output only. The unique resource name of the Backup. + // + // Format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Name of the Firestore database that the backup is from. + // + // Format is `projects/{project}/databases/{database}`. + string database = 2 [ + (google.api.field_behavior) = OUTPUT_ONLY, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Output only. The system-generated UUID4 for the Firestore database that the + // backup is from. + string database_uid = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The backup contains an externally consistent copy of the + // database at this time. + google.protobuf.Timestamp snapshot_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup expires. + google.protobuf.Timestamp expire_time = 4 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Statistics about the backup. + // + // This data only becomes available after the backup is fully materialized to + // secondary storage. This field will be empty till then. + Stats stats = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The current state of the backup. + State state = 8 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto new file mode 100644 index 000000000000..39f69e7e9071 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/database.proto @@ -0,0 +1,403 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/firestore/admin/v1/realtime_updates.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "DatabaseProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/Operation" + pattern: "projects/{project}/databases/{database}/operations/{operation}" +}; + +// A Cloud Firestore Database. +message Database { + option (google.api.resource) = { + type: "firestore.googleapis.com/Database" + pattern: "projects/{project}/databases/{database}" + style: DECLARATIVE_FRIENDLY + }; + + // The type of the database. + // See https://cloud.google.com/datastore/docs/firestore-or-datastore for + // information about how to choose. + // + // Mode changes are only allowed if the database is empty. + enum DatabaseType { + // Not used. + DATABASE_TYPE_UNSPECIFIED = 0; + + // Firestore Native Mode + FIRESTORE_NATIVE = 1; + + // Firestore in Datastore Mode. + DATASTORE_MODE = 2; + } + + // The type of concurrency control mode for transactions. + enum ConcurrencyMode { + // Not used. + CONCURRENCY_MODE_UNSPECIFIED = 0; + + // Use optimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. + // + // This is the default setting for Cloud Firestore Enterprise Edition + // databases. + OPTIMISTIC = 1; + + // Use pessimistic concurrency control by default. This mode is available + // for Cloud Firestore databases. + // + // This is the default setting for Cloud Firestore Standard Edition + // databases. + PESSIMISTIC = 2; + + // Use optimistic concurrency control with entity groups by default. + // + // This mode is enabled for some databases that were automatically upgraded + // from Cloud Datastore to Cloud Firestore with Datastore Mode. + // + // It is not recommended for any new databases, and not supported for + // Firestore Native databases. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // Point In Time Recovery feature enablement. + enum PointInTimeRecoveryEnablement { + // Not used. + POINT_IN_TIME_RECOVERY_ENABLEMENT_UNSPECIFIED = 0; + + // Reads are supported on selected versions of the data from within the past + // 7 days: + // + // * Reads against any timestamp within the past hour + // * Reads against 1-minute snapshots beyond 1 hour and within 7 days + // + // `version_retention_period` and `earliest_version_time` can be + // used to determine the supported versions. + POINT_IN_TIME_RECOVERY_ENABLED = 1; + + // Reads are supported on any version of the data from within the past 1 + // hour. + POINT_IN_TIME_RECOVERY_DISABLED = 2; + } + + // The type of App Engine integration mode. + enum AppEngineIntegrationMode { + // Not used. + APP_ENGINE_INTEGRATION_MODE_UNSPECIFIED = 0; + + // If an App Engine application exists in the same region as this database, + // App Engine configuration will impact this database. This includes + // disabling of the application & database, as well as disabling writes to + // the database. + ENABLED = 1; + + // App Engine has no effect on the ability of this database to serve + // requests. + // + // This is the default setting for databases created with the Firestore API. + DISABLED = 2; + } + + // The delete protection state of the database. + enum DeleteProtectionState { + // The default value. Delete protection type is not specified + DELETE_PROTECTION_STATE_UNSPECIFIED = 0; + + // Delete protection is disabled + DELETE_PROTECTION_DISABLED = 1; + + // Delete protection is enabled + DELETE_PROTECTION_ENABLED = 2; + } + + // The CMEK (Customer Managed Encryption Key) configuration for a Firestore + // database. If not present, the database is secured by the default Google + // encryption key. + message CmekConfig { + // Required. Only keys in the same location as this database are allowed to + // be used for encryption. + // + // For Firestore's nam5 multi-region, this corresponds to Cloud KMS + // multi-region us. For Firestore's eur3 multi-region, this corresponds to + // Cloud KMS multi-region europe. See + // https://cloud.google.com/kms/docs/locations. + // + // The expected format is + // `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. Currently in-use [KMS key + // versions](https://cloud.google.com/kms/docs/resource-hierarchy#key_versions). + // During [key rotation](https://cloud.google.com/kms/docs/key-rotation), + // there can be multiple in-use key versions. + // + // The expected format is + // `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}/cryptoKeyVersions/{key_version}`. + repeated string active_key_version = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Information about the provenance of this database. + message SourceInfo { + // Information about a backup that was used to restore a database. + message BackupSource { + // The resource name of the backup that was used to restore this + // database. Format: + // `projects/{project}/locations/{location}/backups/{backup}`. + string backup = 1 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + }]; + } + + // The source from which this database is derived. + oneof source { + // If set, this database was restored from the specified backup (or a + // snapshot thereof). + BackupSource backup = 1; + } + + // The associated long-running operation. This field may not be set after + // the operation has completed. Format: + // `projects/{project}/databases/{database}/operations/{operation}`. + string operation = 3 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Operation" + }]; + } + + // Encryption configuration for a new database being created from another + // source. + // + // The source could be a [Backup][google.firestore.admin.v1.Backup] or a + // [PitrSnapshot][google.firestore.admin.v1.PitrSnapshot]. + message EncryptionConfig { + // The configuration options for using Google default encryption. + message GoogleDefaultEncryptionOptions {} + + // The configuration options for using the same encryption method as the + // source. + message SourceEncryptionOptions {} + + // The configuration options for using CMEK (Customer Managed Encryption + // Key) encryption. + message CustomerManagedEncryptionOptions { + // Required. Only keys in the same location as the database are allowed to + // be used for encryption. + // + // For Firestore's nam5 multi-region, this corresponds to Cloud KMS + // multi-region us. For Firestore's eur3 multi-region, this corresponds to + // Cloud KMS multi-region europe. See + // https://cloud.google.com/kms/docs/locations. + // + // The expected format is + // `projects/{project_id}/locations/{kms_location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. + string kms_key_name = 1 [(google.api.field_behavior) = REQUIRED]; + } + + // The method for encrypting the database. + oneof encryption_type { + // Use Google default encryption. + GoogleDefaultEncryptionOptions google_default_encryption = 1; + + // The database will use the same encryption configuration as the source. + SourceEncryptionOptions use_source_encryption = 2; + + // Use Customer Managed Encryption Keys (CMEK) for encryption. + CustomerManagedEncryptionOptions customer_managed_encryption = 3; + } + } + + // The edition of the database. + enum DatabaseEdition { + // Not used. + DATABASE_EDITION_UNSPECIFIED = 0; + + // Standard edition. + // + // This is the default setting if not specified. + STANDARD = 1; + + // Enterprise edition. + ENTERPRISE = 2; + } + + // The data access mode. + enum DataAccessMode { + // Not Used. + DATA_ACCESS_MODE_UNSPECIFIED = 0; + + // Accessing the database through the API is allowed. + DATA_ACCESS_MODE_ENABLED = 1; + + // Accessing the database through the API is disallowed. + DATA_ACCESS_MODE_DISABLED = 2; + } + + // The resource name of the Database. + // Format: `projects/{project}/databases/{database}` + string name = 1; + + // Output only. The system-generated UUID4 for this Database. + string uid = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this database was created. Databases + // created before 2016 do not populate create_time. + google.protobuf.Timestamp create_time = 5 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this database was most recently + // updated. Note this only includes updates to the database resource and not + // data contained by the database. + google.protobuf.Timestamp update_time = 6 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this database was deleted. Only set if + // the database has been deleted. + google.protobuf.Timestamp delete_time = 7 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // The location of the database. Available locations are listed at + // https://cloud.google.com/firestore/docs/locations. + string location_id = 9; + + // The type of the database. + // See https://cloud.google.com/datastore/docs/firestore-or-datastore for + // information about how to choose. + DatabaseType type = 10; + + // The concurrency control mode to use for this database. + // + // If unspecified in a CreateDatabase request, this will default based on the + // database edition: Optimistic for Enterprise and Pessimistic for all other + // databases. + ConcurrencyMode concurrency_mode = 15; + + // Output only. The period during which past versions of data are retained in + // the database. + // + // Any [read][google.firestore.v1.GetDocumentRequest.read_time] + // or [query][google.firestore.v1.ListDocumentsRequest.read_time] can specify + // a `read_time` within this window, and will read the state of the database + // at that time. + // + // If the PITR feature is enabled, the retention period is 7 days. Otherwise, + // the retention period is 1 hour. + google.protobuf.Duration version_retention_period = 17 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The earliest timestamp at which older versions of the data can + // be read from the database. See [version_retention_period] above; this field + // is populated with `now - version_retention_period`. + // + // This value is continuously updated, and becomes stale the moment it is + // queried. If you are using this value to recover data, make sure to account + // for the time from the moment when the value is queried to the moment when + // you initiate the recovery. + google.protobuf.Timestamp earliest_version_time = 18 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Whether to enable the PITR feature on this database. + PointInTimeRecoveryEnablement point_in_time_recovery_enablement = 21; + + // The App Engine integration mode to use for this database. + AppEngineIntegrationMode app_engine_integration_mode = 19; + + // Output only. The key_prefix for this database. This key_prefix is used, in + // combination with the project ID ("~") to construct + // the application ID that is returned from the Cloud Datastore APIs in Google + // App Engine first generation runtimes. + // + // This value may be empty in which case the appid to use for URL-encoded keys + // is the project_id (eg: foo instead of v~foo). + string key_prefix = 20 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // State of delete protection for the database. + DeleteProtectionState delete_protection_state = 22; + + // Optional. Presence indicates CMEK is enabled for this database. + CmekConfig cmek_config = 23 [(google.api.field_behavior) = OPTIONAL]; + + // Output only. The database resource's prior database ID. This field is only + // populated for deleted databases. + string previous_id = 25 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Information about the provenance of this database. + SourceInfo source_info = 26 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Optional. Input only. Immutable. Tag keys/values directly bound to this + // resource. For example: + // "123/environment": "production", + // "123/costCenter": "marketing" + map tags = 29 [ + (google.api.field_behavior) = INPUT_ONLY, + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OPTIONAL + ]; + + // Output only. Background: Free tier is the ability of a Firestore database + // to use a small amount of resources every day without being charged. Once + // usage exceeds the free tier limit further usage is charged. + // + // Whether this database can make use of the free tier. Only one database + // per project can be eligible for the free tier. + // + // The first (or next) database that is created in a project without a free + // tier database will be marked as eligible for the free tier. Databases that + // are created while there is a free tier database will not be eligible for + // the free tier. + optional bool free_tier = 30 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // This checksum is computed by the server based on the value of other + // fields, and may be sent on update and delete requests to ensure the + // client has an up-to-date value before proceeding. + string etag = 99; + + // Immutable. The edition of the database. + DatabaseEdition database_edition = 28 + [(google.api.field_behavior) = IMMUTABLE]; + + // Immutable. The default Realtime Updates mode to use for this database. + RealtimeUpdatesMode realtime_updates_mode = 31 + [(google.api.field_behavior) = IMMUTABLE]; + + // Optional. The Firestore API data access mode to use for this database. If + // not set on write: + // - the default value is DATA_ACCESS_MODE_DISABLED for Enterprise Edition. + // - the default value is DATA_ACCESS_MODE_ENABLED for Standard Edition. + DataAccessMode firestore_data_access_mode = 33 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The MongoDB compatible API data access mode to use for this + // database. If not set on write, the default value is + // DATA_ACCESS_MODE_ENABLED for Enterprise Edition. The value is always + // DATA_ACCESS_MODE_DISABLED for Standard Edition. + DataAccessMode mongodb_compatible_data_access_mode = 34 + [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto new file mode 100644 index 000000000000..cdd1c859ef29 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/field.proto @@ -0,0 +1,140 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/firestore/admin/v1/index.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "FieldProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Represents a single field in the database. +// +// Fields are grouped by their "Collection Group", which represent all +// collections in the database with the same ID. +message Field { + option (google.api.resource) = { + type: "firestore.googleapis.com/Field" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/fields/{field}" + }; + + // The index configuration for this field. + message IndexConfig { + // The indexes supported for this field. + repeated Index indexes = 1; + + // Output only. When true, the `Field`'s index configuration is set from the + // configuration specified by the `ancestor_field`. + // When false, the `Field`'s index configuration is defined explicitly. + bool uses_ancestor_config = 2; + + // Output only. Specifies the resource name of the `Field` from which this + // field's index configuration is set (when `uses_ancestor_config` is true), + // or from which it *would* be set if this field had no index configuration + // (when `uses_ancestor_config` is false). + string ancestor_field = 3; + + // Output only + // When true, the `Field`'s index configuration is in the process of being + // reverted. Once complete, the index config will transition to the same + // state as the field specified by `ancestor_field`, at which point + // `uses_ancestor_config` will be `true` and `reverting` will be `false`. + bool reverting = 4; + } + + // The TTL (time-to-live) configuration for documents that have this `Field` + // set. + // + // Storing a timestamp value into a TTL-enabled field will be treated as + // the document's absolute expiration time. For Enterprise edition databases, + // the timestamp value may also be stored in an array value in the + // TTL-enabled field. + // + // Timestamp values in the past indicate that the document is eligible for + // immediate expiration. Using any other data type or leaving the field absent + // will disable expiration for the individual document. + message TtlConfig { + // The state of applying the TTL configuration to all documents. + enum State { + // The state is unspecified or unknown. + STATE_UNSPECIFIED = 0; + + // The TTL is being applied. There is an active long-running operation to + // track the change. Newly written documents will have TTLs applied as + // requested. Requested TTLs on existing documents are still being + // processed. When TTLs on all existing documents have been processed, the + // state will move to 'ACTIVE'. + CREATING = 1; + + // The TTL is active for all documents. + ACTIVE = 2; + + // The TTL configuration could not be enabled for all existing documents. + // Newly written documents will continue to have their TTL applied. + // The LRO returned when last attempting to enable TTL for this `Field` + // has failed, and may have more details. + NEEDS_REPAIR = 3; + } + + // Output only. The state of the TTL configuration. + State state = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Required. A field name of the form: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` + // + // A field path can be a simple field name, e.g. `address` or a path to fields + // within `map_value` , e.g. `address.city`, + // or a special field path. The only valid special field is `*`, which + // represents any field. + // + // Field paths can be quoted using `` ` `` (backtick). The only character that + // must be escaped within a quoted field path is the backtick character + // itself, escaped using a backslash. Special characters in field paths that + // must be quoted include: `*`, `.`, + // `` ` `` (backtick), `[`, `]`, as well as any ascii symbolic characters. + // + // Examples: + // `` `address.city` `` represents a field named `address.city`, not the map + // key `city` in the field `address`. `` `*` `` represents a field named `*`, + // not any field. + // + // A special `Field` contains the default indexing settings for all fields. + // This field's resource name is: + // `projects/{project_id}/databases/{database_id}/collectionGroups/__default__/fields/*` + // Indexes defined on this `Field` will be applied to all fields which do not + // have their own `Field` index configuration. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The index configuration for this field. If unset, field indexing will + // revert to the configuration defined by the `ancestor_field`. To + // explicitly remove all indexes for this field, specify an index config + // with an empty list of indexes. + IndexConfig index_config = 2; + + // The TTL configuration for this `Field`. + // Setting or unsetting this will enable or disable the TTL for + // documents that have this `Field`. + TtlConfig ttl_config = 3; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto new file mode 100644 index 000000000000..1dbf0cec1e0b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/firestore_admin.proto @@ -0,0 +1,1229 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/api/routing.proto"; +import "google/firestore/admin/v1/backup.proto"; +import "google/firestore/admin/v1/database.proto"; +import "google/firestore/admin/v1/field.proto"; +import "google/firestore/admin/v1/index.proto"; +import "google/firestore/admin/v1/operation.proto"; +import "google/firestore/admin/v1/schedule.proto"; +import "google/firestore/admin/v1/snapshot.proto"; +import "google/firestore/admin/v1/user_creds.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreAdminProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/Location" + pattern: "projects/{project}/locations/{location}" +}; +option (google.api.resource_definition) = { + type: "firestore.googleapis.com/CollectionGroup" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}" +}; + +// The Cloud Firestore Admin API. +// +// This API provides several administrative services for Cloud Firestore. +// +// Project, Database, Namespace, Collection, Collection Group, and Document are +// used as defined in the Google Cloud Firestore API. +// +// Operation: An Operation represents work being performed in the background. +// +// The index service manages Cloud Firestore indexes. +// +// Index creation is performed asynchronously. +// An Operation resource is created for each such asynchronous operation. +// The state of the operation (including any errors encountered) +// may be queried via the Operation resource. +// +// The Operations collection provides a record of actions performed for the +// specified Project (including any Operations in progress). Operations are not +// created directly but through calls on other collections or resources. +// +// An Operation that is done may be deleted so that it is no longer listed as +// part of the Operation collection. Operations are garbage collected after +// 30 days. By default, ListOperations will only return in progress and failed +// operations. To list completed operation, issue a ListOperations request with +// the filter `done: true`. +// +// Operations are created by service `FirestoreAdmin`, but are accessed via +// service `google.longrunning.Operations`. +service FirestoreAdmin { + option (google.api.default_host) = "firestore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Creates a composite index. This returns a + // [google.longrunning.Operation][google.longrunning.Operation] which may be + // used to track the status of the creation. The metadata for the operation + // will be the type + // [IndexOperationMetadata][google.firestore.admin.v1.IndexOperationMetadata]. + rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + body: "index" + }; + option (google.api.method_signature) = "parent,index"; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Lists composite indexes. + rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/indexes" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a composite index. + rpc GetIndex(GetIndexRequest) returns (Index) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a composite index. + rpc DeleteIndex(DeleteIndexRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/collectionGroups/*/indexes/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets the metadata and configuration for a Field. + rpc GetField(GetFieldRequest) returns (Field) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/collectionGroups/*/fields/*}" + }; + option (google.api.method_signature) = "name"; + } + + // 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/*`. + rpc UpdateField(UpdateFieldRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{field.name=projects/*/databases/*/collectionGroups/*/fields/*}" + body: "field" + }; + option (google.api.method_signature) = "field"; + option (google.longrunning.operation_info) = { + response_type: "Field" + metadata_type: "FieldOperationMetadata" + }; + } + + // Lists the field configuration and metadata for this database. + // + // Currently, + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + // only supports listing fields that have been explicitly overridden. To issue + // this query, call + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + // with the filter set to `indexConfig.usesAncestorConfig:false` or + // `ttlConfig:*`. + rpc ListFields(ListFieldsRequest) returns (ListFieldsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/collectionGroups/*}/fields" + }; + option (google.api.method_signature) = "parent"; + } + + // 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 export. The export occurs in the + // background and its progress can be monitored and managed via the + // Operation resource that is created. The output of an export may only be + // used once the associated operation is done. If an export operation is + // cancelled before completion it may leave partial data behind in Google + // Cloud Storage. + // + // For more details on export behavior and output format, refer to: + // https://cloud.google.com/firestore/docs/manage-data/export-import + rpc ExportDocuments(ExportDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*}:exportDocuments" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "ExportDocumentsResponse" + metadata_type: "ExportDocumentsMetadata" + }; + } + + // 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 via the Operation resource that is + // created. If an ImportDocuments operation is cancelled, it is possible + // that a subset of the data has already been imported to Cloud Firestore. + rpc ImportDocuments(ImportDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*}:importDocuments" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportDocumentsMetadata" + }; + } + + // Bulk deletes a subset of documents from Google Cloud Firestore. + // Documents created or updated after the underlying system starts to process + // the request will not be deleted. The bulk delete occurs in the background + // and its progress can be monitored and managed via the Operation resource + // that is created. + // + // For more details on bulk delete behavior, refer to: + // https://cloud.google.com/firestore/docs/manage-data/bulk-delete + rpc BulkDeleteDocuments(BulkDeleteDocumentsRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*}:bulkDeleteDocuments" + body: "*" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "BulkDeleteDocumentsResponse" + metadata_type: "BulkDeleteDocumentsMetadata" + }; + } + + // Create a database. + rpc CreateDatabase(CreateDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases" + body: "database" + }; + option (google.api.method_signature) = "parent,database,database_id"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "CreateDatabaseMetadata" + }; + } + + // Gets information about a database. + rpc GetDatabase(GetDatabaseRequest) returns (Database) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List all the databases in the project. + rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*}/databases" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a database. + rpc UpdateDatabase(UpdateDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + patch: "/v1/{database.name=projects/*/databases/*}" + body: "database" + }; + option (google.api.method_signature) = "database,update_mask"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "UpdateDatabaseMetadata" + }; + } + + // Deletes a database. + rpc DeleteDatabase(DeleteDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*}" + }; + option (google.api.method_signature) = "name"; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "DeleteDatabaseMetadata" + }; + } + + // Create a user creds. + rpc CreateUserCreds(CreateUserCredsRequest) returns (UserCreds) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*}/userCreds" + body: "user_creds" + }; + option (google.api.method_signature) = "parent,user_creds,user_creds_id"; + } + + // Gets a user creds resource. Note that the returned resource does not + // contain the secret value itself. + rpc GetUserCreds(GetUserCredsRequest) returns (UserCreds) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/userCreds/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List all user creds in the database. Note that the returned resource + // does not contain the secret value itself. + rpc ListUserCreds(ListUserCredsRequest) returns (ListUserCredsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*}/userCreds" + }; + option (google.api.method_signature) = "parent"; + } + + // Enables a user creds. No-op if the user creds are already enabled. + rpc EnableUserCreds(EnableUserCredsRequest) returns (UserCreds) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*/userCreds/*}:enable" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Disables a user creds. No-op if the user creds are already disabled. + rpc DisableUserCreds(DisableUserCredsRequest) returns (UserCreds) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*/userCreds/*}:disable" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Resets the password of a user creds. + rpc ResetUserPassword(ResetUserPasswordRequest) returns (UserCreds) { + option (google.api.http) = { + post: "/v1/{name=projects/*/databases/*/userCreds/*}:resetPassword" + body: "*" + }; + option (google.api.method_signature) = "name"; + } + + // Deletes a user creds. + rpc DeleteUserCreds(DeleteUserCredsRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/userCreds/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets information about a backup. + rpc GetBackup(GetBackupRequest) returns (Backup) { + option (google.api.http) = { + get: "/v1/{name=projects/*/locations/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the backups. + rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/locations/*}/backups" + }; + option (google.api.method_signature) = "parent"; + } + + // Deletes a backup. + rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/locations/*/backups/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new database by restoring from an existing backup. + // + // The new database must be in the same cloud region or multi-region location + // as the existing backup. This behaves similar to + // [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] + // except instead of creating a new empty database, a new database is created + // with the database type, index configuration, and documents from an existing + // backup. + // + // The [long-running operation][google.longrunning.Operation] can be used to + // track the progress of the restore, with the Operation's + // [metadata][google.longrunning.Operation.metadata] field type being the + // [RestoreDatabaseMetadata][google.firestore.admin.v1.RestoreDatabaseMetadata]. + // The [response][google.longrunning.Operation.response] type is the + // [Database][google.firestore.admin.v1.Database] if the restore was + // successful. The new database is not readable or writeable until the LRO has + // completed. + rpc RestoreDatabase(RestoreDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases:restore" + body: "*" + }; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "RestoreDatabaseMetadata" + }; + } + + // Creates a backup schedule on a database. + // At most two backup schedules can be configured on a database, one daily + // backup schedule and one weekly backup schedule. + rpc CreateBackupSchedule(CreateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*}/backupSchedules" + body: "backup_schedule" + }; + option (google.api.method_signature) = "parent,backup_schedule"; + } + + // Gets information about a backup schedule. + rpc GetBackupSchedule(GetBackupScheduleRequest) returns (BackupSchedule) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List backup schedules. + rpc ListBackupSchedules(ListBackupSchedulesRequest) + returns (ListBackupSchedulesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*}/backupSchedules" + }; + option (google.api.method_signature) = "parent"; + } + + // Updates a backup schedule. + rpc UpdateBackupSchedule(UpdateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + patch: "/v1/{backup_schedule.name=projects/*/databases/*/backupSchedules/*}" + body: "backup_schedule" + }; + option (google.api.method_signature) = "backup_schedule,update_mask"; + } + + // Deletes a backup schedule. + rpc DeleteBackupSchedule(DeleteBackupScheduleRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new database by cloning an existing one. + // + // The new database must be in the same cloud region or multi-region location + // as the existing database. This behaves similar to + // [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase] + // except instead of creating a new empty database, a new database is created + // with the database type, index configuration, and documents from an existing + // database. + // + // The [long-running operation][google.longrunning.Operation] can be used to + // track the progress of the clone, with the Operation's + // [metadata][google.longrunning.Operation.metadata] field type being the + // [CloneDatabaseMetadata][google.firestore.admin.v1.CloneDatabaseMetadata]. + // The [response][google.longrunning.Operation.response] type is the + // [Database][google.firestore.admin.v1.Database] if the clone was + // successful. The new database is not readable or writeable until the LRO has + // completed. + rpc CloneDatabase(CloneDatabaseRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/{parent=projects/*}/databases:clone" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { + field: "pitr_snapshot.database" + path_template: "projects/{project_id=*}/**" + } + routing_parameters { + field: "pitr_snapshot.database" + path_template: "projects/*/databases/{database_id=*}/**" + } + }; + option (google.longrunning.operation_info) = { + response_type: "Database" + metadata_type: "CloneDatabaseMetadata" + }; + } +} + +// A request to list the Firestore Databases in all locations for a project. +message ListDatabasesRequest { + // Required. A parent name of the form + // `projects/{project_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; + + // If true, also returns deleted resources. + bool show_deleted = 4; +} + +// The request for +// [FirestoreAdmin.CreateDatabase][google.firestore.admin.v1.FirestoreAdmin.CreateDatabase]. +message CreateDatabaseRequest { + // Required. A parent name of the form + // `projects/{project_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The Database to create. + Database database = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. + // + // This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ + // with first character a letter and the last a letter or a number. Must not + // be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + // + // "(default)" database ID is also valid if the database is Standard edition. + string database_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// Metadata related to the create database operation. +message CreateDatabaseMetadata {} + +// The list of databases for a project. +message ListDatabasesResponse { + // The databases in the project. + repeated Database databases = 1; + + // In the event that data about individual databases cannot be listed they + // will be recorded here. + // + // An example entry might be: projects/some_project/locations/some_location + // This can happen if the Cloud Region that the Database resides in is + // currently unavailable. In this case we can't fetch all the details about + // the database. You may be able to get a more detailed error message + // (or possibly fetch the resource) by sending a 'Get' request for the + // resource or a 'List' request for the specific location. + repeated string unreachable = 3; +} + +// The request for +// [FirestoreAdmin.GetDatabase][google.firestore.admin.v1.FirestoreAdmin.GetDatabase]. +message GetDatabaseRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; +} + +// The request for +// [FirestoreAdmin.UpdateDatabase][google.firestore.admin.v1.FirestoreAdmin.UpdateDatabase]. +message UpdateDatabaseRequest { + // Required. The database to update. + Database database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Metadata related to the update database operation. +message UpdateDatabaseMetadata {} + +// The request for +// [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase]. +message DeleteDatabaseRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // The current etag of the Database. + // If an etag is provided and does not match the current etag of the database, + // deletion will be blocked and a FAILED_PRECONDITION error will be returned. + string etag = 3; +} + +// Metadata related to the delete database operation. +message DeleteDatabaseMetadata {} + +// The request for +// [FirestoreAdmin.CreateUserCreds][google.firestore.admin.v1.FirestoreAdmin.CreateUserCreds]. +message CreateUserCredsRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/UserCreds" + } + ]; + + // Required. The user creds to create. + UserCreds user_creds = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The ID to use for the user creds, which will become the final + // component of the user creds's resource name. + // + // This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ + // with first character a letter and the last a letter or a number. Must not + // be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + string user_creds_id = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [FirestoreAdmin.GetUserCreds][google.firestore.admin.v1.FirestoreAdmin.GetUserCreds]. +message GetUserCredsRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The request for +// [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds]. +message ListUserCredsRequest { + // Required. A parent database name of the form + // `projects/{project_id}/databases/{database_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The response for +// [FirestoreAdmin.ListUserCreds][google.firestore.admin.v1.FirestoreAdmin.ListUserCreds]. +message ListUserCredsResponse { + // The user creds for the database. + repeated UserCreds user_creds = 1; +} + +// The request for +// [FirestoreAdmin.EnableUserCreds][google.firestore.admin.v1.FirestoreAdmin.EnableUserCreds]. +message EnableUserCredsRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The request for +// [FirestoreAdmin.DisableUserCreds][google.firestore.admin.v1.FirestoreAdmin.DisableUserCreds]. +message DisableUserCredsRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The request for +// [FirestoreAdmin.ResetUserPassword][google.firestore.admin.v1.FirestoreAdmin.ResetUserPassword]. +message ResetUserPasswordRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The request for +// [FirestoreAdmin.DeleteUserCreds][google.firestore.admin.v1.FirestoreAdmin.DeleteUserCreds]. +message DeleteUserCredsRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/userCreds/{user_creds_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/UserCreds" + } + ]; +} + +// The request for +// [FirestoreAdmin.CreateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.CreateBackupSchedule]. +message CreateBackupScheduleRequest { + // Required. The parent database. + // + // Format `projects/{project}/databases/{database}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The backup schedule to create. + BackupSchedule backup_schedule = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [FirestoreAdmin.GetBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.GetBackupSchedule]. +message GetBackupScheduleRequest { + // Required. The name of the backup schedule. + // + // Format + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/BackupSchedule" + } + ]; +} + +// The request for +// [FirestoreAdmin.UpdateBackupSchedule][google.firestore.admin.v1.FirestoreAdmin.UpdateBackupSchedule]. +message UpdateBackupScheduleRequest { + // Required. The backup schedule to update. + BackupSchedule backup_schedule = 1 [(google.api.field_behavior) = REQUIRED]; + + // The list of fields to be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// The request for +// [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules]. +message ListBackupSchedulesRequest { + // Required. The parent database. + // + // Format is `projects/{project}/databases/{database}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; +} + +// The response for +// [FirestoreAdmin.ListBackupSchedules][google.firestore.admin.v1.FirestoreAdmin.ListBackupSchedules]. +message ListBackupSchedulesResponse { + // List of all backup schedules. + repeated BackupSchedule backup_schedules = 1; +} + +// The request for [FirestoreAdmin.DeleteBackupSchedules][]. +message DeleteBackupScheduleRequest { + // Required. The name of the backup schedule. + // + // Format + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/BackupSchedule" + } + ]; +} + +// The request for +// [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. +message CreateIndexRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // Required. The composite index to create. + Index index = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. +message ListIndexesRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // The filter to apply to list results. + string filter = 2; + + // The number of results to return. + int32 page_size = 3; + + // A page token, returned from a previous call to + // [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes], + // that may be used to get the next page of results. + string page_token = 4; +} + +// The response for +// [FirestoreAdmin.ListIndexes][google.firestore.admin.v1.FirestoreAdmin.ListIndexes]. +message ListIndexesResponse { + // The requested indexes. + repeated Index indexes = 1; + + // A page token that may be used to request another page of results. If blank, + // this is the last page. + string next_page_token = 2; +} + +// The request for +// [FirestoreAdmin.GetIndex][google.firestore.admin.v1.FirestoreAdmin.GetIndex]. +message GetIndexRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "firestore.googleapis.com/Index" } + ]; +} + +// The request for +// [FirestoreAdmin.DeleteIndex][google.firestore.admin.v1.FirestoreAdmin.DeleteIndex]. +message DeleteIndexRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "firestore.googleapis.com/Index" } + ]; +} + +// The request for +// [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. +message UpdateFieldRequest { + // Required. The field to be updated. + Field field = 1 [(google.api.field_behavior) = REQUIRED]; + + // A mask, relative to the field. If specified, only configuration specified + // by this field_mask will be updated in the field. + google.protobuf.FieldMask update_mask = 2; +} + +// The request for +// [FirestoreAdmin.GetField][google.firestore.admin.v1.FirestoreAdmin.GetField]. +message GetFieldRequest { + // Required. A name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_id}` + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { type: "firestore.googleapis.com/Field" } + ]; +} + +// The request for +// [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. +message ListFieldsRequest { + // Required. A parent name of the form + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}` + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/CollectionGroup" + } + ]; + + // The filter to apply to list results. Currently, + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + // only supports listing fields that have been explicitly overridden. To issue + // this query, call + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields] + // with a filter that includes `indexConfig.usesAncestorConfig:false` or + // `ttlConfig:*`. + string filter = 2; + + // The number of results to return. + int32 page_size = 3; + + // A page token, returned from a previous call to + // [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields], + // that may be used to get the next page of results. + string page_token = 4; +} + +// The response for +// [FirestoreAdmin.ListFields][google.firestore.admin.v1.FirestoreAdmin.ListFields]. +message ListFieldsResponse { + // The requested fields. + repeated Field fields = 1; + + // A page token that may be used to request another page of results. If blank, + // this is the last page. + string next_page_token = 2; +} + +// The request for +// [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. +message ExportDocumentsRequest { + // Required. Database to export. Should be of the form: + // `projects/{project_id}/databases/{database_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // IDs of the collection groups to export. Unspecified means all + // collection groups. Each collection group in this list must be unique. + repeated string collection_ids = 2; + + // The output URI. Currently only supports Google Cloud Storage URIs of the + // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name + // of the Google Cloud Storage bucket and `NAMESPACE_PATH` is an optional + // Google Cloud Storage namespace path. When + // choosing a name, be sure to consider Google Cloud Storage naming + // guidelines: https://cloud.google.com/storage/docs/naming. + // If the URI is a bucket (without a namespace path), a prefix will be + // generated based on the start time. + string output_uri_prefix = 3; + + // An empty list represents all namespaces. This is the preferred + // usage for databases that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the database has data in non-default namespaces, but doesn't want + // to include them. Each namespace in this list must be unique. + repeated string namespace_ids = 4; + + // The timestamp that corresponds to the version of the database to be + // exported. The timestamp must be in the past, rounded to the minute and not + // older than + // [earliestVersionTime][google.firestore.admin.v1.Database.earliest_version_time]. + // If specified, then the exported documents will represent a consistent view + // of the database at the provided time. Otherwise, there are no guarantees + // about the consistency of the exported documents. + google.protobuf.Timestamp snapshot_time = 5; +} + +// The request for +// [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. +message ImportDocumentsRequest { + // Required. Database to import into. Should be of the form: + // `projects/{project_id}/databases/{database_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // IDs of the collection groups to import. Unspecified means all collection + // groups that were included in the export. Each collection group in this list + // must be unique. + repeated string collection_ids = 2; + + // Location of the exported files. + // This must match the output_uri_prefix of an ExportDocumentsResponse from + // an export that has completed successfully. + // See: + // [google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix][google.firestore.admin.v1.ExportDocumentsResponse.output_uri_prefix]. + string input_uri_prefix = 3; + + // An empty list represents all namespaces. This is the preferred + // usage for databases that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the database has data in non-default namespaces, but doesn't want + // to include them. Each namespace in this list must be unique. + repeated string namespace_ids = 4; +} + +// The request for +// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments]. +// +// When both collection_ids and namespace_ids are set, only documents satisfying +// both conditions will be deleted. +// +// Requests with namespace_ids and collection_ids both empty will be rejected. +// Please use +// [FirestoreAdmin.DeleteDatabase][google.firestore.admin.v1.FirestoreAdmin.DeleteDatabase] +// instead. +message BulkDeleteDocumentsRequest { + // Required. Database to operate. Should be of the form: + // `projects/{project_id}/databases/{database_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Optional. IDs of the collection groups to delete. Unspecified means all + // collection groups. + // + // Each collection group in this list must be unique. + repeated string collection_ids = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Namespaces to delete. + // + // An empty list means all namespaces. This is the recommended + // usage for databases that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the database has data in non-default namespaces, but doesn't want + // to delete from them. + // + // Each namespace in this list must be unique. + repeated string namespace_ids = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments]. +message BulkDeleteDocumentsResponse {} + +// The request for +// [FirestoreAdmin.GetBackup][google.firestore.admin.v1.FirestoreAdmin.GetBackup]. +message GetBackupRequest { + // Required. Name of the backup to fetch. + // + // Format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; +} + +// The request for +// [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups]. +message ListBackupsRequest { + // Required. The location to list backups from. + // + // Format is `projects/{project}/locations/{location}`. + // Use `{location} = '-'` to list backups from all locations for the given + // project. This allows listing backups from a single location or from all + // locations. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Location" + } + ]; + + // An expression that filters the list of returned backups. + // + // A filter expression consists of a field name, a comparison operator, and a + // value for filtering. + // The value must be a string, a number, or a boolean. The comparison operator + // must be one of: `<`, `>`, `<=`, `>=`, `!=`, `=`, or `:`. + // Colon `:` is the contains operator. Filter rules are not case sensitive. + // + // The following fields in the [Backup][google.firestore.admin.v1.Backup] are + // eligible for filtering: + // + // * `database_uid` (supports `=` only) + string filter = 2; +} + +// The response for +// [FirestoreAdmin.ListBackups][google.firestore.admin.v1.FirestoreAdmin.ListBackups]. +message ListBackupsResponse { + // List of all backups for the project. + repeated Backup backups = 1; + + // List of locations that existing backups were not able to be fetched from. + // + // Instead of failing the entire requests when a single location is + // unreachable, this response returns a partial result set and list of + // locations unable to be reached here. The request can be retried against a + // single location to get a concrete error. + repeated string unreachable = 3; +} + +// The request for +// [FirestoreAdmin.DeleteBackup][google.firestore.admin.v1.FirestoreAdmin.DeleteBackup]. +message DeleteBackupRequest { + // Required. Name of the backup to delete. + // + // format is `projects/{project}/locations/{location}/backups/{backup}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; +} + +// The request message for +// [FirestoreAdmin.RestoreDatabase][google.firestore.admin.v1.FirestoreAdmin.RestoreDatabase]. +message RestoreDatabaseRequest { + // Required. The project to restore the database in. Format is + // `projects/{project_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. This database ID must not be + // associated with an existing database. + // + // This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ + // with first character a letter and the last a letter or a number. Must not + // be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + // + // "(default)" database ID is also valid if the database is Standard edition. + string database_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Backup to restore from. Must be from the same project as the + // parent. + // + // The restored database will be created in the same location as the source + // backup. + // + // Format is: `projects/{project_id}/locations/{location}/backups/{backup}` + string backup = 3 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + } + ]; + + // Optional. Encryption configuration for the restored database. + // + // If this field is not specified, the restored database will use + // the same encryption configuration as the backup, namely + // [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption]. + Database.EncryptionConfig encryption_config = 9 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Immutable. Tags to be bound to the restored database. + // + // The tags should be provided in the format of + // `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`. + map tags = 10 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OPTIONAL + ]; +} + +// The request message for +// [FirestoreAdmin.CloneDatabase][google.firestore.admin.v1.FirestoreAdmin.CloneDatabase]. +message CloneDatabaseRequest { + // Required. The project to clone the database in. Format is + // `projects/{project_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "firestore.googleapis.com/Database" + } + ]; + + // Required. The ID to use for the database, which will become the final + // component of the database's resource name. This database ID must not be + // associated with an existing database. + // + // This value should be 4-63 characters. Valid characters are /[a-z][0-9]-/ + // with first character a letter and the last a letter or a number. Must not + // be UUID-like /[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}/. + // + // "(default)" database ID is also valid if the database is Standard edition. + string database_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. Specification of the PITR data to clone from. The source database + // must exist. + // + // The cloned database will be created in the same location as the source + // database. + PitrSnapshot pitr_snapshot = 6 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Encryption configuration for the cloned database. + // + // If this field is not specified, the cloned database will use + // the same encryption configuration as the source database, namely + // [use_source_encryption][google.firestore.admin.v1.Database.EncryptionConfig.use_source_encryption]. + Database.EncryptionConfig encryption_config = 4 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Immutable. Tags to be bound to the cloned database. + // + // The tags should be provided in the format of + // `tagKeys/{tag_key_id} -> tagValues/{tag_value_id}`. + map tags = 5 [ + (google.api.field_behavior) = IMMUTABLE, + (google.api.field_behavior) = OPTIONAL + ]; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto new file mode 100644 index 000000000000..d98753ce497e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/index.proto @@ -0,0 +1,289 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "IndexProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Cloud Firestore indexes enable simple and complex queries against +// documents in a database. +message Index { + option (google.api.resource) = { + type: "firestore.googleapis.com/Index" + pattern: "projects/{project}/databases/{database}/collectionGroups/{collection}/indexes/{index}" + }; + + // Query Scope defines the scope at which a query is run. This is specified on + // a StructuredQuery's `from` field. + enum QueryScope { + // The query scope is unspecified. Not a valid option. + QUERY_SCOPE_UNSPECIFIED = 0; + + // Indexes with a collection query scope specified allow queries + // against a collection that is the child of a specific document, specified + // at query time, and that has the collection ID specified by the index. + COLLECTION = 1; + + // Indexes with a collection group query scope specified allow queries + // against all collections that has the collection ID specified by the + // index. + COLLECTION_GROUP = 2; + + // Include all the collections's ancestor in the index. Only available for + // Datastore Mode databases. + COLLECTION_RECURSIVE = 3; + } + + // API Scope defines the APIs (Firestore Native, or Firestore in + // Datastore Mode) that are supported for queries. + enum ApiScope { + // The index can only be used by the Firestore Native query API. + // This is the default. + ANY_API = 0; + + // The index can only be used by the Firestore in Datastore Mode query API. + DATASTORE_MODE_API = 1; + + // The index can only be used by the MONGODB_COMPATIBLE_API. + MONGODB_COMPATIBLE_API = 2; + } + + // A field in an index. + // The field_path describes which field is indexed, the value_mode describes + // how the field value is indexed. + message IndexField { + // The supported orderings. + enum Order { + // The ordering is unspecified. Not a valid option. + ORDER_UNSPECIFIED = 0; + + // The field is ordered by ascending field value. + ASCENDING = 1; + + // The field is ordered by descending field value. + DESCENDING = 2; + } + + // The supported array value configurations. + enum ArrayConfig { + // The index does not support additional array queries. + ARRAY_CONFIG_UNSPECIFIED = 0; + + // The index supports array containment queries. + CONTAINS = 1; + } + + // The index configuration to support vector search operations + message VectorConfig { + // An index that stores vectors in a flat data structure, and supports + // exhaustive search. + message FlatIndex {} + + // Required. The vector dimension this configuration applies to. + // + // The resulting index will only include vectors of this dimension, and + // can be used for vector search with the same dimension. + int32 dimension = 1 [(google.api.field_behavior) = REQUIRED]; + + // The type of index used. + oneof type { + // Indicates the vector index is a flat index. + FlatIndex flat = 2; + } + } + + // Can be __name__. + // For single field indexes, this must match the name of the field or may + // be omitted. + string field_path = 1; + + // How the field value is indexed. + oneof value_mode { + // Indicates that this field supports ordering by the specified order or + // comparing using =, !=, <, <=, >, >=. + Order order = 2; + + // Indicates that this field supports operations on `array_value`s. + ArrayConfig array_config = 3; + + // Indicates that this field supports nearest neighbor and distance + // operations on vector. + VectorConfig vector_config = 4; + } + } + + // The state of an index. During index creation, an index will be in the + // `CREATING` state. If the index is created successfully, it will transition + // to the `READY` state. If the index creation encounters a problem, the index + // will transition to the `NEEDS_REPAIR` state. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The index is being created. + // There is an active long-running operation for the index. + // The index is updated when writing a document. + // Some index data may exist. + CREATING = 1; + + // The index is ready to be used. + // The index is updated when writing a document. + // The index is fully populated from all stored documents it applies to. + READY = 2; + + // The index was being created, but something went wrong. + // There is no active long-running operation for the index, + // and the most recently finished long-running operation failed. + // The index is not updated when writing a document. + // Some index data may exist. + // Use the google.longrunning.Operations API to determine why the operation + // that last attempted to create this index failed, then re-create the + // index. + NEEDS_REPAIR = 3; + } + + // The density configuration for the index. + enum Density { + // Unspecified. It will use database default setting. This value is input + // only. + DENSITY_UNSPECIFIED = 0; + + // An index entry will only exist if ALL fields are present in the document. + // + // This is both the default and only allowed value for Standard Edition + // databases (for both Cloud Firestore `ANY_API` and Cloud Datastore + // `DATASTORE_MODE_API`). + // + // Take for example the following document: + // + // ``` + // { + // "__name__": "...", + // "a": 1, + // "b": 2, + // "c": 3 + // } + // ``` + // + // an index on `(a ASC, b ASC, c ASC, __name__ ASC)` will generate an index + // entry for this document since `a`, 'b', `c`, and `__name__` are all + // present but an index of `(a ASC, d ASC, __name__ ASC)` will not generate + // an index entry for this document since `d` is missing. + // + // This means that such indexes can only be used to serve a query when the + // query has either implicit or explicit requirements that all fields from + // the index are present. + SPARSE_ALL = 1; + + // An index entry will exist if ANY field are present in the document. + // + // This is used as the definition of a sparse index for Enterprise Edition + // databases. + // + // Take for example the following document: + // + // ``` + // { + // "__name__": "...", + // "a": 1, + // "b": 2, + // "c": 3 + // } + // ``` + // + // an index on `(a ASC, d ASC)` will generate an index entry for this + // document since `a` is present, and will fill in an `unset` value for `d`. + // An index on `(d ASC, e ASC)` will not generate any index entry as neither + // `d` nor `e` are present. + // + // An index that contains `__name__` will generate an index entry for all + // documents since Firestore guarantees that all documents have a `__name__` + // field. + SPARSE_ANY = 2; + + // An index entry will exist regardless of if the fields are present or not. + // + // This is the default density for an Enterprise Edition database. + // + // The index will store `unset` values for fields that are not present in + // the document. + DENSE = 3; + } + + // Output only. A server defined name for this index. + // The form of this name for composite indexes will be: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{composite_index_id}` + // For single field indexes, this field will be empty. + string name = 1; + + // Indexes with a collection query scope specified allow queries + // against a collection that is the child of a specific document, specified at + // query time, and that has the same collection ID. + // + // Indexes with a collection group query scope specified allow queries against + // all collections descended from a specific document, specified at query + // time, and that have the same collection ID as this index. + QueryScope query_scope = 2; + + // The API scope supported by this index. + ApiScope api_scope = 5; + + // The fields supported by this index. + // + // For composite indexes, this requires a minimum of 2 and a maximum of 100 + // fields. The last field entry is always for the field path `__name__`. If, + // on creation, `__name__` was not specified as the last field, it will be + // added automatically with the same direction as that of the last field + // defined. If the final field in a composite index is not directional, the + // `__name__` will be ordered ASCENDING (unless explicitly specified). + // + // For single field indexes, this will always be exactly one entry with a + // field path equal to the field path of the associated field. + repeated IndexField fields = 3; + + // Output only. The serving state of the index. + State state = 4; + + // Immutable. The density configuration of the index. + Density density = 6 [(google.api.field_behavior) = IMMUTABLE]; + + // Optional. Whether the index is multikey. By default, the index is not + // multikey. For non-multikey indexes, none of the paths in the index + // definition reach or traverse an array, except via an explicit array index. + // For multikey indexes, at most one of the paths in the index definition + // reach or traverse an array, except via an explicit array index. Violations + // will result in errors. + // + // Note this field only applies to index with MONGODB_COMPATIBLE_API ApiScope. + bool multikey = 7 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The number of shards for the index. + int32 shard_count = 8 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Whether it is an unique index. Unique index ensures all values + // for the indexed field(s) are unique across documents. + bool unique = 10 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto new file mode 100644 index 000000000000..702138b15185 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/location.proto @@ -0,0 +1,30 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "LocationProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// The metadata message for +// [google.cloud.location.Location.metadata][google.cloud.location.Location.metadata]. +message LocationMetadata {} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto new file mode 100644 index 000000000000..eefc3e3384e1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/operation.proto @@ -0,0 +1,325 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/resource.proto"; +import "google/firestore/admin/v1/index.proto"; +import "google/firestore/admin/v1/snapshot.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "OperationProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] +// results from +// [FirestoreAdmin.CreateIndex][google.firestore.admin.v1.FirestoreAdmin.CreateIndex]. +message IndexOperationMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The index resource that this operation is acting on. For example: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/indexes/{index_id}` + string index = 3; + + // The state of the operation. + OperationState state = 4; + + // The progress, in documents, of this operation. + Progress progress_documents = 5; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 6; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] +// results from +// [FirestoreAdmin.UpdateField][google.firestore.admin.v1.FirestoreAdmin.UpdateField]. +message FieldOperationMetadata { + // Information about an index configuration change. + message IndexConfigDelta { + // Specifies how the index is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The single field index is being added. + ADD = 1; + + // The single field index is being removed. + REMOVE = 2; + } + + // Specifies how the index is changing. + ChangeType change_type = 1; + + // The index being changed. + Index index = 2; + } + + // Information about a TTL configuration change. + message TtlConfigDelta { + // Specifies how the TTL config is changing. + enum ChangeType { + // The type of change is not specified or known. + CHANGE_TYPE_UNSPECIFIED = 0; + + // The TTL config is being added. + ADD = 1; + + // The TTL config is being removed. + REMOVE = 2; + } + + // Specifies how the TTL configuration is changing. + ChangeType change_type = 1; + } + + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The field resource that this operation is acting on. For example: + // `projects/{project_id}/databases/{database_id}/collectionGroups/{collection_id}/fields/{field_path}` + string field = 3; + + // A list of + // [IndexConfigDelta][google.firestore.admin.v1.FieldOperationMetadata.IndexConfigDelta], + // which describe the intent of this operation. + repeated IndexConfigDelta index_config_deltas = 4; + + // The state of the operation. + OperationState state = 5; + + // The progress, in documents, of this operation. + Progress progress_documents = 6; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 7; + + // Describes the deltas of TTL configuration. + TtlConfigDelta ttl_config_delta = 8; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] +// results from +// [FirestoreAdmin.ExportDocuments][google.firestore.admin.v1.FirestoreAdmin.ExportDocuments]. +message ExportDocumentsMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The state of the export operation. + OperationState operation_state = 3; + + // The progress, in documents, of this operation. + Progress progress_documents = 4; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 5; + + // Which collection IDs are being exported. + repeated string collection_ids = 6; + + // Where the documents are being exported to. + string output_uri_prefix = 7; + + // Which namespace IDs are being exported. + repeated string namespace_ids = 8; + + // The timestamp that corresponds to the version of the database that is being + // exported. If unspecified, there are no guarantees about the consistency of + // the documents being exported. + google.protobuf.Timestamp snapshot_time = 9; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] +// results from +// [FirestoreAdmin.ImportDocuments][google.firestore.admin.v1.FirestoreAdmin.ImportDocuments]. +message ImportDocumentsMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The state of the import operation. + OperationState operation_state = 3; + + // The progress, in documents, of this operation. + Progress progress_documents = 4; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 5; + + // Which collection IDs are being imported. + repeated string collection_ids = 6; + + // The location of the documents being imported. + string input_uri_prefix = 7; + + // Which namespace IDs are being imported. + repeated string namespace_ids = 8; +} + +// Metadata for [google.longrunning.Operation][google.longrunning.Operation] +// results from +// [FirestoreAdmin.BulkDeleteDocuments][google.firestore.admin.v1.FirestoreAdmin.BulkDeleteDocuments]. +message BulkDeleteDocumentsMetadata { + // The time this operation started. + google.protobuf.Timestamp start_time = 1; + + // The time this operation completed. Will be unset if operation still in + // progress. + google.protobuf.Timestamp end_time = 2; + + // The state of the operation. + OperationState operation_state = 3; + + // The progress, in documents, of this operation. + Progress progress_documents = 4; + + // The progress, in bytes, of this operation. + Progress progress_bytes = 5; + + // The IDs of the collection groups that are being deleted. + repeated string collection_ids = 6; + + // Which namespace IDs are being deleted. + repeated string namespace_ids = 7; + + // The timestamp that corresponds to the version of the database that is being + // read to get the list of documents to delete. This time can also be used as + // the timestamp of PITR in case of disaster recovery (subject to PITR window + // limit). + google.protobuf.Timestamp snapshot_time = 8; +} + +// Returned in the [google.longrunning.Operation][google.longrunning.Operation] +// response field. +message ExportDocumentsResponse { + // Location of the output files. This can be used to begin an import + // into Cloud Firestore (this project or another project) after the operation + // completes successfully. + string output_uri_prefix = 1; +} + +// Metadata for the [long-running operation][google.longrunning.Operation] from +// the [RestoreDatabase][google.firestore.admin.v1.RestoreDatabase] request. +message RestoreDatabaseMetadata { + // The time the restore was started. + google.protobuf.Timestamp start_time = 1; + + // The time the restore finished, unset for ongoing restores. + google.protobuf.Timestamp end_time = 2; + + // The operation state of the restore. + OperationState operation_state = 3; + + // The name of the database being restored to. + string database = 4 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + }]; + + // The name of the backup restoring from. + string backup = 5 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Backup" + }]; + + // How far along the restore is as an estimated percentage of remaining time. + Progress progress_percentage = 8; +} + +// Metadata for the [long-running operation][google.longrunning.Operation] from +// the [CloneDatabase][google.firestore.admin.v1.CloneDatabase] request. +message CloneDatabaseMetadata { + // The time the clone was started. + google.protobuf.Timestamp start_time = 1; + + // The time the clone finished, unset for ongoing clones. + google.protobuf.Timestamp end_time = 2; + + // The operation state of the clone. + OperationState operation_state = 3; + + // The name of the database being cloned to. + string database = 4 [(google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + }]; + + // The snapshot from which this database was cloned. + PitrSnapshot pitr_snapshot = 7; + + // How far along the clone is as an estimated percentage of remaining time. + Progress progress_percentage = 6; +} + +// Describes the progress of the operation. +// Unit of work is generic and must be interpreted based on where +// [Progress][google.firestore.admin.v1.Progress] is used. +message Progress { + // The amount of work estimated. + int64 estimated_work = 1; + + // The amount of work completed. + int64 completed_work = 2; +} + +// Describes the state of the operation. +enum OperationState { + // Unspecified. + OPERATION_STATE_UNSPECIFIED = 0; + + // Request is being prepared for processing. + INITIALIZING = 1; + + // Request is actively being processed. + PROCESSING = 2; + + // Request is in the process of being cancelled after user called + // google.longrunning.Operations.CancelOperation on the operation. + CANCELLING = 3; + + // Request has been processed and is in its finalization stage. + FINALIZING = 4; + + // Request has completed successfully. + SUCCESSFUL = 5; + + // Request has finished being processed, but encountered an error. + FAILED = 6; + + // Request has finished being cancelled after user called + // google.longrunning.Operations.CancelOperation. + CANCELLED = 7; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/realtime_updates.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/realtime_updates.proto new file mode 100644 index 000000000000..e06a63792ef8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/realtime_updates.proto @@ -0,0 +1,40 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "RealtimeUpdatesProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// The Realtime Updates mode. +enum RealtimeUpdatesMode { + // The Realtime Updates feature is not specified. + REALTIME_UPDATES_MODE_UNSPECIFIED = 0; + + // The Realtime Updates feature is enabled by default. + // + // This could potentially degrade write performance for the database. + REALTIME_UPDATES_MODE_ENABLED = 1; + + // The Realtime Updates feature is disabled by default. + REALTIME_UPDATES_MODE_DISABLED = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto new file mode 100644 index 000000000000..c6f3b3d38254 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/schedule.proto @@ -0,0 +1,95 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/dayofweek.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "ScheduleProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A backup schedule for a Cloud Firestore Database. +// +// This resource is owned by the database it is backing up, and is deleted along +// with the database. The actual backups are not though. +message BackupSchedule { + option (google.api.resource) = { + type: "firestore.googleapis.com/BackupSchedule" + pattern: "projects/{project}/databases/{database}/backupSchedules/{backup_schedule}" + }; + + // Output only. The unique backup schedule identifier across all locations and + // databases for the given project. + // + // This will be auto-assigned. + // + // Format is + // `projects/{project}/databases/{database}/backupSchedules/{backup_schedule}` + string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup schedule was created and + // effective since. + // + // No backups will be created for this schedule before this time. + google.protobuf.Timestamp create_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The timestamp at which this backup schedule was most recently + // updated. When a backup schedule is first created, this is the same as + // create_time. + google.protobuf.Timestamp update_time = 10 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // At what relative time in the future, compared to its creation time, + // the backup should be deleted, e.g. keep backups for 7 days. + // + // The maximum supported retention period is 14 weeks. + google.protobuf.Duration retention = 6; + + // A oneof field to represent when backups will be taken. + oneof recurrence { + // For a schedule that runs daily. + DailyRecurrence daily_recurrence = 7; + + // For a schedule that runs weekly on a specific day. + WeeklyRecurrence weekly_recurrence = 8; + } +} + +// Represents a recurring schedule that runs every day. +// +// The time zone is UTC. +message DailyRecurrence {} + +// Represents a recurring schedule that runs on a specified day of the week. +// +// The time zone is UTC. +message WeeklyRecurrence { + // The day of week to run. + // + // DAY_OF_WEEK_UNSPECIFIED is not allowed. + google.type.DayOfWeek day = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/snapshot.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/snapshot.proto new file mode 100644 index 000000000000..07a5e0bc1e96 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/snapshot.proto @@ -0,0 +1,53 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "PitrSnapshotProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A consistent snapshot of a database at a specific point in time. +// A PITR (Point-in-time recovery) snapshot with previous versions of a +// database's data is available for every minute up to the associated database's +// data retention period. If the PITR feature is enabled, the retention period +// is 7 days; otherwise, it is one hour. +message PitrSnapshot { + // Required. The name of the database that this was a snapshot of. Format: + // `projects/{project}/databases/{database}`. + string database = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "firestore.googleapis.com/Database" + } + ]; + + // Output only. Public UUID of the database the snapshot was associated with. + bytes database_uid = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. Snapshot time of the database. + google.protobuf.Timestamp snapshot_time = 3 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/user_creds.proto b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/user_creds.proto new file mode 100644 index 000000000000..e949a085aa61 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-admin-v1/src/main/proto/google/firestore/admin/v1/user_creds.proto @@ -0,0 +1,86 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.admin.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.Admin.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/admin/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "UserCredsProto"; +option java_package = "com.google.firestore.admin.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Firestore::Admin::V1"; + +// A Cloud Firestore User Creds. +message UserCreds { + option (google.api.resource) = { + type: "firestore.googleapis.com/UserCreds" + pattern: "projects/{project}/databases/{database}/userCreds/{user_creds}" + plural: "userCreds" + singular: "userCreds" + }; + + // The state of the user creds (ENABLED or DISABLED). + enum State { + // The default value. Should not be used. + STATE_UNSPECIFIED = 0; + + // The user creds are enabled. + ENABLED = 1; + + // The user creds are disabled. + DISABLED = 2; + } + + // Describes a Resource Identity principal. + message ResourceIdentity { + // Output only. Principal identifier string. + // See: https://cloud.google.com/iam/docs/principal-identifiers + string principal = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + } + + // Identifier. The resource name of the UserCreds. + // Format: + // `projects/{project}/databases/{database}/userCreds/{user_creds}` + string name = 1 [(google.api.field_behavior) = IDENTIFIER]; + + // Output only. The time the user creds were created. + google.protobuf.Timestamp create_time = 2 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The time the user creds were last updated. + google.protobuf.Timestamp update_time = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Whether the user creds are enabled or disabled. Defaults to + // ENABLED on creation. + State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The plaintext server-generated password for the user creds. + // Only populated in responses for CreateUserCreds and ResetUserPassword. + string secure_password = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Identity associated with this User Creds. + oneof UserCredsIdentity { + // Resource Identity descriptor. + ResourceIdentity resource_identity = 6; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/clirr-ignored-differences.xml b/java-firestore/proto-google-cloud-firestore-bundle-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..713d4037f5df --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/clirr-ignored-differences.xml @@ -0,0 +1,81 @@ + + + + + 7012 + com/google/firestore/bundle/*OrBuilder + * get*(*) + + + 7012 + com/google/firestore/bundle/*OrBuilder + boolean contains*(*) + + + 7012 + com/google/firestore/bundle/*OrBuilder + boolean has*(*) + + + + + 7006 + com/google/firestore/bundle/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/firestore/bundle/** + * addRepeatedField(*) + ** + + + 7006 + com/google/firestore/bundle/** + * clear() + ** + + + 7006 + com/google/firestore/bundle/** + * clearField(*) + ** + + + 7006 + com/google/firestore/bundle/** + * clearOneof(*) + ** + + + 7006 + com/google/firestore/bundle/** + * clone() + ** + + + 7006 + com/google/firestore/bundle/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/firestore/bundle/** + * setField(*) + ** + + + 7006 + com/google/firestore/bundle/** + * setRepeatedField(*) + ** + + + 7006 + com/google/firestore/bundle/** + * setUnknownFields(*) + ** + + diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/pom.xml b/java-firestore/proto-google-cloud-firestore-bundle-v1/pom.xml new file mode 100644 index 000000000000..fbc45e0b0927 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + + proto-google-cloud-firestore-bundle-v1 + 3.38.1-SNAPSHOT + + proto-google-cloud-firestore-bundle-v1 + PROTO library for proto-google-cloud-firestore-bundle-v1 + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + compile + + + com.google.api.grpc + proto-google-cloud-firestore-v1 + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElement.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElement.java new file mode 100644 index 000000000000..920a76c419a9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElement.java @@ -0,0 +1,1374 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +/** + * + * + *
+ * A Firestore bundle is a length-prefixed stream of JSON representations of
+ * `BundleElement`.
+ * Only one `BundleMetadata` is expected, and it should be the first element.
+ * The named queries follow after `metadata`. Every `document_metadata` is
+ * immediately followed by a `document`.
+ * 
+ * + * Protobuf type {@code google.firestore.bundle.BundleElement} + */ +@com.google.protobuf.Generated +public final class BundleElement extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.bundle.BundleElement) + BundleElementOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BundleElement"); + } + + // Use BundleElement.newBuilder() to construct. + private BundleElement(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BundleElement() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleElement_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleElement_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundleElement.class, + com.google.firestore.bundle.BundleElement.Builder.class); + } + + private int elementTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object elementType_; + + public enum ElementTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + METADATA(1), + NAMED_QUERY(2), + DOCUMENT_METADATA(3), + DOCUMENT(4), + ELEMENTTYPE_NOT_SET(0); + private final int value; + + private ElementTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ElementTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ElementTypeCase forNumber(int value) { + switch (value) { + case 1: + return METADATA; + case 2: + return NAMED_QUERY; + case 3: + return DOCUMENT_METADATA; + case 4: + return DOCUMENT; + case 0: + return ELEMENTTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ElementTypeCase getElementTypeCase() { + return ElementTypeCase.forNumber(elementTypeCase_); + } + + public static final int METADATA_FIELD_NUMBER = 1; + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return Whether the metadata field is set. + */ + @java.lang.Override + public boolean hasMetadata() { + return elementTypeCase_ == 1; + } + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return The metadata. + */ + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata getMetadata() { + if (elementTypeCase_ == 1) { + return (com.google.firestore.bundle.BundleMetadata) elementType_; + } + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + @java.lang.Override + public com.google.firestore.bundle.BundleMetadataOrBuilder getMetadataOrBuilder() { + if (elementTypeCase_ == 1) { + return (com.google.firestore.bundle.BundleMetadata) elementType_; + } + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + + public static final int NAMED_QUERY_FIELD_NUMBER = 2; + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return Whether the namedQuery field is set. + */ + @java.lang.Override + public boolean hasNamedQuery() { + return elementTypeCase_ == 2; + } + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return The namedQuery. + */ + @java.lang.Override + public com.google.firestore.bundle.NamedQuery getNamedQuery() { + if (elementTypeCase_ == 2) { + return (com.google.firestore.bundle.NamedQuery) elementType_; + } + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + @java.lang.Override + public com.google.firestore.bundle.NamedQueryOrBuilder getNamedQueryOrBuilder() { + if (elementTypeCase_ == 2) { + return (com.google.firestore.bundle.NamedQuery) elementType_; + } + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + + public static final int DOCUMENT_METADATA_FIELD_NUMBER = 3; + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return Whether the documentMetadata field is set. + */ + @java.lang.Override + public boolean hasDocumentMetadata() { + return elementTypeCase_ == 3; + } + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return The documentMetadata. + */ + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata getDocumentMetadata() { + if (elementTypeCase_ == 3) { + return (com.google.firestore.bundle.BundledDocumentMetadata) elementType_; + } + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadataOrBuilder + getDocumentMetadataOrBuilder() { + if (elementTypeCase_ == 3) { + return (com.google.firestore.bundle.BundledDocumentMetadata) elementType_; + } + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + + public static final int DOCUMENT_FIELD_NUMBER = 4; + + /** + * .google.firestore.v1.Document document = 4; + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return elementTypeCase_ == 4; + } + + /** + * .google.firestore.v1.Document document = 4; + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + if (elementTypeCase_ == 4) { + return (com.google.firestore.v1.Document) elementType_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + /** .google.firestore.v1.Document document = 4; */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if (elementTypeCase_ == 4) { + return (com.google.firestore.v1.Document) elementType_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (elementTypeCase_ == 1) { + output.writeMessage(1, (com.google.firestore.bundle.BundleMetadata) elementType_); + } + if (elementTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.bundle.NamedQuery) elementType_); + } + if (elementTypeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.bundle.BundledDocumentMetadata) elementType_); + } + if (elementTypeCase_ == 4) { + output.writeMessage(4, (com.google.firestore.v1.Document) elementType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (elementTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.bundle.BundleMetadata) elementType_); + } + if (elementTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.bundle.NamedQuery) elementType_); + } + if (elementTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.bundle.BundledDocumentMetadata) elementType_); + } + if (elementTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.firestore.v1.Document) elementType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.bundle.BundleElement)) { + return super.equals(obj); + } + com.google.firestore.bundle.BundleElement other = + (com.google.firestore.bundle.BundleElement) obj; + + if (!getElementTypeCase().equals(other.getElementTypeCase())) return false; + switch (elementTypeCase_) { + case 1: + if (!getMetadata().equals(other.getMetadata())) return false; + break; + case 2: + if (!getNamedQuery().equals(other.getNamedQuery())) return false; + break; + case 3: + if (!getDocumentMetadata().equals(other.getDocumentMetadata())) return false; + break; + case 4: + if (!getDocument().equals(other.getDocument())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (elementTypeCase_) { + case 1: + hash = (37 * hash) + METADATA_FIELD_NUMBER; + hash = (53 * hash) + getMetadata().hashCode(); + break; + case 2: + hash = (37 * hash) + NAMED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getNamedQuery().hashCode(); + break; + case 3: + hash = (37 * hash) + DOCUMENT_METADATA_FIELD_NUMBER; + hash = (53 * hash) + getDocumentMetadata().hashCode(); + break; + case 4: + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.bundle.BundleElement parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleElement parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleElement parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleElement parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleElement parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleElement parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.bundle.BundleElement prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Firestore bundle is a length-prefixed stream of JSON representations of
+   * `BundleElement`.
+   * Only one `BundleMetadata` is expected, and it should be the first element.
+   * The named queries follow after `metadata`. Every `document_metadata` is
+   * immediately followed by a `document`.
+   * 
+ * + * Protobuf type {@code google.firestore.bundle.BundleElement} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.bundle.BundleElement) + com.google.firestore.bundle.BundleElementOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleElement_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleElement_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundleElement.class, + com.google.firestore.bundle.BundleElement.Builder.class); + } + + // Construct using com.google.firestore.bundle.BundleElement.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (metadataBuilder_ != null) { + metadataBuilder_.clear(); + } + if (namedQueryBuilder_ != null) { + namedQueryBuilder_.clear(); + } + if (documentMetadataBuilder_ != null) { + documentMetadataBuilder_.clear(); + } + if (documentBuilder_ != null) { + documentBuilder_.clear(); + } + elementTypeCase_ = 0; + elementType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleElement_descriptor; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleElement getDefaultInstanceForType() { + return com.google.firestore.bundle.BundleElement.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.bundle.BundleElement build() { + com.google.firestore.bundle.BundleElement result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleElement buildPartial() { + com.google.firestore.bundle.BundleElement result = + new com.google.firestore.bundle.BundleElement(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.bundle.BundleElement result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.bundle.BundleElement result) { + result.elementTypeCase_ = elementTypeCase_; + result.elementType_ = this.elementType_; + if (elementTypeCase_ == 1 && metadataBuilder_ != null) { + result.elementType_ = metadataBuilder_.build(); + } + if (elementTypeCase_ == 2 && namedQueryBuilder_ != null) { + result.elementType_ = namedQueryBuilder_.build(); + } + if (elementTypeCase_ == 3 && documentMetadataBuilder_ != null) { + result.elementType_ = documentMetadataBuilder_.build(); + } + if (elementTypeCase_ == 4 && documentBuilder_ != null) { + result.elementType_ = documentBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.bundle.BundleElement) { + return mergeFrom((com.google.firestore.bundle.BundleElement) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.bundle.BundleElement other) { + if (other == com.google.firestore.bundle.BundleElement.getDefaultInstance()) return this; + switch (other.getElementTypeCase()) { + case METADATA: + { + mergeMetadata(other.getMetadata()); + break; + } + case NAMED_QUERY: + { + mergeNamedQuery(other.getNamedQuery()); + break; + } + case DOCUMENT_METADATA: + { + mergeDocumentMetadata(other.getDocumentMetadata()); + break; + } + case DOCUMENT: + { + mergeDocument(other.getDocument()); + break; + } + case ELEMENTTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetMetadataFieldBuilder().getBuilder(), extensionRegistry); + elementTypeCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetNamedQueryFieldBuilder().getBuilder(), extensionRegistry); + elementTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetDocumentMetadataFieldBuilder().getBuilder(), extensionRegistry); + elementTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetDocumentFieldBuilder().getBuilder(), extensionRegistry); + elementTypeCase_ = 4; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int elementTypeCase_ = 0; + private java.lang.Object elementType_; + + public ElementTypeCase getElementTypeCase() { + return ElementTypeCase.forNumber(elementTypeCase_); + } + + public Builder clearElementType() { + elementTypeCase_ = 0; + elementType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundleMetadata, + com.google.firestore.bundle.BundleMetadata.Builder, + com.google.firestore.bundle.BundleMetadataOrBuilder> + metadataBuilder_; + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return Whether the metadata field is set. + */ + @java.lang.Override + public boolean hasMetadata() { + return elementTypeCase_ == 1; + } + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return The metadata. + */ + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata getMetadata() { + if (metadataBuilder_ == null) { + if (elementTypeCase_ == 1) { + return (com.google.firestore.bundle.BundleMetadata) elementType_; + } + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } else { + if (elementTypeCase_ == 1) { + return metadataBuilder_.getMessage(); + } + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + public Builder setMetadata(com.google.firestore.bundle.BundleMetadata value) { + if (metadataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + elementType_ = value; + onChanged(); + } else { + metadataBuilder_.setMessage(value); + } + elementTypeCase_ = 1; + return this; + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + public Builder setMetadata(com.google.firestore.bundle.BundleMetadata.Builder builderForValue) { + if (metadataBuilder_ == null) { + elementType_ = builderForValue.build(); + onChanged(); + } else { + metadataBuilder_.setMessage(builderForValue.build()); + } + elementTypeCase_ = 1; + return this; + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + public Builder mergeMetadata(com.google.firestore.bundle.BundleMetadata value) { + if (metadataBuilder_ == null) { + if (elementTypeCase_ == 1 + && elementType_ != com.google.firestore.bundle.BundleMetadata.getDefaultInstance()) { + elementType_ = + com.google.firestore.bundle.BundleMetadata.newBuilder( + (com.google.firestore.bundle.BundleMetadata) elementType_) + .mergeFrom(value) + .buildPartial(); + } else { + elementType_ = value; + } + onChanged(); + } else { + if (elementTypeCase_ == 1) { + metadataBuilder_.mergeFrom(value); + } else { + metadataBuilder_.setMessage(value); + } + } + elementTypeCase_ = 1; + return this; + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + public Builder clearMetadata() { + if (metadataBuilder_ == null) { + if (elementTypeCase_ == 1) { + elementTypeCase_ = 0; + elementType_ = null; + onChanged(); + } + } else { + if (elementTypeCase_ == 1) { + elementTypeCase_ = 0; + elementType_ = null; + } + metadataBuilder_.clear(); + } + return this; + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + public com.google.firestore.bundle.BundleMetadata.Builder getMetadataBuilder() { + return internalGetMetadataFieldBuilder().getBuilder(); + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + @java.lang.Override + public com.google.firestore.bundle.BundleMetadataOrBuilder getMetadataOrBuilder() { + if ((elementTypeCase_ == 1) && (metadataBuilder_ != null)) { + return metadataBuilder_.getMessageOrBuilder(); + } else { + if (elementTypeCase_ == 1) { + return (com.google.firestore.bundle.BundleMetadata) elementType_; + } + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundleMetadata, + com.google.firestore.bundle.BundleMetadata.Builder, + com.google.firestore.bundle.BundleMetadataOrBuilder> + internalGetMetadataFieldBuilder() { + if (metadataBuilder_ == null) { + if (!(elementTypeCase_ == 1)) { + elementType_ = com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + metadataBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundleMetadata, + com.google.firestore.bundle.BundleMetadata.Builder, + com.google.firestore.bundle.BundleMetadataOrBuilder>( + (com.google.firestore.bundle.BundleMetadata) elementType_, + getParentForChildren(), + isClean()); + elementType_ = null; + } + elementTypeCase_ = 1; + onChanged(); + return metadataBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.NamedQuery, + com.google.firestore.bundle.NamedQuery.Builder, + com.google.firestore.bundle.NamedQueryOrBuilder> + namedQueryBuilder_; + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return Whether the namedQuery field is set. + */ + @java.lang.Override + public boolean hasNamedQuery() { + return elementTypeCase_ == 2; + } + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return The namedQuery. + */ + @java.lang.Override + public com.google.firestore.bundle.NamedQuery getNamedQuery() { + if (namedQueryBuilder_ == null) { + if (elementTypeCase_ == 2) { + return (com.google.firestore.bundle.NamedQuery) elementType_; + } + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } else { + if (elementTypeCase_ == 2) { + return namedQueryBuilder_.getMessage(); + } + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + public Builder setNamedQuery(com.google.firestore.bundle.NamedQuery value) { + if (namedQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + elementType_ = value; + onChanged(); + } else { + namedQueryBuilder_.setMessage(value); + } + elementTypeCase_ = 2; + return this; + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + public Builder setNamedQuery(com.google.firestore.bundle.NamedQuery.Builder builderForValue) { + if (namedQueryBuilder_ == null) { + elementType_ = builderForValue.build(); + onChanged(); + } else { + namedQueryBuilder_.setMessage(builderForValue.build()); + } + elementTypeCase_ = 2; + return this; + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + public Builder mergeNamedQuery(com.google.firestore.bundle.NamedQuery value) { + if (namedQueryBuilder_ == null) { + if (elementTypeCase_ == 2 + && elementType_ != com.google.firestore.bundle.NamedQuery.getDefaultInstance()) { + elementType_ = + com.google.firestore.bundle.NamedQuery.newBuilder( + (com.google.firestore.bundle.NamedQuery) elementType_) + .mergeFrom(value) + .buildPartial(); + } else { + elementType_ = value; + } + onChanged(); + } else { + if (elementTypeCase_ == 2) { + namedQueryBuilder_.mergeFrom(value); + } else { + namedQueryBuilder_.setMessage(value); + } + } + elementTypeCase_ = 2; + return this; + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + public Builder clearNamedQuery() { + if (namedQueryBuilder_ == null) { + if (elementTypeCase_ == 2) { + elementTypeCase_ = 0; + elementType_ = null; + onChanged(); + } + } else { + if (elementTypeCase_ == 2) { + elementTypeCase_ = 0; + elementType_ = null; + } + namedQueryBuilder_.clear(); + } + return this; + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + public com.google.firestore.bundle.NamedQuery.Builder getNamedQueryBuilder() { + return internalGetNamedQueryFieldBuilder().getBuilder(); + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + @java.lang.Override + public com.google.firestore.bundle.NamedQueryOrBuilder getNamedQueryOrBuilder() { + if ((elementTypeCase_ == 2) && (namedQueryBuilder_ != null)) { + return namedQueryBuilder_.getMessageOrBuilder(); + } else { + if (elementTypeCase_ == 2) { + return (com.google.firestore.bundle.NamedQuery) elementType_; + } + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.NamedQuery, + com.google.firestore.bundle.NamedQuery.Builder, + com.google.firestore.bundle.NamedQueryOrBuilder> + internalGetNamedQueryFieldBuilder() { + if (namedQueryBuilder_ == null) { + if (!(elementTypeCase_ == 2)) { + elementType_ = com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + namedQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.NamedQuery, + com.google.firestore.bundle.NamedQuery.Builder, + com.google.firestore.bundle.NamedQueryOrBuilder>( + (com.google.firestore.bundle.NamedQuery) elementType_, + getParentForChildren(), + isClean()); + elementType_ = null; + } + elementTypeCase_ = 2; + onChanged(); + return namedQueryBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledDocumentMetadata, + com.google.firestore.bundle.BundledDocumentMetadata.Builder, + com.google.firestore.bundle.BundledDocumentMetadataOrBuilder> + documentMetadataBuilder_; + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return Whether the documentMetadata field is set. + */ + @java.lang.Override + public boolean hasDocumentMetadata() { + return elementTypeCase_ == 3; + } + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return The documentMetadata. + */ + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata getDocumentMetadata() { + if (documentMetadataBuilder_ == null) { + if (elementTypeCase_ == 3) { + return (com.google.firestore.bundle.BundledDocumentMetadata) elementType_; + } + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } else { + if (elementTypeCase_ == 3) { + return documentMetadataBuilder_.getMessage(); + } + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + public Builder setDocumentMetadata(com.google.firestore.bundle.BundledDocumentMetadata value) { + if (documentMetadataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + elementType_ = value; + onChanged(); + } else { + documentMetadataBuilder_.setMessage(value); + } + elementTypeCase_ = 3; + return this; + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + public Builder setDocumentMetadata( + com.google.firestore.bundle.BundledDocumentMetadata.Builder builderForValue) { + if (documentMetadataBuilder_ == null) { + elementType_ = builderForValue.build(); + onChanged(); + } else { + documentMetadataBuilder_.setMessage(builderForValue.build()); + } + elementTypeCase_ = 3; + return this; + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + public Builder mergeDocumentMetadata( + com.google.firestore.bundle.BundledDocumentMetadata value) { + if (documentMetadataBuilder_ == null) { + if (elementTypeCase_ == 3 + && elementType_ + != com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance()) { + elementType_ = + com.google.firestore.bundle.BundledDocumentMetadata.newBuilder( + (com.google.firestore.bundle.BundledDocumentMetadata) elementType_) + .mergeFrom(value) + .buildPartial(); + } else { + elementType_ = value; + } + onChanged(); + } else { + if (elementTypeCase_ == 3) { + documentMetadataBuilder_.mergeFrom(value); + } else { + documentMetadataBuilder_.setMessage(value); + } + } + elementTypeCase_ = 3; + return this; + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + public Builder clearDocumentMetadata() { + if (documentMetadataBuilder_ == null) { + if (elementTypeCase_ == 3) { + elementTypeCase_ = 0; + elementType_ = null; + onChanged(); + } + } else { + if (elementTypeCase_ == 3) { + elementTypeCase_ = 0; + elementType_ = null; + } + documentMetadataBuilder_.clear(); + } + return this; + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + public com.google.firestore.bundle.BundledDocumentMetadata.Builder + getDocumentMetadataBuilder() { + return internalGetDocumentMetadataFieldBuilder().getBuilder(); + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadataOrBuilder + getDocumentMetadataOrBuilder() { + if ((elementTypeCase_ == 3) && (documentMetadataBuilder_ != null)) { + return documentMetadataBuilder_.getMessageOrBuilder(); + } else { + if (elementTypeCase_ == 3) { + return (com.google.firestore.bundle.BundledDocumentMetadata) elementType_; + } + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + } + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledDocumentMetadata, + com.google.firestore.bundle.BundledDocumentMetadata.Builder, + com.google.firestore.bundle.BundledDocumentMetadataOrBuilder> + internalGetDocumentMetadataFieldBuilder() { + if (documentMetadataBuilder_ == null) { + if (!(elementTypeCase_ == 3)) { + elementType_ = com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + documentMetadataBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledDocumentMetadata, + com.google.firestore.bundle.BundledDocumentMetadata.Builder, + com.google.firestore.bundle.BundledDocumentMetadataOrBuilder>( + (com.google.firestore.bundle.BundledDocumentMetadata) elementType_, + getParentForChildren(), + isClean()); + elementType_ = null; + } + elementTypeCase_ = 3; + onChanged(); + return documentMetadataBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentBuilder_; + + /** + * .google.firestore.v1.Document document = 4; + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return elementTypeCase_ == 4; + } + + /** + * .google.firestore.v1.Document document = 4; + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + if (documentBuilder_ == null) { + if (elementTypeCase_ == 4) { + return (com.google.firestore.v1.Document) elementType_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } else { + if (elementTypeCase_ == 4) { + return documentBuilder_.getMessage(); + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** .google.firestore.v1.Document document = 4; */ + public Builder setDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + elementType_ = value; + onChanged(); + } else { + documentBuilder_.setMessage(value); + } + elementTypeCase_ = 4; + return this; + } + + /** .google.firestore.v1.Document document = 4; */ + public Builder setDocument(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentBuilder_ == null) { + elementType_ = builderForValue.build(); + onChanged(); + } else { + documentBuilder_.setMessage(builderForValue.build()); + } + elementTypeCase_ = 4; + return this; + } + + /** .google.firestore.v1.Document document = 4; */ + public Builder mergeDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (elementTypeCase_ == 4 + && elementType_ != com.google.firestore.v1.Document.getDefaultInstance()) { + elementType_ = + com.google.firestore.v1.Document.newBuilder( + (com.google.firestore.v1.Document) elementType_) + .mergeFrom(value) + .buildPartial(); + } else { + elementType_ = value; + } + onChanged(); + } else { + if (elementTypeCase_ == 4) { + documentBuilder_.mergeFrom(value); + } else { + documentBuilder_.setMessage(value); + } + } + elementTypeCase_ = 4; + return this; + } + + /** .google.firestore.v1.Document document = 4; */ + public Builder clearDocument() { + if (documentBuilder_ == null) { + if (elementTypeCase_ == 4) { + elementTypeCase_ = 0; + elementType_ = null; + onChanged(); + } + } else { + if (elementTypeCase_ == 4) { + elementTypeCase_ = 0; + elementType_ = null; + } + documentBuilder_.clear(); + } + return this; + } + + /** .google.firestore.v1.Document document = 4; */ + public com.google.firestore.v1.Document.Builder getDocumentBuilder() { + return internalGetDocumentFieldBuilder().getBuilder(); + } + + /** .google.firestore.v1.Document document = 4; */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if ((elementTypeCase_ == 4) && (documentBuilder_ != null)) { + return documentBuilder_.getMessageOrBuilder(); + } else { + if (elementTypeCase_ == 4) { + return (com.google.firestore.v1.Document) elementType_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** .google.firestore.v1.Document document = 4; */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentFieldBuilder() { + if (documentBuilder_ == null) { + if (!(elementTypeCase_ == 4)) { + elementType_ = com.google.firestore.v1.Document.getDefaultInstance(); + } + documentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + (com.google.firestore.v1.Document) elementType_, getParentForChildren(), isClean()); + elementType_ = null; + } + elementTypeCase_ = 4; + onChanged(); + return documentBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.bundle.BundleElement) + } + + // @@protoc_insertion_point(class_scope:google.firestore.bundle.BundleElement) + private static final com.google.firestore.bundle.BundleElement DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.bundle.BundleElement(); + } + + public static com.google.firestore.bundle.BundleElement getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BundleElement parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleElement getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElementOrBuilder.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElementOrBuilder.java new file mode 100644 index 000000000000..a29cad54694d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleElementOrBuilder.java @@ -0,0 +1,98 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public interface BundleElementOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.bundle.BundleElement) + com.google.protobuf.MessageOrBuilder { + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return Whether the metadata field is set. + */ + boolean hasMetadata(); + + /** + * .google.firestore.bundle.BundleMetadata metadata = 1; + * + * @return The metadata. + */ + com.google.firestore.bundle.BundleMetadata getMetadata(); + + /** .google.firestore.bundle.BundleMetadata metadata = 1; */ + com.google.firestore.bundle.BundleMetadataOrBuilder getMetadataOrBuilder(); + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return Whether the namedQuery field is set. + */ + boolean hasNamedQuery(); + + /** + * .google.firestore.bundle.NamedQuery named_query = 2; + * + * @return The namedQuery. + */ + com.google.firestore.bundle.NamedQuery getNamedQuery(); + + /** .google.firestore.bundle.NamedQuery named_query = 2; */ + com.google.firestore.bundle.NamedQueryOrBuilder getNamedQueryOrBuilder(); + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return Whether the documentMetadata field is set. + */ + boolean hasDocumentMetadata(); + + /** + * .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; + * + * @return The documentMetadata. + */ + com.google.firestore.bundle.BundledDocumentMetadata getDocumentMetadata(); + + /** .google.firestore.bundle.BundledDocumentMetadata document_metadata = 3; */ + com.google.firestore.bundle.BundledDocumentMetadataOrBuilder getDocumentMetadataOrBuilder(); + + /** + * .google.firestore.v1.Document document = 4; + * + * @return Whether the document field is set. + */ + boolean hasDocument(); + + /** + * .google.firestore.v1.Document document = 4; + * + * @return The document. + */ + com.google.firestore.v1.Document getDocument(); + + /** .google.firestore.v1.Document document = 4; */ + com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder(); + + com.google.firestore.bundle.BundleElement.ElementTypeCase getElementTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadata.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadata.java new file mode 100644 index 000000000000..65bcee5fdf76 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadata.java @@ -0,0 +1,1174 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +/** + * + * + *
+ * Metadata describing the bundle file/stream.
+ * 
+ * + * Protobuf type {@code google.firestore.bundle.BundleMetadata} + */ +@com.google.protobuf.Generated +public final class BundleMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.bundle.BundleMetadata) + BundleMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BundleMetadata"); + } + + // Use BundleMetadata.newBuilder() to construct. + private BundleMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BundleMetadata() { + id_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundleMetadata.class, + com.google.firestore.bundle.BundleMetadata.Builder.class); + } + + private int bitField0_; + public static final int ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object id_ = ""; + + /** + * + * + *
+   * The ID of the bundle.
+   * 
+ * + * string id = 1; + * + * @return The id. + */ + @java.lang.Override + public java.lang.String getId() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } + } + + /** + * + * + *
+   * The ID of the bundle.
+   * 
+ * + * string id = 1; + * + * @return The bytes for id. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATE_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int VERSION_FIELD_NUMBER = 3; + private int version_ = 0; + + /** + * + * + *
+   * The schema version of the bundle.
+   * 
+ * + * uint32 version = 3; + * + * @return The version. + */ + @java.lang.Override + public int getVersion() { + return version_; + } + + public static final int TOTAL_DOCUMENTS_FIELD_NUMBER = 4; + private int totalDocuments_ = 0; + + /** + * + * + *
+   * The number of documents in the bundle.
+   * 
+ * + * uint32 total_documents = 4; + * + * @return The totalDocuments. + */ + @java.lang.Override + public int getTotalDocuments() { + return totalDocuments_; + } + + public static final int TOTAL_BYTES_FIELD_NUMBER = 5; + private long totalBytes_ = 0L; + + /** + * + * + *
+   * The size of the bundle in bytes, excluding this `BundleMetadata`.
+   * 
+ * + * uint64 total_bytes = 5; + * + * @return The totalBytes. + */ + @java.lang.Override + public long getTotalBytes() { + return totalBytes_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(id_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, id_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getCreateTime()); + } + if (version_ != 0) { + output.writeUInt32(3, version_); + } + if (totalDocuments_ != 0) { + output.writeUInt32(4, totalDocuments_); + } + if (totalBytes_ != 0L) { + output.writeUInt64(5, totalBytes_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(id_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, id_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCreateTime()); + } + if (version_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeUInt32Size(3, version_); + } + if (totalDocuments_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeUInt32Size(4, totalDocuments_); + } + if (totalBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeUInt64Size(5, totalBytes_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.bundle.BundleMetadata)) { + return super.equals(obj); + } + com.google.firestore.bundle.BundleMetadata other = + (com.google.firestore.bundle.BundleMetadata) obj; + + if (!getId().equals(other.getId())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (getVersion() != other.getVersion()) return false; + if (getTotalDocuments() != other.getTotalDocuments()) return false; + if (getTotalBytes() != other.getTotalBytes()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + getId().hashCode(); + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + getVersion(); + hash = (37 * hash) + TOTAL_DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getTotalDocuments(); + hash = (37 * hash) + TOTAL_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getTotalBytes()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundleMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.bundle.BundleMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata describing the bundle file/stream.
+   * 
+ * + * Protobuf type {@code google.firestore.bundle.BundleMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.bundle.BundleMetadata) + com.google.firestore.bundle.BundleMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundleMetadata.class, + com.google.firestore.bundle.BundleMetadata.Builder.class); + } + + // Construct using com.google.firestore.bundle.BundleMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCreateTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + id_ = ""; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + version_ = 0; + totalDocuments_ = 0; + totalBytes_ = 0L; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundleMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata getDefaultInstanceForType() { + return com.google.firestore.bundle.BundleMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata build() { + com.google.firestore.bundle.BundleMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata buildPartial() { + com.google.firestore.bundle.BundleMetadata result = + new com.google.firestore.bundle.BundleMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.bundle.BundleMetadata result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.id_ = id_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.version_ = version_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.totalDocuments_ = totalDocuments_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.totalBytes_ = totalBytes_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.bundle.BundleMetadata) { + return mergeFrom((com.google.firestore.bundle.BundleMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.bundle.BundleMetadata other) { + if (other == com.google.firestore.bundle.BundleMetadata.getDefaultInstance()) return this; + if (!other.getId().isEmpty()) { + id_ = other.id_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.getVersion() != 0) { + setVersion(other.getVersion()); + } + if (other.getTotalDocuments() != 0) { + setTotalDocuments(other.getTotalDocuments()); + } + if (other.getTotalBytes() != 0L) { + setTotalBytes(other.getTotalBytes()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + id_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + version_ = input.readUInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 32: + { + totalDocuments_ = input.readUInt32(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 40: + { + totalBytes_ = input.readUInt64(); + bitField0_ |= 0x00000010; + break; + } // case 40 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object id_ = ""; + + /** + * + * + *
+     * The ID of the bundle.
+     * 
+ * + * string id = 1; + * + * @return The id. + */ + public java.lang.String getId() { + java.lang.Object ref = id_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + id_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The ID of the bundle.
+     * 
+ * + * string id = 1; + * + * @return The bytes for id. + */ + public com.google.protobuf.ByteString getIdBytes() { + java.lang.Object ref = id_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + id_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The ID of the bundle.
+     * 
+ * + * string id = 1; + * + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + id_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the bundle.
+     * 
+ * + * string id = 1; + * + * @return This builder for chaining. + */ + public Builder clearId() { + id_ = getDefaultInstance().getId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the bundle.
+     * 
+ * + * string id = 1; + * + * @param value The bytes for id to set. + * @return This builder for chaining. + */ + public Builder setIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + id_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000002); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * Time at which the documents snapshot is taken for this bundle.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private int version_; + + /** + * + * + *
+     * The schema version of the bundle.
+     * 
+ * + * uint32 version = 3; + * + * @return The version. + */ + @java.lang.Override + public int getVersion() { + return version_; + } + + /** + * + * + *
+     * The schema version of the bundle.
+     * 
+ * + * uint32 version = 3; + * + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion(int value) { + + version_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The schema version of the bundle.
+     * 
+ * + * uint32 version = 3; + * + * @return This builder for chaining. + */ + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000004); + version_ = 0; + onChanged(); + return this; + } + + private int totalDocuments_; + + /** + * + * + *
+     * The number of documents in the bundle.
+     * 
+ * + * uint32 total_documents = 4; + * + * @return The totalDocuments. + */ + @java.lang.Override + public int getTotalDocuments() { + return totalDocuments_; + } + + /** + * + * + *
+     * The number of documents in the bundle.
+     * 
+ * + * uint32 total_documents = 4; + * + * @param value The totalDocuments to set. + * @return This builder for chaining. + */ + public Builder setTotalDocuments(int value) { + + totalDocuments_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of documents in the bundle.
+     * 
+ * + * uint32 total_documents = 4; + * + * @return This builder for chaining. + */ + public Builder clearTotalDocuments() { + bitField0_ = (bitField0_ & ~0x00000008); + totalDocuments_ = 0; + onChanged(); + return this; + } + + private long totalBytes_; + + /** + * + * + *
+     * The size of the bundle in bytes, excluding this `BundleMetadata`.
+     * 
+ * + * uint64 total_bytes = 5; + * + * @return The totalBytes. + */ + @java.lang.Override + public long getTotalBytes() { + return totalBytes_; + } + + /** + * + * + *
+     * The size of the bundle in bytes, excluding this `BundleMetadata`.
+     * 
+ * + * uint64 total_bytes = 5; + * + * @param value The totalBytes to set. + * @return This builder for chaining. + */ + public Builder setTotalBytes(long value) { + + totalBytes_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The size of the bundle in bytes, excluding this `BundleMetadata`.
+     * 
+ * + * uint64 total_bytes = 5; + * + * @return This builder for chaining. + */ + public Builder clearTotalBytes() { + bitField0_ = (bitField0_ & ~0x00000010); + totalBytes_ = 0L; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.bundle.BundleMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.bundle.BundleMetadata) + private static final com.google.firestore.bundle.BundleMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.bundle.BundleMetadata(); + } + + public static com.google.firestore.bundle.BundleMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BundleMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.bundle.BundleMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadataOrBuilder.java new file mode 100644 index 000000000000..21534a290b63 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleMetadataOrBuilder.java @@ -0,0 +1,130 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public interface BundleMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.bundle.BundleMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The ID of the bundle.
+   * 
+ * + * string id = 1; + * + * @return The id. + */ + java.lang.String getId(); + + /** + * + * + *
+   * The ID of the bundle.
+   * 
+ * + * string id = 1; + * + * @return The bytes for id. + */ + com.google.protobuf.ByteString getIdBytes(); + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * Time at which the documents snapshot is taken for this bundle.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * The schema version of the bundle.
+   * 
+ * + * uint32 version = 3; + * + * @return The version. + */ + int getVersion(); + + /** + * + * + *
+   * The number of documents in the bundle.
+   * 
+ * + * uint32 total_documents = 4; + * + * @return The totalDocuments. + */ + int getTotalDocuments(); + + /** + * + * + *
+   * The size of the bundle in bytes, excluding this `BundleMetadata`.
+   * 
+ * + * uint64 total_bytes = 5; + * + * @return The totalBytes. + */ + long getTotalBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleProto.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleProto.java new file mode 100644 index 000000000000..8994e8e30c52 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundleProto.java @@ -0,0 +1,159 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public final class BundleProto extends com.google.protobuf.GeneratedFile { + private BundleProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BundleProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_bundle_BundledQuery_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_bundle_BundledQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_bundle_NamedQuery_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_bundle_NamedQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_bundle_BundledDocumentMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_bundle_BundleMetadata_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_bundle_BundleMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_bundle_BundleElement_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_bundle_BundleElement_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n$google/firestore/bundle/bundle.proto\022\027" + + "google.firestore.bundle\032\"google/firestor" + + "e/v1/document.proto\032\037google/firestore/v1" + + "/query.proto\032\037google/protobuf/timestamp." + + "proto\"\325\001\n\014BundledQuery\022\016\n\006parent\030\001 \001(\t\022@" + + "\n\020structured_query\030\002 \001(\0132$.google.firest" + + "ore.v1.StructuredQueryH\000\022C\n\nlimit_type\030\003" + + " \001(\0162/.google.firestore.bundle.BundledQu" + + "ery.LimitType\" \n\tLimitType\022\t\n\005FIRST\020\000\022\010\n" + + "\004LAST\020\001B\014\n\nquery_type\"\207\001\n\nNamedQuery\022\014\n\004" + + "name\030\001 \001(\t\022<\n\rbundled_query\030\002 \001(\0132%.goog" + + "le.firestore.bundle.BundledQuery\022-\n\tread" + + "_time\030\003 \001(\0132\032.google.protobuf.Timestamp\"" + + "w\n\027BundledDocumentMetadata\022\014\n\004name\030\001 \001(\t" + + "\022-\n\tread_time\030\002 \001(\0132\032.google.protobuf.Ti" + + "mestamp\022\016\n\006exists\030\003 \001(\010\022\017\n\007queries\030\004 \003(\t" + + "\"\214\001\n\016BundleMetadata\022\n\n\002id\030\001 \001(\t\022/\n\013creat" + + "e_time\030\002 \001(\0132\032.google.protobuf.Timestamp" + + "\022\017\n\007version\030\003 \001(\r\022\027\n\017total_documents\030\004 \001" + + "(\r\022\023\n\013total_bytes\030\005 \001(\004\"\232\002\n\rBundleElemen" + + "t\022;\n\010metadata\030\001 \001(\0132\'.google.firestore.b" + + "undle.BundleMetadataH\000\022:\n\013named_query\030\002 " + + "\001(\0132#.google.firestore.bundle.NamedQuery" + + "H\000\022M\n\021document_metadata\030\003 \001(\01320.google.f" + + "irestore.bundle.BundledDocumentMetadataH" + + "\000\0221\n\010document\030\004 \001(\0132\035.google.firestore.v" + + "1.DocumentH\000B\016\n\014element_typeB\222\001\n\033com.goo" + + "gle.firestore.bundleB\013BundleProtoP\001Z6clo" + + "ud.google.com/go/firestore/bundle/bundle" + + "pb;bundlepb\242\002\005FSTPB\252\002\020Firestore.Bundle\312\002" + + "\020Firestore\\Bundleb\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.firestore.v1.DocumentProto.getDescriptor(), + com.google.firestore.v1.QueryProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_bundle_BundledQuery_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_bundle_BundledQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_bundle_BundledQuery_descriptor, + new java.lang.String[] { + "Parent", "StructuredQuery", "LimitType", "QueryType", + }); + internal_static_google_firestore_bundle_NamedQuery_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_bundle_NamedQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_bundle_NamedQuery_descriptor, + new java.lang.String[] { + "Name", "BundledQuery", "ReadTime", + }); + internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor = + getDescriptor().getMessageType(2); + internal_static_google_firestore_bundle_BundledDocumentMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor, + new java.lang.String[] { + "Name", "ReadTime", "Exists", "Queries", + }); + internal_static_google_firestore_bundle_BundleMetadata_descriptor = + getDescriptor().getMessageType(3); + internal_static_google_firestore_bundle_BundleMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_bundle_BundleMetadata_descriptor, + new java.lang.String[] { + "Id", "CreateTime", "Version", "TotalDocuments", "TotalBytes", + }); + internal_static_google_firestore_bundle_BundleElement_descriptor = + getDescriptor().getMessageType(4); + internal_static_google_firestore_bundle_BundleElement_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_bundle_BundleElement_descriptor, + new java.lang.String[] { + "Metadata", "NamedQuery", "DocumentMetadata", "Document", "ElementType", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.firestore.v1.DocumentProto.getDescriptor(); + com.google.firestore.v1.QueryProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadata.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadata.java new file mode 100644 index 000000000000..cf68bf2dde7f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadata.java @@ -0,0 +1,1267 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +/** + * + * + *
+ * Metadata describing a Firestore document saved in the bundle.
+ * 
+ * + * Protobuf type {@code google.firestore.bundle.BundledDocumentMetadata} + */ +@com.google.protobuf.Generated +public final class BundledDocumentMetadata extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.bundle.BundledDocumentMetadata) + BundledDocumentMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BundledDocumentMetadata"); + } + + // Use BundledDocumentMetadata.newBuilder() to construct. + private BundledDocumentMetadata(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BundledDocumentMetadata() { + name_ = ""; + queries_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledDocumentMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundledDocumentMetadata.class, + com.google.firestore.bundle.BundledDocumentMetadata.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * The document key of a bundled document.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * The document key of a bundled document.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int READ_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + public static final int EXISTS_FIELD_NUMBER = 3; + private boolean exists_ = false; + + /** + * + * + *
+   * Whether the document exists.
+   * 
+ * + * bool exists = 3; + * + * @return The exists. + */ + @java.lang.Override + public boolean getExists() { + return exists_; + } + + public static final int QUERIES_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList queries_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @return A list containing the queries. + */ + public com.google.protobuf.ProtocolStringList getQueriesList() { + return queries_; + } + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @return The count of queries. + */ + public int getQueriesCount() { + return queries_.size(); + } + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @param index The index of the element to return. + * @return The queries at the given index. + */ + public java.lang.String getQueries(int index) { + return queries_.get(index); + } + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @param index The index of the value to return. + * @return The bytes of the queries at the given index. + */ + public com.google.protobuf.ByteString getQueriesBytes(int index) { + return queries_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getReadTime()); + } + if (exists_ != false) { + output.writeBool(3, exists_); + } + for (int i = 0; i < queries_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, queries_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getReadTime()); + } + if (exists_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, exists_); + } + { + int dataSize = 0; + for (int i = 0; i < queries_.size(); i++) { + dataSize += computeStringSizeNoTag(queries_.getRaw(i)); + } + size += dataSize; + size += 1 * getQueriesList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.bundle.BundledDocumentMetadata)) { + return super.equals(obj); + } + com.google.firestore.bundle.BundledDocumentMetadata other = + (com.google.firestore.bundle.BundledDocumentMetadata) obj; + + if (!getName().equals(other.getName())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (getExists() != other.getExists()) return false; + if (!getQueriesList().equals(other.getQueriesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (37 * hash) + EXISTS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getExists()); + if (getQueriesCount() > 0) { + hash = (37 * hash) + QUERIES_FIELD_NUMBER; + hash = (53 * hash) + getQueriesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.bundle.BundledDocumentMetadata prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata describing a Firestore document saved in the bundle.
+   * 
+ * + * Protobuf type {@code google.firestore.bundle.BundledDocumentMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.bundle.BundledDocumentMetadata) + com.google.firestore.bundle.BundledDocumentMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledDocumentMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundledDocumentMetadata.class, + com.google.firestore.bundle.BundledDocumentMetadata.Builder.class); + } + + // Construct using com.google.firestore.bundle.BundledDocumentMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + exists_ = false; + queries_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledDocumentMetadata_descriptor; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata getDefaultInstanceForType() { + return com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata build() { + com.google.firestore.bundle.BundledDocumentMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata buildPartial() { + com.google.firestore.bundle.BundledDocumentMetadata result = + new com.google.firestore.bundle.BundledDocumentMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.bundle.BundledDocumentMetadata result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.exists_ = exists_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + queries_.makeImmutable(); + result.queries_ = queries_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.bundle.BundledDocumentMetadata) { + return mergeFrom((com.google.firestore.bundle.BundledDocumentMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.bundle.BundledDocumentMetadata other) { + if (other == com.google.firestore.bundle.BundledDocumentMetadata.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + if (other.getExists() != false) { + setExists(other.getExists()); + } + if (!other.queries_.isEmpty()) { + if (queries_.isEmpty()) { + queries_ = other.queries_; + bitField0_ |= 0x00000008; + } else { + ensureQueriesIsMutable(); + queries_.addAll(other.queries_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + exists_ = input.readBool(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureQueriesIsMutable(); + queries_.add(s); + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * The document key of a bundled document.
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The document key of a bundled document.
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The document key of a bundled document.
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The document key of a bundled document.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The document key of a bundled document.
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000002); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The snapshot version of the document data bundled.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + private boolean exists_; + + /** + * + * + *
+     * Whether the document exists.
+     * 
+ * + * bool exists = 3; + * + * @return The exists. + */ + @java.lang.Override + public boolean getExists() { + return exists_; + } + + /** + * + * + *
+     * Whether the document exists.
+     * 
+ * + * bool exists = 3; + * + * @param value The exists to set. + * @return This builder for chaining. + */ + public Builder setExists(boolean value) { + + exists_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Whether the document exists.
+     * 
+ * + * bool exists = 3; + * + * @return This builder for chaining. + */ + public Builder clearExists() { + bitField0_ = (bitField0_ & ~0x00000004); + exists_ = false; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList queries_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureQueriesIsMutable() { + if (!queries_.isModifiable()) { + queries_ = new com.google.protobuf.LazyStringArrayList(queries_); + } + bitField0_ |= 0x00000008; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @return A list containing the queries. + */ + public com.google.protobuf.ProtocolStringList getQueriesList() { + queries_.makeImmutable(); + return queries_; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @return The count of queries. + */ + public int getQueriesCount() { + return queries_.size(); + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param index The index of the element to return. + * @return The queries at the given index. + */ + public java.lang.String getQueries(int index) { + return queries_.get(index); + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param index The index of the value to return. + * @return The bytes of the queries at the given index. + */ + public com.google.protobuf.ByteString getQueriesBytes(int index) { + return queries_.getByteString(index); + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param index The index to set the value at. + * @param value The queries to set. + * @return This builder for chaining. + */ + public Builder setQueries(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureQueriesIsMutable(); + queries_.set(index, value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param value The queries to add. + * @return This builder for chaining. + */ + public Builder addQueries(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureQueriesIsMutable(); + queries_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param values The queries to add. + * @return This builder for chaining. + */ + public Builder addAllQueries(java.lang.Iterable values) { + ensureQueriesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, queries_); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @return This builder for chaining. + */ + public Builder clearQueries() { + queries_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the queries in this bundle that this document matches to.
+     * 
+ * + * repeated string queries = 4; + * + * @param value The bytes of the queries to add. + * @return This builder for chaining. + */ + public Builder addQueriesBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureQueriesIsMutable(); + queries_.add(value); + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.bundle.BundledDocumentMetadata) + } + + // @@protoc_insertion_point(class_scope:google.firestore.bundle.BundledDocumentMetadata) + private static final com.google.firestore.bundle.BundledDocumentMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.bundle.BundledDocumentMetadata(); + } + + public static com.google.firestore.bundle.BundledDocumentMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BundledDocumentMetadata parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledDocumentMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadataOrBuilder.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadataOrBuilder.java new file mode 100644 index 000000000000..312af973bfa7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledDocumentMetadataOrBuilder.java @@ -0,0 +1,158 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public interface BundledDocumentMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.bundle.BundledDocumentMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The document key of a bundled document.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * The document key of a bundled document.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The snapshot version of the document data bundled.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * Whether the document exists.
+   * 
+ * + * bool exists = 3; + * + * @return The exists. + */ + boolean getExists(); + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @return A list containing the queries. + */ + java.util.List getQueriesList(); + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @return The count of queries. + */ + int getQueriesCount(); + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @param index The index of the element to return. + * @return The queries at the given index. + */ + java.lang.String getQueries(int index); + + /** + * + * + *
+   * The names of the queries in this bundle that this document matches to.
+   * 
+ * + * repeated string queries = 4; + * + * @param index The index of the value to return. + * @return The bytes of the queries at the given index. + */ + com.google.protobuf.ByteString getQueriesBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQuery.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQuery.java new file mode 100644 index 000000000000..deafec5ca6bf --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQuery.java @@ -0,0 +1,1215 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +/** + * + * + *
+ * Encodes a query saved in the bundle.
+ * 
+ * + * Protobuf type {@code google.firestore.bundle.BundledQuery} + */ +@com.google.protobuf.Generated +public final class BundledQuery extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.bundle.BundledQuery) + BundledQueryOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BundledQuery"); + } + + // Use BundledQuery.newBuilder() to construct. + private BundledQuery(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BundledQuery() { + parent_ = ""; + limitType_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundledQuery.class, + com.google.firestore.bundle.BundledQuery.Builder.class); + } + + /** + * + * + *
+   * If the query is a limit query, should the limit be applied to the beginning or
+   * the end of results.
+   * 
+ * + * Protobuf enum {@code google.firestore.bundle.BundledQuery.LimitType} + */ + public enum LimitType implements com.google.protobuf.ProtocolMessageEnum { + /** FIRST = 0; */ + FIRST(0), + /** LAST = 1; */ + LAST(1), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "LimitType"); + } + + /** FIRST = 0; */ + public static final int FIRST_VALUE = 0; + + /** LAST = 1; */ + public static final int LAST_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static LimitType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static LimitType forNumber(int value) { + switch (value) { + case 0: + return FIRST; + case 1: + return LAST; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public LimitType findValueByNumber(int number) { + return LimitType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.bundle.BundledQuery.getDescriptor().getEnumTypes().get(0); + } + + private static final LimitType[] VALUES = values(); + + public static LimitType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private LimitType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.bundle.BundledQuery.LimitType) + } + + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_QUERY(2), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * The parent resource name.
+   * 
+ * + * string parent = 1; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * The parent resource name.
+   * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + public static final int LIMIT_TYPE_FIELD_NUMBER = 3; + private int limitType_ = 0; + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The enum numeric value on the wire for limitType. + */ + @java.lang.Override + public int getLimitTypeValue() { + return limitType_; + } + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The limitType. + */ + @java.lang.Override + public com.google.firestore.bundle.BundledQuery.LimitType getLimitType() { + com.google.firestore.bundle.BundledQuery.LimitType result = + com.google.firestore.bundle.BundledQuery.LimitType.forNumber(limitType_); + return result == null + ? com.google.firestore.bundle.BundledQuery.LimitType.UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (queryTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (limitType_ != com.google.firestore.bundle.BundledQuery.LimitType.FIRST.getNumber()) { + output.writeEnum(3, limitType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (queryTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (limitType_ != com.google.firestore.bundle.BundledQuery.LimitType.FIRST.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, limitType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.bundle.BundledQuery)) { + return super.equals(obj); + } + com.google.firestore.bundle.BundledQuery other = (com.google.firestore.bundle.BundledQuery) obj; + + if (!getParent().equals(other.getParent())) return false; + if (limitType_ != other.limitType_) return false; + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 2: + if (!getStructuredQuery().equals(other.getStructuredQuery())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + LIMIT_TYPE_FIELD_NUMBER; + hash = (53 * hash) + limitType_; + switch (queryTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.bundle.BundledQuery parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledQuery parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.BundledQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.bundle.BundledQuery prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Encodes a query saved in the bundle.
+   * 
+ * + * Protobuf type {@code google.firestore.bundle.BundledQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.bundle.BundledQuery) + com.google.firestore.bundle.BundledQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.BundledQuery.class, + com.google.firestore.bundle.BundledQuery.Builder.class); + } + + // Construct using com.google.firestore.bundle.BundledQuery.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + if (structuredQueryBuilder_ != null) { + structuredQueryBuilder_.clear(); + } + limitType_ = 0; + queryTypeCase_ = 0; + queryType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_BundledQuery_descriptor; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledQuery getDefaultInstanceForType() { + return com.google.firestore.bundle.BundledQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.bundle.BundledQuery build() { + com.google.firestore.bundle.BundledQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledQuery buildPartial() { + com.google.firestore.bundle.BundledQuery result = + new com.google.firestore.bundle.BundledQuery(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.bundle.BundledQuery result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.limitType_ = limitType_; + } + } + + private void buildPartialOneofs(com.google.firestore.bundle.BundledQuery result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 2 && structuredQueryBuilder_ != null) { + result.queryType_ = structuredQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.bundle.BundledQuery) { + return mergeFrom((com.google.firestore.bundle.BundledQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.bundle.BundledQuery other) { + if (other == com.google.firestore.bundle.BundledQuery.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.limitType_ != 0) { + setLimitTypeValue(other.getLimitTypeValue()); + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_QUERY: + { + mergeStructuredQuery(other.getStructuredQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 2; + break; + } // case 18 + case 24: + { + limitType_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * The parent resource name.
+     * 
+ * + * string parent = 1; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The parent resource name.
+     * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The parent resource name.
+     * 
+ * + * string parent = 1; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The parent resource name.
+     * 
+ * + * string parent = 1; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The parent resource name.
+     * 
+ * + * string parent = 1; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + structuredQueryBuilder_; + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 2) { + return structuredQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery( + com.google.firestore.v1.StructuredQuery.Builder builderForValue) { + if (structuredQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder mergeStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2 + && queryType_ != com.google.firestore.v1.StructuredQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredQuery.newBuilder( + (com.google.firestore.v1.StructuredQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 2) { + structuredQueryBuilder_.mergeFrom(value); + } else { + structuredQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder clearStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public com.google.firestore.v1.StructuredQuery.Builder getStructuredQueryBuilder() { + return internalGetStructuredQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if ((queryTypeCase_ == 2) && (structuredQueryBuilder_ != null)) { + return structuredQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + internalGetStructuredQueryFieldBuilder() { + if (structuredQueryBuilder_ == null) { + if (!(queryTypeCase_ == 2)) { + queryType_ = com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + structuredQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder>( + (com.google.firestore.v1.StructuredQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 2; + onChanged(); + return structuredQueryBuilder_; + } + + private int limitType_ = 0; + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The enum numeric value on the wire for limitType. + */ + @java.lang.Override + public int getLimitTypeValue() { + return limitType_; + } + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @param value The enum numeric value on the wire for limitType to set. + * @return This builder for chaining. + */ + public Builder setLimitTypeValue(int value) { + limitType_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The limitType. + */ + @java.lang.Override + public com.google.firestore.bundle.BundledQuery.LimitType getLimitType() { + com.google.firestore.bundle.BundledQuery.LimitType result = + com.google.firestore.bundle.BundledQuery.LimitType.forNumber(limitType_); + return result == null + ? com.google.firestore.bundle.BundledQuery.LimitType.UNRECOGNIZED + : result; + } + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @param value The limitType to set. + * @return This builder for chaining. + */ + public Builder setLimitType(com.google.firestore.bundle.BundledQuery.LimitType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + limitType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return This builder for chaining. + */ + public Builder clearLimitType() { + bitField0_ = (bitField0_ & ~0x00000004); + limitType_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.bundle.BundledQuery) + } + + // @@protoc_insertion_point(class_scope:google.firestore.bundle.BundledQuery) + private static final com.google.firestore.bundle.BundledQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.bundle.BundledQuery(); + } + + public static com.google.firestore.bundle.BundledQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BundledQuery parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.bundle.BundledQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQueryOrBuilder.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQueryOrBuilder.java new file mode 100644 index 000000000000..fb76f167b2a1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/BundledQueryOrBuilder.java @@ -0,0 +1,107 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public interface BundledQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.bundle.BundledQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The parent resource name.
+   * 
+ * + * string parent = 1; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * The parent resource name.
+   * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + boolean hasStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + com.google.firestore.v1.StructuredQuery getStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The enum numeric value on the wire for limitType. + */ + int getLimitTypeValue(); + + /** + * .google.firestore.bundle.BundledQuery.LimitType limit_type = 3; + * + * @return The limitType. + */ + com.google.firestore.bundle.BundledQuery.LimitType getLimitType(); + + com.google.firestore.bundle.BundledQuery.QueryTypeCase getQueryTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQuery.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQuery.java new file mode 100644 index 000000000000..a186b2b3639d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQuery.java @@ -0,0 +1,1189 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +/** + * + * + *
+ * A Query associated with a name, created as part of the bundle file, and can be read
+ * by client SDKs once the bundle containing them is loaded.
+ * 
+ * + * Protobuf type {@code google.firestore.bundle.NamedQuery} + */ +@com.google.protobuf.Generated +public final class NamedQuery extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.bundle.NamedQuery) + NamedQueryOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "NamedQuery"); + } + + // Use NamedQuery.newBuilder() to construct. + private NamedQuery(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private NamedQuery() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_NamedQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_NamedQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.NamedQuery.class, + com.google.firestore.bundle.NamedQuery.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Name of the query, such that client can use the name to load this query
+   * from bundle, and resume from when the query results are materialized
+   * into this bundle.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Name of the query, such that client can use the name to load this query
+   * from bundle, and resume from when the query results are materialized
+   * into this bundle.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BUNDLED_QUERY_FIELD_NUMBER = 2; + private com.google.firestore.bundle.BundledQuery bundledQuery_; + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return Whether the bundledQuery field is set. + */ + @java.lang.Override + public boolean hasBundledQuery() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return The bundledQuery. + */ + @java.lang.Override + public com.google.firestore.bundle.BundledQuery getBundledQuery() { + return bundledQuery_ == null + ? com.google.firestore.bundle.BundledQuery.getDefaultInstance() + : bundledQuery_; + } + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + @java.lang.Override + public com.google.firestore.bundle.BundledQueryOrBuilder getBundledQueryOrBuilder() { + return bundledQuery_ == null + ? com.google.firestore.bundle.BundledQuery.getDefaultInstance() + : bundledQuery_; + } + + public static final int READ_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getBundledQuery()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getBundledQuery()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getReadTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.bundle.NamedQuery)) { + return super.equals(obj); + } + com.google.firestore.bundle.NamedQuery other = (com.google.firestore.bundle.NamedQuery) obj; + + if (!getName().equals(other.getName())) return false; + if (hasBundledQuery() != other.hasBundledQuery()) return false; + if (hasBundledQuery()) { + if (!getBundledQuery().equals(other.getBundledQuery())) return false; + } + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasBundledQuery()) { + hash = (37 * hash) + BUNDLED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getBundledQuery().hashCode(); + } + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.bundle.NamedQuery parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.NamedQuery parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.NamedQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.bundle.NamedQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.bundle.NamedQuery prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Query associated with a name, created as part of the bundle file, and can be read
+   * by client SDKs once the bundle containing them is loaded.
+   * 
+ * + * Protobuf type {@code google.firestore.bundle.NamedQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.bundle.NamedQuery) + com.google.firestore.bundle.NamedQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_NamedQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_NamedQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.bundle.NamedQuery.class, + com.google.firestore.bundle.NamedQuery.Builder.class); + } + + // Construct using com.google.firestore.bundle.NamedQuery.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetBundledQueryFieldBuilder(); + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + bundledQuery_ = null; + if (bundledQueryBuilder_ != null) { + bundledQueryBuilder_.dispose(); + bundledQueryBuilder_ = null; + } + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.bundle.BundleProto + .internal_static_google_firestore_bundle_NamedQuery_descriptor; + } + + @java.lang.Override + public com.google.firestore.bundle.NamedQuery getDefaultInstanceForType() { + return com.google.firestore.bundle.NamedQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.bundle.NamedQuery build() { + com.google.firestore.bundle.NamedQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.bundle.NamedQuery buildPartial() { + com.google.firestore.bundle.NamedQuery result = + new com.google.firestore.bundle.NamedQuery(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.bundle.NamedQuery result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.bundledQuery_ = + bundledQueryBuilder_ == null ? bundledQuery_ : bundledQueryBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.bundle.NamedQuery) { + return mergeFrom((com.google.firestore.bundle.NamedQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.bundle.NamedQuery other) { + if (other == com.google.firestore.bundle.NamedQuery.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasBundledQuery()) { + mergeBundledQuery(other.getBundledQuery()); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetBundledQueryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Name of the query, such that client can use the name to load this query
+     * from bundle, and resume from when the query results are materialized
+     * into this bundle.
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Name of the query, such that client can use the name to load this query
+     * from bundle, and resume from when the query results are materialized
+     * into this bundle.
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Name of the query, such that client can use the name to load this query
+     * from bundle, and resume from when the query results are materialized
+     * into this bundle.
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Name of the query, such that client can use the name to load this query
+     * from bundle, and resume from when the query results are materialized
+     * into this bundle.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Name of the query, such that client can use the name to load this query
+     * from bundle, and resume from when the query results are materialized
+     * into this bundle.
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.bundle.BundledQuery bundledQuery_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledQuery, + com.google.firestore.bundle.BundledQuery.Builder, + com.google.firestore.bundle.BundledQueryOrBuilder> + bundledQueryBuilder_; + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return Whether the bundledQuery field is set. + */ + public boolean hasBundledQuery() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return The bundledQuery. + */ + public com.google.firestore.bundle.BundledQuery getBundledQuery() { + if (bundledQueryBuilder_ == null) { + return bundledQuery_ == null + ? com.google.firestore.bundle.BundledQuery.getDefaultInstance() + : bundledQuery_; + } else { + return bundledQueryBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public Builder setBundledQuery(com.google.firestore.bundle.BundledQuery value) { + if (bundledQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + bundledQuery_ = value; + } else { + bundledQueryBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public Builder setBundledQuery( + com.google.firestore.bundle.BundledQuery.Builder builderForValue) { + if (bundledQueryBuilder_ == null) { + bundledQuery_ = builderForValue.build(); + } else { + bundledQueryBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public Builder mergeBundledQuery(com.google.firestore.bundle.BundledQuery value) { + if (bundledQueryBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && bundledQuery_ != null + && bundledQuery_ != com.google.firestore.bundle.BundledQuery.getDefaultInstance()) { + getBundledQueryBuilder().mergeFrom(value); + } else { + bundledQuery_ = value; + } + } else { + bundledQueryBuilder_.mergeFrom(value); + } + if (bundledQuery_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public Builder clearBundledQuery() { + bitField0_ = (bitField0_ & ~0x00000002); + bundledQuery_ = null; + if (bundledQueryBuilder_ != null) { + bundledQueryBuilder_.dispose(); + bundledQueryBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public com.google.firestore.bundle.BundledQuery.Builder getBundledQueryBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetBundledQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + public com.google.firestore.bundle.BundledQueryOrBuilder getBundledQueryOrBuilder() { + if (bundledQueryBuilder_ != null) { + return bundledQueryBuilder_.getMessageOrBuilder(); + } else { + return bundledQuery_ == null + ? com.google.firestore.bundle.BundledQuery.getDefaultInstance() + : bundledQuery_; + } + } + + /** + * + * + *
+     * The query saved in the bundle.
+     * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledQuery, + com.google.firestore.bundle.BundledQuery.Builder, + com.google.firestore.bundle.BundledQueryOrBuilder> + internalGetBundledQueryFieldBuilder() { + if (bundledQueryBuilder_ == null) { + bundledQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.bundle.BundledQuery, + com.google.firestore.bundle.BundledQuery.Builder, + com.google.firestore.bundle.BundledQueryOrBuilder>( + getBundledQuery(), getParentForChildren(), isClean()); + bundledQuery_ = null; + } + return bundledQueryBuilder_; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The read time of the query, when it is used to build the bundle. This is useful to
+     * resume the query from the bundle, once it is loaded by client SDKs.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.bundle.NamedQuery) + } + + // @@protoc_insertion_point(class_scope:google.firestore.bundle.NamedQuery) + private static final com.google.firestore.bundle.NamedQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.bundle.NamedQuery(); + } + + public static com.google.firestore.bundle.NamedQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public NamedQuery parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.bundle.NamedQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQueryOrBuilder.java b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQueryOrBuilder.java new file mode 100644 index 000000000000..f9369435d2bd --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/java/com/google/firestore/bundle/NamedQueryOrBuilder.java @@ -0,0 +1,135 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/bundle/bundle.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.bundle; + +@com.google.protobuf.Generated +public interface NamedQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.bundle.NamedQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Name of the query, such that client can use the name to load this query
+   * from bundle, and resume from when the query results are materialized
+   * into this bundle.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Name of the query, such that client can use the name to load this query
+   * from bundle, and resume from when the query results are materialized
+   * into this bundle.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return Whether the bundledQuery field is set. + */ + boolean hasBundledQuery(); + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + * + * @return The bundledQuery. + */ + com.google.firestore.bundle.BundledQuery getBundledQuery(); + + /** + * + * + *
+   * The query saved in the bundle.
+   * 
+ * + * .google.firestore.bundle.BundledQuery bundled_query = 2; + */ + com.google.firestore.bundle.BundledQueryOrBuilder getBundledQueryOrBuilder(); + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The read time of the query, when it is used to build the bundle. This is useful to
+   * resume the query from the bundle, once it is loaded by client SDKs.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/proto/google/firestore/bundle/bundle.proto b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/proto/google/firestore/bundle/bundle.proto new file mode 100644 index 000000000000..914d150a4f70 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-bundle-v1/src/main/proto/google/firestore/bundle/bundle.proto @@ -0,0 +1,120 @@ +// Copyright 2025 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// This file defines the format of Firestore bundle file/stream. It is not a part of the +// Firestore API, only a specification used by Server and Client SDK to write and read +// bundles. + +syntax = "proto3"; + +package google.firestore.bundle; + +import "google/firestore/v1/document.proto"; +import "google/firestore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Firestore.Bundle"; +option go_package = "cloud.google.com/go/firestore/bundle/bundlepb;bundlepb"; +option java_multiple_files = true; +option java_outer_classname = "BundleProto"; +option java_package = "com.google.firestore.bundle"; +option objc_class_prefix = "FSTPB"; +option php_namespace = "Firestore\\Bundle"; + +// Encodes a query saved in the bundle. +message BundledQuery { + // The parent resource name. + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + google.firestore.v1.StructuredQuery structured_query = 2; + } + + // If the query is a limit query, should the limit be applied to the beginning or + // the end of results. + enum LimitType { + FIRST = 0; + LAST = 1; + } + LimitType limit_type = 3; +} + +// A Query associated with a name, created as part of the bundle file, and can be read +// by client SDKs once the bundle containing them is loaded. +message NamedQuery { + // Name of the query, such that client can use the name to load this query + // from bundle, and resume from when the query results are materialized + // into this bundle. + string name = 1; + + // The query saved in the bundle. + BundledQuery bundled_query = 2; + + // The read time of the query, when it is used to build the bundle. This is useful to + // resume the query from the bundle, once it is loaded by client SDKs. + google.protobuf.Timestamp read_time = 3; +} + +// Metadata describing a Firestore document saved in the bundle. +message BundledDocumentMetadata { + // The document key of a bundled document. + string name = 1; + + // The snapshot version of the document data bundled. + google.protobuf.Timestamp read_time = 2; + + // Whether the document exists. + bool exists = 3; + + // The names of the queries in this bundle that this document matches to. + repeated string queries = 4; +} + +// Metadata describing the bundle file/stream. +message BundleMetadata { + // The ID of the bundle. + string id = 1; + + // Time at which the documents snapshot is taken for this bundle. + google.protobuf.Timestamp create_time = 2; + + // The schema version of the bundle. + uint32 version = 3; + + // The number of documents in the bundle. + uint32 total_documents = 4; + + // The size of the bundle in bytes, excluding this `BundleMetadata`. + uint64 total_bytes = 5; +} + +// A Firestore bundle is a length-prefixed stream of JSON representations of +// `BundleElement`. +// Only one `BundleMetadata` is expected, and it should be the first element. +// The named queries follow after `metadata`. Every `document_metadata` is +// immediately followed by a `document`. +message BundleElement { + oneof element_type { + BundleMetadata metadata = 1; + + NamedQuery named_query = 2; + + BundledDocumentMetadata document_metadata = 3; + + google.firestore.v1.Document document = 4; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/clirr-ignored-differences.xml b/java-firestore/proto-google-cloud-firestore-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..27e17c5fa9f0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/clirr-ignored-differences.xml @@ -0,0 +1,231 @@ + + + + + 8001 + com/google/firestore/v1/QueryMode + + + 8001 + com/google/firestore/v1/QueryPlan* + + + 8001 + com/google/firestore/v1/QueryProfileProto + + + 8001 + com/google/firestore/v1/ResultSetStatsOrBuilder + + + 8001 + com/google/firestore/v1/ResultSetStats* + + + 6011 + com/google/firestore/v1/Run*QueryRequest + MODE_FIELD_NUMBER + + + 6011 + com/google/firestore/v1/Run*QueryResponse + STATS_FIELD_NUMBER + + + 7002 + com/google/firestore/v1/Run*QueryRequest* + * getMode() + + + 7002 + com/google/firestore/v1/Run*QueryRequest* + * getModeValue() + + + 7002 + com/google/firestore/v1/Run*QueryRequest* + * clearMode() + + + 7002 + com/google/firestore/v1/Run*QueryRequest$Builder + * setMode(*) + + + 7002 + com/google/firestore/v1/Run*QueryRequest$Builder + * setModeValue(*) + + + 7002 + com/google/firestore/v1/Run*QueryResponse* + * getStats() + + + 7002 + com/google/firestore/v1/Run*QueryResponse* + * hasStats() + + + 7002 + com/google/firestore/v1/Run*QueryResponse$Builder + * clearStats() + + + 7002 + com/google/firestore/v1/Run*QueryResponse$Builder + * setStats(*) + + + 7002 + com/google/firestore/v1/Run*QueryResponse* + * getStatsOrBuilder() + + + 7002 + com/google/firestore/v1/Run*QueryResponse$Builder + * getStatsBuilder() + + + 7002 + com/google/firestore/v1/Run*QueryResponse$Builder + * mergeStats(*) + + + 7012 + com/google/firestore/v1/Run*QueryRequestOrBuilder + com.google.firestore.v1.ExplainOptions getExplainOptions() + + + 7012 + com/google/firestore/v1/Run*QueryRequestOrBuilder + com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() + + + 7012 + com/google/firestore/v1/Run*QueryRequestOrBuilder + boolean hasExplainOptions() + + + 7012 + com/google/firestore/v1/Run*QueryResponseOrBuilder + com.google.firestore.v1.ExplainMetrics getExplainMetrics() + + + 7012 + com/google/firestore/v1/Run*QueryResponseOrBuilder + com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() + + + 7012 + com/google/firestore/v1/Run*QueryResponseOrBuilder + boolean hasExplainMetrics() + + + 7012 + com/google/firestore/v1/StructuredQueryOrBuilder + com.google.firestore.v1.StructuredQuery$FindNearest getFindNearest() + + + 7012 + com/google/firestore/v1/StructuredQueryOrBuilder + com.google.firestore.v1.StructuredQuery$FindNearestOrBuilder getFindNearestOrBuilder() + + + 7012 + com/google/firestore/v1/StructuredQueryOrBuilder + boolean hasFindNearest() + + + 7012 + com/google/firestore/v1/StructuredQuery$FindNearestOrBuilder + java.lang.String getDistanceResultField() + + + 7012 + com/google/firestore/v1/StructuredQuery$FindNearestOrBuilder + com.google.protobuf.ByteString getDistanceResultFieldBytes() + + + 7012 + com/google/firestore/v1/StructuredQuery$FindNearestOrBuilder + com.google.protobuf.DoubleValue getDistanceThreshold() + + + 7012 + com/google/firestore/v1/StructuredQuery$FindNearestOrBuilder + com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder() + + + 7012 + com/google/firestore/v1/StructuredQuery$FindNearestOrBuilder + boolean hasDistanceThreshold() + + + + + 7006 + com/google/firestore/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/firestore/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/firestore/v1/** + * clear() + ** + + + 7006 + com/google/firestore/v1/** + * clearField(*) + ** + + + 7006 + com/google/firestore/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/firestore/v1/** + * clone() + ** + + + 7006 + com/google/firestore/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/firestore/v1/** + * setField(*) + ** + + + 7006 + com/google/firestore/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/firestore/v1/** + * setUnknownFields(*) + ** + + + 7012 + com/google/firestore/v1/ValueOrBuilder + * + + diff --git a/java-firestore/proto-google-cloud-firestore-v1/pom.xml b/java-firestore/proto-google-cloud-firestore-v1/pom.xml new file mode 100644 index 000000000000..d6d5f7339ffd --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/pom.xml @@ -0,0 +1,58 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-firestore-v1 + 3.38.1-SNAPSHOT + proto-google-cloud-firestore-v1 + PROTO library for proto-google-cloud-firestore-v1 + + com.google.cloud + google-cloud-firestore-parent + 3.38.1-SNAPSHOT + + + + com.google.protobuf + protobuf-java + compile + + + com.google.api + api-common + compile + + + com.google.api.grpc + proto-google-common-protos + compile + + + com.google.guava + guava + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResult.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResult.java new file mode 100644 index 000000000000..70758730bf02 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResult.java @@ -0,0 +1,901 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/aggregation_result.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The result of a single bucket from a Firestore aggregation query.
+ *
+ * The keys of `aggregate_fields` are the same for all results in an aggregation
+ * query, unlike document queries which can have different fields present for
+ * each result.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.AggregationResult} + */ +@com.google.protobuf.Generated +public final class AggregationResult extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.AggregationResult) + AggregationResultOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "AggregationResult"); + } + + // Use AggregationResult.newBuilder() to construct. + private AggregationResult(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private AggregationResult() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetAggregateFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.AggregationResult.class, + com.google.firestore.v1.AggregationResult.Builder.class); + } + + public static final int AGGREGATE_FIELDS_FIELD_NUMBER = 2; + + private static final class AggregateFieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField + aggregateFields_; + + private com.google.protobuf.MapField + internalGetAggregateFields() { + if (aggregateFields_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AggregateFieldsDefaultEntryHolder.defaultEntry); + } + return aggregateFields_; + } + + public int getAggregateFieldsCount() { + return internalGetAggregateFields().getMap().size(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public boolean containsAggregateFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetAggregateFields().getMap().containsKey(key); + } + + /** Use {@link #getAggregateFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getAggregateFields() { + return getAggregateFieldsMap(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public java.util.Map getAggregateFieldsMap() { + return internalGetAggregateFields().getMap(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getAggregateFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetAggregateFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getAggregateFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetAggregateFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetAggregateFields(), AggregateFieldsDefaultEntryHolder.defaultEntry, 2); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (java.util.Map.Entry entry : + internalGetAggregateFields().getMap().entrySet()) { + com.google.protobuf.MapEntry + aggregateFields__ = + AggregateFieldsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, aggregateFields__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.AggregationResult)) { + return super.equals(obj); + } + com.google.firestore.v1.AggregationResult other = + (com.google.firestore.v1.AggregationResult) obj; + + if (!internalGetAggregateFields().equals(other.internalGetAggregateFields())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (!internalGetAggregateFields().getMap().isEmpty()) { + hash = (37 * hash) + AGGREGATE_FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetAggregateFields().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.AggregationResult parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.AggregationResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.AggregationResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.AggregationResult parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.AggregationResult parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.AggregationResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.AggregationResult prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The result of a single bucket from a Firestore aggregation query.
+   *
+   * The keys of `aggregate_fields` are the same for all results in an aggregation
+   * query, unlike document queries which can have different fields present for
+   * each result.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.AggregationResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.AggregationResult) + com.google.firestore.v1.AggregationResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetAggregateFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableAggregateFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.AggregationResult.class, + com.google.firestore.v1.AggregationResult.Builder.class); + } + + // Construct using com.google.firestore.v1.AggregationResult.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + internalGetMutableAggregateFields().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.AggregationResultProto + .internal_static_google_firestore_v1_AggregationResult_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.AggregationResult getDefaultInstanceForType() { + return com.google.firestore.v1.AggregationResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.AggregationResult build() { + com.google.firestore.v1.AggregationResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.AggregationResult buildPartial() { + com.google.firestore.v1.AggregationResult result = + new com.google.firestore.v1.AggregationResult(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.AggregationResult result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.aggregateFields_ = + internalGetAggregateFields().build(AggregateFieldsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.AggregationResult) { + return mergeFrom((com.google.firestore.v1.AggregationResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.AggregationResult other) { + if (other == com.google.firestore.v1.AggregationResult.getDefaultInstance()) return this; + internalGetMutableAggregateFields().mergeFrom(other.internalGetAggregateFields()); + bitField0_ |= 0x00000001; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + com.google.protobuf.MapEntry + aggregateFields__ = + input.readMessage( + AggregateFieldsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableAggregateFields() + .ensureBuilderMap() + .put(aggregateFields__.getKey(), aggregateFields__.getValue()); + bitField0_ |= 0x00000001; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private static final class AggregateFieldsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return AggregateFieldsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final AggregateFieldsConverter aggregateFieldsConverter = + new AggregateFieldsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + aggregateFields_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetAggregateFields() { + if (aggregateFields_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(aggregateFieldsConverter); + } + return aggregateFields_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableAggregateFields() { + if (aggregateFields_ == null) { + aggregateFields_ = new com.google.protobuf.MapFieldBuilder<>(aggregateFieldsConverter); + } + bitField0_ |= 0x00000001; + onChanged(); + return aggregateFields_; + } + + public int getAggregateFieldsCount() { + return internalGetAggregateFields().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public boolean containsAggregateFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetAggregateFields().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getAggregateFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getAggregateFields() { + return getAggregateFieldsMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public java.util.Map getAggregateFieldsMap() { + return internalGetAggregateFields().getImmutableMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getAggregateFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableAggregateFields().ensureBuilderMap(); + return map.containsKey(key) ? aggregateFieldsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getAggregateFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableAggregateFields().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return aggregateFieldsConverter.build(map.get(key)); + } + + public Builder clearAggregateFields() { + bitField0_ = (bitField0_ & ~0x00000001); + internalGetMutableAggregateFields().clear(); + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + public Builder removeAggregateFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableAggregateFields().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map + getMutableAggregateFields() { + bitField0_ |= 0x00000001; + return internalGetMutableAggregateFields().ensureMessageMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + public Builder putAggregateFields(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableAggregateFields().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + public Builder putAllAggregateFields( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableAggregateFields().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+     *
+     * The key is the
+     * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+     * assigned to the aggregation function on input and the size of this map
+     * equals the number of aggregation functions in the query.
+     * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + public com.google.firestore.v1.Value.Builder putAggregateFieldsBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = + internalGetMutableAggregateFields().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.AggregationResult) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.AggregationResult) + private static final com.google.firestore.v1.AggregationResult DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.AggregationResult(); + } + + public static com.google.firestore.v1.AggregationResult getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AggregationResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.AggregationResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultOrBuilder.java new file mode 100644 index 000000000000..dd6606ed99d5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultOrBuilder.java @@ -0,0 +1,116 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/aggregation_result.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface AggregationResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.AggregationResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + int getAggregateFieldsCount(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + boolean containsAggregateFields(java.lang.String key); + + /** Use {@link #getAggregateFieldsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getAggregateFields(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + java.util.Map getAggregateFieldsMap(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + /* nullable */ + com.google.firestore.v1.Value getAggregateFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_docs`.
+   *
+   * The key is the
+   * [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias]
+   * assigned to the aggregation function on input and the size of this map
+   * equals the number of aggregation functions in the query.
+   * 
+ * + * map<string, .google.firestore.v1.Value> aggregate_fields = 2; + */ + com.google.firestore.v1.Value getAggregateFieldsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultProto.java new file mode 100644 index 000000000000..1c5a51d2b8d1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AggregationResultProto.java @@ -0,0 +1,101 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/aggregation_result.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class AggregationResultProto extends com.google.protobuf.GeneratedFile { + private AggregationResultProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "AggregationResultProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_AggregationResult_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_AggregationResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n,google/firestore/v1/aggregation_result" + + ".proto\022\023google.firestore.v1\032\"google/fire" + + "store/v1/document.proto\"\276\001\n\021AggregationR" + + "esult\022U\n\020aggregate_fields\030\002 \003(\0132;.google" + + ".firestore.v1.AggregationResult.Aggregat" + + "eFieldsEntry\032R\n\024AggregateFieldsEntry\022\013\n\003" + + "key\030\001 \001(\t\022)\n\005value\030\002 \001(\0132\032.google.firest" + + "ore.v1.Value:\0028\001B\316\001\n\027com.google.firestor" + + "e.v1B\026AggregationResultProtoP\001Z;cloud.go" + + "ogle.com/go/firestore/apiv1/firestorepb;" + + "firestorepb\242\002\004GCFS\252\002\031Google.Cloud.Firest" + + "ore.V1\312\002\031Google\\Cloud\\Firestore\\V1\352\002\034Goo" + + "gle::Cloud::Firestore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.firestore.v1.DocumentProto.getDescriptor(), + }); + internal_static_google_firestore_v1_AggregationResult_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_AggregationResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_AggregationResult_descriptor, + new java.lang.String[] { + "AggregateFields", + }); + internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_descriptor = + internal_static_google_firestore_v1_AggregationResult_descriptor.getNestedType(0); + internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_AggregationResult_AggregateFieldsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.firestore.v1.DocumentProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AnyPathName.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AnyPathName.java new file mode 100644 index 000000000000..47bfc00cb137 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/AnyPathName.java @@ -0,0 +1,242 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") +public class AnyPathName implements ResourceName { + + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/documents/{document}/{any_path=**}"); + + private volatile Map fieldValuesMap; + + private final String project; + private final String database; + private final String document; + private final String anyPath; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getDocument() { + return document; + } + + public String getAnyPath() { + return anyPath; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private AnyPathName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + document = Preconditions.checkNotNull(builder.getDocument()); + anyPath = Preconditions.checkNotNull(builder.getAnyPath()); + } + + public static AnyPathName of(String project, String database, String document, String anyPath) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setDocument(document) + .setAnyPath(anyPath) + .build(); + } + + public static String format(String project, String database, String document, String anyPath) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setDocument(document) + .setAnyPath(anyPath) + .build() + .toString(); + } + + public static AnyPathName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, "AnyPathName.parse: formattedString not in valid format"); + return of( + matchMap.get("project"), + matchMap.get("database"), + matchMap.get("document"), + matchMap.get("any_path")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList(values.size()); + for (AnyPathName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + 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("document", document); + fieldMapBuilder.put("anyPath", anyPath); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate( + "project", project, "database", database, "document", document, "any_path", anyPath); + } + + /** Builder for AnyPathName. */ + public static class Builder { + + private String project; + private String database; + private String document; + private String anyPath; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getDocument() { + return document; + } + + public String getAnyPath() { + return anyPath; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setDocument(String document) { + this.document = document; + return this; + } + + public Builder setAnyPath(String anyPath) { + this.anyPath = anyPath; + return this; + } + + private Builder() {} + + private Builder(AnyPathName anyPathName) { + project = anyPathName.project; + database = anyPathName.database; + document = anyPathName.document; + anyPath = anyPathName.anyPath; + } + + public AnyPathName build() { + return new AnyPathName(this); + } + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof AnyPathName) { + AnyPathName that = (AnyPathName) o; + return (this.project.equals(that.project)) + && (this.database.equals(that.database)) + && (this.document.equals(that.document)) + && (this.anyPath.equals(that.anyPath)); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= project.hashCode(); + h *= 1000003; + h ^= database.hashCode(); + h *= 1000003; + h ^= document.hashCode(); + h *= 1000003; + h ^= anyPath.hashCode(); + return h; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValue.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValue.java new file mode 100644 index 000000000000..1058092721c9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValue.java @@ -0,0 +1,912 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * An array value.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ArrayValue} + */ +@com.google.protobuf.Generated +public final class ArrayValue extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ArrayValue) + ArrayValueOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ArrayValue"); + } + + // Use ArrayValue.newBuilder() to construct. + private ArrayValue(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ArrayValue() { + values_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_ArrayValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ArrayValue.class, + com.google.firestore.v1.ArrayValue.Builder.class); + } + + public static final int VALUES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List values_; + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesList() { + return values_; + } + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesOrBuilderList() { + return values_; + } + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public int getValuesCount() { + return values_.size(); + } + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Value getValues(int index) { + return values_.get(index); + } + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index) { + return values_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < values_.size(); i++) { + output.writeMessage(1, values_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < values_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, values_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ArrayValue)) { + return super.equals(obj); + } + com.google.firestore.v1.ArrayValue other = (com.google.firestore.v1.ArrayValue) obj; + + if (!getValuesList().equals(other.getValuesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getValuesCount() > 0) { + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValuesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ArrayValue parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ArrayValue parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ArrayValue parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ArrayValue parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ArrayValue parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ArrayValue parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ArrayValue parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ArrayValue prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * An array value.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ArrayValue} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ArrayValue) + com.google.firestore.v1.ArrayValueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_ArrayValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ArrayValue.class, + com.google.firestore.v1.ArrayValue.Builder.class); + } + + // Construct using com.google.firestore.v1.ArrayValue.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + } else { + values_ = null; + valuesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ArrayValue getDefaultInstanceForType() { + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ArrayValue build() { + com.google.firestore.v1.ArrayValue result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ArrayValue buildPartial() { + com.google.firestore.v1.ArrayValue result = new com.google.firestore.v1.ArrayValue(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.ArrayValue result) { + if (valuesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + values_ = java.util.Collections.unmodifiableList(values_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.values_ = values_; + } else { + result.values_ = valuesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.ArrayValue result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ArrayValue) { + return mergeFrom((com.google.firestore.v1.ArrayValue) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ArrayValue other) { + if (other == com.google.firestore.v1.ArrayValue.getDefaultInstance()) return this; + if (valuesBuilder_ == null) { + if (!other.values_.isEmpty()) { + if (values_.isEmpty()) { + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureValuesIsMutable(); + values_.addAll(other.values_); + } + onChanged(); + } + } else { + if (!other.values_.isEmpty()) { + if (valuesBuilder_.isEmpty()) { + valuesBuilder_.dispose(); + valuesBuilder_ = null; + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000001); + valuesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetValuesFieldBuilder() + : null; + } else { + valuesBuilder_.addAllMessages(other.values_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(m); + } else { + valuesBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List values_ = + java.util.Collections.emptyList(); + + private void ensureValuesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + values_ = new java.util.ArrayList(values_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + valuesBuilder_; + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List getValuesList() { + if (valuesBuilder_ == null) { + return java.util.Collections.unmodifiableList(values_); + } else { + return valuesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public int getValuesCount() { + if (valuesBuilder_ == null) { + return values_.size(); + } else { + return valuesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value getValues(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.set(index, value); + onChanged(); + } else { + valuesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.set(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(value); + onChanged(); + } else { + valuesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(index, value); + onChanged(); + } else { + valuesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addAllValues( + java.lang.Iterable values) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, values_); + onChanged(); + } else { + valuesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder clearValues() { + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + valuesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder removeValues(int index) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.remove(index); + onChanged(); + } else { + valuesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder getValuesBuilder(int index) { + return internalGetValuesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List + getValuesOrBuilderList() { + if (valuesBuilder_ != null) { + return valuesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(values_); + } + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder addValuesBuilder() { + return internalGetValuesFieldBuilder() + .addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder addValuesBuilder(int index) { + return internalGetValuesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Values in the array.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List getValuesBuilderList() { + return internalGetValuesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetValuesFieldBuilder() { + if (valuesBuilder_ == null) { + valuesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + values_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + values_ = null; + } + return valuesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ArrayValue) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ArrayValue) + private static final com.google.firestore.v1.ArrayValue DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ArrayValue(); + } + + public static com.google.firestore.v1.ArrayValue getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ArrayValue parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ArrayValue getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValueOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValueOrBuilder.java new file mode 100644 index 000000000000..7fc93cb3a71f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ArrayValueOrBuilder.java @@ -0,0 +1,83 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ArrayValueOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ArrayValue) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + java.util.List getValuesList(); + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + com.google.firestore.v1.Value getValues(int index); + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + int getValuesCount(); + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + java.util.List getValuesOrBuilderList(); + + /** + * + * + *
+   * Values in the array.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java new file mode 100644 index 000000000000..0d7b9ab1a9c6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequest.java @@ -0,0 +1,2175 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BatchGetDocumentsRequest} + */ +@com.google.protobuf.Generated +public final class BatchGetDocumentsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BatchGetDocumentsRequest) + BatchGetDocumentsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BatchGetDocumentsRequest"); + } + + // Use BatchGetDocumentsRequest.newBuilder() to construct. + private BatchGetDocumentsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BatchGetDocumentsRequest() { + database_ = ""; + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchGetDocumentsRequest.class, + com.google.firestore.v1.BatchGetDocumentsRequest.Builder.class); + } + + private int bitField0_; + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(4), + NEW_TRANSACTION(5), + READ_TIME(7), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 4: + return TRANSACTION; + case 5: + return NEW_TRANSACTION; + case 7: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOCUMENTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList documents_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + public com.google.protobuf.ProtocolStringList getDocumentsList() { + return documents_; + } + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + public int getDocumentsCount() { + return documents_.size(); + } + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + public java.lang.String getDocuments(int index) { + return documents_.get(index); + } + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + public com.google.protobuf.ByteString getDocumentsBytes(int index) { + return documents_.getByteString(index); + } + + public static final int MASK_FIELD_NUMBER = 3; + private com.google.firestore.v1.DocumentMask mask_; + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + @java.lang.Override + public boolean hasMask() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getMask() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + 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; + } + + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 7; + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + for (int i = 0; i < documents_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, documents_.getRaw(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getMask()); + } + if (consistencySelectorCase_ == 4) { + output.writeBytes(4, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + output.writeMessage(5, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + output.writeMessage(7, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + { + int dataSize = 0; + for (int i = 0; i < documents_.size(); i++) { + dataSize += computeStringSizeNoTag(documents_.getRaw(i)); + } + size += dataSize; + size += 1 * getDocumentsList().size(); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getMask()); + } + if (consistencySelectorCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 4, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BatchGetDocumentsRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.BatchGetDocumentsRequest other = + (com.google.firestore.v1.BatchGetDocumentsRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getDocumentsList().equals(other.getDocumentsList())) return false; + if (hasMask() != other.hasMask()) return false; + if (hasMask()) { + if (!getMask().equals(other.getMask())) return false; + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 4: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 5: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + case 7: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (getDocumentsCount() > 0) { + hash = (37 * hash) + DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getDocumentsList().hashCode(); + } + if (hasMask()) { + hash = (37 * hash) + MASK_FIELD_NUMBER; + hash = (53 * hash) + getMask().hashCode(); + } + switch (consistencySelectorCase_) { + case 4: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 5: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + case 7: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BatchGetDocumentsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BatchGetDocumentsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BatchGetDocumentsRequest) + com.google.firestore.v1.BatchGetDocumentsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchGetDocumentsRequest.class, + com.google.firestore.v1.BatchGetDocumentsRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.BatchGetDocumentsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsRequest getDefaultInstanceForType() { + return com.google.firestore.v1.BatchGetDocumentsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsRequest build() { + com.google.firestore.v1.BatchGetDocumentsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsRequest buildPartial() { + com.google.firestore.v1.BatchGetDocumentsRequest result = + new com.google.firestore.v1.BatchGetDocumentsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BatchGetDocumentsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + documents_.makeImmutable(); + result.documents_ = documents_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.mask_ = maskBuilder_ == null ? mask_ : maskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.BatchGetDocumentsRequest result) { + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 5 && newTransactionBuilder_ != null) { + result.consistencySelector_ = newTransactionBuilder_.build(); + } + if (consistencySelectorCase_ == 7 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BatchGetDocumentsRequest) { + return mergeFrom((com.google.firestore.v1.BatchGetDocumentsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BatchGetDocumentsRequest other) { + if (other == com.google.firestore.v1.BatchGetDocumentsRequest.getDefaultInstance()) + return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.documents_.isEmpty()) { + if (documents_.isEmpty()) { + documents_ = other.documents_; + bitField0_ |= 0x00000002; + } else { + ensureDocumentsIsMutable(); + documents_.addAll(other.documents_); + } + onChanged(); + } + if (other.hasMask()) { + mergeMask(other.getMask()); + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureDocumentsIsMutable(); + documents_.add(s); + break; + } // case 18 + case 26: + { + input.readMessage(internalGetMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 5; + break; + } // case 42 + case 58: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 7; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.LazyStringArrayList documents_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureDocumentsIsMutable() { + if (!documents_.isModifiable()) { + documents_ = new com.google.protobuf.LazyStringArrayList(documents_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + public com.google.protobuf.ProtocolStringList getDocumentsList() { + documents_.makeImmutable(); + return documents_; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + public int getDocumentsCount() { + return documents_.size(); + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + public java.lang.String getDocuments(int index) { + return documents_.get(index); + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + public com.google.protobuf.ByteString getDocumentsBytes(int index) { + return documents_.getByteString(index); + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index to set the value at. + * @param value The documents to set. + * @return This builder for chaining. + */ + public Builder setDocuments(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.set(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param value The documents to add. + * @return This builder for chaining. + */ + public Builder addDocuments(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param values The documents to add. + * @return This builder for chaining. + */ + public Builder addAllDocuments(java.lang.Iterable values) { + ensureDocumentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documents_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return This builder for chaining. + */ + public Builder clearDocuments() { + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of the
+     * given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param value The bytes of the documents to add. + * @return This builder for chaining. + */ + public Builder addDocumentsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureDocumentsIsMutable(); + documents_.add(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.firestore.v1.DocumentMask mask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + maskBuilder_; + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + public boolean hasMask() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + public com.google.firestore.v1.DocumentMask getMask() { + if (maskBuilder_ == null) { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } else { + return maskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mask_ = value; + } else { + maskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (maskBuilder_ == null) { + mask_ = builderForValue.build(); + } else { + maskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder mergeMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && mask_ != null + && mask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getMaskBuilder().mergeFrom(value); + } else { + mask_ = value; + } + } else { + maskBuilder_.mergeFrom(value); + } + if (mask_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder clearMask() { + bitField0_ = (bitField0_ & ~0x00000004); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public com.google.firestore.v1.DocumentMask.Builder getMaskBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + if (maskBuilder_ != null) { + return maskBuilder_.getMessageOrBuilder(); + } else { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field will
+     * not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetMaskFieldBuilder() { + if (maskBuilder_ == null) { + maskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getMask(), getParentForChildren(), isClean()); + mask_ = null; + } + return maskBuilder_; + } + + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 4; + } + + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 4; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 4; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Reads documents in a transaction.
+     * 
+ * + * bytes transaction = 4; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 5) { + return newTransactionBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder setNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder setNewTransaction( + com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder mergeNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5 + && consistencySelector_ + != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + consistencySelector_ = + com.google.firestore.v1.TransactionOptions.newBuilder( + (com.google.firestore.v1.TransactionOptions) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 5) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public com.google.firestore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return internalGetNewTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencySelectorCase_ == 5) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + internalGetNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencySelectorCase_ == 5)) { + consistencySelector_ = com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + (com.google.firestore.v1.TransactionOptions) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 5; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 7) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 7) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 7) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 7)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 7; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BatchGetDocumentsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BatchGetDocumentsRequest) + private static final com.google.firestore.v1.BatchGetDocumentsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BatchGetDocumentsRequest(); + } + + public static com.google.firestore.v1.BatchGetDocumentsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BatchGetDocumentsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java new file mode 100644 index 000000000000..ed0283499ee4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsRequestOrBuilder.java @@ -0,0 +1,292 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BatchGetDocumentsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BatchGetDocumentsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + java.util.List getDocumentsList(); + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + int getDocumentsCount(); + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + java.lang.String getDocuments(int index); + + /** + * + * + *
+   * The names of the documents to retrieve. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * The request will fail if any of the document is not a child resource of the
+   * given `database`. Duplicate names will be elided.
+   * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + com.google.protobuf.ByteString getDocumentsBytes(int index); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + boolean hasMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + com.google.firestore.v1.DocumentMask getMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field will
+   * not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Reads documents in a transaction.
+   * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + com.google.firestore.v1.TransactionOptions getNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.BatchGetDocumentsRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java new file mode 100644 index 000000000000..f8623d92ea97 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponse.java @@ -0,0 +1,1476 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The streamed response for
+ * [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BatchGetDocumentsResponse} + */ +@com.google.protobuf.Generated +public final class BatchGetDocumentsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BatchGetDocumentsResponse) + BatchGetDocumentsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BatchGetDocumentsResponse"); + } + + // Use BatchGetDocumentsResponse.newBuilder() to construct. + private BatchGetDocumentsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BatchGetDocumentsResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchGetDocumentsResponse.class, + com.google.firestore.v1.BatchGetDocumentsResponse.Builder.class); + } + + private int bitField0_; + private int resultCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object result_; + + public enum ResultCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + FOUND(1), + MISSING(2), + RESULT_NOT_SET(0); + private final int value; + + private ResultCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ResultCase valueOf(int value) { + return forNumber(value); + } + + public static ResultCase forNumber(int value) { + switch (value) { + case 1: + return FOUND; + case 2: + return MISSING; + case 0: + return RESULT_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ResultCase getResultCase() { + return ResultCase.forNumber(resultCase_); + } + + public static final int FOUND_FIELD_NUMBER = 1; + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return Whether the found field is set. + */ + @java.lang.Override + public boolean hasFound() { + return resultCase_ == 1; + } + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return The found. + */ + @java.lang.Override + public com.google.firestore.v1.Document getFound() { + if (resultCase_ == 1) { + return (com.google.firestore.v1.Document) result_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getFoundOrBuilder() { + if (resultCase_ == 1) { + return (com.google.firestore.v1.Document) result_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + 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; + } + + /** + * + * + *
+   * 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 The missing. + */ + public java.lang.String getMissing() { + java.lang.Object ref = ""; + if (resultCase_ == 2) { + ref = result_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (resultCase_ == 2) { + result_ = s; + } + return s; + } + } + + /** + * + * + *
+   * 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 The bytes for missing. + */ + public com.google.protobuf.ByteString getMissingBytes() { + java.lang.Object ref = ""; + if (resultCase_ == 2) { + ref = result_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (resultCase_ == 2) { + result_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TRANSACTION_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   * Will only be set in the first response, and only if
+   * [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
+   * was set in the request.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int READ_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (resultCase_ == 1) { + output.writeMessage(1, (com.google.firestore.v1.Document) result_); + } + if (resultCase_ == 2) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, result_); + } + if (!transaction_.isEmpty()) { + output.writeBytes(3, transaction_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (resultCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.v1.Document) result_); + } + if (resultCase_ == 2) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, result_); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, transaction_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getReadTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BatchGetDocumentsResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.BatchGetDocumentsResponse other = + (com.google.firestore.v1.BatchGetDocumentsResponse) obj; + + if (!getTransaction().equals(other.getTransaction())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (!getResultCase().equals(other.getResultCase())) return false; + switch (resultCase_) { + case 1: + if (!getFound().equals(other.getFound())) return false; + break; + case 2: + if (!getMissing().equals(other.getMissing())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + switch (resultCase_) { + case 1: + hash = (37 * hash) + FOUND_FIELD_NUMBER; + hash = (53 * hash) + getFound().hashCode(); + break; + case 2: + hash = (37 * hash) + MISSING_FIELD_NUMBER; + hash = (53 * hash) + getMissing().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BatchGetDocumentsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The streamed response for
+   * [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BatchGetDocumentsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BatchGetDocumentsResponse) + com.google.firestore.v1.BatchGetDocumentsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchGetDocumentsResponse.class, + com.google.firestore.v1.BatchGetDocumentsResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.BatchGetDocumentsResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (foundBuilder_ != null) { + foundBuilder_.clear(); + } + transaction_ = com.google.protobuf.ByteString.EMPTY; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + resultCase_ = 0; + result_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchGetDocumentsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsResponse getDefaultInstanceForType() { + return com.google.firestore.v1.BatchGetDocumentsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsResponse build() { + com.google.firestore.v1.BatchGetDocumentsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsResponse buildPartial() { + com.google.firestore.v1.BatchGetDocumentsResponse result = + new com.google.firestore.v1.BatchGetDocumentsResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BatchGetDocumentsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transaction_ = transaction_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.BatchGetDocumentsResponse result) { + result.resultCase_ = resultCase_; + result.result_ = this.result_; + if (resultCase_ == 1 && foundBuilder_ != null) { + result.result_ = foundBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BatchGetDocumentsResponse) { + return mergeFrom((com.google.firestore.v1.BatchGetDocumentsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BatchGetDocumentsResponse other) { + if (other == com.google.firestore.v1.BatchGetDocumentsResponse.getDefaultInstance()) + return this; + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + switch (other.getResultCase()) { + case FOUND: + { + mergeFound(other.getFound()); + break; + } + case MISSING: + { + resultCase_ = 2; + result_ = other.result_; + onChanged(); + break; + } + case RESULT_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetFoundFieldBuilder().getBuilder(), extensionRegistry); + resultCase_ = 1; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + resultCase_ = 2; + result_ = s; + break; + } // case 18 + case 26: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int resultCase_ = 0; + private java.lang.Object result_; + + public ResultCase getResultCase() { + return ResultCase.forNumber(resultCase_); + } + + public Builder clearResult() { + resultCase_ = 0; + result_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + foundBuilder_; + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return Whether the found field is set. + */ + @java.lang.Override + public boolean hasFound() { + return resultCase_ == 1; + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return The found. + */ + @java.lang.Override + public com.google.firestore.v1.Document getFound() { + if (foundBuilder_ == null) { + if (resultCase_ == 1) { + return (com.google.firestore.v1.Document) result_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } else { + if (resultCase_ == 1) { + return foundBuilder_.getMessage(); + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + public Builder setFound(com.google.firestore.v1.Document value) { + if (foundBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + onChanged(); + } else { + foundBuilder_.setMessage(value); + } + resultCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + public Builder setFound(com.google.firestore.v1.Document.Builder builderForValue) { + if (foundBuilder_ == null) { + result_ = builderForValue.build(); + onChanged(); + } else { + foundBuilder_.setMessage(builderForValue.build()); + } + resultCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + public Builder mergeFound(com.google.firestore.v1.Document value) { + if (foundBuilder_ == null) { + if (resultCase_ == 1 && result_ != com.google.firestore.v1.Document.getDefaultInstance()) { + result_ = + com.google.firestore.v1.Document.newBuilder( + (com.google.firestore.v1.Document) result_) + .mergeFrom(value) + .buildPartial(); + } else { + result_ = value; + } + onChanged(); + } else { + if (resultCase_ == 1) { + foundBuilder_.mergeFrom(value); + } else { + foundBuilder_.setMessage(value); + } + } + resultCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + public Builder clearFound() { + if (foundBuilder_ == null) { + if (resultCase_ == 1) { + resultCase_ = 0; + result_ = null; + onChanged(); + } + } else { + if (resultCase_ == 1) { + resultCase_ = 0; + result_ = null; + } + foundBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + public com.google.firestore.v1.Document.Builder getFoundBuilder() { + return internalGetFoundFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getFoundOrBuilder() { + if ((resultCase_ == 1) && (foundBuilder_ != null)) { + return foundBuilder_.getMessageOrBuilder(); + } else { + if (resultCase_ == 1) { + return (com.google.firestore.v1.Document) result_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A document that was requested.
+     * 
+ * + * .google.firestore.v1.Document found = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetFoundFieldBuilder() { + if (foundBuilder_ == null) { + if (!(resultCase_ == 1)) { + result_ = com.google.firestore.v1.Document.getDefaultInstance(); + } + foundBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + (com.google.firestore.v1.Document) result_, getParentForChildren(), isClean()); + result_ = null; + } + resultCase_ = 1; + onChanged(); + 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; + } + + /** + * + * + *
+     * 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 The missing. + */ + @java.lang.Override + public java.lang.String getMissing() { + java.lang.Object ref = ""; + if (resultCase_ == 2) { + ref = result_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (resultCase_ == 2) { + result_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * 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 The bytes for missing. + */ + @java.lang.Override + public com.google.protobuf.ByteString getMissingBytes() { + java.lang.Object ref = ""; + if (resultCase_ == 2) { + ref = result_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (resultCase_ == 2) { + result_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * 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; + * + * @param value The missing to set. + * @return This builder for chaining. + */ + public Builder setMissing(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + resultCase_ = 2; + result_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * 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 This builder for chaining. + */ + public Builder clearMissing() { + if (resultCase_ == 2) { + resultCase_ = 0; + result_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * 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; + * + * @param value The bytes for missing to set. + * @return This builder for chaining. + */ + public Builder setMissingBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + resultCase_ = 2; + result_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Will only be set in the first response, and only if
+     * [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
+     * was set in the request.
+     * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Will only be set in the first response, and only if
+     * [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
+     * was set in the request.
+     * 
+ * + * bytes transaction = 3; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Will only be set in the first response, and only if
+     * [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
+     * was set in the request.
+     * 
+ * + * bytes transaction = 3; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000008); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The time at which the document was read.
+     * This may be monotically increasing, in this case the previous documents in
+     * the result stream are guaranteed not to have changed between their
+     * read_time and this one.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BatchGetDocumentsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BatchGetDocumentsResponse) + private static final com.google.firestore.v1.BatchGetDocumentsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BatchGetDocumentsResponse(); + } + + public static com.google.firestore.v1.BatchGetDocumentsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BatchGetDocumentsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BatchGetDocumentsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java new file mode 100644 index 000000000000..728fcca2e759 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchGetDocumentsResponseOrBuilder.java @@ -0,0 +1,171 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BatchGetDocumentsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BatchGetDocumentsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return Whether the found field is set. + */ + boolean hasFound(); + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + * + * @return The found. + */ + com.google.firestore.v1.Document getFound(); + + /** + * + * + *
+   * A document that was requested.
+   * 
+ * + * .google.firestore.v1.Document found = 1; + */ + 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(); + + /** + * + * + *
+   * 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 The missing. + */ + java.lang.String getMissing(); + + /** + * + * + *
+   * 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 The bytes for missing. + */ + com.google.protobuf.ByteString getMissingBytes(); + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   * Will only be set in the first response, and only if
+   * [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction]
+   * was set in the request.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The time at which the document was read.
+   * This may be monotically increasing, in this case the previous documents in
+   * the result stream are guaranteed not to have changed between their
+   * read_time and this one.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.BatchGetDocumentsResponse.ResultCase getResultCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequest.java new file mode 100644 index 000000000000..90a3d6b87497 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequest.java @@ -0,0 +1,1554 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BatchWriteRequest} + */ +@com.google.protobuf.Generated +public final class BatchWriteRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BatchWriteRequest) + BatchWriteRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BatchWriteRequest"); + } + + // Use BatchWriteRequest.newBuilder() to construct. + private BatchWriteRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BatchWriteRequest() { + database_ = ""; + writes_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchWriteRequest.class, + com.google.firestore.v1.BatchWriteRequest.Builder.class); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int WRITES_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List writes_; + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public java.util.List getWritesList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public java.util.List getWritesOrBuilderList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public int getWritesCount() { + return writes_.size(); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Write getWrites(int index) { + return writes_.get(index); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + return writes_.get(index); + } + + public static final int LABELS_FIELD_NUMBER = 3; + + private static final class LabelsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_LabelsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + for (int i = 0; i < writes_.size(); i++) { + output.writeMessage(2, writes_.get(i)); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 3); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + for (int i = 0; i < writes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, writes_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetLabels().getMap().entrySet()) { + com.google.protobuf.MapEntry labels__ = + LabelsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, labels__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BatchWriteRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.BatchWriteRequest other = + (com.google.firestore.v1.BatchWriteRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getWritesList().equals(other.getWritesList())) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (getWritesCount() > 0) { + hash = (37 * hash) + WRITES_FIELD_NUMBER; + hash = (53 * hash) + getWritesList().hashCode(); + } + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BatchWriteRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BatchWriteRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BatchWriteRequest) + com.google.firestore.v1.BatchWriteRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchWriteRequest.class, + com.google.firestore.v1.BatchWriteRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.BatchWriteRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + } else { + writes_ = null; + writesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableLabels().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteRequest getDefaultInstanceForType() { + return com.google.firestore.v1.BatchWriteRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteRequest build() { + com.google.firestore.v1.BatchWriteRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteRequest buildPartial() { + com.google.firestore.v1.BatchWriteRequest result = + new com.google.firestore.v1.BatchWriteRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.BatchWriteRequest result) { + if (writesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + writes_ = java.util.Collections.unmodifiableList(writes_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.writes_ = writes_; + } else { + result.writes_ = writesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.BatchWriteRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BatchWriteRequest) { + return mergeFrom((com.google.firestore.v1.BatchWriteRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BatchWriteRequest other) { + if (other == com.google.firestore.v1.BatchWriteRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (writesBuilder_ == null) { + if (!other.writes_.isEmpty()) { + if (writes_.isEmpty()) { + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureWritesIsMutable(); + writes_.addAll(other.writes_); + } + onChanged(); + } + } else { + if (!other.writes_.isEmpty()) { + if (writesBuilder_.isEmpty()) { + writesBuilder_.dispose(); + writesBuilder_ = null; + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000002); + writesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWritesFieldBuilder() + : null; + } else { + writesBuilder_.addAllMessages(other.writes_); + } + } + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000004; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Write m = + input.readMessage(com.google.firestore.v1.Write.parser(), extensionRegistry); + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(m); + } else { + writesBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.protobuf.MapEntry labels__ = + input.readMessage( + LabelsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableLabels() + .getMutableMap() + .put(labels__.getKey(), labels__.getValue()); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List writes_ = + java.util.Collections.emptyList(); + + private void ensureWritesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + writes_ = new java.util.ArrayList(writes_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + writesBuilder_; + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List getWritesList() { + if (writesBuilder_ == null) { + return java.util.Collections.unmodifiableList(writes_); + } else { + return writesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public int getWritesCount() { + if (writesBuilder_ == null) { + return writes_.size(); + } else { + return writesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write getWrites(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.set(index, value); + onChanged(); + } else { + writesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.set(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(value); + onChanged(); + } else { + writesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(index, value); + onChanged(); + } else { + writesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addAllWrites( + java.lang.Iterable values) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writes_); + onChanged(); + } else { + writesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder clearWrites() { + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + writesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder removeWrites(int index) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.remove(index); + onChanged(); + } else { + writesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder getWritesBuilder(int index) { + return internalGetWritesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List + getWritesOrBuilderList() { + if (writesBuilder_ != null) { + return writesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writes_); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder() { + return internalGetWritesFieldBuilder() + .addBuilder(com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder(int index) { + return internalGetWritesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Method does not apply writes atomically and does not guarantee ordering.
+     * Each write succeeds or fails independently. You cannot write to the same
+     * document more than once per request.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List getWritesBuilderList() { + return internalGetWritesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + internalGetWritesFieldBuilder() { + if (writesBuilder_ == null) { + writesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder>( + writes_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + writes_ = null; + } + return writesBuilder_; + } + + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + private com.google.protobuf.MapField + internalGetMutableLabels() { + if (labels_ == null) { + labels_ = com.google.protobuf.MapField.newMapField(LabelsDefaultEntryHolder.defaultEntry); + } + if (!labels_.isMutable()) { + labels_ = labels_.copy(); + } + bitField0_ |= 0x00000004; + onChanged(); + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLabels() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableLabels().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + public Builder removeLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableLabels().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableLabels() { + bitField0_ |= 0x00000004; + return internalGetMutableLabels().getMutableMap(); + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + public Builder putLabels(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableLabels().getMutableMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+     * Labels associated with this batch write.
+     * 
+ * + * map<string, string> labels = 3; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BatchWriteRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BatchWriteRequest) + private static final com.google.firestore.v1.BatchWriteRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BatchWriteRequest(); + } + + public static com.google.firestore.v1.BatchWriteRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BatchWriteRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequestOrBuilder.java new file mode 100644 index 000000000000..ab96fafd26cc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteRequestOrBuilder.java @@ -0,0 +1,194 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BatchWriteRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BatchWriteRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + java.util.List getWritesList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + com.google.firestore.v1.Write getWrites(int index); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + int getWritesCount(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + java.util.List getWritesOrBuilderList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Method does not apply writes atomically and does not guarantee ordering.
+   * Each write succeeds or fails independently. You cannot write to the same
+   * document more than once per request.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index); + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + int getLabelsCount(); + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Labels associated with this batch write.
+   * 
+ * + * map<string, string> labels = 3; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponse.java new file mode 100644 index 000000000000..40c362643c57 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponse.java @@ -0,0 +1,1557 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response from
+ * [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BatchWriteResponse} + */ +@com.google.protobuf.Generated +public final class BatchWriteResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BatchWriteResponse) + BatchWriteResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BatchWriteResponse"); + } + + // Use BatchWriteResponse.newBuilder() to construct. + private BatchWriteResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BatchWriteResponse() { + writeResults_ = java.util.Collections.emptyList(); + status_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchWriteResponse.class, + com.google.firestore.v1.BatchWriteResponse.Builder.class); + } + + public static final int WRITE_RESULTS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List writeResults_; + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public java.util.List getWriteResultsList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public java.util.List + getWriteResultsOrBuilderList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public int getWriteResultsCount() { + return writeResults_.size(); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + return writeResults_.get(index); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + return writeResults_.get(index); + } + + public static final int STATUS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List status_; + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + @java.lang.Override + public java.util.List getStatusList() { + return status_; + } + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + @java.lang.Override + public java.util.List getStatusOrBuilderList() { + return status_; + } + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + @java.lang.Override + public int getStatusCount() { + return status_.size(); + } + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + @java.lang.Override + public com.google.rpc.Status getStatus(int index) { + return status_.get(index); + } + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + @java.lang.Override + public com.google.rpc.StatusOrBuilder getStatusOrBuilder(int index) { + return status_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < writeResults_.size(); i++) { + output.writeMessage(1, writeResults_.get(i)); + } + for (int i = 0; i < status_.size(); i++) { + output.writeMessage(2, status_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < writeResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, writeResults_.get(i)); + } + for (int i = 0; i < status_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, status_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BatchWriteResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.BatchWriteResponse other = + (com.google.firestore.v1.BatchWriteResponse) obj; + + if (!getWriteResultsList().equals(other.getWriteResultsList())) return false; + if (!getStatusList().equals(other.getStatusList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getWriteResultsCount() > 0) { + hash = (37 * hash) + WRITE_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getWriteResultsList().hashCode(); + } + if (getStatusCount() > 0) { + hash = (37 * hash) + STATUS_FIELD_NUMBER; + hash = (53 * hash) + getStatusList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BatchWriteResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BatchWriteResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response from
+   * [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BatchWriteResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BatchWriteResponse) + com.google.firestore.v1.BatchWriteResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BatchWriteResponse.class, + com.google.firestore.v1.BatchWriteResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.BatchWriteResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + } else { + writeResults_ = null; + writeResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (statusBuilder_ == null) { + status_ = java.util.Collections.emptyList(); + } else { + status_ = null; + statusBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BatchWriteResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteResponse getDefaultInstanceForType() { + return com.google.firestore.v1.BatchWriteResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteResponse build() { + com.google.firestore.v1.BatchWriteResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteResponse buildPartial() { + com.google.firestore.v1.BatchWriteResponse result = + new com.google.firestore.v1.BatchWriteResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.BatchWriteResponse result) { + if (writeResultsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + writeResults_ = java.util.Collections.unmodifiableList(writeResults_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.writeResults_ = writeResults_; + } else { + result.writeResults_ = writeResultsBuilder_.build(); + } + if (statusBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + status_ = java.util.Collections.unmodifiableList(status_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.status_ = status_; + } else { + result.status_ = statusBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.BatchWriteResponse result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BatchWriteResponse) { + return mergeFrom((com.google.firestore.v1.BatchWriteResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BatchWriteResponse other) { + if (other == com.google.firestore.v1.BatchWriteResponse.getDefaultInstance()) return this; + if (writeResultsBuilder_ == null) { + if (!other.writeResults_.isEmpty()) { + if (writeResults_.isEmpty()) { + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureWriteResultsIsMutable(); + writeResults_.addAll(other.writeResults_); + } + onChanged(); + } + } else { + if (!other.writeResults_.isEmpty()) { + if (writeResultsBuilder_.isEmpty()) { + writeResultsBuilder_.dispose(); + writeResultsBuilder_ = null; + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000001); + writeResultsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWriteResultsFieldBuilder() + : null; + } else { + writeResultsBuilder_.addAllMessages(other.writeResults_); + } + } + } + if (statusBuilder_ == null) { + if (!other.status_.isEmpty()) { + if (status_.isEmpty()) { + status_ = other.status_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureStatusIsMutable(); + status_.addAll(other.status_); + } + onChanged(); + } + } else { + if (!other.status_.isEmpty()) { + if (statusBuilder_.isEmpty()) { + statusBuilder_.dispose(); + statusBuilder_ = null; + status_ = other.status_; + bitField0_ = (bitField0_ & ~0x00000002); + statusBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetStatusFieldBuilder() + : null; + } else { + statusBuilder_.addAllMessages(other.status_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.WriteResult m = + input.readMessage( + com.google.firestore.v1.WriteResult.parser(), extensionRegistry); + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(m); + } else { + writeResultsBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + com.google.rpc.Status m = + input.readMessage(com.google.rpc.Status.parser(), extensionRegistry); + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + status_.add(m); + } else { + statusBuilder_.addMessage(m); + } + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List writeResults_ = + java.util.Collections.emptyList(); + + private void ensureWriteResultsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + writeResults_ = new java.util.ArrayList(writeResults_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + writeResultsBuilder_; + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List getWriteResultsList() { + if (writeResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(writeResults_); + } else { + return writeResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public int getWriteResultsCount() { + if (writeResultsBuilder_ == null) { + return writeResults_.size(); + } else { + return writeResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder setWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.set(index, value); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder setWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.set(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(index, value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addAllWriteResults( + java.lang.Iterable values) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writeResults_); + onChanged(); + } else { + writeResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder clearWriteResults() { + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + writeResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder removeWriteResults(int index) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.remove(index); + onChanged(); + } else { + writeResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder getWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List + getWriteResultsOrBuilderList() { + if (writeResultsBuilder_ != null) { + return writeResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writeResults_); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder() { + return internalGetWriteResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List + getWriteResultsBuilderList() { + return internalGetWriteResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + internalGetWriteResultsFieldBuilder() { + if (writeResultsBuilder_ == null) { + writeResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder>( + writeResults_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + writeResults_ = null; + } + return writeResultsBuilder_; + } + + private java.util.List status_ = java.util.Collections.emptyList(); + + private void ensureStatusIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + status_ = new java.util.ArrayList(status_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + statusBuilder_; + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public java.util.List getStatusList() { + if (statusBuilder_ == null) { + return java.util.Collections.unmodifiableList(status_); + } else { + return statusBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public int getStatusCount() { + if (statusBuilder_ == null) { + return status_.size(); + } else { + return statusBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public com.google.rpc.Status getStatus(int index) { + if (statusBuilder_ == null) { + return status_.get(index); + } else { + return statusBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder setStatus(int index, com.google.rpc.Status value) { + if (statusBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStatusIsMutable(); + status_.set(index, value); + onChanged(); + } else { + statusBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder setStatus(int index, com.google.rpc.Status.Builder builderForValue) { + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + status_.set(index, builderForValue.build()); + onChanged(); + } else { + statusBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder addStatus(com.google.rpc.Status value) { + if (statusBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStatusIsMutable(); + status_.add(value); + onChanged(); + } else { + statusBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder addStatus(int index, com.google.rpc.Status value) { + if (statusBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStatusIsMutable(); + status_.add(index, value); + onChanged(); + } else { + statusBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder addStatus(com.google.rpc.Status.Builder builderForValue) { + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + status_.add(builderForValue.build()); + onChanged(); + } else { + statusBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder addStatus(int index, com.google.rpc.Status.Builder builderForValue) { + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + status_.add(index, builderForValue.build()); + onChanged(); + } else { + statusBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder addAllStatus(java.lang.Iterable values) { + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, status_); + onChanged(); + } else { + statusBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder clearStatus() { + if (statusBuilder_ == null) { + status_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + statusBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public Builder removeStatus(int index) { + if (statusBuilder_ == null) { + ensureStatusIsMutable(); + status_.remove(index); + onChanged(); + } else { + statusBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public com.google.rpc.Status.Builder getStatusBuilder(int index) { + return internalGetStatusFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public com.google.rpc.StatusOrBuilder getStatusOrBuilder(int index) { + if (statusBuilder_ == null) { + return status_.get(index); + } else { + return statusBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public java.util.List getStatusOrBuilderList() { + if (statusBuilder_ != null) { + return statusBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(status_); + } + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public com.google.rpc.Status.Builder addStatusBuilder() { + return internalGetStatusFieldBuilder().addBuilder(com.google.rpc.Status.getDefaultInstance()); + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public com.google.rpc.Status.Builder addStatusBuilder(int index) { + return internalGetStatusFieldBuilder() + .addBuilder(index, com.google.rpc.Status.getDefaultInstance()); + } + + /** + * + * + *
+     * The status of applying the writes.
+     *
+     * This i-th write status corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.rpc.Status status = 2; + */ + public java.util.List getStatusBuilderList() { + return internalGetStatusFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + internalGetStatusFieldBuilder() { + if (statusBuilder_ == null) { + statusBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.rpc.Status, + com.google.rpc.Status.Builder, + com.google.rpc.StatusOrBuilder>( + status_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + status_ = null; + } + return statusBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BatchWriteResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BatchWriteResponse) + private static final com.google.firestore.v1.BatchWriteResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BatchWriteResponse(); + } + + public static com.google.firestore.v1.BatchWriteResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BatchWriteResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BatchWriteResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponseOrBuilder.java new file mode 100644 index 000000000000..9b0836b470c0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BatchWriteResponseOrBuilder.java @@ -0,0 +1,169 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BatchWriteResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BatchWriteResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + java.util.List getWriteResultsList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + com.google.firestore.v1.WriteResult getWriteResults(int index); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + int getWriteResultsCount(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + java.util.List + getWriteResultsOrBuilderList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index); + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + java.util.List getStatusList(); + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + com.google.rpc.Status getStatus(int index); + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + int getStatusCount(); + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + java.util.List getStatusOrBuilderList(); + + /** + * + * + *
+   * The status of applying the writes.
+   *
+   * This i-th write status corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.rpc.Status status = 2; + */ + com.google.rpc.StatusOrBuilder getStatusOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequest.java new file mode 100644 index 000000000000..78a71949df20 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequest.java @@ -0,0 +1,908 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BeginTransactionRequest} + */ +@com.google.protobuf.Generated +public final class BeginTransactionRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BeginTransactionRequest) + BeginTransactionRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BeginTransactionRequest"); + } + + // Use BeginTransactionRequest.newBuilder() to construct. + private BeginTransactionRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BeginTransactionRequest() { + database_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BeginTransactionRequest.class, + com.google.firestore.v1.BeginTransactionRequest.Builder.class); + } + + private int bitField0_; + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OPTIONS_FIELD_NUMBER = 2; + private com.google.firestore.v1.TransactionOptions options_; + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return Whether the options field is set. + */ + @java.lang.Override + public boolean hasOptions() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return The options. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getOptions() { + return options_ == null + ? com.google.firestore.v1.TransactionOptions.getDefaultInstance() + : options_; + } + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getOptionsOrBuilder() { + return options_ == null + ? com.google.firestore.v1.TransactionOptions.getDefaultInstance() + : options_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getOptions()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BeginTransactionRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.BeginTransactionRequest other = + (com.google.firestore.v1.BeginTransactionRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (hasOptions() != other.hasOptions()) return false; + if (hasOptions()) { + if (!getOptions().equals(other.getOptions())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (hasOptions()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BeginTransactionRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BeginTransactionRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BeginTransactionRequest) + com.google.firestore.v1.BeginTransactionRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BeginTransactionRequest.class, + com.google.firestore.v1.BeginTransactionRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.BeginTransactionRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + options_ = null; + if (optionsBuilder_ != null) { + optionsBuilder_.dispose(); + optionsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionRequest getDefaultInstanceForType() { + return com.google.firestore.v1.BeginTransactionRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionRequest build() { + com.google.firestore.v1.BeginTransactionRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionRequest buildPartial() { + com.google.firestore.v1.BeginTransactionRequest result = + new com.google.firestore.v1.BeginTransactionRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BeginTransactionRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.options_ = optionsBuilder_ == null ? options_ : optionsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BeginTransactionRequest) { + return mergeFrom((com.google.firestore.v1.BeginTransactionRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BeginTransactionRequest other) { + if (other == com.google.firestore.v1.BeginTransactionRequest.getDefaultInstance()) + return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasOptions()) { + mergeOptions(other.getOptions()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.v1.TransactionOptions options_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + optionsBuilder_; + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return Whether the options field is set. + */ + public boolean hasOptions() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return The options. + */ + public com.google.firestore.v1.TransactionOptions getOptions() { + if (optionsBuilder_ == null) { + return options_ == null + ? com.google.firestore.v1.TransactionOptions.getDefaultInstance() + : options_; + } else { + return optionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public Builder setOptions(com.google.firestore.v1.TransactionOptions value) { + if (optionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + options_ = value; + } else { + optionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public Builder setOptions(com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (optionsBuilder_ == null) { + options_ = builderForValue.build(); + } else { + optionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public Builder mergeOptions(com.google.firestore.v1.TransactionOptions value) { + if (optionsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && options_ != null + && options_ != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + getOptionsBuilder().mergeFrom(value); + } else { + options_ = value; + } + } else { + optionsBuilder_.mergeFrom(value); + } + if (options_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000002); + options_ = null; + if (optionsBuilder_ != null) { + optionsBuilder_.dispose(); + optionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public com.google.firestore.v1.TransactionOptions.Builder getOptionsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + public com.google.firestore.v1.TransactionOptionsOrBuilder getOptionsOrBuilder() { + if (optionsBuilder_ != null) { + return optionsBuilder_.getMessageOrBuilder(); + } else { + return options_ == null + ? com.google.firestore.v1.TransactionOptions.getDefaultInstance() + : options_; + } + } + + /** + * + * + *
+     * The options for the transaction.
+     * Defaults to a read-write transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + internalGetOptionsFieldBuilder() { + if (optionsBuilder_ == null) { + optionsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + getOptions(), getParentForChildren(), isClean()); + options_ = null; + } + return optionsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BeginTransactionRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BeginTransactionRequest) + private static final com.google.firestore.v1.BeginTransactionRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BeginTransactionRequest(); + } + + public static com.google.firestore.v1.BeginTransactionRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BeginTransactionRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequestOrBuilder.java new file mode 100644 index 000000000000..6cdc05d78f24 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionRequestOrBuilder.java @@ -0,0 +1,96 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BeginTransactionRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BeginTransactionRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return Whether the options field is set. + */ + boolean hasOptions(); + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + * + * @return The options. + */ + com.google.firestore.v1.TransactionOptions getOptions(); + + /** + * + * + *
+   * The options for the transaction.
+   * Defaults to a read-write transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions options = 2; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getOptionsOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponse.java new file mode 100644 index 000000000000..d8525becbb7e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponse.java @@ -0,0 +1,509 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for
+ * [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BeginTransactionResponse} + */ +@com.google.protobuf.Generated +public final class BeginTransactionResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BeginTransactionResponse) + BeginTransactionResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BeginTransactionResponse"); + } + + // Use BeginTransactionResponse.newBuilder() to construct. + private BeginTransactionResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BeginTransactionResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BeginTransactionResponse.class, + com.google.firestore.v1.BeginTransactionResponse.Builder.class); + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The transaction that was started.
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!transaction_.isEmpty()) { + output.writeBytes(1, transaction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, transaction_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BeginTransactionResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.BeginTransactionResponse other = + (com.google.firestore.v1.BeginTransactionResponse) obj; + + if (!getTransaction().equals(other.getTransaction())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BeginTransactionResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BeginTransactionResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BeginTransactionResponse) + com.google.firestore.v1.BeginTransactionResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BeginTransactionResponse.class, + com.google.firestore.v1.BeginTransactionResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.BeginTransactionResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + transaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionResponse getDefaultInstanceForType() { + return com.google.firestore.v1.BeginTransactionResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionResponse build() { + com.google.firestore.v1.BeginTransactionResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionResponse buildPartial() { + com.google.firestore.v1.BeginTransactionResponse result = + new com.google.firestore.v1.BeginTransactionResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BeginTransactionResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.transaction_ = transaction_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BeginTransactionResponse) { + return mergeFrom((com.google.firestore.v1.BeginTransactionResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BeginTransactionResponse other) { + if (other == com.google.firestore.v1.BeginTransactionResponse.getDefaultInstance()) + return this; + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The transaction that was started.
+     * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The transaction that was started.
+     * 
+ * + * bytes transaction = 1; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction that was started.
+     * 
+ * + * bytes transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BeginTransactionResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BeginTransactionResponse) + private static final com.google.firestore.v1.BeginTransactionResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BeginTransactionResponse(); + } + + public static com.google.firestore.v1.BeginTransactionResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BeginTransactionResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BeginTransactionResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponseOrBuilder.java new file mode 100644 index 000000000000..2cbef0475658 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BeginTransactionResponseOrBuilder.java @@ -0,0 +1,41 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BeginTransactionResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BeginTransactionResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The transaction that was started.
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequence.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequence.java new file mode 100644 index 000000000000..e862a46fe3fc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequence.java @@ -0,0 +1,640 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/bloom_filter.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A sequence of bits, encoded in a byte array.
+ *
+ * Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only
+ * exception is the last byte, which may store 8 _or fewer_ bits. The `padding`
+ * defines the number of bits of the last byte to be ignored as "padding". The
+ * values of these "padding" bits are unspecified and must be ignored.
+ *
+ * To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`.
+ * To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`.
+ * To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`.
+ * To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`.
+ * To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`.
+ *
+ * The "size" of a `BitSequence` (the number of bits it contains) is calculated
+ * by this formula: `(bitmap.length * 8) - padding`.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BitSequence} + */ +@com.google.protobuf.Generated +public final class BitSequence extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BitSequence) + BitSequenceOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BitSequence"); + } + + // Use BitSequence.newBuilder() to construct. + private BitSequence(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BitSequence() { + bitmap_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BitSequence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BitSequence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BitSequence.class, + com.google.firestore.v1.BitSequence.Builder.class); + } + + public static final int BITMAP_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString bitmap_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The bytes that encode the bit sequence.
+   * May have a length of zero.
+   * 
+ * + * bytes bitmap = 1; + * + * @return The bitmap. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBitmap() { + return bitmap_; + } + + public static final int PADDING_FIELD_NUMBER = 2; + private int padding_ = 0; + + /** + * + * + *
+   * The number of bits of the last byte in `bitmap` to ignore as "padding".
+   * If the length of `bitmap` is zero, then this value must be `0`.
+   * Otherwise, this value must be between 0 and 7, inclusive.
+   * 
+ * + * int32 padding = 2; + * + * @return The padding. + */ + @java.lang.Override + public int getPadding() { + return padding_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!bitmap_.isEmpty()) { + output.writeBytes(1, bitmap_); + } + if (padding_ != 0) { + output.writeInt32(2, padding_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!bitmap_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, bitmap_); + } + if (padding_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, padding_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BitSequence)) { + return super.equals(obj); + } + com.google.firestore.v1.BitSequence other = (com.google.firestore.v1.BitSequence) obj; + + if (!getBitmap().equals(other.getBitmap())) return false; + if (getPadding() != other.getPadding()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + BITMAP_FIELD_NUMBER; + hash = (53 * hash) + getBitmap().hashCode(); + hash = (37 * hash) + PADDING_FIELD_NUMBER; + hash = (53 * hash) + getPadding(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BitSequence parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BitSequence parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BitSequence parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BitSequence parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BitSequence parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BitSequence parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BitSequence parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BitSequence prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A sequence of bits, encoded in a byte array.
+   *
+   * Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only
+   * exception is the last byte, which may store 8 _or fewer_ bits. The `padding`
+   * defines the number of bits of the last byte to be ignored as "padding". The
+   * values of these "padding" bits are unspecified and must be ignored.
+   *
+   * To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`.
+   * To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`.
+   * To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`.
+   * To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`.
+   * To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`.
+   *
+   * The "size" of a `BitSequence` (the number of bits it contains) is calculated
+   * by this formula: `(bitmap.length * 8) - padding`.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BitSequence} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BitSequence) + com.google.firestore.v1.BitSequenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BitSequence_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BitSequence_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BitSequence.class, + com.google.firestore.v1.BitSequence.Builder.class); + } + + // Construct using com.google.firestore.v1.BitSequence.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + bitmap_ = com.google.protobuf.ByteString.EMPTY; + padding_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BitSequence_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BitSequence getDefaultInstanceForType() { + return com.google.firestore.v1.BitSequence.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BitSequence build() { + com.google.firestore.v1.BitSequence result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BitSequence buildPartial() { + com.google.firestore.v1.BitSequence result = new com.google.firestore.v1.BitSequence(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BitSequence result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.bitmap_ = bitmap_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.padding_ = padding_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BitSequence) { + return mergeFrom((com.google.firestore.v1.BitSequence) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BitSequence other) { + if (other == com.google.firestore.v1.BitSequence.getDefaultInstance()) return this; + if (!other.getBitmap().isEmpty()) { + setBitmap(other.getBitmap()); + } + if (other.getPadding() != 0) { + setPadding(other.getPadding()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + bitmap_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + padding_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString bitmap_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The bytes that encode the bit sequence.
+     * May have a length of zero.
+     * 
+ * + * bytes bitmap = 1; + * + * @return The bitmap. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBitmap() { + return bitmap_; + } + + /** + * + * + *
+     * The bytes that encode the bit sequence.
+     * May have a length of zero.
+     * 
+ * + * bytes bitmap = 1; + * + * @param value The bitmap to set. + * @return This builder for chaining. + */ + public Builder setBitmap(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + bitmap_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The bytes that encode the bit sequence.
+     * May have a length of zero.
+     * 
+ * + * bytes bitmap = 1; + * + * @return This builder for chaining. + */ + public Builder clearBitmap() { + bitField0_ = (bitField0_ & ~0x00000001); + bitmap_ = getDefaultInstance().getBitmap(); + onChanged(); + return this; + } + + private int padding_; + + /** + * + * + *
+     * The number of bits of the last byte in `bitmap` to ignore as "padding".
+     * If the length of `bitmap` is zero, then this value must be `0`.
+     * Otherwise, this value must be between 0 and 7, inclusive.
+     * 
+ * + * int32 padding = 2; + * + * @return The padding. + */ + @java.lang.Override + public int getPadding() { + return padding_; + } + + /** + * + * + *
+     * The number of bits of the last byte in `bitmap` to ignore as "padding".
+     * If the length of `bitmap` is zero, then this value must be `0`.
+     * Otherwise, this value must be between 0 and 7, inclusive.
+     * 
+ * + * int32 padding = 2; + * + * @param value The padding to set. + * @return This builder for chaining. + */ + public Builder setPadding(int value) { + + padding_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of bits of the last byte in `bitmap` to ignore as "padding".
+     * If the length of `bitmap` is zero, then this value must be `0`.
+     * Otherwise, this value must be between 0 and 7, inclusive.
+     * 
+ * + * int32 padding = 2; + * + * @return This builder for chaining. + */ + public Builder clearPadding() { + bitField0_ = (bitField0_ & ~0x00000002); + padding_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BitSequence) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BitSequence) + private static final com.google.firestore.v1.BitSequence DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BitSequence(); + } + + public static com.google.firestore.v1.BitSequence getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BitSequence parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BitSequence getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequenceOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequenceOrBuilder.java new file mode 100644 index 000000000000..8f1381f20810 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BitSequenceOrBuilder.java @@ -0,0 +1,57 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/bloom_filter.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BitSequenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BitSequence) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The bytes that encode the bit sequence.
+   * May have a length of zero.
+   * 
+ * + * bytes bitmap = 1; + * + * @return The bitmap. + */ + com.google.protobuf.ByteString getBitmap(); + + /** + * + * + *
+   * The number of bits of the last byte in `bitmap` to ignore as "padding".
+   * If the length of `bitmap` is zero, then this value must be `0`.
+   * Otherwise, this value must be between 0 and 7, inclusive.
+   * 
+ * + * int32 padding = 2; + * + * @return The padding. + */ + int getPadding(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilter.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilter.java new file mode 100644 index 000000000000..baf17ea8d388 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilter.java @@ -0,0 +1,806 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/bloom_filter.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter).
+ *
+ * The bloom filter hashes the entries with MD5 and treats the resulting 128-bit
+ * hash as 2 distinct 64-bit hash values, interpreted as unsigned integers
+ * using 2's complement encoding.
+ *
+ * These two hash values, named `h1` and `h2`, are then used to compute the
+ * `hash_count` hash values using the formula, starting at `i=0`:
+ *
+ * h(i) = h1 + (i * h2)
+ *
+ * These resulting values are then taken modulo the number of bits in the bloom
+ * filter to get the bits of the bloom filter to test for the given entry.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.BloomFilter} + */ +@com.google.protobuf.Generated +public final class BloomFilter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.BloomFilter) + BloomFilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BloomFilter"); + } + + // Use BloomFilter.newBuilder() to construct. + private BloomFilter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private BloomFilter() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BloomFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BloomFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BloomFilter.class, + com.google.firestore.v1.BloomFilter.Builder.class); + } + + private int bitField0_; + public static final int BITS_FIELD_NUMBER = 1; + private com.google.firestore.v1.BitSequence bits_; + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return Whether the bits field is set. + */ + @java.lang.Override + public boolean hasBits() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return The bits. + */ + @java.lang.Override + public com.google.firestore.v1.BitSequence getBits() { + return bits_ == null ? com.google.firestore.v1.BitSequence.getDefaultInstance() : bits_; + } + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + @java.lang.Override + public com.google.firestore.v1.BitSequenceOrBuilder getBitsOrBuilder() { + return bits_ == null ? com.google.firestore.v1.BitSequence.getDefaultInstance() : bits_; + } + + public static final int HASH_COUNT_FIELD_NUMBER = 2; + private int hashCount_ = 0; + + /** + * + * + *
+   * The number of hashes used by the algorithm.
+   * 
+ * + * int32 hash_count = 2; + * + * @return The hashCount. + */ + @java.lang.Override + public int getHashCount() { + return hashCount_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getBits()); + } + if (hashCount_ != 0) { + output.writeInt32(2, hashCount_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getBits()); + } + if (hashCount_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, hashCount_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.BloomFilter)) { + return super.equals(obj); + } + com.google.firestore.v1.BloomFilter other = (com.google.firestore.v1.BloomFilter) obj; + + if (hasBits() != other.hasBits()) return false; + if (hasBits()) { + if (!getBits().equals(other.getBits())) return false; + } + if (getHashCount() != other.getHashCount()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBits()) { + hash = (37 * hash) + BITS_FIELD_NUMBER; + hash = (53 * hash) + getBits().hashCode(); + } + hash = (37 * hash) + HASH_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getHashCount(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.BloomFilter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BloomFilter parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BloomFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.BloomFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BloomFilter parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BloomFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.BloomFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.BloomFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter).
+   *
+   * The bloom filter hashes the entries with MD5 and treats the resulting 128-bit
+   * hash as 2 distinct 64-bit hash values, interpreted as unsigned integers
+   * using 2's complement encoding.
+   *
+   * These two hash values, named `h1` and `h2`, are then used to compute the
+   * `hash_count` hash values using the formula, starting at `i=0`:
+   *
+   * h(i) = h1 + (i * h2)
+   *
+   * These resulting values are then taken modulo the number of bits in the bloom
+   * filter to get the bits of the bloom filter to test for the given entry.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.BloomFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.BloomFilter) + com.google.firestore.v1.BloomFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BloomFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BloomFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.BloomFilter.class, + com.google.firestore.v1.BloomFilter.Builder.class); + } + + // Construct using com.google.firestore.v1.BloomFilter.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetBitsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + bits_ = null; + if (bitsBuilder_ != null) { + bitsBuilder_.dispose(); + bitsBuilder_ = null; + } + hashCount_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.BloomFilterProto + .internal_static_google_firestore_v1_BloomFilter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.BloomFilter getDefaultInstanceForType() { + return com.google.firestore.v1.BloomFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.BloomFilter build() { + com.google.firestore.v1.BloomFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.BloomFilter buildPartial() { + com.google.firestore.v1.BloomFilter result = new com.google.firestore.v1.BloomFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.BloomFilter result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.bits_ = bitsBuilder_ == null ? bits_ : bitsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.hashCount_ = hashCount_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.BloomFilter) { + return mergeFrom((com.google.firestore.v1.BloomFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.BloomFilter other) { + if (other == com.google.firestore.v1.BloomFilter.getDefaultInstance()) return this; + if (other.hasBits()) { + mergeBits(other.getBits()); + } + if (other.getHashCount() != 0) { + setHashCount(other.getHashCount()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetBitsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + hashCount_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.BitSequence bits_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BitSequence, + com.google.firestore.v1.BitSequence.Builder, + com.google.firestore.v1.BitSequenceOrBuilder> + bitsBuilder_; + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return Whether the bits field is set. + */ + public boolean hasBits() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return The bits. + */ + public com.google.firestore.v1.BitSequence getBits() { + if (bitsBuilder_ == null) { + return bits_ == null ? com.google.firestore.v1.BitSequence.getDefaultInstance() : bits_; + } else { + return bitsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public Builder setBits(com.google.firestore.v1.BitSequence value) { + if (bitsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + bits_ = value; + } else { + bitsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public Builder setBits(com.google.firestore.v1.BitSequence.Builder builderForValue) { + if (bitsBuilder_ == null) { + bits_ = builderForValue.build(); + } else { + bitsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public Builder mergeBits(com.google.firestore.v1.BitSequence value) { + if (bitsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && bits_ != null + && bits_ != com.google.firestore.v1.BitSequence.getDefaultInstance()) { + getBitsBuilder().mergeFrom(value); + } else { + bits_ = value; + } + } else { + bitsBuilder_.mergeFrom(value); + } + if (bits_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public Builder clearBits() { + bitField0_ = (bitField0_ & ~0x00000001); + bits_ = null; + if (bitsBuilder_ != null) { + bitsBuilder_.dispose(); + bitsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public com.google.firestore.v1.BitSequence.Builder getBitsBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetBitsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + public com.google.firestore.v1.BitSequenceOrBuilder getBitsOrBuilder() { + if (bitsBuilder_ != null) { + return bitsBuilder_.getMessageOrBuilder(); + } else { + return bits_ == null ? com.google.firestore.v1.BitSequence.getDefaultInstance() : bits_; + } + } + + /** + * + * + *
+     * The bloom filter data.
+     * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BitSequence, + com.google.firestore.v1.BitSequence.Builder, + com.google.firestore.v1.BitSequenceOrBuilder> + internalGetBitsFieldBuilder() { + if (bitsBuilder_ == null) { + bitsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BitSequence, + com.google.firestore.v1.BitSequence.Builder, + com.google.firestore.v1.BitSequenceOrBuilder>( + getBits(), getParentForChildren(), isClean()); + bits_ = null; + } + return bitsBuilder_; + } + + private int hashCount_; + + /** + * + * + *
+     * The number of hashes used by the algorithm.
+     * 
+ * + * int32 hash_count = 2; + * + * @return The hashCount. + */ + @java.lang.Override + public int getHashCount() { + return hashCount_; + } + + /** + * + * + *
+     * The number of hashes used by the algorithm.
+     * 
+ * + * int32 hash_count = 2; + * + * @param value The hashCount to set. + * @return This builder for chaining. + */ + public Builder setHashCount(int value) { + + hashCount_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of hashes used by the algorithm.
+     * 
+ * + * int32 hash_count = 2; + * + * @return This builder for chaining. + */ + public Builder clearHashCount() { + bitField0_ = (bitField0_ & ~0x00000002); + hashCount_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.BloomFilter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.BloomFilter) + private static final com.google.firestore.v1.BloomFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.BloomFilter(); + } + + public static com.google.firestore.v1.BloomFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BloomFilter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.BloomFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterOrBuilder.java new file mode 100644 index 000000000000..2f14d7925ab1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterOrBuilder.java @@ -0,0 +1,78 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/bloom_filter.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface BloomFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.BloomFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return Whether the bits field is set. + */ + boolean hasBits(); + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + * + * @return The bits. + */ + com.google.firestore.v1.BitSequence getBits(); + + /** + * + * + *
+   * The bloom filter data.
+   * 
+ * + * .google.firestore.v1.BitSequence bits = 1; + */ + com.google.firestore.v1.BitSequenceOrBuilder getBitsOrBuilder(); + + /** + * + * + *
+   * The number of hashes used by the algorithm.
+   * 
+ * + * int32 hash_count = 2; + * + * @return The hashCount. + */ + int getHashCount(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterProto.java new file mode 100644 index 000000000000..94465cda5906 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/BloomFilterProto.java @@ -0,0 +1,93 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/bloom_filter.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class BloomFilterProto extends com.google.protobuf.GeneratedFile { + private BloomFilterProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "BloomFilterProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BitSequence_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BitSequence_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BloomFilter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BloomFilter_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n&google/firestore/v1/bloom_filter.proto" + + "\022\023google.firestore.v1\".\n\013BitSequence\022\016\n\006" + + "bitmap\030\001 \001(\014\022\017\n\007padding\030\002 \001(\005\"Q\n\013BloomFi" + + "lter\022.\n\004bits\030\001 \001(\0132 .google.firestore.v1" + + ".BitSequence\022\022\n\nhash_count\030\002 \001(\005B\310\001\n\027com" + + ".google.firestore.v1B\020BloomFilterProtoP\001" + + "Z;cloud.google.com/go/firestore/apiv1/fi" + + "restorepb;firestorepb\242\002\004GCFS\252\002\031Google.Cl" + + "oud.Firestore.V1\312\002\031Google\\Cloud\\Firestor" + + "e\\V1\352\002\034Google::Cloud::Firestore::V1b\006pro" + + "to3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_firestore_v1_BitSequence_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_BitSequence_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_BitSequence_descriptor, + new java.lang.String[] { + "Bitmap", "Padding", + }); + internal_static_google_firestore_v1_BloomFilter_descriptor = getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_BloomFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_BloomFilter_descriptor, + new java.lang.String[] { + "Bits", "HashCount", + }); + descriptor.resolveAllFeaturesImmutable(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequest.java new file mode 100644 index 000000000000..8fd579f56ff1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequest.java @@ -0,0 +1,1255 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.CommitRequest} + */ +@com.google.protobuf.Generated +public final class CommitRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.CommitRequest) + CommitRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CommitRequest"); + } + + // Use CommitRequest.newBuilder() to construct. + private CommitRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CommitRequest() { + database_ = ""; + writes_ = java.util.Collections.emptyList(); + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CommitRequest.class, + com.google.firestore.v1.CommitRequest.Builder.class); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int WRITES_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List writes_; + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public java.util.List getWritesList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public java.util.List getWritesOrBuilderList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public int getWritesCount() { + return writes_.size(); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Write getWrites(int index) { + return writes_.get(index); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + @java.lang.Override + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + return writes_.get(index); + } + + public static final int TRANSACTION_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * If set, applies all writes in this transaction, and commits it.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + for (int i = 0; i < writes_.size(); i++) { + output.writeMessage(2, writes_.get(i)); + } + if (!transaction_.isEmpty()) { + output.writeBytes(3, transaction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + for (int i = 0; i < writes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, writes_.get(i)); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, transaction_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.CommitRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.CommitRequest other = (com.google.firestore.v1.CommitRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getWritesList().equals(other.getWritesList())) return false; + if (!getTransaction().equals(other.getTransaction())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (getWritesCount() > 0) { + hash = (37 * hash) + WRITES_FIELD_NUMBER; + hash = (53 * hash) + getWritesList().hashCode(); + } + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.CommitRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitRequest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CommitRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.CommitRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.CommitRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.CommitRequest) + com.google.firestore.v1.CommitRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CommitRequest.class, + com.google.firestore.v1.CommitRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.CommitRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + } else { + writes_ = null; + writesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + transaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.CommitRequest getDefaultInstanceForType() { + return com.google.firestore.v1.CommitRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.CommitRequest build() { + com.google.firestore.v1.CommitRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.CommitRequest buildPartial() { + com.google.firestore.v1.CommitRequest result = + new com.google.firestore.v1.CommitRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.CommitRequest result) { + if (writesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + writes_ = java.util.Collections.unmodifiableList(writes_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.writes_ = writes_; + } else { + result.writes_ = writesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.CommitRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transaction_ = transaction_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.CommitRequest) { + return mergeFrom((com.google.firestore.v1.CommitRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.CommitRequest other) { + if (other == com.google.firestore.v1.CommitRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (writesBuilder_ == null) { + if (!other.writes_.isEmpty()) { + if (writes_.isEmpty()) { + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureWritesIsMutable(); + writes_.addAll(other.writes_); + } + onChanged(); + } + } else { + if (!other.writes_.isEmpty()) { + if (writesBuilder_.isEmpty()) { + writesBuilder_.dispose(); + writesBuilder_ = null; + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000002); + writesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWritesFieldBuilder() + : null; + } else { + writesBuilder_.addAllMessages(other.writes_); + } + } + } + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Write m = + input.readMessage(com.google.firestore.v1.Write.parser(), extensionRegistry); + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(m); + } else { + writesBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List writes_ = + java.util.Collections.emptyList(); + + private void ensureWritesIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + writes_ = new java.util.ArrayList(writes_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + writesBuilder_; + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List getWritesList() { + if (writesBuilder_ == null) { + return java.util.Collections.unmodifiableList(writes_); + } else { + return writesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public int getWritesCount() { + if (writesBuilder_ == null) { + return writes_.size(); + } else { + return writesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write getWrites(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.set(index, value); + onChanged(); + } else { + writesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.set(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(value); + onChanged(); + } else { + writesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(index, value); + onChanged(); + } else { + writesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder addAllWrites( + java.lang.Iterable values) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writes_); + onChanged(); + } else { + writesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder clearWrites() { + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + writesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public Builder removeWrites(int index) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.remove(index); + onChanged(); + } else { + writesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder getWritesBuilder(int index) { + return internalGetWritesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List + getWritesOrBuilderList() { + if (writesBuilder_ != null) { + return writesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writes_); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder() { + return internalGetWritesFieldBuilder() + .addBuilder(com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder(int index) { + return internalGetWritesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + public java.util.List getWritesBuilderList() { + return internalGetWritesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + internalGetWritesFieldBuilder() { + if (writesBuilder_ == null) { + writesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder>( + writes_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + writes_ = null; + } + return writesBuilder_; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * If set, applies all writes in this transaction, and commits it.
+     * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * If set, applies all writes in this transaction, and commits it.
+     * 
+ * + * bytes transaction = 3; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * If set, applies all writes in this transaction, and commits it.
+     * 
+ * + * bytes transaction = 3; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.CommitRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.CommitRequest) + private static final com.google.firestore.v1.CommitRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.CommitRequest(); + } + + public static com.google.firestore.v1.CommitRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CommitRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.CommitRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequestOrBuilder.java new file mode 100644 index 000000000000..a866cdcc47e4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitRequestOrBuilder.java @@ -0,0 +1,134 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface CommitRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.CommitRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + java.util.List getWritesList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + com.google.firestore.v1.Write getWrites(int index); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + int getWritesCount(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + java.util.List getWritesOrBuilderList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 2; + */ + com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index); + + /** + * + * + *
+   * If set, applies all writes in this transaction, and commits it.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponse.java new file mode 100644 index 000000000000..f142fea557b9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponse.java @@ -0,0 +1,1289 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.CommitResponse} + */ +@com.google.protobuf.Generated +public final class CommitResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.CommitResponse) + CommitResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CommitResponse"); + } + + // Use CommitResponse.newBuilder() to construct. + private CommitResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CommitResponse() { + writeResults_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CommitResponse.class, + com.google.firestore.v1.CommitResponse.Builder.class); + } + + private int bitField0_; + public static final int WRITE_RESULTS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List writeResults_; + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public java.util.List getWriteResultsList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public java.util.List + getWriteResultsOrBuilderList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public int getWriteResultsCount() { + return writeResults_.size(); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + return writeResults_.get(index); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + return writeResults_.get(index); + } + + public static final int COMMIT_TIME_FIELD_NUMBER = 2; + private com.google.protobuf.Timestamp commitTime_; + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return Whether the commitTime field is set. + */ + @java.lang.Override + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return The commitTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCommitTime() { + return commitTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : commitTime_; + } + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder() { + return commitTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : commitTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < writeResults_.size(); i++) { + output.writeMessage(1, writeResults_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getCommitTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < writeResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, writeResults_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCommitTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.CommitResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.CommitResponse other = (com.google.firestore.v1.CommitResponse) obj; + + if (!getWriteResultsList().equals(other.getWriteResultsList())) return false; + if (hasCommitTime() != other.hasCommitTime()) return false; + if (hasCommitTime()) { + if (!getCommitTime().equals(other.getCommitTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getWriteResultsCount() > 0) { + hash = (37 * hash) + WRITE_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getWriteResultsList().hashCode(); + } + if (hasCommitTime()) { + hash = (37 * hash) + COMMIT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCommitTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.CommitResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CommitResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CommitResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CommitResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.CommitResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.CommitResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.CommitResponse) + com.google.firestore.v1.CommitResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CommitResponse.class, + com.google.firestore.v1.CommitResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.CommitResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetWriteResultsFieldBuilder(); + internalGetCommitTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + } else { + writeResults_ = null; + writeResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.CommitResponse getDefaultInstanceForType() { + return com.google.firestore.v1.CommitResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.CommitResponse build() { + com.google.firestore.v1.CommitResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.CommitResponse buildPartial() { + com.google.firestore.v1.CommitResponse result = + new com.google.firestore.v1.CommitResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.CommitResponse result) { + if (writeResultsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + writeResults_ = java.util.Collections.unmodifiableList(writeResults_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.writeResults_ = writeResults_; + } else { + result.writeResults_ = writeResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.CommitResponse result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.commitTime_ = commitTimeBuilder_ == null ? commitTime_ : commitTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.CommitResponse) { + return mergeFrom((com.google.firestore.v1.CommitResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.CommitResponse other) { + if (other == com.google.firestore.v1.CommitResponse.getDefaultInstance()) return this; + if (writeResultsBuilder_ == null) { + if (!other.writeResults_.isEmpty()) { + if (writeResults_.isEmpty()) { + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureWriteResultsIsMutable(); + writeResults_.addAll(other.writeResults_); + } + onChanged(); + } + } else { + if (!other.writeResults_.isEmpty()) { + if (writeResultsBuilder_.isEmpty()) { + writeResultsBuilder_.dispose(); + writeResultsBuilder_ = null; + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000001); + writeResultsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWriteResultsFieldBuilder() + : null; + } else { + writeResultsBuilder_.addAllMessages(other.writeResults_); + } + } + } + if (other.hasCommitTime()) { + mergeCommitTime(other.getCommitTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.WriteResult m = + input.readMessage( + com.google.firestore.v1.WriteResult.parser(), extensionRegistry); + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(m); + } else { + writeResultsBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetCommitTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List writeResults_ = + java.util.Collections.emptyList(); + + private void ensureWriteResultsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + writeResults_ = new java.util.ArrayList(writeResults_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + writeResultsBuilder_; + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List getWriteResultsList() { + if (writeResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(writeResults_); + } else { + return writeResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public int getWriteResultsCount() { + if (writeResultsBuilder_ == null) { + return writeResults_.size(); + } else { + return writeResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder setWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.set(index, value); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder setWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.set(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(index, value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder addAllWriteResults( + java.lang.Iterable values) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writeResults_); + onChanged(); + } else { + writeResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder clearWriteResults() { + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + writeResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public Builder removeWriteResults(int index) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.remove(index); + onChanged(); + } else { + writeResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder getWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List + getWriteResultsOrBuilderList() { + if (writeResultsBuilder_ != null) { + return writeResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writeResults_); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder() { + return internalGetWriteResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + public java.util.List + getWriteResultsBuilderList() { + return internalGetWriteResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + internalGetWriteResultsFieldBuilder() { + if (writeResultsBuilder_ == null) { + writeResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder>( + writeResults_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + writeResults_ = null; + } + return writeResultsBuilder_; + } + + private com.google.protobuf.Timestamp commitTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + commitTimeBuilder_; + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return Whether the commitTime field is set. + */ + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return The commitTime. + */ + public com.google.protobuf.Timestamp getCommitTime() { + if (commitTimeBuilder_ == null) { + return commitTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : commitTime_; + } else { + return commitTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + commitTime_ = value; + } else { + commitTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (commitTimeBuilder_ == null) { + commitTime_ = builderForValue.build(); + } else { + commitTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public Builder mergeCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && commitTime_ != null + && commitTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCommitTimeBuilder().mergeFrom(value); + } else { + commitTime_ = value; + } + } else { + commitTimeBuilder_.mergeFrom(value); + } + if (commitTime_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public Builder clearCommitTime() { + bitField0_ = (bitField0_ & ~0x00000002); + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getCommitTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetCommitTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + public com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder() { + if (commitTimeBuilder_ != null) { + return commitTimeBuilder_.getMessageOrBuilder(); + } else { + return commitTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : commitTime_; + } + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the commit.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCommitTimeFieldBuilder() { + if (commitTimeBuilder_ == null) { + commitTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCommitTime(), getParentForChildren(), isClean()); + commitTime_ = null; + } + return commitTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.CommitResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.CommitResponse) + private static final com.google.firestore.v1.CommitResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.CommitResponse(); + } + + public static com.google.firestore.v1.CommitResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CommitResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.CommitResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponseOrBuilder.java new file mode 100644 index 000000000000..799767d5a91d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommitResponseOrBuilder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface CommitResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.CommitResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + java.util.List getWriteResultsList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + com.google.firestore.v1.WriteResult getWriteResults(int index); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + int getWriteResultsCount(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + java.util.List + getWriteResultsOrBuilderList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 1; + */ + com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return Whether the commitTime field is set. + */ + boolean hasCommitTime(); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + * + * @return The commitTime. + */ + com.google.protobuf.Timestamp getCommitTime(); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the commit.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommonProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommonProto.java new file mode 100644 index 000000000000..f90e31d29cce --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CommonProto.java @@ -0,0 +1,141 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class CommonProto extends com.google.protobuf.GeneratedFile { + private CommonProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CommonProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentMask_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentMask_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Precondition_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Precondition_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_TransactionOptions_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_TransactionOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_TransactionOptions_ReadWrite_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_TransactionOptions_ReadOnly_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n google/firestore/v1/common.proto\022\023goog" + + "le.firestore.v1\032\037google/protobuf/timesta" + + "mp.proto\"#\n\014DocumentMask\022\023\n\013field_paths\030" + + "\001 \003(\t\"e\n\014Precondition\022\020\n\006exists\030\001 \001(\010H\000\022" + + "1\n\013update_time\030\002 \001(\0132\032.google.protobuf.T" + + "imestampH\000B\020\n\016condition_type\"\251\002\n\022Transac" + + "tionOptions\022E\n\tread_only\030\002 \001(\01320.google." + + "firestore.v1.TransactionOptions.ReadOnly" + + "H\000\022G\n\nread_write\030\003 \001(\01321.google.firestor" + + "e.v1.TransactionOptions.ReadWriteH\000\032&\n\tR" + + "eadWrite\022\031\n\021retry_transaction\030\001 \001(\014\032S\n\010R" + + "eadOnly\022/\n\tread_time\030\002 \001(\0132\032.google.prot" + + "obuf.TimestampH\000B\026\n\024consistency_selector" + + "B\006\n\004modeB\303\001\n\027com.google.firestore.v1B\013Co" + + "mmonProtoP\001Z;cloud.google.com/go/firesto" + + "re/apiv1/firestorepb;firestorepb\242\002\004GCFS\252" + + "\002\031Google.Cloud.Firestore.V1\312\002\031Google\\Clo" + + "ud\\Firestore\\V1\352\002\034Google::Cloud::Firesto" + + "re::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_v1_DocumentMask_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_DocumentMask_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentMask_descriptor, + new java.lang.String[] { + "FieldPaths", + }); + internal_static_google_firestore_v1_Precondition_descriptor = getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_Precondition_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Precondition_descriptor, + new java.lang.String[] { + "Exists", "UpdateTime", "ConditionType", + }); + internal_static_google_firestore_v1_TransactionOptions_descriptor = + getDescriptor().getMessageType(2); + internal_static_google_firestore_v1_TransactionOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_TransactionOptions_descriptor, + new java.lang.String[] { + "ReadOnly", "ReadWrite", "Mode", + }); + internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor = + internal_static_google_firestore_v1_TransactionOptions_descriptor.getNestedType(0); + internal_static_google_firestore_v1_TransactionOptions_ReadWrite_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor, + new java.lang.String[] { + "RetryTransaction", + }); + internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor = + internal_static_google_firestore_v1_TransactionOptions_descriptor.getNestedType(1); + internal_static_google_firestore_v1_TransactionOptions_ReadOnly_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor, + new java.lang.String[] { + "ReadTime", "ConsistencySelector", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequest.java new file mode 100644 index 000000000000..40ef4517b9c2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequest.java @@ -0,0 +1,1618 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.CreateDocumentRequest} + */ +@com.google.protobuf.Generated +public final class CreateDocumentRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.CreateDocumentRequest) + CreateDocumentRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CreateDocumentRequest"); + } + + // Use CreateDocumentRequest.newBuilder() to construct. + private CreateDocumentRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CreateDocumentRequest() { + parent_ = ""; + collectionId_ = ""; + documentId_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CreateDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CreateDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CreateDocumentRequest.class, + com.google.firestore.v1.CreateDocumentRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent resource. For example:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent resource. For example:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLLECTION_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object collectionId_ = ""; + + /** + * + * + *
+   * Required. The collection ID, relative to `parent`, to list. For example:
+   * `chatrooms`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The collectionId. + */ + @java.lang.Override + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The collection ID, relative to `parent`, to list. For example:
+   * `chatrooms`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for collectionId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOCUMENT_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object documentId_ = ""; + + /** + * + * + *
+   * The client-assigned document ID to use for this document.
+   *
+   * Optional. If not specified, an ID will be assigned by the service.
+   * 
+ * + * string document_id = 3; + * + * @return The documentId. + */ + @java.lang.Override + public java.lang.String getDocumentId() { + java.lang.Object ref = documentId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + documentId_ = s; + return s; + } + } + + /** + * + * + *
+   * The client-assigned document ID to use for this document.
+   *
+   * Optional. If not specified, an ID will be assigned by the service.
+   * 
+ * + * string document_id = 3; + * + * @return The bytes for documentId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDocumentIdBytes() { + java.lang.Object ref = documentId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + documentId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DOCUMENT_FIELD_NUMBER = 4; + private com.google.firestore.v1.Document document_; + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + public static final int MASK_FIELD_NUMBER = 5; + private com.google.firestore.v1.DocumentMask mask_; + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return Whether the mask field is set. + */ + @java.lang.Override + public boolean hasMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return The mask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getMask() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionId_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(documentId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, documentId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getDocument()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(5, getMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, collectionId_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(documentId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, documentId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getDocument()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.CreateDocumentRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.CreateDocumentRequest other = + (com.google.firestore.v1.CreateDocumentRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getCollectionId().equals(other.getCollectionId())) return false; + if (!getDocumentId().equals(other.getDocumentId())) return false; + if (hasDocument() != other.hasDocument()) return false; + if (hasDocument()) { + if (!getDocument().equals(other.getDocument())) return false; + } + if (hasMask() != other.hasMask()) return false; + if (hasMask()) { + if (!getMask().equals(other.getMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + COLLECTION_ID_FIELD_NUMBER; + hash = (53 * hash) + getCollectionId().hashCode(); + hash = (37 * hash) + DOCUMENT_ID_FIELD_NUMBER; + hash = (53 * hash) + getDocumentId().hashCode(); + if (hasDocument()) { + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + } + if (hasMask()) { + hash = (37 * hash) + MASK_FIELD_NUMBER; + hash = (53 * hash) + getMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.CreateDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.CreateDocumentRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.CreateDocumentRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.CreateDocumentRequest) + com.google.firestore.v1.CreateDocumentRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CreateDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CreateDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.CreateDocumentRequest.class, + com.google.firestore.v1.CreateDocumentRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.CreateDocumentRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDocumentFieldBuilder(); + internalGetMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + collectionId_ = ""; + documentId_ = ""; + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_CreateDocumentRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.CreateDocumentRequest getDefaultInstanceForType() { + return com.google.firestore.v1.CreateDocumentRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.CreateDocumentRequest build() { + com.google.firestore.v1.CreateDocumentRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.CreateDocumentRequest buildPartial() { + com.google.firestore.v1.CreateDocumentRequest result = + new com.google.firestore.v1.CreateDocumentRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.CreateDocumentRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.collectionId_ = collectionId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.documentId_ = documentId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.document_ = documentBuilder_ == null ? document_ : documentBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.mask_ = maskBuilder_ == null ? mask_ : maskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.CreateDocumentRequest) { + return mergeFrom((com.google.firestore.v1.CreateDocumentRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.CreateDocumentRequest other) { + if (other == com.google.firestore.v1.CreateDocumentRequest.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getCollectionId().isEmpty()) { + collectionId_ = other.collectionId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getDocumentId().isEmpty()) { + documentId_ = other.documentId_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.hasDocument()) { + mergeDocument(other.getDocument()); + } + if (other.hasMask()) { + mergeMask(other.getMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + collectionId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + documentId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + input.readMessage(internalGetMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent resource. For example:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource. For example:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource. For example:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource. For example:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource. For example:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object collectionId_ = ""; + + /** + * + * + *
+     * Required. The collection ID, relative to `parent`, to list. For example:
+     * `chatrooms`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The collectionId. + */ + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The collection ID, relative to `parent`, to list. For example:
+     * `chatrooms`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for collectionId. + */ + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The collection ID, relative to `parent`, to list. For example:
+     * `chatrooms`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + collectionId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The collection ID, relative to `parent`, to list. For example:
+     * `chatrooms`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearCollectionId() { + collectionId_ = getDefaultInstance().getCollectionId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The collection ID, relative to `parent`, to list. For example:
+     * `chatrooms`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + collectionId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object documentId_ = ""; + + /** + * + * + *
+     * The client-assigned document ID to use for this document.
+     *
+     * Optional. If not specified, an ID will be assigned by the service.
+     * 
+ * + * string document_id = 3; + * + * @return The documentId. + */ + public java.lang.String getDocumentId() { + java.lang.Object ref = documentId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + documentId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The client-assigned document ID to use for this document.
+     *
+     * Optional. If not specified, an ID will be assigned by the service.
+     * 
+ * + * string document_id = 3; + * + * @return The bytes for documentId. + */ + public com.google.protobuf.ByteString getDocumentIdBytes() { + java.lang.Object ref = documentId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + documentId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The client-assigned document ID to use for this document.
+     *
+     * Optional. If not specified, an ID will be assigned by the service.
+     * 
+ * + * string document_id = 3; + * + * @param value The documentId to set. + * @return This builder for chaining. + */ + public Builder setDocumentId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + documentId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The client-assigned document ID to use for this document.
+     *
+     * Optional. If not specified, an ID will be assigned by the service.
+     * 
+ * + * string document_id = 3; + * + * @return This builder for chaining. + */ + public Builder clearDocumentId() { + documentId_ = getDefaultInstance().getDocumentId(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * The client-assigned document ID to use for this document.
+     *
+     * Optional. If not specified, an ID will be assigned by the service.
+     * 
+ * + * string document_id = 3; + * + * @param value The bytes for documentId to set. + * @return This builder for chaining. + */ + public Builder setDocumentIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + documentId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.firestore.v1.Document document_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentBuilder_; + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + public boolean hasDocument() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + public com.google.firestore.v1.Document getDocument() { + if (documentBuilder_ == null) { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } else { + return documentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + } else { + documentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDocument(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentBuilder_ == null) { + document_ = builderForValue.build(); + } else { + documentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && document_ != null + && document_ != com.google.firestore.v1.Document.getDefaultInstance()) { + getDocumentBuilder().mergeFrom(value); + } else { + document_ = value; + } + } else { + documentBuilder_.mergeFrom(value); + } + if (document_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearDocument() { + bitField0_ = (bitField0_ & ~0x00000008); + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Document.Builder getDocumentBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if (documentBuilder_ != null) { + return documentBuilder_.getMessageOrBuilder(); + } else { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } + } + + /** + * + * + *
+     * Required. The document to create. `name` must not be set.
+     * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentFieldBuilder() { + if (documentBuilder_ == null) { + documentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + getDocument(), getParentForChildren(), isClean()); + document_ = null; + } + return documentBuilder_; + } + + private com.google.firestore.v1.DocumentMask mask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + maskBuilder_; + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return Whether the mask field is set. + */ + public boolean hasMask() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return The mask. + */ + public com.google.firestore.v1.DocumentMask getMask() { + if (maskBuilder_ == null) { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } else { + return maskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mask_ = value; + } else { + maskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (maskBuilder_ == null) { + mask_ = builderForValue.build(); + } else { + maskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public Builder mergeMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && mask_ != null + && mask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getMaskBuilder().mergeFrom(value); + } else { + mask_ = value; + } + } else { + maskBuilder_.mergeFrom(value); + } + if (mask_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public Builder clearMask() { + bitField0_ = (bitField0_ & ~0x00000010); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public com.google.firestore.v1.DocumentMask.Builder getMaskBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + if (maskBuilder_ != null) { + return maskBuilder_.getMessageOrBuilder(); + } else { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetMaskFieldBuilder() { + if (maskBuilder_ == null) { + maskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getMask(), getParentForChildren(), isClean()); + mask_ = null; + } + return maskBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.CreateDocumentRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.CreateDocumentRequest) + private static final com.google.firestore.v1.CreateDocumentRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.CreateDocumentRequest(); + } + + public static com.google.firestore.v1.CreateDocumentRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateDocumentRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.CreateDocumentRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequestOrBuilder.java new file mode 100644 index 000000000000..6ded34402d39 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CreateDocumentRequestOrBuilder.java @@ -0,0 +1,202 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface CreateDocumentRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.CreateDocumentRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent resource. For example:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent resource. For example:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The collection ID, relative to `parent`, to list. For example:
+   * `chatrooms`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The collectionId. + */ + java.lang.String getCollectionId(); + + /** + * + * + *
+   * Required. The collection ID, relative to `parent`, to list. For example:
+   * `chatrooms`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for collectionId. + */ + com.google.protobuf.ByteString getCollectionIdBytes(); + + /** + * + * + *
+   * The client-assigned document ID to use for this document.
+   *
+   * Optional. If not specified, an ID will be assigned by the service.
+   * 
+ * + * string document_id = 3; + * + * @return The documentId. + */ + java.lang.String getDocumentId(); + + /** + * + * + *
+   * The client-assigned document ID to use for this document.
+   *
+   * Optional. If not specified, an ID will be assigned by the service.
+   * 
+ * + * string document_id = 3; + * + * @return The bytes for documentId. + */ + com.google.protobuf.ByteString getDocumentIdBytes(); + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + boolean hasDocument(); + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + com.google.firestore.v1.Document getDocument(); + + /** + * + * + *
+   * Required. The document to create. `name` must not be set.
+   * 
+ * + * .google.firestore.v1.Document document = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return Whether the mask field is set. + */ + boolean hasMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + * + * @return The mask. + */ + com.google.firestore.v1.DocumentMask getMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 5; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Cursor.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Cursor.java new file mode 100644 index 000000000000..c2816c415f0e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Cursor.java @@ -0,0 +1,1079 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A position in a query result set.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Cursor} + */ +@com.google.protobuf.Generated +public final class Cursor extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Cursor) + CursorOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Cursor"); + } + + // Use Cursor.newBuilder() to construct. + private Cursor(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Cursor() { + values_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto.internal_static_google_firestore_v1_Cursor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_Cursor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Cursor.class, com.google.firestore.v1.Cursor.Builder.class); + } + + public static final int VALUES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List values_; + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesList() { + return values_; + } + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesOrBuilderList() { + return values_; + } + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public int getValuesCount() { + return values_.size(); + } + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Value getValues(int index) { + return values_.get(index); + } + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index) { + return values_.get(index); + } + + public static final int BEFORE_FIELD_NUMBER = 2; + private boolean before_ = false; + + /** + * + * + *
+   * If the position is just before or just after the given values, relative
+   * to the sort order defined by the query.
+   * 
+ * + * bool before = 2; + * + * @return The before. + */ + @java.lang.Override + public boolean getBefore() { + return before_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < values_.size(); i++) { + output.writeMessage(1, values_.get(i)); + } + if (before_ != false) { + output.writeBool(2, before_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < values_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, values_.get(i)); + } + if (before_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, before_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Cursor)) { + return super.equals(obj); + } + com.google.firestore.v1.Cursor other = (com.google.firestore.v1.Cursor) obj; + + if (!getValuesList().equals(other.getValuesList())) return false; + if (getBefore() != other.getBefore()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getValuesCount() > 0) { + hash = (37 * hash) + VALUES_FIELD_NUMBER; + hash = (53 * hash) + getValuesList().hashCode(); + } + hash = (37 * hash) + BEFORE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getBefore()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Cursor parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Cursor parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Cursor parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Cursor parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Cursor parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Cursor parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Cursor parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Cursor parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Cursor parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Cursor parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Cursor parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Cursor parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Cursor prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A position in a query result set.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Cursor} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Cursor) + com.google.firestore.v1.CursorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_Cursor_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_Cursor_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Cursor.class, com.google.firestore.v1.Cursor.Builder.class); + } + + // Construct using com.google.firestore.v1.Cursor.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + } else { + values_ = null; + valuesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + before_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_Cursor_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Cursor getDefaultInstanceForType() { + return com.google.firestore.v1.Cursor.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Cursor build() { + com.google.firestore.v1.Cursor result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Cursor buildPartial() { + com.google.firestore.v1.Cursor result = new com.google.firestore.v1.Cursor(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Cursor result) { + if (valuesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + values_ = java.util.Collections.unmodifiableList(values_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.values_ = values_; + } else { + result.values_ = valuesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Cursor result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.before_ = before_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Cursor) { + return mergeFrom((com.google.firestore.v1.Cursor) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Cursor other) { + if (other == com.google.firestore.v1.Cursor.getDefaultInstance()) return this; + if (valuesBuilder_ == null) { + if (!other.values_.isEmpty()) { + if (values_.isEmpty()) { + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureValuesIsMutable(); + values_.addAll(other.values_); + } + onChanged(); + } + } else { + if (!other.values_.isEmpty()) { + if (valuesBuilder_.isEmpty()) { + valuesBuilder_.dispose(); + valuesBuilder_ = null; + values_ = other.values_; + bitField0_ = (bitField0_ & ~0x00000001); + valuesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetValuesFieldBuilder() + : null; + } else { + valuesBuilder_.addAllMessages(other.values_); + } + } + } + if (other.getBefore() != false) { + setBefore(other.getBefore()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(m); + } else { + valuesBuilder_.addMessage(m); + } + break; + } // case 10 + case 16: + { + before_ = input.readBool(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List values_ = + java.util.Collections.emptyList(); + + private void ensureValuesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + values_ = new java.util.ArrayList(values_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + valuesBuilder_; + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List getValuesList() { + if (valuesBuilder_ == null) { + return java.util.Collections.unmodifiableList(values_); + } else { + return valuesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public int getValuesCount() { + if (valuesBuilder_ == null) { + return values_.size(); + } else { + return valuesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value getValues(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.set(index, value); + onChanged(); + } else { + valuesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.set(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(value); + onChanged(); + } else { + valuesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.firestore.v1.Value value) { + if (valuesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureValuesIsMutable(); + values_.add(index, value); + onChanged(); + } else { + valuesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(index, builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder addAllValues( + java.lang.Iterable values) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, values_); + onChanged(); + } else { + valuesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder clearValues() { + if (valuesBuilder_ == null) { + values_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + valuesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public Builder removeValues(int index) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.remove(index); + onChanged(); + } else { + valuesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder getValuesBuilder(int index) { + return internalGetValuesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List + getValuesOrBuilderList() { + if (valuesBuilder_ != null) { + return valuesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(values_); + } + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder addValuesBuilder() { + return internalGetValuesFieldBuilder() + .addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public com.google.firestore.v1.Value.Builder addValuesBuilder(int index) { + return internalGetValuesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The values that represent a position, in the order they appear in
+     * the order by clause of a query.
+     *
+     * Can contain fewer values than specified in the order by clause.
+     * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + public java.util.List getValuesBuilderList() { + return internalGetValuesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetValuesFieldBuilder() { + if (valuesBuilder_ == null) { + valuesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + values_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + values_ = null; + } + return valuesBuilder_; + } + + private boolean before_; + + /** + * + * + *
+     * If the position is just before or just after the given values, relative
+     * to the sort order defined by the query.
+     * 
+ * + * bool before = 2; + * + * @return The before. + */ + @java.lang.Override + public boolean getBefore() { + return before_; + } + + /** + * + * + *
+     * If the position is just before or just after the given values, relative
+     * to the sort order defined by the query.
+     * 
+ * + * bool before = 2; + * + * @param value The before to set. + * @return This builder for chaining. + */ + public Builder setBefore(boolean value) { + + before_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * If the position is just before or just after the given values, relative
+     * to the sort order defined by the query.
+     * 
+ * + * bool before = 2; + * + * @return This builder for chaining. + */ + public Builder clearBefore() { + bitField0_ = (bitField0_ & ~0x00000002); + before_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Cursor) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Cursor) + private static final com.google.firestore.v1.Cursor DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Cursor(); + } + + public static com.google.firestore.v1.Cursor getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Cursor parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Cursor getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CursorOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CursorOrBuilder.java new file mode 100644 index 000000000000..380bfc719152 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/CursorOrBuilder.java @@ -0,0 +1,112 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface CursorOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Cursor) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + java.util.List getValuesList(); + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + com.google.firestore.v1.Value getValues(int index); + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + int getValuesCount(); + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + java.util.List getValuesOrBuilderList(); + + /** + * + * + *
+   * The values that represent a position, in the order they appear in
+   * the order by clause of a query.
+   *
+   * Can contain fewer values than specified in the order by clause.
+   * 
+ * + * repeated .google.firestore.v1.Value values = 1; + */ + com.google.firestore.v1.ValueOrBuilder getValuesOrBuilder(int index); + + /** + * + * + *
+   * If the position is just before or just after the given values, relative
+   * to the sort order defined by the query.
+   * 
+ * + * bool before = 2; + * + * @return The before. + */ + boolean getBefore(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DatabaseRootName.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DatabaseRootName.java new file mode 100644 index 000000000000..3750517911f4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DatabaseRootName.java @@ -0,0 +1,182 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") +public class DatabaseRootName implements ResourceName { + + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}"); + + private volatile Map fieldValuesMap; + + private final String project; + private final String database; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private DatabaseRootName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + } + + public static DatabaseRootName of(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build(); + } + + public static String format(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build().toString(); + } + + public static DatabaseRootName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, "DatabaseRootName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList(values.size()); + for (DatabaseRootName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + fieldMapBuilder.put("project", project); + fieldMapBuilder.put("database", database); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate("project", project, "database", database); + } + + /** Builder for DatabaseRootName. */ + public static class Builder { + + private String project; + private String database; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + private Builder() {} + + private Builder(DatabaseRootName databaseRootName) { + project = databaseRootName.project; + database = databaseRootName.database; + } + + public DatabaseRootName build() { + return new DatabaseRootName(this); + } + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof DatabaseRootName) { + DatabaseRootName that = (DatabaseRootName) 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/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequest.java new file mode 100644 index 000000000000..2c96938feb13 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequest.java @@ -0,0 +1,910 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DeleteDocumentRequest} + */ +@com.google.protobuf.Generated +public final class DeleteDocumentRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DeleteDocumentRequest) + DeleteDocumentRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DeleteDocumentRequest"); + } + + // Use DeleteDocumentRequest.newBuilder() to construct. + private DeleteDocumentRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DeleteDocumentRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_DeleteDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_DeleteDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DeleteDocumentRequest.class, + com.google.firestore.v1.DeleteDocumentRequest.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. The resource name of the Document to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The resource name of the Document to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CURRENT_DOCUMENT_FIELD_NUMBER = 2; + private com.google.firestore.v1.Precondition currentDocument_; + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return Whether the currentDocument field is set. + */ + @java.lang.Override + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return The currentDocument. + */ + @java.lang.Override + public com.google.firestore.v1.Precondition getCurrentDocument() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + @java.lang.Override + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getCurrentDocument()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getCurrentDocument()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DeleteDocumentRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.DeleteDocumentRequest other = + (com.google.firestore.v1.DeleteDocumentRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (hasCurrentDocument() != other.hasCurrentDocument()) return false; + if (hasCurrentDocument()) { + if (!getCurrentDocument().equals(other.getCurrentDocument())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasCurrentDocument()) { + hash = (37 * hash) + CURRENT_DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getCurrentDocument().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DeleteDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DeleteDocumentRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DeleteDocumentRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DeleteDocumentRequest) + com.google.firestore.v1.DeleteDocumentRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_DeleteDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_DeleteDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DeleteDocumentRequest.class, + com.google.firestore.v1.DeleteDocumentRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.DeleteDocumentRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCurrentDocumentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_DeleteDocumentRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DeleteDocumentRequest getDefaultInstanceForType() { + return com.google.firestore.v1.DeleteDocumentRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DeleteDocumentRequest build() { + com.google.firestore.v1.DeleteDocumentRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DeleteDocumentRequest buildPartial() { + com.google.firestore.v1.DeleteDocumentRequest result = + new com.google.firestore.v1.DeleteDocumentRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DeleteDocumentRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.currentDocument_ = + currentDocumentBuilder_ == null ? currentDocument_ : currentDocumentBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DeleteDocumentRequest) { + return mergeFrom((com.google.firestore.v1.DeleteDocumentRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DeleteDocumentRequest other) { + if (other == com.google.firestore.v1.DeleteDocumentRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasCurrentDocument()) { + mergeCurrentDocument(other.getCurrentDocument()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetCurrentDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The resource name of the Document to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The resource name of the Document to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The resource name of the Document to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The resource name of the Document to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The resource name of the Document to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.v1.Precondition currentDocument_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + currentDocumentBuilder_; + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return Whether the currentDocument field is set. + */ + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return The currentDocument. + */ + public com.google.firestore.v1.Precondition getCurrentDocument() { + if (currentDocumentBuilder_ == null) { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } else { + return currentDocumentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public Builder setCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + currentDocument_ = value; + } else { + currentDocumentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public Builder setCurrentDocument( + com.google.firestore.v1.Precondition.Builder builderForValue) { + if (currentDocumentBuilder_ == null) { + currentDocument_ = builderForValue.build(); + } else { + currentDocumentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public Builder mergeCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && currentDocument_ != null + && currentDocument_ != com.google.firestore.v1.Precondition.getDefaultInstance()) { + getCurrentDocumentBuilder().mergeFrom(value); + } else { + currentDocument_ = value; + } + } else { + currentDocumentBuilder_.mergeFrom(value); + } + if (currentDocument_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public Builder clearCurrentDocument() { + bitField0_ = (bitField0_ & ~0x00000002); + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public com.google.firestore.v1.Precondition.Builder getCurrentDocumentBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetCurrentDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + if (currentDocumentBuilder_ != null) { + return currentDocumentBuilder_.getMessageOrBuilder(); + } else { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + internalGetCurrentDocumentFieldBuilder() { + if (currentDocumentBuilder_ == null) { + currentDocumentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder>( + getCurrentDocument(), getParentForChildren(), isClean()); + currentDocument_ = null; + } + return currentDocumentBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DeleteDocumentRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DeleteDocumentRequest) + private static final com.google.firestore.v1.DeleteDocumentRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DeleteDocumentRequest(); + } + + public static com.google.firestore.v1.DeleteDocumentRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteDocumentRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DeleteDocumentRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequestOrBuilder.java new file mode 100644 index 000000000000..0baff7fe807b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DeleteDocumentRequestOrBuilder.java @@ -0,0 +1,96 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DeleteDocumentRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DeleteDocumentRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The resource name of the Document to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. The resource name of the Document to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return Whether the currentDocument field is set. + */ + boolean hasCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + * + * @return The currentDocument. + */ + com.google.firestore.v1.Precondition getCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 2; + */ + com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Document.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Document.java new file mode 100644 index 000000000000..ccff0e59ffe2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Document.java @@ -0,0 +1,1960 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore document.
+ *
+ * Must not exceed 1 MiB - 4 bytes.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Document} + */ +@com.google.protobuf.Generated +public final class Document extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Document) + DocumentOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Document"); + } + + // Use Document.newBuilder() to construct. + private Document(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Document() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Document.class, com.google.firestore.v1.Document.Builder.class); + } + + private int bitField0_; + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * The resource name of the document, for example
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource name of the document, for example
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FIELDS_FIELD_NUMBER = 2; + + private static final class FieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_FieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField fields_; + + private com.google.protobuf.MapField + internalGetFields() { + if (fields_ == null) { + return com.google.protobuf.MapField.emptyMapField(FieldsDefaultEntryHolder.defaultEntry); + } + return fields_; + } + + public int getFieldsCount() { + return internalGetFields().getMap().size(); + } + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public boolean containsFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetFields().getMap().containsKey(key); + } + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getFields() { + return getFieldsMap(); + } + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public java.util.Map getFieldsMap() { + return internalGetFields().getMap(); + } + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int CREATE_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetFields(), FieldsDefaultEntryHolder.defaultEntry, 2); + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getUpdateTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + for (java.util.Map.Entry entry : + internalGetFields().getMap().entrySet()) { + com.google.protobuf.MapEntry fields__ = + FieldsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, fields__); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCreateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getUpdateTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Document)) { + return super.equals(obj); + } + com.google.firestore.v1.Document other = (com.google.firestore.v1.Document) obj; + + if (!getName().equals(other.getName())) return false; + if (!internalGetFields().equals(other.internalGetFields())) return false; + if (hasCreateTime() != other.hasCreateTime()) return false; + if (hasCreateTime()) { + if (!getCreateTime().equals(other.getCreateTime())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (!internalGetFields().getMap().isEmpty()) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetFields().hashCode(); + } + if (hasCreateTime()) { + hash = (37 * hash) + CREATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCreateTime().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Document parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Document parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Document parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Document parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Document parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Document parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Document parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Document parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Document parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Document parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Document parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Document parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Document prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Firestore document.
+   *
+   * Must not exceed 1 MiB - 4 bytes.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Document} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Document) + com.google.firestore.v1.DocumentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Document.class, + com.google.firestore.v1.Document.Builder.class); + } + + // Construct using com.google.firestore.v1.Document.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCreateTimeFieldBuilder(); + internalGetUpdateTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + internalGetMutableFields().clear(); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Document_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Document getDefaultInstanceForType() { + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Document build() { + com.google.firestore.v1.Document result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Document buildPartial() { + com.google.firestore.v1.Document result = new com.google.firestore.v1.Document(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Document result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.fields_ = internalGetFields().build(FieldsDefaultEntryHolder.defaultEntry); + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Document) { + return mergeFrom((com.google.firestore.v1.Document) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Document other) { + if (other == com.google.firestore.v1.Document.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + internalGetMutableFields().mergeFrom(other.internalGetFields()); + bitField0_ |= 0x00000002; + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.protobuf.MapEntry + fields__ = + input.readMessage( + FieldsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableFields() + .ensureBuilderMap() + .put(fields__.getKey(), fields__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * The resource name of the document, for example
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource name of the document, for example
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource name of the document, for example
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the document, for example
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the document, for example
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private static final class FieldsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return FieldsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final FieldsConverter fieldsConverter = new FieldsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + fields_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetFields() { + if (fields_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(fieldsConverter); + } + return fields_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableFields() { + if (fields_ == null) { + fields_ = new com.google.protobuf.MapFieldBuilder<>(fieldsConverter); + } + bitField0_ |= 0x00000002; + onChanged(); + return fields_; + } + + public int getFieldsCount() { + return internalGetFields().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public boolean containsFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetFields().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getFields() { + return getFieldsMap(); + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public java.util.Map getFieldsMap() { + return internalGetFields().getImmutableMap(); + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableFields().ensureBuilderMap(); + return map.containsKey(key) ? fieldsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableFields().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return fieldsConverter.build(map.get(key)); + } + + public Builder clearFields() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableFields().clear(); + return this; + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + public Builder removeFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableFields().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableFields() { + bitField0_ |= 0x00000002; + return internalGetMutableFields().ensureMessageMap(); + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + public Builder putFields(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableFields().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + public Builder putAllFields( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableFields().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * The document's fields.
+     *
+     * The map keys represent field names.
+     *
+     * Field names matching the regular expression `__.*__` are reserved. Reserved
+     * field names are forbidden except in certain documented contexts. The field
+     * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+     * empty.
+     *
+     * Field paths may be used in other contexts to refer to structured fields
+     * defined here. For `map_value`, the field path is represented by a
+     * dot-delimited (`.`) string of segments. Each segment is either a simple
+     * field name (defined below) or a quoted field name. For example, the
+     * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+     * }}}` would be represented by the field path `` foo.`x&y` ``.
+     *
+     * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+     * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+     * `foo_bar_17`.
+     *
+     * A quoted field name starts and ends with `` ` `` and
+     * may contain any character. Some characters, including `` ` ``, must be
+     * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+     * `` `bak\`tik` `` represents `` bak`tik ``.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + public com.google.firestore.v1.Value.Builder putFieldsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableFields().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. + */ + public com.google.protobuf.Timestamp getCreateTime() { + if (createTimeBuilder_ == null) { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } else { + return createTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public Builder setCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + createTime_ = value; + } else { + createTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public Builder setCreateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (createTimeBuilder_ == null) { + createTime_ = builderForValue.build(); + } else { + createTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public Builder mergeCreateTime(com.google.protobuf.Timestamp value) { + if (createTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && createTime_ != null + && createTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCreateTimeBuilder().mergeFrom(value); + } else { + createTime_ = value; + } + } else { + createTimeBuilder_.mergeFrom(value); + } + if (createTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * Output only. The time at which the document was created.
+     *
+     * This value increases monotonically when a document is deleted then
+     * recreated. It can also be compared to values from other documents and
+     * the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCreateTime(), getParentForChildren(), isClean()); + createTime_ = null; + } + return createTimeBuilder_; + } + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000008); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * Output only. The time at which the document was last changed.
+     *
+     * This value is initially set to the `create_time` then increases
+     * monotonically with each change to the document. It can also be
+     * compared to values from other documents and the `read_time` of a query.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Document) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Document) + private static final com.google.firestore.v1.Document DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Document(); + } + + public static com.google.firestore.v1.Document getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Document parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Document getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChange.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChange.java new file mode 100644 index 000000000000..7b37aa1de98c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChange.java @@ -0,0 +1,1235 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A [Document][google.firestore.v1.Document] has changed.
+ *
+ * May be the result of multiple [writes][google.firestore.v1.Write], including
+ * deletes, that ultimately resulted in a new value for the
+ * [Document][google.firestore.v1.Document].
+ *
+ * Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be
+ * returned for the same logical change, if multiple targets are affected.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentChange} + */ +@com.google.protobuf.Generated +public final class DocumentChange extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentChange) + DocumentChangeOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentChange"); + } + + // Use DocumentChange.newBuilder() to construct. + private DocumentChange(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentChange() { + targetIds_ = emptyIntList(); + removedTargetIds_ = emptyIntList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentChange_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentChange.class, + com.google.firestore.v1.DocumentChange.Builder.class); + } + + private int bitField0_; + public static final int DOCUMENT_FIELD_NUMBER = 1; + private com.google.firestore.v1.Document document_; + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + public static final int TARGET_IDS_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList targetIds_ = emptyIntList(); + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @return A list containing the targetIds. + */ + @java.lang.Override + public java.util.List getTargetIdsList() { + return targetIds_; + } + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @return The count of targetIds. + */ + public int getTargetIdsCount() { + return targetIds_.size(); + } + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + public int getTargetIds(int index) { + return targetIds_.getInt(index); + } + + private int targetIdsMemoizedSerializedSize = -1; + + public static final int REMOVED_TARGET_IDS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + @java.lang.Override + public java.util.List getRemovedTargetIdsList() { + return removedTargetIds_; + } + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + private int removedTargetIdsMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getDocument()); + } + if (getTargetIdsList().size() > 0) { + output.writeUInt32NoTag(42); + output.writeUInt32NoTag(targetIdsMemoizedSerializedSize); + } + for (int i = 0; i < targetIds_.size(); i++) { + output.writeInt32NoTag(targetIds_.getInt(i)); + } + if (getRemovedTargetIdsList().size() > 0) { + output.writeUInt32NoTag(50); + output.writeUInt32NoTag(removedTargetIdsMemoizedSerializedSize); + } + for (int i = 0; i < removedTargetIds_.size(); i++) { + output.writeInt32NoTag(removedTargetIds_.getInt(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDocument()); + } + { + int dataSize = 0; + for (int i = 0; i < targetIds_.size(); i++) { + dataSize += + com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(targetIds_.getInt(i)); + } + size += dataSize; + if (!getTargetIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + targetIdsMemoizedSerializedSize = dataSize; + } + { + int dataSize = 0; + for (int i = 0; i < removedTargetIds_.size(); i++) { + dataSize += + com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag( + removedTargetIds_.getInt(i)); + } + size += dataSize; + if (!getRemovedTargetIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + removedTargetIdsMemoizedSerializedSize = dataSize; + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentChange)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentChange other = (com.google.firestore.v1.DocumentChange) obj; + + if (hasDocument() != other.hasDocument()) return false; + if (hasDocument()) { + if (!getDocument().equals(other.getDocument())) return false; + } + if (!getTargetIdsList().equals(other.getTargetIdsList())) return false; + if (!getRemovedTargetIdsList().equals(other.getRemovedTargetIdsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasDocument()) { + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + } + if (getTargetIdsCount() > 0) { + hash = (37 * hash) + TARGET_IDS_FIELD_NUMBER; + hash = (53 * hash) + getTargetIdsList().hashCode(); + } + if (getRemovedTargetIdsCount() > 0) { + hash = (37 * hash) + REMOVED_TARGET_IDS_FIELD_NUMBER; + hash = (53 * hash) + getRemovedTargetIdsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentChange parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentChange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentChange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentChange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentChange parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentChange parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DocumentChange prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   *
+   * May be the result of multiple [writes][google.firestore.v1.Write], including
+   * deletes, that ultimately resulted in a new value for the
+   * [Document][google.firestore.v1.Document].
+   *
+   * Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be
+   * returned for the same logical change, if multiple targets are affected.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentChange} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentChange) + com.google.firestore.v1.DocumentChangeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentChange_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentChange.class, + com.google.firestore.v1.DocumentChange.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentChange.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDocumentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + targetIds_ = emptyIntList(); + removedTargetIds_ = emptyIntList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentChange_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentChange getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentChange build() { + com.google.firestore.v1.DocumentChange result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentChange buildPartial() { + com.google.firestore.v1.DocumentChange result = + new com.google.firestore.v1.DocumentChange(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DocumentChange result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.document_ = documentBuilder_ == null ? document_ : documentBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + targetIds_.makeImmutable(); + result.targetIds_ = targetIds_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + removedTargetIds_.makeImmutable(); + result.removedTargetIds_ = removedTargetIds_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentChange) { + return mergeFrom((com.google.firestore.v1.DocumentChange) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentChange other) { + if (other == com.google.firestore.v1.DocumentChange.getDefaultInstance()) return this; + if (other.hasDocument()) { + mergeDocument(other.getDocument()); + } + if (!other.targetIds_.isEmpty()) { + if (targetIds_.isEmpty()) { + targetIds_ = other.targetIds_; + targetIds_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureTargetIdsIsMutable(); + targetIds_.addAll(other.targetIds_); + } + onChanged(); + } + if (!other.removedTargetIds_.isEmpty()) { + if (removedTargetIds_.isEmpty()) { + removedTargetIds_ = other.removedTargetIds_; + removedTargetIds_.makeImmutable(); + bitField0_ |= 0x00000004; + } else { + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addAll(other.removedTargetIds_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 40: + { + int v = input.readInt32(); + ensureTargetIdsIsMutable(); + targetIds_.addInt(v); + break; + } // case 40 + case 42: + { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureTargetIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + targetIds_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 42 + case 48: + { + int v = input.readInt32(); + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(v); + break; + } // case 48 + case 50: + { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureRemovedTargetIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + removedTargetIds_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.Document document_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentBuilder_; + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + public com.google.firestore.v1.Document getDocument() { + if (documentBuilder_ == null) { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } else { + return documentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder setDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + } else { + documentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder setDocument(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentBuilder_ == null) { + document_ = builderForValue.build(); + } else { + documentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder mergeDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && document_ != null + && document_ != com.google.firestore.v1.Document.getDefaultInstance()) { + getDocumentBuilder().mergeFrom(value); + } else { + document_ = value; + } + } else { + documentBuilder_.mergeFrom(value); + } + if (document_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder clearDocument() { + bitField0_ = (bitField0_ & ~0x00000001); + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public com.google.firestore.v1.Document.Builder getDocumentBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if (documentBuilder_ != null) { + return documentBuilder_.getMessageOrBuilder(); + } else { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } + } + + /** + * + * + *
+     * The new state of the [Document][google.firestore.v1.Document].
+     *
+     * If `mask` is set, contains only fields that were updated or added.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentFieldBuilder() { + if (documentBuilder_ == null) { + documentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + getDocument(), getParentForChildren(), isClean()); + document_ = null; + } + return documentBuilder_; + } + + private com.google.protobuf.Internal.IntList targetIds_ = emptyIntList(); + + private void ensureTargetIdsIsMutable() { + if (!targetIds_.isModifiable()) { + targetIds_ = makeMutableCopy(targetIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @return A list containing the targetIds. + */ + public java.util.List getTargetIdsList() { + targetIds_.makeImmutable(); + return targetIds_; + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @return The count of targetIds. + */ + public int getTargetIdsCount() { + return targetIds_.size(); + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + public int getTargetIds(int index) { + return targetIds_.getInt(index); + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @param index The index to set the value at. + * @param value The targetIds to set. + * @return This builder for chaining. + */ + public Builder setTargetIds(int index, int value) { + + ensureTargetIdsIsMutable(); + targetIds_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @param value The targetIds to add. + * @return This builder for chaining. + */ + public Builder addTargetIds(int value) { + + ensureTargetIdsIsMutable(); + targetIds_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @param values The targetIds to add. + * @return This builder for chaining. + */ + public Builder addAllTargetIds(java.lang.Iterable values) { + ensureTargetIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, targetIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs of targets that match this document.
+     * 
+ * + * repeated int32 target_ids = 5; + * + * @return This builder for chaining. + */ + public Builder clearTargetIds() { + targetIds_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + private void ensureRemovedTargetIdsIsMutable() { + if (!removedTargetIds_.isModifiable()) { + removedTargetIds_ = makeMutableCopy(removedTargetIds_); + } + bitField0_ |= 0x00000004; + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + public java.util.List getRemovedTargetIdsList() { + removedTargetIds_.makeImmutable(); + return removedTargetIds_; + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index to set the value at. + * @param value The removedTargetIds to set. + * @return This builder for chaining. + */ + public Builder setRemovedTargetIds(int index, int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.setInt(index, value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param value The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addRemovedTargetIds(int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(value); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param values The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addAllRemovedTargetIds(java.lang.Iterable values) { + ensureRemovedTargetIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, removedTargetIds_); + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that no longer match this document.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return This builder for chaining. + */ + public Builder clearRemovedTargetIds() { + removedTargetIds_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentChange) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentChange) + private static final com.google.firestore.v1.DocumentChange DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentChange(); + } + + public static com.google.firestore.v1.DocumentChange getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentChange parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentChange getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChangeOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChangeOrBuilder.java new file mode 100644 index 000000000000..a80530af6f61 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentChangeOrBuilder.java @@ -0,0 +1,151 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentChangeOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentChange) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + boolean hasDocument(); + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + com.google.firestore.v1.Document getDocument(); + + /** + * + * + *
+   * The new state of the [Document][google.firestore.v1.Document].
+   *
+   * If `mask` is set, contains only fields that were updated or added.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + */ + com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder(); + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @return A list containing the targetIds. + */ + java.util.List getTargetIdsList(); + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @return The count of targetIds. + */ + int getTargetIdsCount(); + + /** + * + * + *
+   * A set of target IDs of targets that match this document.
+   * 
+ * + * repeated int32 target_ids = 5; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + int getTargetIds(int index); + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + java.util.List getRemovedTargetIdsList(); + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + int getRemovedTargetIdsCount(); + + /** + * + * + *
+   * A set of target IDs for targets that no longer match this document.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + int getRemovedTargetIds(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDelete.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDelete.java new file mode 100644 index 000000000000..624985f46cee --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDelete.java @@ -0,0 +1,1176 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A [Document][google.firestore.v1.Document] has been deleted.
+ *
+ * May be the result of multiple [writes][google.firestore.v1.Write], including
+ * updates, the last of which deleted the
+ * [Document][google.firestore.v1.Document].
+ *
+ * Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be
+ * returned for the same logical delete, if multiple targets are affected.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentDelete} + */ +@com.google.protobuf.Generated +public final class DocumentDelete extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentDelete) + DocumentDeleteOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentDelete"); + } + + // Use DocumentDelete.newBuilder() to construct. + private DocumentDelete(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentDelete() { + document_ = ""; + removedTargetIds_ = emptyIntList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentDelete_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentDelete_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentDelete.class, + com.google.firestore.v1.DocumentDelete.Builder.class); + } + + private int bitField0_; + public static final int DOCUMENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object document_ = ""; + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that was
+   * deleted.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + @java.lang.Override + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that was
+   * deleted.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REMOVED_TARGET_IDS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + @java.lang.Override + public java.util.List getRemovedTargetIdsList() { + return removedTargetIds_; + } + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + private int removedTargetIdsMemoizedSerializedSize = -1; + + public static final int READ_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, document_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getReadTime()); + } + if (getRemovedTargetIdsList().size() > 0) { + output.writeUInt32NoTag(50); + output.writeUInt32NoTag(removedTargetIdsMemoizedSerializedSize); + } + for (int i = 0; i < removedTargetIds_.size(); i++) { + output.writeInt32NoTag(removedTargetIds_.getInt(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, document_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getReadTime()); + } + { + int dataSize = 0; + for (int i = 0; i < removedTargetIds_.size(); i++) { + dataSize += + com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag( + removedTargetIds_.getInt(i)); + } + size += dataSize; + if (!getRemovedTargetIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + removedTargetIdsMemoizedSerializedSize = dataSize; + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentDelete)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentDelete other = (com.google.firestore.v1.DocumentDelete) obj; + + if (!getDocument().equals(other.getDocument())) return false; + if (!getRemovedTargetIdsList().equals(other.getRemovedTargetIdsList())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + if (getRemovedTargetIdsCount() > 0) { + hash = (37 * hash) + REMOVED_TARGET_IDS_FIELD_NUMBER; + hash = (53 * hash) + getRemovedTargetIdsList().hashCode(); + } + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentDelete parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentDelete parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentDelete parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentDelete parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DocumentDelete prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   *
+   * May be the result of multiple [writes][google.firestore.v1.Write], including
+   * updates, the last of which deleted the
+   * [Document][google.firestore.v1.Document].
+   *
+   * Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be
+   * returned for the same logical delete, if multiple targets are affected.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentDelete} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentDelete) + com.google.firestore.v1.DocumentDeleteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentDelete_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentDelete_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentDelete.class, + com.google.firestore.v1.DocumentDelete.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentDelete.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + document_ = ""; + removedTargetIds_ = emptyIntList(); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentDelete_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentDelete getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentDelete build() { + com.google.firestore.v1.DocumentDelete result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentDelete buildPartial() { + com.google.firestore.v1.DocumentDelete result = + new com.google.firestore.v1.DocumentDelete(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DocumentDelete result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.document_ = document_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + removedTargetIds_.makeImmutable(); + result.removedTargetIds_ = removedTargetIds_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentDelete) { + return mergeFrom((com.google.firestore.v1.DocumentDelete) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentDelete other) { + if (other == com.google.firestore.v1.DocumentDelete.getDefaultInstance()) return this; + if (!other.getDocument().isEmpty()) { + document_ = other.document_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.removedTargetIds_.isEmpty()) { + if (removedTargetIds_.isEmpty()) { + removedTargetIds_ = other.removedTargetIds_; + removedTargetIds_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addAll(other.removedTargetIds_); + } + onChanged(); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + document_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 34: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 34 + case 48: + { + int v = input.readInt32(); + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(v); + break; + } // case 48 + case 50: + { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureRemovedTargetIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + removedTargetIds_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object document_ = ""; + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that was
+     * deleted.
+     * 
+ * + * string document = 1; + * + * @return The document. + */ + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that was
+     * deleted.
+     * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that was
+     * deleted.
+     * 
+ * + * string document = 1; + * + * @param value The document to set. + * @return This builder for chaining. + */ + public Builder setDocument(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that was
+     * deleted.
+     * 
+ * + * string document = 1; + * + * @return This builder for chaining. + */ + public Builder clearDocument() { + document_ = getDefaultInstance().getDocument(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that was
+     * deleted.
+     * 
+ * + * string document = 1; + * + * @param value The bytes for document to set. + * @return This builder for chaining. + */ + public Builder setDocumentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + private void ensureRemovedTargetIdsIsMutable() { + if (!removedTargetIds_.isModifiable()) { + removedTargetIds_ = makeMutableCopy(removedTargetIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + public java.util.List getRemovedTargetIdsList() { + removedTargetIds_.makeImmutable(); + return removedTargetIds_; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index to set the value at. + * @param value The removedTargetIds to set. + * @return This builder for chaining. + */ + public Builder setRemovedTargetIds(int index, int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param value The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addRemovedTargetIds(int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param values The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addAllRemovedTargetIds(java.lang.Iterable values) { + ensureRemovedTargetIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, removedTargetIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this entity.
+     * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return This builder for chaining. + */ + public Builder clearRemovedTargetIds() { + removedTargetIds_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The read timestamp at which the delete was observed.
+     *
+     * Greater or equal to the `commit_time` of the delete.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentDelete) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentDelete) + private static final com.google.firestore.v1.DocumentDelete DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentDelete(); + } + + public static com.google.firestore.v1.DocumentDelete getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentDelete parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentDelete getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDeleteOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDeleteOrBuilder.java new file mode 100644 index 000000000000..3fe5ddbf951a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentDeleteOrBuilder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentDeleteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentDelete) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that was
+   * deleted.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + java.lang.String getDocument(); + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that was
+   * deleted.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + com.google.protobuf.ByteString getDocumentBytes(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return A list containing the removedTargetIds. + */ + java.util.List getRemovedTargetIdsList(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @return The count of removedTargetIds. + */ + int getRemovedTargetIdsCount(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this entity.
+   * 
+ * + * repeated int32 removed_target_ids = 6; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + int getRemovedTargetIds(int index); + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The read timestamp at which the delete was observed.
+   *
+   * Greater or equal to the `commit_time` of the delete.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMask.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMask.java new file mode 100644 index 000000000000..391c861c1779 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMask.java @@ -0,0 +1,729 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A set of field paths on a document.
+ * Used to restrict a get or update operation on a document to a subset of its
+ * fields.
+ * This is different from standard field masks, as this is always scoped to a
+ * [Document][google.firestore.v1.Document], and takes in account the dynamic
+ * nature of [Value][google.firestore.v1.Value].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentMask} + */ +@com.google.protobuf.Generated +public final class DocumentMask extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentMask) + DocumentMaskOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentMask"); + } + + // Use DocumentMask.newBuilder() to construct. + private DocumentMask(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentMask() { + fieldPaths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_DocumentMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_DocumentMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentMask.class, + com.google.firestore.v1.DocumentMask.Builder.class); + } + + public static final int FIELD_PATHS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList fieldPaths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @return A list containing the fieldPaths. + */ + public com.google.protobuf.ProtocolStringList getFieldPathsList() { + return fieldPaths_; + } + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @return The count of fieldPaths. + */ + public int getFieldPathsCount() { + return fieldPaths_.size(); + } + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the element to return. + * @return The fieldPaths at the given index. + */ + public java.lang.String getFieldPaths(int index) { + return fieldPaths_.get(index); + } + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the fieldPaths at the given index. + */ + public com.google.protobuf.ByteString getFieldPathsBytes(int index) { + return fieldPaths_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < fieldPaths_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, fieldPaths_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < fieldPaths_.size(); i++) { + dataSize += computeStringSizeNoTag(fieldPaths_.getRaw(i)); + } + size += dataSize; + size += 1 * getFieldPathsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentMask)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentMask other = (com.google.firestore.v1.DocumentMask) obj; + + if (!getFieldPathsList().equals(other.getFieldPathsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getFieldPathsCount() > 0) { + hash = (37 * hash) + FIELD_PATHS_FIELD_NUMBER; + hash = (53 * hash) + getFieldPathsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentMask parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentMask parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentMask parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentMask parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentMask parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentMask parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentMask parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DocumentMask prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A set of field paths on a document.
+   * Used to restrict a get or update operation on a document to a subset of its
+   * fields.
+   * This is different from standard field masks, as this is always scoped to a
+   * [Document][google.firestore.v1.Document], and takes in account the dynamic
+   * nature of [Value][google.firestore.v1.Value].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentMask} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentMask) + com.google.firestore.v1.DocumentMaskOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_DocumentMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_DocumentMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentMask.class, + com.google.firestore.v1.DocumentMask.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentMask.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + fieldPaths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_DocumentMask_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentMask getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentMask.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentMask build() { + com.google.firestore.v1.DocumentMask result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentMask buildPartial() { + com.google.firestore.v1.DocumentMask result = new com.google.firestore.v1.DocumentMask(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DocumentMask result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + fieldPaths_.makeImmutable(); + result.fieldPaths_ = fieldPaths_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentMask) { + return mergeFrom((com.google.firestore.v1.DocumentMask) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentMask other) { + if (other == com.google.firestore.v1.DocumentMask.getDefaultInstance()) return this; + if (!other.fieldPaths_.isEmpty()) { + if (fieldPaths_.isEmpty()) { + fieldPaths_ = other.fieldPaths_; + bitField0_ |= 0x00000001; + } else { + ensureFieldPathsIsMutable(); + fieldPaths_.addAll(other.fieldPaths_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureFieldPathsIsMutable(); + fieldPaths_.add(s); + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.LazyStringArrayList fieldPaths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureFieldPathsIsMutable() { + if (!fieldPaths_.isModifiable()) { + fieldPaths_ = new com.google.protobuf.LazyStringArrayList(fieldPaths_); + } + bitField0_ |= 0x00000001; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @return A list containing the fieldPaths. + */ + public com.google.protobuf.ProtocolStringList getFieldPathsList() { + fieldPaths_.makeImmutable(); + return fieldPaths_; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @return The count of fieldPaths. + */ + public int getFieldPathsCount() { + return fieldPaths_.size(); + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the element to return. + * @return The fieldPaths at the given index. + */ + public java.lang.String getFieldPaths(int index) { + return fieldPaths_.get(index); + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the fieldPaths at the given index. + */ + public com.google.protobuf.ByteString getFieldPathsBytes(int index) { + return fieldPaths_.getByteString(index); + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param index The index to set the value at. + * @param value The fieldPaths to set. + * @return This builder for chaining. + */ + public Builder setFieldPaths(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldPathsIsMutable(); + fieldPaths_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param value The fieldPaths to add. + * @return This builder for chaining. + */ + public Builder addFieldPaths(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldPathsIsMutable(); + fieldPaths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param values The fieldPaths to add. + * @return This builder for chaining. + */ + public Builder addAllFieldPaths(java.lang.Iterable values) { + ensureFieldPathsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, fieldPaths_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @return This builder for chaining. + */ + public Builder clearFieldPaths() { + fieldPaths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The list of field paths in the mask. See
+     * [Document.fields][google.firestore.v1.Document.fields] for a field path
+     * syntax reference.
+     * 
+ * + * repeated string field_paths = 1; + * + * @param value The bytes of the fieldPaths to add. + * @return This builder for chaining. + */ + public Builder addFieldPathsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureFieldPathsIsMutable(); + fieldPaths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentMask) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentMask) + private static final com.google.firestore.v1.DocumentMask DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentMask(); + } + + public static com.google.firestore.v1.DocumentMask getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentMask parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentMask getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMaskOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMaskOrBuilder.java new file mode 100644 index 000000000000..a48c53617048 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentMaskOrBuilder.java @@ -0,0 +1,90 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentMaskOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentMask) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @return A list containing the fieldPaths. + */ + java.util.List getFieldPathsList(); + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @return The count of fieldPaths. + */ + int getFieldPathsCount(); + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the element to return. + * @return The fieldPaths at the given index. + */ + java.lang.String getFieldPaths(int index); + + /** + * + * + *
+   * The list of field paths in the mask. See
+   * [Document.fields][google.firestore.v1.Document.fields] for a field path
+   * syntax reference.
+   * 
+ * + * repeated string field_paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the fieldPaths at the given index. + */ + com.google.protobuf.ByteString getFieldPathsBytes(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentOrBuilder.java new file mode 100644 index 000000000000..3eb22eb241b1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentOrBuilder.java @@ -0,0 +1,332 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Document) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The resource name of the document, for example
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * The resource name of the document, for example
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + int getFieldsCount(); + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + boolean containsFields(java.lang.String key); + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getFields(); + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + java.util.Map getFieldsMap(); + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + /* nullable */ + com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+   * The document's fields.
+   *
+   * The map keys represent field names.
+   *
+   * Field names matching the regular expression `__.*__` are reserved. Reserved
+   * field names are forbidden except in certain documented contexts. The field
+   * names, represented as UTF-8, must not exceed 1,500 bytes and cannot be
+   * empty.
+   *
+   * Field paths may be used in other contexts to refer to structured fields
+   * defined here. For `map_value`, the field path is represented by a
+   * dot-delimited (`.`) string of segments. Each segment is either a simple
+   * field name (defined below) or a quoted field name. For example, the
+   * structured field `"foo" : { map_value: { "x&y" : { string_value: "hello"
+   * }}}` would be represented by the field path `` foo.`x&y` ``.
+   *
+   * A simple field name contains only characters `a` to `z`, `A` to `Z`,
+   * `0` to `9`, or `_`, and must not start with `0` to `9`. For example,
+   * `foo_bar_17`.
+   *
+   * A quoted field name starts and ends with `` ` `` and
+   * may contain any character. Some characters, including `` ` ``, must be
+   * escaped using a `\`. For example, `` `x&y` `` represents `x&y` and
+   * `` `bak\`tik` `` represents `` bak`tik ``.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 2; + */ + com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key); + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * Output only. The time at which the document was created.
+   *
+   * This value increases monotonically when a document is deleted then
+   * recreated. It can also be compared to values from other documents and
+   * the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * Output only. The time at which the document was last changed.
+   *
+   * This value is initially set to the `create_time` then increases
+   * monotonically with each change to the document. It can also be
+   * compared to values from other documents and the `read_time` of a query.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentPathName.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentPathName.java new file mode 100644 index 000000000000..820219fe6478 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentPathName.java @@ -0,0 +1,215 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") +public class DocumentPathName implements ResourceName { + + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/databases/{database}/documents/{document_path=**}"); + + private volatile Map fieldValuesMap; + + private final String project; + private final String database; + private final String documentPath; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getDocumentPath() { + return documentPath; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private DocumentPathName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + documentPath = Preconditions.checkNotNull(builder.getDocumentPath()); + } + + public static DocumentPathName of(String project, String database, String documentPath) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setDocumentPath(documentPath) + .build(); + } + + public static String format(String project, String database, String documentPath) { + return newBuilder() + .setProject(project) + .setDatabase(database) + .setDocumentPath(documentPath) + .build() + .toString(); + } + + public static DocumentPathName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, "DocumentPathName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database"), matchMap.get("document_path")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList(values.size()); + for (DocumentPathName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + 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("documentPath", documentPath); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate( + "project", project, "database", database, "document_path", documentPath); + } + + /** Builder for DocumentPathName. */ + public static class Builder { + + private String project; + private String database; + private String documentPath; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public String getDocumentPath() { + return documentPath; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setDocumentPath(String documentPath) { + this.documentPath = documentPath; + return this; + } + + private Builder() {} + + private Builder(DocumentPathName documentPathName) { + project = documentPathName.project; + database = documentPathName.database; + documentPath = documentPathName.documentPath; + } + + public DocumentPathName build() { + return new DocumentPathName(this); + } + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof DocumentPathName) { + DocumentPathName that = (DocumentPathName) o; + return (this.project.equals(that.project)) + && (this.database.equals(that.database)) + && (this.documentPath.equals(that.documentPath)); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= project.hashCode(); + h *= 1000003; + h ^= database.hashCode(); + h *= 1000003; + h ^= documentPath.hashCode(); + return h; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java new file mode 100644 index 000000000000..37faefdca4d1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentProto.java @@ -0,0 +1,277 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class DocumentProto extends com.google.protobuf.GeneratedFile { + private DocumentProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Document_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Document_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Document_FieldsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Document_FieldsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Value_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Value_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ArrayValue_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ArrayValue_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_MapValue_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_MapValue_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_MapValue_FieldsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_MapValue_FieldsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Function_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Function_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Function_OptionsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "\"google/firestore/v1/document.proto\022\023go" + + "ogle.firestore.v1\032\037google/api/field_beha" + + "vior.proto\032\034google/protobuf/struct.proto" + + "\032\037google/protobuf/timestamp.proto\032\030google/type/latlng.proto\"\200\002\n" + + "\010Document\022\014\n" + + "\004name\030\001 \001(\t\0229\n" + + "\006fields\030\002 \003(\0132).google.firestore.v1.Document.FieldsEntry\022/\n" + + "\013create_time\030\003 \001(\0132\032.google.protobuf.Timestamp\022/\n" + + "\013update_time\030\004 \001(\0132\032.google.protobuf.Timestamp\032I\n" + + "\013FieldsEntry\022\013\n" + + "\003key\030\001 \001(\t\022)\n" + + "\005value\030\002 \001(\0132\032.google.firestore.v1.Value:\0028\001\"\345\004\n" + + "\005Value\0220\n\n" + + "null_value\030\013 \001(\0162\032.google.protobuf.NullValueH\000\022\027\n\r" + + "boolean_value\030\001 \001(\010H\000\022\027\n\r" + + "integer_value\030\002 \001(\003H\000\022\026\n" + + "\014double_value\030\003 \001(\001H\000\0225\n" + + "\017timestamp_value\030\n" + + " \001(\0132\032.google.protobuf.TimestampH\000\022\026\n" + + "\014string_value\030\021 \001(\tH\000\022\025\n" + + "\013bytes_value\030\022 \001(\014H\000\022\031\n" + + "\017reference_value\030\005 \001(\tH\000\022.\n" + + "\017geo_point_value\030\010 \001(\0132\023.google.type.LatLngH\000\0226\n" + + "\013array_value\030\t \001(\0132\037.google.firestore.v1.ArrayValueH\000\0222\n" + + "\tmap_value\030\006 \001(\0132\035.google.firestore.v1.MapValueH\000\022\037\n" + + "\025field_reference_value\030\023 \001(\tH\000\022\"\n" + + "\030variable_reference_value\030\026 \001(\tH\000\0227\n" + + "\016function_value\030\024 \001(\0132\035.google.firestore.v1.FunctionH\000\0227\n" + + "\016pipeline_value\030\025 \001(\0132\035.google.firestore.v1.PipelineH\000B\014\n\n" + + "value_type\"8\n\n" + + "ArrayValue\022*\n" + + "\006values\030\001 \003(\0132\032.google.firestore.v1.Value\"\220\001\n" + + "\010MapValue\0229\n" + + "\006fields\030\001 \003(\0132).google.firestore.v1.MapValue.FieldsEntry\032I\n" + + "\013FieldsEntry\022\013\n" + + "\003key\030\001 \001(\t\022)\n" + + "\005value\030\002 \001(\0132\032.google.firestore.v1.Value:\0028\001\"\332\001\n" + + "\010Function\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022-\n" + + "\004args\030\002 \003(\0132\032.google.firestore.v1.ValueB\003\340A\001\022@\n" + + "\007options\030\003 \003(\0132*.go" + + "ogle.firestore.v1.Function.OptionsEntryB\003\340A\001\032J\n" + + "\014OptionsEntry\022\013\n" + + "\003key\030\001 \001(\t\022)\n" + + "\005value\030\002 \001(\0132\032.google.firestore.v1.Value:\0028\001\"\244\002\n" + + "\010Pipeline\0228\n" + + "\006stages\030\001" + + " \003(\0132#.google.firestore.v1.Pipeline.StageB\003\340A\002\032\335\001\n" + + "\005Stage\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022-\n" + + "\004args\030\002 \003(\0132\032.google.firestore.v1.ValueB\003\340A\001\022F\n" + + "\007options\030\003" + + " \003(\01320.google.firestore.v1.Pipeline.Stage.OptionsEntryB\003\340A\001\032J\n" + + "\014OptionsEntry\022\013\n" + + "\003key\030\001 \001(\t\022)\n" + + "\005value\030\002 \001(\0132\032.google.firestore.v1.Value:\0028\001B\305\001\n" + + "\027com.google.firestore.v1B\r" + + "DocumentProtoP\001Z;cloud.google.com/go/firestore/apiv1/firestorepb;firestorep" + + "b\242\002\004GCFS\252\002\031Google.Cloud.Firestore.V1\312\002\031G" + + "oogle\\Cloud\\Firestore\\V1\352\002\034Google::Cloud::Firestore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.protobuf.StructProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.type.LatLngProto.getDescriptor(), + }); + internal_static_google_firestore_v1_Document_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_Document_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Document_descriptor, + new java.lang.String[] { + "Name", "Fields", "CreateTime", "UpdateTime", + }); + internal_static_google_firestore_v1_Document_FieldsEntry_descriptor = + internal_static_google_firestore_v1_Document_descriptor.getNestedType(0); + internal_static_google_firestore_v1_Document_FieldsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Document_FieldsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_firestore_v1_Value_descriptor = getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_Value_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Value_descriptor, + new java.lang.String[] { + "NullValue", + "BooleanValue", + "IntegerValue", + "DoubleValue", + "TimestampValue", + "StringValue", + "BytesValue", + "ReferenceValue", + "GeoPointValue", + "ArrayValue", + "MapValue", + "FieldReferenceValue", + "VariableReferenceValue", + "FunctionValue", + "PipelineValue", + "ValueType", + }); + internal_static_google_firestore_v1_ArrayValue_descriptor = getDescriptor().getMessageType(2); + internal_static_google_firestore_v1_ArrayValue_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ArrayValue_descriptor, + new java.lang.String[] { + "Values", + }); + internal_static_google_firestore_v1_MapValue_descriptor = getDescriptor().getMessageType(3); + internal_static_google_firestore_v1_MapValue_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_MapValue_descriptor, + new java.lang.String[] { + "Fields", + }); + internal_static_google_firestore_v1_MapValue_FieldsEntry_descriptor = + internal_static_google_firestore_v1_MapValue_descriptor.getNestedType(0); + internal_static_google_firestore_v1_MapValue_FieldsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_MapValue_FieldsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_firestore_v1_Function_descriptor = getDescriptor().getMessageType(4); + internal_static_google_firestore_v1_Function_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Function_descriptor, + new java.lang.String[] { + "Name", "Args", "Options", + }); + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor = + internal_static_google_firestore_v1_Function_descriptor.getNestedType(0); + internal_static_google_firestore_v1_Function_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Function_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_firestore_v1_Pipeline_descriptor = getDescriptor().getMessageType(5); + internal_static_google_firestore_v1_Pipeline_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_descriptor, + new java.lang.String[] { + "Stages", + }); + internal_static_google_firestore_v1_Pipeline_Stage_descriptor = + internal_static_google_firestore_v1_Pipeline_descriptor.getNestedType(0); + internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_Stage_descriptor, + new java.lang.String[] { + "Name", "Args", "Options", + }); + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor = + internal_static_google_firestore_v1_Pipeline_Stage_descriptor.getNestedType(0); + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.protobuf.StructProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.type.LatLngProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemove.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemove.java new file mode 100644 index 000000000000..1c41461e7f33 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemove.java @@ -0,0 +1,1180 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A [Document][google.firestore.v1.Document] has been removed from the view of
+ * the targets.
+ *
+ * Sent if the document is no longer relevant to a target and is out of view.
+ * Can be sent instead of a DocumentDelete or a DocumentChange if the server
+ * can not send the new value of the document.
+ *
+ * Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be
+ * returned for the same logical write or delete, if multiple targets are
+ * affected.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentRemove} + */ +@com.google.protobuf.Generated +public final class DocumentRemove extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentRemove) + DocumentRemoveOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentRemove"); + } + + // Use DocumentRemove.newBuilder() to construct. + private DocumentRemove(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentRemove() { + document_ = ""; + removedTargetIds_ = emptyIntList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentRemove_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentRemove_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentRemove.class, + com.google.firestore.v1.DocumentRemove.Builder.class); + } + + private int bitField0_; + public static final int DOCUMENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object document_ = ""; + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that has
+   * gone out of view.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + @java.lang.Override + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that has
+   * gone out of view.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int REMOVED_TARGET_IDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return A list containing the removedTargetIds. + */ + @java.lang.Override + public java.util.List getRemovedTargetIdsList() { + return removedTargetIds_; + } + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + private int removedTargetIdsMemoizedSerializedSize = -1; + + public static final int READ_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, document_); + } + if (getRemovedTargetIdsList().size() > 0) { + output.writeUInt32NoTag(18); + output.writeUInt32NoTag(removedTargetIdsMemoizedSerializedSize); + } + for (int i = 0; i < removedTargetIds_.size(); i++) { + output.writeInt32NoTag(removedTargetIds_.getInt(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, document_); + } + { + int dataSize = 0; + for (int i = 0; i < removedTargetIds_.size(); i++) { + dataSize += + com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag( + removedTargetIds_.getInt(i)); + } + size += dataSize; + if (!getRemovedTargetIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + removedTargetIdsMemoizedSerializedSize = dataSize; + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getReadTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentRemove)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentRemove other = (com.google.firestore.v1.DocumentRemove) obj; + + if (!getDocument().equals(other.getDocument())) return false; + if (!getRemovedTargetIdsList().equals(other.getRemovedTargetIdsList())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + if (getRemovedTargetIdsCount() > 0) { + hash = (37 * hash) + REMOVED_TARGET_IDS_FIELD_NUMBER; + hash = (53 * hash) + getRemovedTargetIdsList().hashCode(); + } + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentRemove parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentRemove parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentRemove parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentRemove parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DocumentRemove prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from the view of
+   * the targets.
+   *
+   * Sent if the document is no longer relevant to a target and is out of view.
+   * Can be sent instead of a DocumentDelete or a DocumentChange if the server
+   * can not send the new value of the document.
+   *
+   * Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be
+   * returned for the same logical write or delete, if multiple targets are
+   * affected.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentRemove} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentRemove) + com.google.firestore.v1.DocumentRemoveOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentRemove_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentRemove_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentRemove.class, + com.google.firestore.v1.DocumentRemove.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentRemove.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + document_ = ""; + removedTargetIds_ = emptyIntList(); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentRemove_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentRemove getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentRemove build() { + com.google.firestore.v1.DocumentRemove result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentRemove buildPartial() { + com.google.firestore.v1.DocumentRemove result = + new com.google.firestore.v1.DocumentRemove(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DocumentRemove result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.document_ = document_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + removedTargetIds_.makeImmutable(); + result.removedTargetIds_ = removedTargetIds_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentRemove) { + return mergeFrom((com.google.firestore.v1.DocumentRemove) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentRemove other) { + if (other == com.google.firestore.v1.DocumentRemove.getDefaultInstance()) return this; + if (!other.getDocument().isEmpty()) { + document_ = other.document_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.removedTargetIds_.isEmpty()) { + if (removedTargetIds_.isEmpty()) { + removedTargetIds_ = other.removedTargetIds_; + removedTargetIds_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addAll(other.removedTargetIds_); + } + onChanged(); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + document_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + int v = input.readInt32(); + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(v); + break; + } // case 16 + case 18: + { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureRemovedTargetIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + removedTargetIds_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 18 + case 34: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object document_ = ""; + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that has
+     * gone out of view.
+     * 
+ * + * string document = 1; + * + * @return The document. + */ + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that has
+     * gone out of view.
+     * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that has
+     * gone out of view.
+     * 
+ * + * string document = 1; + * + * @param value The document to set. + * @return This builder for chaining. + */ + public Builder setDocument(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that has
+     * gone out of view.
+     * 
+ * + * string document = 1; + * + * @return This builder for chaining. + */ + public Builder clearDocument() { + document_ = getDefaultInstance().getDocument(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource name of the [Document][google.firestore.v1.Document] that has
+     * gone out of view.
+     * 
+ * + * string document = 1; + * + * @param value The bytes for document to set. + * @return This builder for chaining. + */ + public Builder setDocumentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.Internal.IntList removedTargetIds_ = emptyIntList(); + + private void ensureRemovedTargetIdsIsMutable() { + if (!removedTargetIds_.isModifiable()) { + removedTargetIds_ = makeMutableCopy(removedTargetIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return A list containing the removedTargetIds. + */ + public java.util.List getRemovedTargetIdsList() { + removedTargetIds_.makeImmutable(); + return removedTargetIds_; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return The count of removedTargetIds. + */ + public int getRemovedTargetIdsCount() { + return removedTargetIds_.size(); + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + public int getRemovedTargetIds(int index) { + return removedTargetIds_.getInt(index); + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param index The index to set the value at. + * @param value The removedTargetIds to set. + * @return This builder for chaining. + */ + public Builder setRemovedTargetIds(int index, int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param value The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addRemovedTargetIds(int value) { + + ensureRemovedTargetIdsIsMutable(); + removedTargetIds_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param values The removedTargetIds to add. + * @return This builder for chaining. + */ + public Builder addAllRemovedTargetIds(java.lang.Iterable values) { + ensureRemovedTargetIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, removedTargetIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A set of target IDs for targets that previously matched this document.
+     * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return This builder for chaining. + */ + public Builder clearRemovedTargetIds() { + removedTargetIds_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The read timestamp at which the remove was observed.
+     *
+     * Greater or equal to the `commit_time` of the change/delete/remove.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentRemove) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentRemove) + private static final com.google.firestore.v1.DocumentRemove DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentRemove(); + } + + public static com.google.firestore.v1.DocumentRemove getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentRemove parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentRemove getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemoveOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemoveOrBuilder.java new file mode 100644 index 000000000000..28f8573158f1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRemoveOrBuilder.java @@ -0,0 +1,139 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentRemoveOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentRemove) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that has
+   * gone out of view.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + java.lang.String getDocument(); + + /** + * + * + *
+   * The resource name of the [Document][google.firestore.v1.Document] that has
+   * gone out of view.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + com.google.protobuf.ByteString getDocumentBytes(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return A list containing the removedTargetIds. + */ + java.util.List getRemovedTargetIdsList(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @return The count of removedTargetIds. + */ + int getRemovedTargetIdsCount(); + + /** + * + * + *
+   * A set of target IDs for targets that previously matched this document.
+   * 
+ * + * repeated int32 removed_target_ids = 2; + * + * @param index The index of the element to return. + * @return The removedTargetIds at the given index. + */ + int getRemovedTargetIds(int index); + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The read timestamp at which the remove was observed.
+   *
+   * Greater or equal to the `commit_time` of the change/delete/remove.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRootName.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRootName.java new file mode 100644 index 000000000000..93b37f116553 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentRootName.java @@ -0,0 +1,182 @@ +/* + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.firestore.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** AUTO-GENERATED DOCUMENTATION AND CLASS */ +@javax.annotation.Generated("by GAPIC protoc plugin") +public class DocumentRootName implements ResourceName { + + private static final PathTemplate PATH_TEMPLATE = + PathTemplate.createWithoutUrlEncoding("projects/{project}/databases/{database}/documents"); + + private volatile Map fieldValuesMap; + + private final String project; + private final String database; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + private DocumentRootName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + database = Preconditions.checkNotNull(builder.getDatabase()); + } + + public static DocumentRootName of(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build(); + } + + public static String format(String project, String database) { + return newBuilder().setProject(project).setDatabase(database).build().toString(); + } + + public static DocumentRootName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PATH_TEMPLATE.validatedMatch( + formattedString, "DocumentRootName.parse: formattedString not in valid format"); + return of(matchMap.get("project"), matchMap.get("database")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList(values.size()); + for (DocumentRootName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PATH_TEMPLATE.matches(formattedString); + } + + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + fieldMapBuilder.put("project", project); + fieldMapBuilder.put("database", database); + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PATH_TEMPLATE.instantiate("project", project, "database", database); + } + + /** Builder for DocumentRootName. */ + public static class Builder { + + private String project; + private String database; + + public String getProject() { + return project; + } + + public String getDatabase() { + return database; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + private Builder() {} + + private Builder(DocumentRootName documentRootName) { + project = documentRootName.project; + database = documentRootName.database; + } + + public DocumentRootName build() { + return new DocumentRootName(this); + } + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o instanceof DocumentRootName) { + DocumentRootName that = (DocumentRootName) 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/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java new file mode 100644 index 000000000000..74de0f1a8ea4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransform.java @@ -0,0 +1,4828 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A transformation of a document.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentTransform} + */ +@com.google.protobuf.Generated +public final class DocumentTransform extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentTransform) + DocumentTransformOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentTransform"); + } + + // Use DocumentTransform.newBuilder() to construct. + private DocumentTransform(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentTransform() { + document_ = ""; + fieldTransforms_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentTransform.class, + com.google.firestore.v1.DocumentTransform.Builder.class); + } + + public interface FieldTransformOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentTransform.FieldTransform) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The path of the field. See
+     * [Document.fields][google.firestore.v1.Document.fields] for the field path
+     * syntax reference.
+     * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + java.lang.String getFieldPath(); + + /** + * + * + *
+     * The path of the field. See
+     * [Document.fields][google.firestore.v1.Document.fields] for the field path
+     * syntax reference.
+     * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + 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(); + + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The enum numeric value on the wire for setToServerValue. + */ + int getSetToServerValueValue(); + + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The setToServerValue. + */ + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue getSetToServerValue(); + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + boolean hasIncrement(); + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return The increment. + */ + com.google.firestore.v1.Value getIncrement(); + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + com.google.firestore.v1.ValueOrBuilder getIncrementOrBuilder(); + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + boolean hasMaximum(); + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return The maximum. + */ + com.google.firestore.v1.Value getMaximum(); + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + com.google.firestore.v1.ValueOrBuilder getMaximumOrBuilder(); + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + boolean hasMinimum(); + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return The minimum. + */ + com.google.firestore.v1.Value getMinimum(); + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + com.google.firestore.v1.ValueOrBuilder getMinimumOrBuilder(); + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + boolean hasAppendMissingElements(); + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + com.google.firestore.v1.ArrayValue getAppendMissingElements(); + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + com.google.firestore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder(); + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + boolean hasRemoveAllFromArray(); + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + com.google.firestore.v1.ArrayValue getRemoveAllFromArray(); + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + com.google.firestore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder(); + + com.google.firestore.v1.DocumentTransform.FieldTransform.TransformTypeCase + getTransformTypeCase(); + } + + /** + * + * + *
+   * A transformation of a field of the document.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentTransform.FieldTransform} + */ + public static final class FieldTransform extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.DocumentTransform.FieldTransform) + FieldTransformOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FieldTransform"); + } + + // Use FieldTransform.newBuilder() to construct. + private FieldTransform(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FieldTransform() { + fieldPath_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_FieldTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentTransform.FieldTransform.class, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder.class); + } + + /** + * + * + *
+     * A value that is calculated by the server.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.DocumentTransform.FieldTransform.ServerValue} + */ + public enum ServerValue implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * SERVER_VALUE_UNSPECIFIED = 0; + */ + SERVER_VALUE_UNSPECIFIED(0), + /** + * + * + *
+       * The time at which the server processed the request, with millisecond
+       * 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; + */ + REQUEST_TIME(1), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ServerValue"); + } + + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * SERVER_VALUE_UNSPECIFIED = 0; + */ + public static final int SERVER_VALUE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The time at which the server processed the request, with millisecond
+       * 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; + */ + public static final int REQUEST_TIME_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ServerValue valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static ServerValue forNumber(int value) { + switch (value) { + case 0: + return SERVER_VALUE_UNSPECIFIED; + case 1: + return REQUEST_TIME; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public ServerValue findValueByNumber(int number) { + return ServerValue.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.DocumentTransform.FieldTransform.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final ServerValue[] VALUES = values(); + + public static ServerValue valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private ServerValue(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.DocumentTransform.FieldTransform.ServerValue) + } + + private int transformTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object transformType_; + + public enum TransformTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + SET_TO_SERVER_VALUE(2), + INCREMENT(3), + MAXIMUM(4), + MINIMUM(5), + APPEND_MISSING_ELEMENTS(6), + REMOVE_ALL_FROM_ARRAY(7), + TRANSFORMTYPE_NOT_SET(0); + private final int value; + + private TransformTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TransformTypeCase valueOf(int value) { + return forNumber(value); + } + + public static TransformTypeCase forNumber(int value) { + switch (value) { + case 2: + return SET_TO_SERVER_VALUE; + case 3: + return INCREMENT; + case 4: + return MAXIMUM; + case 5: + return MINIMUM; + case 6: + return APPEND_MISSING_ELEMENTS; + case 7: + return REMOVE_ALL_FROM_ARRAY; + case 0: + return TRANSFORMTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TransformTypeCase getTransformTypeCase() { + return TransformTypeCase.forNumber(transformTypeCase_); + } + + public static final int FIELD_PATH_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+     * The path of the field. See
+     * [Document.fields][google.firestore.v1.Document.fields] for the field path
+     * syntax reference.
+     * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + @java.lang.Override + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } + } + + /** + * + * + *
+     * The path of the field. See
+     * [Document.fields][google.firestore.v1.Document.fields] for the field path
+     * syntax reference.
+     * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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; + } + + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The enum numeric value on the wire for setToServerValue. + */ + public int getSetToServerValueValue() { + if (transformTypeCase_ == 2) { + return (java.lang.Integer) transformType_; + } + return 0; + } + + /** + * + * + *
+     * Sets the field to the given server value.
+     * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The setToServerValue. + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue + getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue result = + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue + .SERVER_VALUE_UNSPECIFIED; + } + + public static final int INCREMENT_FIELD_NUMBER = 3; + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + @java.lang.Override + public boolean hasIncrement() { + return transformTypeCase_ == 3; + } + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.firestore.v1.Value getIncrement() { + if (transformTypeCase_ == 3) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+     * Adds the given value to the field's current value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If either of the given value or the current field value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follow IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the field is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getIncrementOrBuilder() { + if (transformTypeCase_ == 3) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + public static final int MAXIMUM_FIELD_NUMBER = 4; + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.firestore.v1.Value getMaximum() { + if (transformTypeCase_ == 4) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+     * Sets the field to the maximum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the given value.
+     * If a maximum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+     * zero input value is always the stored value.
+     * The maximum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getMaximumOrBuilder() { + if (transformTypeCase_ == 4) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + public static final int MINIMUM_FIELD_NUMBER = 5; + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.firestore.v1.Value getMinimum() { + if (transformTypeCase_ == 5) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+     * Sets the field to the minimum of its current value and the given value.
+     *
+     * This must be an integer or a double value.
+     * If the field is not an integer or double, or if the field does not yet
+     * exist, the transformation will set the field to the input value.
+     * If a minimum operation is applied where the field and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the field takes on the type of the smaller operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the field does not change.
+     * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+     * zero input value is always the stored value.
+     * The minimum of any numeric value x and NaN is NaN.
+     * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getMinimumOrBuilder() { + if (transformTypeCase_ == 5) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + public static final int APPEND_MISSING_ELEMENTS_FIELD_NUMBER = 6; + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getAppendMissingElements() { + if (transformTypeCase_ == 6) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+     * Append the given elements in order if they are not already present in
+     * the current field value.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * first set to the empty array.
+     *
+     * Equivalent numbers of different types (e.g. 3L and 3.0) are
+     * considered equal when checking if a value is missing.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if (transformTypeCase_ == 6) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + public static final int REMOVE_ALL_FROM_ARRAY_FIELD_NUMBER = 7; + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getRemoveAllFromArray() { + if (transformTypeCase_ == 7) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+     * Remove all of the given elements from the array in the field.
+     * If the field is not an array, or if the field does not yet exist, it is
+     * set to the empty array.
+     *
+     * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+     * considered equal when deciding whether an element should be removed.
+     * NaN is equal to NaN, and Null is equal to Null.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform_result will be the null value.
+     * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if (transformTypeCase_ == 7) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, fieldPath_); + } + if (transformTypeCase_ == 2) { + output.writeEnum(2, ((java.lang.Integer) transformType_)); + } + if (transformTypeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + output.writeMessage(4, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + output.writeMessage(5, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + output.writeMessage(7, (com.google.firestore.v1.ArrayValue) transformType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, fieldPath_); + } + if (transformTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 2, ((java.lang.Integer) transformType_)); + } + if (transformTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.firestore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.firestore.v1.ArrayValue) transformType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentTransform.FieldTransform)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentTransform.FieldTransform other = + (com.google.firestore.v1.DocumentTransform.FieldTransform) obj; + + if (!getFieldPath().equals(other.getFieldPath())) return false; + if (!getTransformTypeCase().equals(other.getTransformTypeCase())) return false; + switch (transformTypeCase_) { + case 2: + if (getSetToServerValueValue() != other.getSetToServerValueValue()) return false; + break; + case 3: + if (!getIncrement().equals(other.getIncrement())) return false; + break; + case 4: + if (!getMaximum().equals(other.getMaximum())) return false; + break; + case 5: + if (!getMinimum().equals(other.getMinimum())) return false; + break; + case 6: + if (!getAppendMissingElements().equals(other.getAppendMissingElements())) return false; + break; + case 7: + if (!getRemoveAllFromArray().equals(other.getRemoveAllFromArray())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FIELD_PATH_FIELD_NUMBER; + hash = (53 * hash) + getFieldPath().hashCode(); + switch (transformTypeCase_) { + case 2: + hash = (37 * hash) + SET_TO_SERVER_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getSetToServerValueValue(); + break; + case 3: + hash = (37 * hash) + INCREMENT_FIELD_NUMBER; + hash = (53 * hash) + getIncrement().hashCode(); + break; + case 4: + hash = (37 * hash) + MAXIMUM_FIELD_NUMBER; + hash = (53 * hash) + getMaximum().hashCode(); + break; + case 5: + hash = (37 * hash) + MINIMUM_FIELD_NUMBER; + hash = (53 * hash) + getMinimum().hashCode(); + break; + case 6: + hash = (37 * hash) + APPEND_MISSING_ELEMENTS_FIELD_NUMBER; + hash = (53 * hash) + getAppendMissingElements().hashCode(); + break; + case 7: + hash = (37 * hash) + REMOVE_ALL_FROM_ARRAY_FIELD_NUMBER; + hash = (53 * hash) + getRemoveAllFromArray().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.DocumentTransform.FieldTransform prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A transformation of a field of the document.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentTransform.FieldTransform} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentTransform.FieldTransform) + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_FieldTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentTransform.FieldTransform.class, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentTransform.FieldTransform.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + fieldPath_ = ""; + if (incrementBuilder_ != null) { + incrementBuilder_.clear(); + } + if (maximumBuilder_ != null) { + maximumBuilder_.clear(); + } + if (minimumBuilder_ != null) { + minimumBuilder_.clear(); + } + if (appendMissingElementsBuilder_ != null) { + appendMissingElementsBuilder_.clear(); + } + if (removeAllFromArrayBuilder_ != null) { + removeAllFromArrayBuilder_.clear(); + } + transformTypeCase_ = 0; + transformType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform build() { + com.google.firestore.v1.DocumentTransform.FieldTransform result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform buildPartial() { + com.google.firestore.v1.DocumentTransform.FieldTransform result = + new com.google.firestore.v1.DocumentTransform.FieldTransform(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.DocumentTransform.FieldTransform result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.fieldPath_ = fieldPath_; + } + } + + private void buildPartialOneofs( + com.google.firestore.v1.DocumentTransform.FieldTransform result) { + result.transformTypeCase_ = transformTypeCase_; + result.transformType_ = this.transformType_; + if (transformTypeCase_ == 3 && incrementBuilder_ != null) { + result.transformType_ = incrementBuilder_.build(); + } + if (transformTypeCase_ == 4 && maximumBuilder_ != null) { + result.transformType_ = maximumBuilder_.build(); + } + if (transformTypeCase_ == 5 && minimumBuilder_ != null) { + result.transformType_ = minimumBuilder_.build(); + } + if (transformTypeCase_ == 6 && appendMissingElementsBuilder_ != null) { + result.transformType_ = appendMissingElementsBuilder_.build(); + } + if (transformTypeCase_ == 7 && removeAllFromArrayBuilder_ != null) { + result.transformType_ = removeAllFromArrayBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentTransform.FieldTransform) { + return mergeFrom((com.google.firestore.v1.DocumentTransform.FieldTransform) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentTransform.FieldTransform other) { + if (other == com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance()) + return this; + if (!other.getFieldPath().isEmpty()) { + fieldPath_ = other.fieldPath_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getTransformTypeCase()) { + case SET_TO_SERVER_VALUE: + { + setSetToServerValueValue(other.getSetToServerValueValue()); + break; + } + case INCREMENT: + { + mergeIncrement(other.getIncrement()); + break; + } + case MAXIMUM: + { + mergeMaximum(other.getMaximum()); + break; + } + case MINIMUM: + { + mergeMinimum(other.getMinimum()); + break; + } + case APPEND_MISSING_ELEMENTS: + { + mergeAppendMissingElements(other.getAppendMissingElements()); + break; + } + case REMOVE_ALL_FROM_ARRAY: + { + mergeRemoveAllFromArray(other.getRemoveAllFromArray()); + break; + } + case TRANSFORMTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + fieldPath_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + int rawValue = input.readEnum(); + transformTypeCase_ = 2; + transformType_ = rawValue; + break; + } // case 16 + case 26: + { + input.readMessage( + internalGetIncrementFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetMaximumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetMinimumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetAppendMissingElementsFieldBuilder().getBuilder(), + extensionRegistry); + transformTypeCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetRemoveAllFromArrayFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 7; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int transformTypeCase_ = 0; + private java.lang.Object transformType_; + + public TransformTypeCase getTransformTypeCase() { + return TransformTypeCase.forNumber(transformTypeCase_); + } + + public Builder clearTransformType() { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+       * The path of the field. See
+       * [Document.fields][google.firestore.v1.Document.fields] for the field path
+       * syntax reference.
+       * 
+ * + * string field_path = 1; + * + * @return The fieldPath. + */ + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The path of the field. See
+       * [Document.fields][google.firestore.v1.Document.fields] for the field path
+       * syntax reference.
+       * 
+ * + * string field_path = 1; + * + * @return The bytes for fieldPath. + */ + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The path of the field. See
+       * [Document.fields][google.firestore.v1.Document.fields] for the field path
+       * syntax reference.
+       * 
+ * + * string field_path = 1; + * + * @param value The fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPath(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The path of the field. See
+       * [Document.fields][google.firestore.v1.Document.fields] for the field path
+       * syntax reference.
+       * 
+ * + * string field_path = 1; + * + * @return This builder for chaining. + */ + public Builder clearFieldPath() { + fieldPath_ = getDefaultInstance().getFieldPath(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * The path of the field. See
+       * [Document.fields][google.firestore.v1.Document.fields] for the field path
+       * syntax reference.
+       * 
+ * + * string field_path = 1; + * + * @param value The bytes for fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPathBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + 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; + } + + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The enum numeric value on the wire for setToServerValue. + */ + @java.lang.Override + public int getSetToServerValueValue() { + if (transformTypeCase_ == 2) { + return ((java.lang.Integer) transformType_).intValue(); + } + return 0; + } + + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @param value The enum numeric value on the wire for setToServerValue to set. + * @return This builder for chaining. + */ + public Builder setSetToServerValueValue(int value) { + transformTypeCase_ = 2; + transformType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return The setToServerValue. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue + getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue result = + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue + .SERVER_VALUE_UNSPECIFIED; + } + + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @param value The setToServerValue to set. + * @return This builder for chaining. + */ + public Builder setSetToServerValue( + com.google.firestore.v1.DocumentTransform.FieldTransform.ServerValue value) { + if (value == null) { + throw new NullPointerException(); + } + transformTypeCase_ = 2; + transformType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Sets the field to the given server value.
+       * 
+ * + * + * .google.firestore.v1.DocumentTransform.FieldTransform.ServerValue set_to_server_value = 2; + * + * + * @return This builder for chaining. + */ + public Builder clearSetToServerValue() { + if (transformTypeCase_ == 2) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + incrementBuilder_; + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + @java.lang.Override + public boolean hasIncrement() { + return transformTypeCase_ == 3; + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.firestore.v1.Value getIncrement() { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 3) { + return incrementBuilder_.getMessage(); + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.firestore.v1.Value value) { + if (incrementBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + incrementBuilder_.setMessage(value); + } + transformTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.firestore.v1.Value.Builder builderForValue) { + if (incrementBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + incrementBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + public Builder mergeIncrement(com.google.firestore.v1.Value value) { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3 + && transformType_ != com.google.firestore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.firestore.v1.Value.newBuilder( + (com.google.firestore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 3) { + incrementBuilder_.mergeFrom(value); + } else { + incrementBuilder_.setMessage(value); + } + } + transformTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + public Builder clearIncrement() { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 3) { + transformTypeCase_ = 0; + transformType_ = null; + } + incrementBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + public com.google.firestore.v1.Value.Builder getIncrementBuilder() { + return internalGetIncrementFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getIncrementOrBuilder() { + if ((transformTypeCase_ == 3) && (incrementBuilder_ != null)) { + return incrementBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 3) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Adds the given value to the field's current value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If either of the given value or the current field value are doubles,
+       * both values will be interpreted as doubles. Double arithmetic and
+       * representation of double values follow IEEE 754 semantics.
+       * If there is positive/negative integer overflow, the field is resolved
+       * to the largest magnitude positive/negative integer.
+       * 
+ * + * .google.firestore.v1.Value increment = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetIncrementFieldBuilder() { + if (incrementBuilder_ == null) { + if (!(transformTypeCase_ == 3)) { + transformType_ = com.google.firestore.v1.Value.getDefaultInstance(); + } + incrementBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + (com.google.firestore.v1.Value) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 3; + onChanged(); + return incrementBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + maximumBuilder_; + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.firestore.v1.Value getMaximum() { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 4) { + return maximumBuilder_.getMessage(); + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.firestore.v1.Value value) { + if (maximumBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + maximumBuilder_.setMessage(value); + } + transformTypeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.firestore.v1.Value.Builder builderForValue) { + if (maximumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + maximumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + public Builder mergeMaximum(com.google.firestore.v1.Value value) { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4 + && transformType_ != com.google.firestore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.firestore.v1.Value.newBuilder( + (com.google.firestore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 4) { + maximumBuilder_.mergeFrom(value); + } else { + maximumBuilder_.setMessage(value); + } + } + transformTypeCase_ = 4; + return this; + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + public Builder clearMaximum() { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 4) { + transformTypeCase_ = 0; + transformType_ = null; + } + maximumBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + public com.google.firestore.v1.Value.Builder getMaximumBuilder() { + return internalGetMaximumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getMaximumOrBuilder() { + if ((transformTypeCase_ == 4) && (maximumBuilder_ != null)) { + return maximumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 4) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sets the field to the maximum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the given value.
+       * If a maximum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the larger operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
+       * zero input value is always the stored value.
+       * The maximum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value maximum = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetMaximumFieldBuilder() { + if (maximumBuilder_ == null) { + if (!(transformTypeCase_ == 4)) { + transformType_ = com.google.firestore.v1.Value.getDefaultInstance(); + } + maximumBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + (com.google.firestore.v1.Value) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 4; + onChanged(); + return maximumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + minimumBuilder_; + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.firestore.v1.Value getMinimum() { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 5) { + return minimumBuilder_.getMessage(); + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.firestore.v1.Value value) { + if (minimumBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + minimumBuilder_.setMessage(value); + } + transformTypeCase_ = 5; + return this; + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.firestore.v1.Value.Builder builderForValue) { + if (minimumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + minimumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 5; + return this; + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + public Builder mergeMinimum(com.google.firestore.v1.Value value) { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5 + && transformType_ != com.google.firestore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.firestore.v1.Value.newBuilder( + (com.google.firestore.v1.Value) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 5) { + minimumBuilder_.mergeFrom(value); + } else { + minimumBuilder_.setMessage(value); + } + } + transformTypeCase_ = 5; + return this; + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + public Builder clearMinimum() { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 5) { + transformTypeCase_ = 0; + transformType_ = null; + } + minimumBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + public com.google.firestore.v1.Value.Builder getMinimumBuilder() { + return internalGetMinimumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getMinimumOrBuilder() { + if ((transformTypeCase_ == 5) && (minimumBuilder_ != null)) { + return minimumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 5) { + return (com.google.firestore.v1.Value) transformType_; + } + return com.google.firestore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sets the field to the minimum of its current value and the given value.
+       *
+       * This must be an integer or a double value.
+       * If the field is not an integer or double, or if the field does not yet
+       * exist, the transformation will set the field to the input value.
+       * If a minimum operation is applied where the field and the input value
+       * are of mixed types (that is - one is an integer and one is a double)
+       * the field takes on the type of the smaller operand. If the operands are
+       * equivalent (e.g. 3 and 3.0), the field does not change.
+       * 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and
+       * zero input value is always the stored value.
+       * The minimum of any numeric value x and NaN is NaN.
+       * 
+ * + * .google.firestore.v1.Value minimum = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetMinimumFieldBuilder() { + if (minimumBuilder_ == null) { + if (!(transformTypeCase_ == 5)) { + transformType_ = com.google.firestore.v1.Value.getDefaultInstance(); + } + minimumBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + (com.google.firestore.v1.Value) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 5; + onChanged(); + return minimumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + appendMissingElementsBuilder_; + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getAppendMissingElements() { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 6) { + return appendMissingElementsBuilder_.getMessage(); + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements(com.google.firestore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(value); + } + transformTypeCase_ = 6; + return this; + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements( + com.google.firestore.v1.ArrayValue.Builder builderForValue) { + if (appendMissingElementsBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 6; + return this; + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder mergeAppendMissingElements(com.google.firestore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6 + && transformType_ != com.google.firestore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.firestore.v1.ArrayValue.newBuilder( + (com.google.firestore.v1.ArrayValue) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 6) { + appendMissingElementsBuilder_.mergeFrom(value); + } else { + appendMissingElementsBuilder_.setMessage(value); + } + } + transformTypeCase_ = 6; + return this; + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder clearAppendMissingElements() { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 6) { + transformTypeCase_ = 0; + transformType_ = null; + } + appendMissingElementsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + public com.google.firestore.v1.ArrayValue.Builder getAppendMissingElementsBuilder() { + return internalGetAppendMissingElementsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if ((transformTypeCase_ == 6) && (appendMissingElementsBuilder_ != null)) { + return appendMissingElementsBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 6) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Append the given elements in order if they are not already present in
+       * the current field value.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * first set to the empty array.
+       *
+       * Equivalent numbers of different types (e.g. 3L and 3.0) are
+       * considered equal when checking if a value is missing.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * If the input contains multiple equivalent values, only the first will
+       * be considered.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue append_missing_elements = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + internalGetAppendMissingElementsFieldBuilder() { + if (appendMissingElementsBuilder_ == null) { + if (!(transformTypeCase_ == 6)) { + transformType_ = com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + appendMissingElementsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder>( + (com.google.firestore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 6; + onChanged(); + return appendMissingElementsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + removeAllFromArrayBuilder_; + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getRemoveAllFromArray() { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 7) { + return removeAllFromArrayBuilder_.getMessage(); + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray(com.google.firestore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(value); + } + transformTypeCase_ = 7; + return this; + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray( + com.google.firestore.v1.ArrayValue.Builder builderForValue) { + if (removeAllFromArrayBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 7; + return this; + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder mergeRemoveAllFromArray(com.google.firestore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7 + && transformType_ != com.google.firestore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.firestore.v1.ArrayValue.newBuilder( + (com.google.firestore.v1.ArrayValue) transformType_) + .mergeFrom(value) + .buildPartial(); + } else { + transformType_ = value; + } + onChanged(); + } else { + if (transformTypeCase_ == 7) { + removeAllFromArrayBuilder_.mergeFrom(value); + } else { + removeAllFromArrayBuilder_.setMessage(value); + } + } + transformTypeCase_ = 7; + return this; + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder clearRemoveAllFromArray() { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7) { + transformTypeCase_ = 0; + transformType_ = null; + onChanged(); + } + } else { + if (transformTypeCase_ == 7) { + transformTypeCase_ = 0; + transformType_ = null; + } + removeAllFromArrayBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + public com.google.firestore.v1.ArrayValue.Builder getRemoveAllFromArrayBuilder() { + return internalGetRemoveAllFromArrayFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if ((transformTypeCase_ == 7) && (removeAllFromArrayBuilder_ != null)) { + return removeAllFromArrayBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 7) { + return (com.google.firestore.v1.ArrayValue) transformType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Remove all of the given elements from the array in the field.
+       * If the field is not an array, or if the field does not yet exist, it is
+       * set to the empty array.
+       *
+       * Equivalent numbers of the different types (e.g. 3L and 3.0) are
+       * considered equal when deciding whether an element should be removed.
+       * NaN is equal to NaN, and Null is equal to Null.
+       * This will remove all equivalent values if there are duplicates.
+       *
+       * The corresponding transform_result will be the null value.
+       * 
+ * + * .google.firestore.v1.ArrayValue remove_all_from_array = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + internalGetRemoveAllFromArrayFieldBuilder() { + if (removeAllFromArrayBuilder_ == null) { + if (!(transformTypeCase_ == 7)) { + transformType_ = com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + removeAllFromArrayBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder>( + (com.google.firestore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 7; + onChanged(); + return removeAllFromArrayBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentTransform.FieldTransform) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentTransform.FieldTransform) + private static final com.google.firestore.v1.DocumentTransform.FieldTransform DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentTransform.FieldTransform(); + } + + public static com.google.firestore.v1.DocumentTransform.FieldTransform getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FieldTransform parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int DOCUMENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object document_ = ""; + + /** + * + * + *
+   * The name of the document to transform.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + @java.lang.Override + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } + } + + /** + * + * + *
+   * The name of the document to transform.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FIELD_TRANSFORMS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List fieldTransforms_; + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + @java.lang.Override + public java.util.List + getFieldTransformsList() { + return fieldTransforms_; + } + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + @java.lang.Override + public java.util.List + getFieldTransformsOrBuilderList() { + return fieldTransforms_; + } + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + @java.lang.Override + public int getFieldTransformsCount() { + return fieldTransforms_.size(); + } + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform getFieldTransforms(int index) { + return fieldTransforms_.get(index); + } + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder + getFieldTransformsOrBuilder(int index) { + return fieldTransforms_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, document_); + } + for (int i = 0; i < fieldTransforms_.size(); i++) { + output.writeMessage(2, fieldTransforms_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(document_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, document_); + } + for (int i = 0; i < fieldTransforms_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, fieldTransforms_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.DocumentTransform)) { + return super.equals(obj); + } + com.google.firestore.v1.DocumentTransform other = + (com.google.firestore.v1.DocumentTransform) obj; + + if (!getDocument().equals(other.getDocument())) return false; + if (!getFieldTransformsList().equals(other.getFieldTransformsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + if (getFieldTransformsCount() > 0) { + hash = (37 * hash) + FIELD_TRANSFORMS_FIELD_NUMBER; + hash = (53 * hash) + getFieldTransformsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.DocumentTransform parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.DocumentTransform parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.DocumentTransform prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A transformation of a document.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.DocumentTransform} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.DocumentTransform) + com.google.firestore.v1.DocumentTransformOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.DocumentTransform.class, + com.google.firestore.v1.DocumentTransform.Builder.class); + } + + // Construct using com.google.firestore.v1.DocumentTransform.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + document_ = ""; + if (fieldTransformsBuilder_ == null) { + fieldTransforms_ = java.util.Collections.emptyList(); + } else { + fieldTransforms_ = null; + fieldTransformsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_DocumentTransform_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform getDefaultInstanceForType() { + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform build() { + com.google.firestore.v1.DocumentTransform result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform buildPartial() { + com.google.firestore.v1.DocumentTransform result = + new com.google.firestore.v1.DocumentTransform(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.DocumentTransform result) { + if (fieldTransformsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + fieldTransforms_ = java.util.Collections.unmodifiableList(fieldTransforms_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.fieldTransforms_ = fieldTransforms_; + } else { + result.fieldTransforms_ = fieldTransformsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.DocumentTransform result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.document_ = document_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.DocumentTransform) { + return mergeFrom((com.google.firestore.v1.DocumentTransform) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.DocumentTransform other) { + if (other == com.google.firestore.v1.DocumentTransform.getDefaultInstance()) return this; + if (!other.getDocument().isEmpty()) { + document_ = other.document_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (fieldTransformsBuilder_ == null) { + if (!other.fieldTransforms_.isEmpty()) { + if (fieldTransforms_.isEmpty()) { + fieldTransforms_ = other.fieldTransforms_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureFieldTransformsIsMutable(); + fieldTransforms_.addAll(other.fieldTransforms_); + } + onChanged(); + } + } else { + if (!other.fieldTransforms_.isEmpty()) { + if (fieldTransformsBuilder_.isEmpty()) { + fieldTransformsBuilder_.dispose(); + fieldTransformsBuilder_ = null; + fieldTransforms_ = other.fieldTransforms_; + bitField0_ = (bitField0_ & ~0x00000002); + fieldTransformsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFieldTransformsFieldBuilder() + : null; + } else { + fieldTransformsBuilder_.addAllMessages(other.fieldTransforms_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + document_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.DocumentTransform.FieldTransform m = + input.readMessage( + com.google.firestore.v1.DocumentTransform.FieldTransform.parser(), + extensionRegistry); + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + fieldTransforms_.add(m); + } else { + fieldTransformsBuilder_.addMessage(m); + } + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object document_ = ""; + + /** + * + * + *
+     * The name of the document to transform.
+     * 
+ * + * string document = 1; + * + * @return The document. + */ + public java.lang.String getDocument() { + java.lang.Object ref = document_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + document_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The name of the document to transform.
+     * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + public com.google.protobuf.ByteString getDocumentBytes() { + java.lang.Object ref = document_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + document_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The name of the document to transform.
+     * 
+ * + * string document = 1; + * + * @param value The document to set. + * @return This builder for chaining. + */ + public Builder setDocument(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the document to transform.
+     * 
+ * + * string document = 1; + * + * @return This builder for chaining. + */ + public Builder clearDocument() { + document_ = getDefaultInstance().getDocument(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the document to transform.
+     * 
+ * + * string document = 1; + * + * @param value The bytes for document to set. + * @return This builder for chaining. + */ + public Builder setDocumentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + document_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List + fieldTransforms_ = java.util.Collections.emptyList(); + + private void ensureFieldTransformsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + fieldTransforms_ = + new java.util.ArrayList( + fieldTransforms_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + fieldTransformsBuilder_; + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public java.util.List + getFieldTransformsList() { + if (fieldTransformsBuilder_ == null) { + return java.util.Collections.unmodifiableList(fieldTransforms_); + } else { + return fieldTransformsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public int getFieldTransformsCount() { + if (fieldTransformsBuilder_ == null) { + return fieldTransforms_.size(); + } else { + return fieldTransformsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform getFieldTransforms(int index) { + if (fieldTransformsBuilder_ == null) { + return fieldTransforms_.get(index); + } else { + return fieldTransformsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder setFieldTransforms( + int index, com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (fieldTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldTransformsIsMutable(); + fieldTransforms_.set(index, value); + onChanged(); + } else { + fieldTransformsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder setFieldTransforms( + int index, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + fieldTransforms_.set(index, builderForValue.build()); + onChanged(); + } else { + fieldTransformsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder addFieldTransforms( + com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (fieldTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldTransformsIsMutable(); + fieldTransforms_.add(value); + onChanged(); + } else { + fieldTransformsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder addFieldTransforms( + int index, com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (fieldTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldTransformsIsMutable(); + fieldTransforms_.add(index, value); + onChanged(); + } else { + fieldTransformsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder addFieldTransforms( + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + fieldTransforms_.add(builderForValue.build()); + onChanged(); + } else { + fieldTransformsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder addFieldTransforms( + int index, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + fieldTransforms_.add(index, builderForValue.build()); + onChanged(); + } else { + fieldTransformsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder addAllFieldTransforms( + java.lang.Iterable + values) { + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, fieldTransforms_); + onChanged(); + } else { + fieldTransformsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder clearFieldTransforms() { + if (fieldTransformsBuilder_ == null) { + fieldTransforms_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + fieldTransformsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public Builder removeFieldTransforms(int index) { + if (fieldTransformsBuilder_ == null) { + ensureFieldTransformsIsMutable(); + fieldTransforms_.remove(index); + onChanged(); + } else { + fieldTransformsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + getFieldTransformsBuilder(int index) { + return internalGetFieldTransformsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder + getFieldTransformsOrBuilder(int index) { + if (fieldTransformsBuilder_ == null) { + return fieldTransforms_.get(index); + } else { + return fieldTransformsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public java.util.List< + ? extends com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + getFieldTransformsOrBuilderList() { + if (fieldTransformsBuilder_ != null) { + return fieldTransformsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(fieldTransforms_); + } + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + addFieldTransformsBuilder() { + return internalGetFieldTransformsFieldBuilder() + .addBuilder( + com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + addFieldTransformsBuilder(int index) { + return internalGetFieldTransformsFieldBuilder() + .addBuilder( + index, com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * The list of transformations to apply to the fields of the document, in
+     * order.
+     * This must not be empty.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + public java.util.List + getFieldTransformsBuilderList() { + return internalGetFieldTransformsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + internalGetFieldTransformsFieldBuilder() { + if (fieldTransformsBuilder_ == null) { + fieldTransformsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder>( + fieldTransforms_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + fieldTransforms_ = null; + } + return fieldTransformsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.DocumentTransform) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.DocumentTransform) + private static final com.google.firestore.v1.DocumentTransform DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.DocumentTransform(); + } + + public static com.google.firestore.v1.DocumentTransform getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentTransform parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.DocumentTransform getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransformOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransformOrBuilder.java new file mode 100644 index 000000000000..e95604f1b471 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/DocumentTransformOrBuilder.java @@ -0,0 +1,126 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface DocumentTransformOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.DocumentTransform) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The name of the document to transform.
+   * 
+ * + * string document = 1; + * + * @return The document. + */ + java.lang.String getDocument(); + + /** + * + * + *
+   * The name of the document to transform.
+   * 
+ * + * string document = 1; + * + * @return The bytes for document. + */ + com.google.protobuf.ByteString getDocumentBytes(); + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + java.util.List getFieldTransformsList(); + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + com.google.firestore.v1.DocumentTransform.FieldTransform getFieldTransforms(int index); + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + int getFieldTransformsCount(); + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + java.util.List + getFieldTransformsOrBuilderList(); + + /** + * + * + *
+   * The list of transformations to apply to the fields of the document, in
+   * order.
+   * This must not be empty.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform field_transforms = 2; + * + */ + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder getFieldTransformsOrBuilder( + int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java new file mode 100644 index 000000000000..355b18b46646 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequest.java @@ -0,0 +1,1923 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineRequest} + */ +@com.google.protobuf.Generated +public final class ExecutePipelineRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutePipelineRequest) + ExecutePipelineRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExecutePipelineRequest"); + } + + // Use ExecutePipelineRequest.newBuilder() to construct. + private ExecutePipelineRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExecutePipelineRequest() { + database_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineRequest.class, + com.google.firestore.v1.ExecutePipelineRequest.Builder.class); + } + + private int pipelineTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object pipelineType_; + + public enum PipelineTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_PIPELINE(2), + PIPELINETYPE_NOT_SET(0); + private final int value; + + private PipelineTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static PipelineTypeCase valueOf(int value) { + return forNumber(value); + } + + public static PipelineTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_PIPELINE; + case 0: + return PIPELINETYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public PipelineTypeCase getPipelineTypeCase() { + return PipelineTypeCase.forNumber(pipelineTypeCase_); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(5), + NEW_TRANSACTION(6), + READ_TIME(7), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 5: + return TRANSACTION; + case 6: + return NEW_TRANSACTION; + case 7: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. Database identifier, in the form
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Database identifier, in the form
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_PIPELINE_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + @java.lang.Override + public boolean hasStructuredPipeline() { + return pipelineTypeCase_ == 2; + } + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getStructuredPipeline() { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder() { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 7; + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (pipelineTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredPipeline) pipelineType_); + } + if (consistencySelectorCase_ == 5) { + output.writeBytes(5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + output.writeMessage(7, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (pipelineTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredPipeline) pipelineType_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutePipelineRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutePipelineRequest other = + (com.google.firestore.v1.ExecutePipelineRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getPipelineTypeCase().equals(other.getPipelineTypeCase())) return false; + switch (pipelineTypeCase_) { + case 2: + if (!getStructuredPipeline().equals(other.getStructuredPipeline())) return false; + break; + case 0: + default: + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 5: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 6: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + case 7: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + switch (pipelineTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_PIPELINE_FIELD_NUMBER; + hash = (53 * hash) + getStructuredPipeline().hashCode(); + break; + case 0: + default: + } + switch (consistencySelectorCase_) { + case 5: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 6: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + case 7: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutePipelineRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutePipelineRequest) + com.google.firestore.v1.ExecutePipelineRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineRequest.class, + com.google.firestore.v1.ExecutePipelineRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutePipelineRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + if (structuredPipelineBuilder_ != null) { + structuredPipelineBuilder_.clear(); + } + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + pipelineTypeCase_ = 0; + pipelineType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest build() { + com.google.firestore.v1.ExecutePipelineRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest buildPartial() { + com.google.firestore.v1.ExecutePipelineRequest result = + new com.google.firestore.v1.ExecutePipelineRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExecutePipelineRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.ExecutePipelineRequest result) { + result.pipelineTypeCase_ = pipelineTypeCase_; + result.pipelineType_ = this.pipelineType_; + if (pipelineTypeCase_ == 2 && structuredPipelineBuilder_ != null) { + result.pipelineType_ = structuredPipelineBuilder_.build(); + } + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 6 && newTransactionBuilder_ != null) { + result.consistencySelector_ = newTransactionBuilder_.build(); + } + if (consistencySelectorCase_ == 7 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutePipelineRequest) { + return mergeFrom((com.google.firestore.v1.ExecutePipelineRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutePipelineRequest other) { + if (other == com.google.firestore.v1.ExecutePipelineRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getPipelineTypeCase()) { + case STRUCTURED_PIPELINE: + { + mergeStructuredPipeline(other.getStructuredPipeline()); + break; + } + case PIPELINETYPE_NOT_SET: + { + break; + } + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredPipelineFieldBuilder().getBuilder(), extensionRegistry); + pipelineTypeCase_ = 2; + break; + } // case 18 + case 42: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 7; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int pipelineTypeCase_ = 0; + private java.lang.Object pipelineType_; + + public PipelineTypeCase getPipelineTypeCase() { + return PipelineTypeCase.forNumber(pipelineTypeCase_); + } + + public Builder clearPipelineType() { + pipelineTypeCase_ = 0; + pipelineType_ = null; + onChanged(); + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. Database identifier, in the form
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Database identifier, in the form
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Database identifier, in the form
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database identifier, in the form
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Database identifier, in the form
+     * `projects/{project}/databases/{database}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder> + structuredPipelineBuilder_; + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + @java.lang.Override + public boolean hasStructuredPipeline() { + return pipelineTypeCase_ == 2; + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getStructuredPipeline() { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } else { + if (pipelineTypeCase_ == 2) { + return structuredPipelineBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder setStructuredPipeline(com.google.firestore.v1.StructuredPipeline value) { + if (structuredPipelineBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pipelineType_ = value; + onChanged(); + } else { + structuredPipelineBuilder_.setMessage(value); + } + pipelineTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder setStructuredPipeline( + com.google.firestore.v1.StructuredPipeline.Builder builderForValue) { + if (structuredPipelineBuilder_ == null) { + pipelineType_ = builderForValue.build(); + onChanged(); + } else { + structuredPipelineBuilder_.setMessage(builderForValue.build()); + } + pipelineTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder mergeStructuredPipeline(com.google.firestore.v1.StructuredPipeline value) { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2 + && pipelineType_ != com.google.firestore.v1.StructuredPipeline.getDefaultInstance()) { + pipelineType_ = + com.google.firestore.v1.StructuredPipeline.newBuilder( + (com.google.firestore.v1.StructuredPipeline) pipelineType_) + .mergeFrom(value) + .buildPartial(); + } else { + pipelineType_ = value; + } + onChanged(); + } else { + if (pipelineTypeCase_ == 2) { + structuredPipelineBuilder_.mergeFrom(value); + } else { + structuredPipelineBuilder_.setMessage(value); + } + } + pipelineTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public Builder clearStructuredPipeline() { + if (structuredPipelineBuilder_ == null) { + if (pipelineTypeCase_ == 2) { + pipelineTypeCase_ = 0; + pipelineType_ = null; + onChanged(); + } + } else { + if (pipelineTypeCase_ == 2) { + pipelineTypeCase_ = 0; + pipelineType_ = null; + } + structuredPipelineBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + public com.google.firestore.v1.StructuredPipeline.Builder getStructuredPipelineBuilder() { + return internalGetStructuredPipelineFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder() { + if ((pipelineTypeCase_ == 2) && (structuredPipelineBuilder_ != null)) { + return structuredPipelineBuilder_.getMessageOrBuilder(); + } else { + if (pipelineTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredPipeline) pipelineType_; + } + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A pipelined operation.
+     * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder> + internalGetStructuredPipelineFieldBuilder() { + if (structuredPipelineBuilder_ == null) { + if (!(pipelineTypeCase_ == 2)) { + pipelineType_ = com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + structuredPipelineBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredPipeline, + com.google.firestore.v1.StructuredPipeline.Builder, + com.google.firestore.v1.StructuredPipelineOrBuilder>( + (com.google.firestore.v1.StructuredPipeline) pipelineType_, + getParentForChildren(), + isClean()); + pipelineType_ = null; + } + pipelineTypeCase_ = 2; + onChanged(); + return structuredPipelineBuilder_; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 5; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return newTransactionBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction( + com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder mergeNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ + != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + consistencySelector_ = + com.google.firestore.v1.TransactionOptions.newBuilder( + (com.google.firestore.v1.TransactionOptions) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public com.google.firestore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return internalGetNewTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencySelectorCase_ == 6) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Execute the pipeline in a new transaction.
+     *
+     * The identifier of the newly created transaction will be returned in the
+     * first response on the stream. This defaults to a read-only transaction.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + internalGetNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + (com.google.firestore.v1.TransactionOptions) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 7) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 7) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 7) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Execute the pipeline in a snapshot transaction at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 7)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 7; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutePipelineRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutePipelineRequest) + private static final com.google.firestore.v1.ExecutePipelineRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutePipelineRequest(); + } + + public static com.google.firestore.v1.ExecutePipelineRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutePipelineRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java new file mode 100644 index 000000000000..4083a3627e6d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineRequestOrBuilder.java @@ -0,0 +1,223 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExecutePipelineRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutePipelineRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Database identifier, in the form
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. Database identifier, in the form
+   * `projects/{project}/databases/{database}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return Whether the structuredPipeline field is set. + */ + boolean hasStructuredPipeline(); + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + * + * @return The structuredPipeline. + */ + com.google.firestore.v1.StructuredPipeline getStructuredPipeline(); + + /** + * + * + *
+   * A pipelined operation.
+   * 
+ * + * .google.firestore.v1.StructuredPipeline structured_pipeline = 2; + */ + com.google.firestore.v1.StructuredPipelineOrBuilder getStructuredPipelineOrBuilder(); + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + com.google.firestore.v1.TransactionOptions getNewTransaction(); + + /** + * + * + *
+   * Execute the pipeline in a new transaction.
+   *
+   * The identifier of the newly created transaction will be returned in the
+   * first response on the stream. This defaults to a read-only transaction.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Execute the pipeline in a snapshot transaction at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.ExecutePipelineRequest.PipelineTypeCase getPipelineTypeCase(); + + com.google.firestore.v1.ExecutePipelineRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java new file mode 100644 index 000000000000..22b441a95ca7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponse.java @@ -0,0 +1,2043 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for [Firestore.Execute][].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineResponse} + */ +@com.google.protobuf.Generated +public final class ExecutePipelineResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutePipelineResponse) + ExecutePipelineResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExecutePipelineResponse"); + } + + // Use ExecutePipelineResponse.newBuilder() to construct. + private ExecutePipelineResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExecutePipelineResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + results_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineResponse.class, + com.google.firestore.v1.ExecutePipelineResponse.Builder.class); + } + + private int bitField0_; + public static final int TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * Newly created transaction identifier.
+   *
+   * This field is only specified as part of the first response from the server,
+   * alongside the `results` field when the original request specified
+   * [ExecuteRequest.new_transaction][].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int RESULTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List results_; + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public java.util.List getResultsList() { + return results_; + } + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public java.util.List + getResultsOrBuilderList() { + return results_; + } + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public int getResultsCount() { + return results_.size(); + } + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Document getResults(int index) { + return results_.get(index); + } + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index) { + return results_.get(index); + } + + public static final int EXECUTION_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp executionTime_; + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + @java.lang.Override + public boolean hasExecutionTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getExecutionTime() { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder() { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + + public static final int EXPLAIN_STATS_FIELD_NUMBER = 4; + private com.google.firestore.v1.ExplainStats explainStats_; + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return Whether the explainStats field is set. + */ + @java.lang.Override + public boolean hasExplainStats() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return The explainStats. + */ + @java.lang.Override + public com.google.firestore.v1.ExplainStats getExplainStats() { + return explainStats_ == null + ? com.google.firestore.v1.ExplainStats.getDefaultInstance() + : explainStats_; + } + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + @java.lang.Override + public com.google.firestore.v1.ExplainStatsOrBuilder getExplainStatsOrBuilder() { + return explainStats_ == null + ? com.google.firestore.v1.ExplainStats.getDefaultInstance() + : explainStats_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!transaction_.isEmpty()) { + output.writeBytes(1, transaction_); + } + for (int i = 0; i < results_.size(); i++) { + output.writeMessage(2, results_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getExecutionTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getExplainStats()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, transaction_); + } + for (int i = 0; i < results_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, results_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExecutionTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getExplainStats()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutePipelineResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutePipelineResponse other = + (com.google.firestore.v1.ExecutePipelineResponse) obj; + + if (!getTransaction().equals(other.getTransaction())) return false; + if (!getResultsList().equals(other.getResultsList())) return false; + if (hasExecutionTime() != other.hasExecutionTime()) return false; + if (hasExecutionTime()) { + if (!getExecutionTime().equals(other.getExecutionTime())) return false; + } + if (hasExplainStats() != other.hasExplainStats()) return false; + if (hasExplainStats()) { + if (!getExplainStats().equals(other.getExplainStats())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + if (getResultsCount() > 0) { + hash = (37 * hash) + RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getResultsList().hashCode(); + } + if (hasExecutionTime()) { + hash = (37 * hash) + EXECUTION_TIME_FIELD_NUMBER; + hash = (53 * hash) + getExecutionTime().hashCode(); + } + if (hasExplainStats()) { + hash = (37 * hash) + EXPLAIN_STATS_FIELD_NUMBER; + hash = (53 * hash) + getExplainStats().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutePipelineResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutePipelineResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Firestore.Execute][].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutePipelineResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutePipelineResponse) + com.google.firestore.v1.ExecutePipelineResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutePipelineResponse.class, + com.google.firestore.v1.ExecutePipelineResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutePipelineResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetResultsFieldBuilder(); + internalGetExecutionTimeFieldBuilder(); + internalGetExplainStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + transaction_ = com.google.protobuf.ByteString.EMPTY; + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + } else { + results_ = null; + resultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + executionTime_ = null; + if (executionTimeBuilder_ != null) { + executionTimeBuilder_.dispose(); + executionTimeBuilder_ = null; + } + explainStats_ = null; + if (explainStatsBuilder_ != null) { + explainStatsBuilder_.dispose(); + explainStatsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse build() { + com.google.firestore.v1.ExecutePipelineResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse buildPartial() { + com.google.firestore.v1.ExecutePipelineResponse result = + new com.google.firestore.v1.ExecutePipelineResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.v1.ExecutePipelineResponse result) { + if (resultsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + results_ = java.util.Collections.unmodifiableList(results_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.results_ = results_; + } else { + result.results_ = resultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.ExecutePipelineResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.transaction_ = transaction_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.executionTime_ = + executionTimeBuilder_ == null ? executionTime_ : executionTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.explainStats_ = + explainStatsBuilder_ == null ? explainStats_ : explainStatsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutePipelineResponse) { + return mergeFrom((com.google.firestore.v1.ExecutePipelineResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutePipelineResponse other) { + if (other == com.google.firestore.v1.ExecutePipelineResponse.getDefaultInstance()) + return this; + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + if (resultsBuilder_ == null) { + if (!other.results_.isEmpty()) { + if (results_.isEmpty()) { + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureResultsIsMutable(); + results_.addAll(other.results_); + } + onChanged(); + } + } else { + if (!other.results_.isEmpty()) { + if (resultsBuilder_.isEmpty()) { + resultsBuilder_.dispose(); + resultsBuilder_ = null; + results_ = other.results_; + bitField0_ = (bitField0_ & ~0x00000002); + resultsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetResultsFieldBuilder() + : null; + } else { + resultsBuilder_.addAllMessages(other.results_); + } + } + } + if (other.hasExecutionTime()) { + mergeExecutionTime(other.getExecutionTime()); + } + if (other.hasExplainStats()) { + mergeExplainStats(other.getExplainStats()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Document m = + input.readMessage(com.google.firestore.v1.Document.parser(), extensionRegistry); + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(m); + } else { + resultsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetExecutionTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetExplainStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified as part of the first response from the server,
+     * alongside the `results` field when the original request specified
+     * [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified as part of the first response from the server,
+     * alongside the `results` field when the original request specified
+     * [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Newly created transaction identifier.
+     *
+     * This field is only specified as part of the first response from the server,
+     * alongside the `results` field when the original request specified
+     * [ExecuteRequest.new_transaction][].
+     * 
+ * + * bytes transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private java.util.List results_ = + java.util.Collections.emptyList(); + + private void ensureResultsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + results_ = new java.util.ArrayList(results_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + resultsBuilder_; + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List getResultsList() { + if (resultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(results_); + } else { + return resultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public int getResultsCount() { + if (resultsBuilder_ == null) { + return results_.size(); + } else { + return resultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document getResults(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder setResults(int index, com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.set(index, value); + onChanged(); + } else { + resultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder setResults(int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.set(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(value); + onChanged(); + } else { + resultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(int index, com.google.firestore.v1.Document value) { + if (resultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureResultsIsMutable(); + results_.add(index, value); + onChanged(); + } else { + resultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addResults(int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.add(index, builderForValue.build()); + onChanged(); + } else { + resultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder addAllResults( + java.lang.Iterable values) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, results_); + onChanged(); + } else { + resultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder clearResults() { + if (resultsBuilder_ == null) { + results_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + resultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public Builder removeResults(int index) { + if (resultsBuilder_ == null) { + ensureResultsIsMutable(); + results_.remove(index); + onChanged(); + } else { + resultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder getResultsBuilder(int index) { + return internalGetResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index) { + if (resultsBuilder_ == null) { + return results_.get(index); + } else { + return resultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List + getResultsOrBuilderList() { + if (resultsBuilder_ != null) { + return resultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(results_); + } + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder addResultsBuilder() { + return internalGetResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.Document.getDefaultInstance()); + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public com.google.firestore.v1.Document.Builder addResultsBuilder(int index) { + return internalGetResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Document.getDefaultInstance()); + } + + /** + * + * + *
+     * An ordered batch of results returned executing a pipeline.
+     *
+     * The batch size is variable, and can even be zero for when only a partial
+     * progress message is returned.
+     *
+     * The fields present in the returned documents are only those that were
+     * explicitly requested in the pipeline, this includes those like
+     * [`__name__`][google.firestore.v1.Document.name] and
+     * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+     * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+     * RPCs which always return such fields even when they are not specified in
+     * the [`mask`][google.firestore.v1.DocumentMask].
+     * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + public java.util.List getResultsBuilderList() { + return internalGetResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetResultsFieldBuilder() { + if (resultsBuilder_ == null) { + resultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + results_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + results_ = null; + } + return resultsBuilder_; + } + + private com.google.protobuf.Timestamp executionTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + executionTimeBuilder_; + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + public boolean hasExecutionTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + public com.google.protobuf.Timestamp getExecutionTime() { + if (executionTimeBuilder_ == null) { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } else { + return executionTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder setExecutionTime(com.google.protobuf.Timestamp value) { + if (executionTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionTime_ = value; + } else { + executionTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder setExecutionTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (executionTimeBuilder_ == null) { + executionTime_ = builderForValue.build(); + } else { + executionTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder mergeExecutionTime(com.google.protobuf.Timestamp value) { + if (executionTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && executionTime_ != null + && executionTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getExecutionTimeBuilder().mergeFrom(value); + } else { + executionTime_ = value; + } + } else { + executionTimeBuilder_.mergeFrom(value); + } + if (executionTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public Builder clearExecutionTime() { + bitField0_ = (bitField0_ & ~0x00000004); + executionTime_ = null; + if (executionTimeBuilder_ != null) { + executionTimeBuilder_.dispose(); + executionTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getExecutionTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetExecutionTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder() { + if (executionTimeBuilder_ != null) { + return executionTimeBuilder_.getMessageOrBuilder(); + } else { + return executionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : executionTime_; + } + } + + /** + * + * + *
+     * The time at which the results are valid.
+     *
+     * This is a (not strictly) monotonically increasing value across multiple
+     * responses in the same stream. The API guarantees that all previously
+     * returned results are still valid at the latest `execution_time`. This
+     * allows the API consumer to treat the query if it ran at the latest
+     * `execution_time` returned.
+     *
+     * If the query returns no results, a response with `execution_time` and no
+     * `results` will be sent, and this represents the time at which the operation
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetExecutionTimeFieldBuilder() { + if (executionTimeBuilder_ == null) { + executionTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getExecutionTime(), getParentForChildren(), isClean()); + executionTime_ = null; + } + return executionTimeBuilder_; + } + + private com.google.firestore.v1.ExplainStats explainStats_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainStats, + com.google.firestore.v1.ExplainStats.Builder, + com.google.firestore.v1.ExplainStatsOrBuilder> + explainStatsBuilder_; + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return Whether the explainStats field is set. + */ + public boolean hasExplainStats() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return The explainStats. + */ + public com.google.firestore.v1.ExplainStats getExplainStats() { + if (explainStatsBuilder_ == null) { + return explainStats_ == null + ? com.google.firestore.v1.ExplainStats.getDefaultInstance() + : explainStats_; + } else { + return explainStatsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public Builder setExplainStats(com.google.firestore.v1.ExplainStats value) { + if (explainStatsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainStats_ = value; + } else { + explainStatsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public Builder setExplainStats(com.google.firestore.v1.ExplainStats.Builder builderForValue) { + if (explainStatsBuilder_ == null) { + explainStats_ = builderForValue.build(); + } else { + explainStatsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public Builder mergeExplainStats(com.google.firestore.v1.ExplainStats value) { + if (explainStatsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && explainStats_ != null + && explainStats_ != com.google.firestore.v1.ExplainStats.getDefaultInstance()) { + getExplainStatsBuilder().mergeFrom(value); + } else { + explainStats_ = value; + } + } else { + explainStatsBuilder_.mergeFrom(value); + } + if (explainStats_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public Builder clearExplainStats() { + bitField0_ = (bitField0_ & ~0x00000008); + explainStats_ = null; + if (explainStatsBuilder_ != null) { + explainStatsBuilder_.dispose(); + explainStatsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public com.google.firestore.v1.ExplainStats.Builder getExplainStatsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetExplainStatsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + public com.google.firestore.v1.ExplainStatsOrBuilder getExplainStatsOrBuilder() { + if (explainStatsBuilder_ != null) { + return explainStatsBuilder_.getMessageOrBuilder(); + } else { + return explainStats_ == null + ? com.google.firestore.v1.ExplainStats.getDefaultInstance() + : explainStats_; + } + } + + /** + * + * + *
+     * Query explain stats.
+     *
+     * This is present on the **last** response if the request configured explain
+     * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+     * does not return any results, a response with `explain_stats` and no
+     * `results` will still be sent.
+     * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainStats, + com.google.firestore.v1.ExplainStats.Builder, + com.google.firestore.v1.ExplainStatsOrBuilder> + internalGetExplainStatsFieldBuilder() { + if (explainStatsBuilder_ == null) { + explainStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainStats, + com.google.firestore.v1.ExplainStats.Builder, + com.google.firestore.v1.ExplainStatsOrBuilder>( + getExplainStats(), getParentForChildren(), isClean()); + explainStats_ = null; + } + return explainStatsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutePipelineResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutePipelineResponse) + private static final com.google.firestore.v1.ExecutePipelineResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutePipelineResponse(); + } + + public static com.google.firestore.v1.ExecutePipelineResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutePipelineResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutePipelineResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java new file mode 100644 index 000000000000..ce255f7030fc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutePipelineResponseOrBuilder.java @@ -0,0 +1,274 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExecutePipelineResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutePipelineResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Newly created transaction identifier.
+   *
+   * This field is only specified as part of the first response from the server,
+   * alongside the `results` field when the original request specified
+   * [ExecuteRequest.new_transaction][].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + java.util.List getResultsList(); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + com.google.firestore.v1.Document getResults(int index); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + int getResultsCount(); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + java.util.List getResultsOrBuilderList(); + + /** + * + * + *
+   * An ordered batch of results returned executing a pipeline.
+   *
+   * The batch size is variable, and can even be zero for when only a partial
+   * progress message is returned.
+   *
+   * The fields present in the returned documents are only those that were
+   * explicitly requested in the pipeline, this includes those like
+   * [`__name__`][google.firestore.v1.Document.name] and
+   * [`__update_time__`][google.firestore.v1.Document.update_time]. This is
+   * explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument`
+   * RPCs which always return such fields even when they are not specified in
+   * the [`mask`][google.firestore.v1.DocumentMask].
+   * 
+ * + * repeated .google.firestore.v1.Document results = 2; + */ + com.google.firestore.v1.DocumentOrBuilder getResultsOrBuilder(int index); + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return Whether the executionTime field is set. + */ + boolean hasExecutionTime(); + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + * + * @return The executionTime. + */ + com.google.protobuf.Timestamp getExecutionTime(); + + /** + * + * + *
+   * The time at which the results are valid.
+   *
+   * This is a (not strictly) monotonically increasing value across multiple
+   * responses in the same stream. The API guarantees that all previously
+   * returned results are still valid at the latest `execution_time`. This
+   * allows the API consumer to treat the query if it ran at the latest
+   * `execution_time` returned.
+   *
+   * If the query returns no results, a response with `execution_time` and no
+   * `results` will be sent, and this represents the time at which the operation
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp execution_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getExecutionTimeOrBuilder(); + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return Whether the explainStats field is set. + */ + boolean hasExplainStats(); + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + * + * @return The explainStats. + */ + com.google.firestore.v1.ExplainStats getExplainStats(); + + /** + * + * + *
+   * Query explain stats.
+   *
+   * This is present on the **last** response if the request configured explain
+   * to run in 'analyze' or 'explain' mode in the pipeline options. If the query
+   * does not return any results, a response with `explain_stats` and no
+   * `results` will still be sent.
+   * 
+ * + * .google.firestore.v1.ExplainStats explain_stats = 4; + */ + com.google.firestore.v1.ExplainStatsOrBuilder getExplainStatsOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java new file mode 100644 index 000000000000..4191145556bb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStats.java @@ -0,0 +1,1302 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Execution statistics for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutionStats} + */ +@com.google.protobuf.Generated +public final class ExecutionStats extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExecutionStats) + ExecutionStatsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExecutionStats"); + } + + // Use ExecutionStats.newBuilder() to construct. + private ExecutionStats(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExecutionStats() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutionStats.class, + com.google.firestore.v1.ExecutionStats.Builder.class); + } + + private int bitField0_; + public static final int RESULTS_RETURNED_FIELD_NUMBER = 1; + private long resultsReturned_ = 0L; + + /** + * + * + *
+   * Total number of results returned, including documents, projections,
+   * aggregation results, keys.
+   * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + @java.lang.Override + public long getResultsReturned() { + return resultsReturned_; + } + + public static final int EXECUTION_DURATION_FIELD_NUMBER = 3; + private com.google.protobuf.Duration executionDuration_; + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + @java.lang.Override + public boolean hasExecutionDuration() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + @java.lang.Override + public com.google.protobuf.Duration getExecutionDuration() { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder() { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + + public static final int READ_OPERATIONS_FIELD_NUMBER = 4; + private long readOperations_ = 0L; + + /** + * + * + *
+   * Total billable read operations.
+   * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + @java.lang.Override + public long getReadOperations() { + return readOperations_; + } + + public static final int DEBUG_STATS_FIELD_NUMBER = 5; + private com.google.protobuf.Struct debugStats_; + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + @java.lang.Override + public boolean hasDebugStats() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + @java.lang.Override + public com.google.protobuf.Struct getDebugStats() { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + @java.lang.Override + public com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder() { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (resultsReturned_ != 0L) { + output.writeInt64(1, resultsReturned_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getExecutionDuration()); + } + if (readOperations_ != 0L) { + output.writeInt64(4, readOperations_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(5, getDebugStats()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (resultsReturned_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, resultsReturned_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getExecutionDuration()); + } + if (readOperations_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, readOperations_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getDebugStats()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExecutionStats)) { + return super.equals(obj); + } + com.google.firestore.v1.ExecutionStats other = (com.google.firestore.v1.ExecutionStats) obj; + + if (getResultsReturned() != other.getResultsReturned()) return false; + if (hasExecutionDuration() != other.hasExecutionDuration()) return false; + if (hasExecutionDuration()) { + if (!getExecutionDuration().equals(other.getExecutionDuration())) return false; + } + if (getReadOperations() != other.getReadOperations()) return false; + if (hasDebugStats() != other.hasDebugStats()) return false; + if (hasDebugStats()) { + if (!getDebugStats().equals(other.getDebugStats())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RESULTS_RETURNED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getResultsReturned()); + if (hasExecutionDuration()) { + hash = (37 * hash) + EXECUTION_DURATION_FIELD_NUMBER; + hash = (53 * hash) + getExecutionDuration().hashCode(); + } + hash = (37 * hash) + READ_OPERATIONS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getReadOperations()); + if (hasDebugStats()) { + hash = (37 * hash) + DEBUG_STATS_FIELD_NUMBER; + hash = (53 * hash) + getDebugStats().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExecutionStats prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Execution statistics for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExecutionStats} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExecutionStats) + com.google.firestore.v1.ExecutionStatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExecutionStats.class, + com.google.firestore.v1.ExecutionStats.Builder.class); + } + + // Construct using com.google.firestore.v1.ExecutionStats.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetExecutionDurationFieldBuilder(); + internalGetDebugStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + resultsReturned_ = 0L; + executionDuration_ = null; + if (executionDurationBuilder_ != null) { + executionDurationBuilder_.dispose(); + executionDurationBuilder_ = null; + } + readOperations_ = 0L; + debugStats_ = null; + if (debugStatsBuilder_ != null) { + debugStatsBuilder_.dispose(); + debugStatsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getDefaultInstanceForType() { + return com.google.firestore.v1.ExecutionStats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats build() { + com.google.firestore.v1.ExecutionStats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats buildPartial() { + com.google.firestore.v1.ExecutionStats result = + new com.google.firestore.v1.ExecutionStats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExecutionStats result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.resultsReturned_ = resultsReturned_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.executionDuration_ = + executionDurationBuilder_ == null + ? executionDuration_ + : executionDurationBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readOperations_ = readOperations_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.debugStats_ = debugStatsBuilder_ == null ? debugStats_ : debugStatsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExecutionStats) { + return mergeFrom((com.google.firestore.v1.ExecutionStats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExecutionStats other) { + if (other == com.google.firestore.v1.ExecutionStats.getDefaultInstance()) return this; + if (other.getResultsReturned() != 0L) { + setResultsReturned(other.getResultsReturned()); + } + if (other.hasExecutionDuration()) { + mergeExecutionDuration(other.getExecutionDuration()); + } + if (other.getReadOperations() != 0L) { + setReadOperations(other.getReadOperations()); + } + if (other.hasDebugStats()) { + mergeDebugStats(other.getDebugStats()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + resultsReturned_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 26: + { + input.readMessage( + internalGetExecutionDurationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 32: + { + readOperations_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 32 + case 42: + { + input.readMessage( + internalGetDebugStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private long resultsReturned_; + + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + @java.lang.Override + public long getResultsReturned() { + return resultsReturned_; + } + + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @param value The resultsReturned to set. + * @return This builder for chaining. + */ + public Builder setResultsReturned(long value) { + + resultsReturned_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Total number of results returned, including documents, projections,
+     * aggregation results, keys.
+     * 
+ * + * int64 results_returned = 1; + * + * @return This builder for chaining. + */ + public Builder clearResultsReturned() { + bitField0_ = (bitField0_ & ~0x00000001); + resultsReturned_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Duration executionDuration_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + executionDurationBuilder_; + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + public boolean hasExecutionDuration() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + public com.google.protobuf.Duration getExecutionDuration() { + if (executionDurationBuilder_ == null) { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } else { + return executionDurationBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder setExecutionDuration(com.google.protobuf.Duration value) { + if (executionDurationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionDuration_ = value; + } else { + executionDurationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder setExecutionDuration(com.google.protobuf.Duration.Builder builderForValue) { + if (executionDurationBuilder_ == null) { + executionDuration_ = builderForValue.build(); + } else { + executionDurationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder mergeExecutionDuration(com.google.protobuf.Duration value) { + if (executionDurationBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && executionDuration_ != null + && executionDuration_ != com.google.protobuf.Duration.getDefaultInstance()) { + getExecutionDurationBuilder().mergeFrom(value); + } else { + executionDuration_ = value; + } + } else { + executionDurationBuilder_.mergeFrom(value); + } + if (executionDuration_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public Builder clearExecutionDuration() { + bitField0_ = (bitField0_ & ~0x00000002); + executionDuration_ = null; + if (executionDurationBuilder_ != null) { + executionDurationBuilder_.dispose(); + executionDurationBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public com.google.protobuf.Duration.Builder getExecutionDurationBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetExecutionDurationFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + public com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder() { + if (executionDurationBuilder_ != null) { + return executionDurationBuilder_.getMessageOrBuilder(); + } else { + return executionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : executionDuration_; + } + } + + /** + * + * + *
+     * Total time to execute the query in the backend.
+     * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + internalGetExecutionDurationFieldBuilder() { + if (executionDurationBuilder_ == null) { + executionDurationBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getExecutionDuration(), getParentForChildren(), isClean()); + executionDuration_ = null; + } + return executionDurationBuilder_; + } + + private long readOperations_; + + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + @java.lang.Override + public long getReadOperations() { + return readOperations_; + } + + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @param value The readOperations to set. + * @return This builder for chaining. + */ + public Builder setReadOperations(long value) { + + readOperations_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Total billable read operations.
+     * 
+ * + * int64 read_operations = 4; + * + * @return This builder for chaining. + */ + public Builder clearReadOperations() { + bitField0_ = (bitField0_ & ~0x00000004); + readOperations_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Struct debugStats_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + debugStatsBuilder_; + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + public boolean hasDebugStats() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + public com.google.protobuf.Struct getDebugStats() { + if (debugStatsBuilder_ == null) { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } else { + return debugStatsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder setDebugStats(com.google.protobuf.Struct value) { + if (debugStatsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + debugStats_ = value; + } else { + debugStatsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder setDebugStats(com.google.protobuf.Struct.Builder builderForValue) { + if (debugStatsBuilder_ == null) { + debugStats_ = builderForValue.build(); + } else { + debugStatsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder mergeDebugStats(com.google.protobuf.Struct value) { + if (debugStatsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && debugStats_ != null + && debugStats_ != com.google.protobuf.Struct.getDefaultInstance()) { + getDebugStatsBuilder().mergeFrom(value); + } else { + debugStats_ = value; + } + } else { + debugStatsBuilder_.mergeFrom(value); + } + if (debugStats_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public Builder clearDebugStats() { + bitField0_ = (bitField0_ & ~0x00000008); + debugStats_ = null; + if (debugStatsBuilder_ != null) { + debugStatsBuilder_.dispose(); + debugStatsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public com.google.protobuf.Struct.Builder getDebugStatsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetDebugStatsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + public com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder() { + if (debugStatsBuilder_ != null) { + return debugStatsBuilder_.getMessageOrBuilder(); + } else { + return debugStats_ == null ? com.google.protobuf.Struct.getDefaultInstance() : debugStats_; + } + } + + /** + * + * + *
+     * Debugging statistics from the execution of the query. Note that the
+     * debugging stats are subject to change as Firestore evolves. It could
+     * include:
+     * {
+     * "indexes_entries_scanned": "1000",
+     * "documents_scanned": "20",
+     * "billing_details" : {
+     * "documents_billable": "20",
+     * "index_entries_billable": "1000",
+     * "min_query_cost": "0"
+     * }
+     * }
+     * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + internalGetDebugStatsFieldBuilder() { + if (debugStatsBuilder_ == null) { + debugStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + getDebugStats(), getParentForChildren(), isClean()); + debugStats_ = null; + } + return debugStatsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExecutionStats) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExecutionStats) + private static final com.google.firestore.v1.ExecutionStats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExecutionStats(); + } + + public static com.google.firestore.v1.ExecutionStats getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExecutionStats parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java new file mode 100644 index 000000000000..1c0c8826b55d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExecutionStatsOrBuilder.java @@ -0,0 +1,162 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExecutionStatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExecutionStats) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Total number of results returned, including documents, projections,
+   * aggregation results, keys.
+   * 
+ * + * int64 results_returned = 1; + * + * @return The resultsReturned. + */ + long getResultsReturned(); + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return Whether the executionDuration field is set. + */ + boolean hasExecutionDuration(); + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + * + * @return The executionDuration. + */ + com.google.protobuf.Duration getExecutionDuration(); + + /** + * + * + *
+   * Total time to execute the query in the backend.
+   * 
+ * + * .google.protobuf.Duration execution_duration = 3; + */ + com.google.protobuf.DurationOrBuilder getExecutionDurationOrBuilder(); + + /** + * + * + *
+   * Total billable read operations.
+   * 
+ * + * int64 read_operations = 4; + * + * @return The readOperations. + */ + long getReadOperations(); + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return Whether the debugStats field is set. + */ + boolean hasDebugStats(); + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + * + * @return The debugStats. + */ + com.google.protobuf.Struct getDebugStats(); + + /** + * + * + *
+   * Debugging statistics from the execution of the query. Note that the
+   * debugging stats are subject to change as Firestore evolves. It could
+   * include:
+   * {
+   * "indexes_entries_scanned": "1000",
+   * "documents_scanned": "20",
+   * "billing_details" : {
+   * "documents_billable": "20",
+   * "index_entries_billable": "1000",
+   * "min_query_cost": "0"
+   * }
+   * }
+   * 
+ * + * .google.protobuf.Struct debug_stats = 5; + */ + com.google.protobuf.StructOrBuilder getDebugStatsOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilter.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilter.java new file mode 100644 index 000000000000..77fe9c241920 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilter.java @@ -0,0 +1,1047 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A digest of all the documents that match a given target.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExistenceFilter} + */ +@com.google.protobuf.Generated +public final class ExistenceFilter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExistenceFilter) + ExistenceFilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExistenceFilter"); + } + + // Use ExistenceFilter.newBuilder() to construct. + private ExistenceFilter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExistenceFilter() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_ExistenceFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_ExistenceFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExistenceFilter.class, + com.google.firestore.v1.ExistenceFilter.Builder.class); + } + + private int bitField0_; + public static final int TARGET_ID_FIELD_NUMBER = 1; + private int targetId_ = 0; + + /** + * + * + *
+   * The target ID to which this filter applies.
+   * 
+ * + * int32 target_id = 1; + * + * @return The targetId. + */ + @java.lang.Override + public int getTargetId() { + return targetId_; + } + + public static final int COUNT_FIELD_NUMBER = 2; + private int count_ = 0; + + /** + * + * + *
+   * The total count of documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id].
+   *
+   * If different from the count of documents in the client that match, the
+   * client must manually determine which documents no longer match the target.
+   *
+   * The client can use the `unchanged_names` bloom filter to assist with
+   * this determination by testing ALL the document names against the filter;
+   * if the document name is NOT in the filter, it means the document no
+   * longer matches the target.
+   * 
+ * + * int32 count = 2; + * + * @return The count. + */ + @java.lang.Override + public int getCount() { + return count_; + } + + public static final int UNCHANGED_NAMES_FIELD_NUMBER = 3; + private com.google.firestore.v1.BloomFilter unchangedNames_; + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return Whether the unchangedNames field is set. + */ + @java.lang.Override + public boolean hasUnchangedNames() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return The unchangedNames. + */ + @java.lang.Override + public com.google.firestore.v1.BloomFilter getUnchangedNames() { + return unchangedNames_ == null + ? com.google.firestore.v1.BloomFilter.getDefaultInstance() + : unchangedNames_; + } + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + @java.lang.Override + public com.google.firestore.v1.BloomFilterOrBuilder getUnchangedNamesOrBuilder() { + return unchangedNames_ == null + ? com.google.firestore.v1.BloomFilter.getDefaultInstance() + : unchangedNames_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (targetId_ != 0) { + output.writeInt32(1, targetId_); + } + if (count_ != 0) { + output.writeInt32(2, count_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getUnchangedNames()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (targetId_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(1, targetId_); + } + if (count_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, count_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getUnchangedNames()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExistenceFilter)) { + return super.equals(obj); + } + com.google.firestore.v1.ExistenceFilter other = (com.google.firestore.v1.ExistenceFilter) obj; + + if (getTargetId() != other.getTargetId()) return false; + if (getCount() != other.getCount()) return false; + if (hasUnchangedNames() != other.hasUnchangedNames()) return false; + if (hasUnchangedNames()) { + if (!getUnchangedNames().equals(other.getUnchangedNames())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TARGET_ID_FIELD_NUMBER; + hash = (53 * hash) + getTargetId(); + hash = (37 * hash) + COUNT_FIELD_NUMBER; + hash = (53 * hash) + getCount(); + if (hasUnchangedNames()) { + hash = (37 * hash) + UNCHANGED_NAMES_FIELD_NUMBER; + hash = (53 * hash) + getUnchangedNames().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExistenceFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExistenceFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExistenceFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExistenceFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A digest of all the documents that match a given target.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExistenceFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExistenceFilter) + com.google.firestore.v1.ExistenceFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_ExistenceFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_ExistenceFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExistenceFilter.class, + com.google.firestore.v1.ExistenceFilter.Builder.class); + } + + // Construct using com.google.firestore.v1.ExistenceFilter.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetUnchangedNamesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + targetId_ = 0; + count_ = 0; + unchangedNames_ = null; + if (unchangedNamesBuilder_ != null) { + unchangedNamesBuilder_.dispose(); + unchangedNamesBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_ExistenceFilter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter getDefaultInstanceForType() { + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter build() { + com.google.firestore.v1.ExistenceFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter buildPartial() { + com.google.firestore.v1.ExistenceFilter result = + new com.google.firestore.v1.ExistenceFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExistenceFilter result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.targetId_ = targetId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.count_ = count_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.unchangedNames_ = + unchangedNamesBuilder_ == null ? unchangedNames_ : unchangedNamesBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExistenceFilter) { + return mergeFrom((com.google.firestore.v1.ExistenceFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExistenceFilter other) { + if (other == com.google.firestore.v1.ExistenceFilter.getDefaultInstance()) return this; + if (other.getTargetId() != 0) { + setTargetId(other.getTargetId()); + } + if (other.getCount() != 0) { + setCount(other.getCount()); + } + if (other.hasUnchangedNames()) { + mergeUnchangedNames(other.getUnchangedNames()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + targetId_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + count_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + input.readMessage( + internalGetUnchangedNamesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int targetId_; + + /** + * + * + *
+     * The target ID to which this filter applies.
+     * 
+ * + * int32 target_id = 1; + * + * @return The targetId. + */ + @java.lang.Override + public int getTargetId() { + return targetId_; + } + + /** + * + * + *
+     * The target ID to which this filter applies.
+     * 
+ * + * int32 target_id = 1; + * + * @param value The targetId to set. + * @return This builder for chaining. + */ + public Builder setTargetId(int value) { + + targetId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The target ID to which this filter applies.
+     * 
+ * + * int32 target_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearTargetId() { + bitField0_ = (bitField0_ & ~0x00000001); + targetId_ = 0; + onChanged(); + return this; + } + + private int count_; + + /** + * + * + *
+     * The total count of documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id].
+     *
+     * If different from the count of documents in the client that match, the
+     * client must manually determine which documents no longer match the target.
+     *
+     * The client can use the `unchanged_names` bloom filter to assist with
+     * this determination by testing ALL the document names against the filter;
+     * if the document name is NOT in the filter, it means the document no
+     * longer matches the target.
+     * 
+ * + * int32 count = 2; + * + * @return The count. + */ + @java.lang.Override + public int getCount() { + return count_; + } + + /** + * + * + *
+     * The total count of documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id].
+     *
+     * If different from the count of documents in the client that match, the
+     * client must manually determine which documents no longer match the target.
+     *
+     * The client can use the `unchanged_names` bloom filter to assist with
+     * this determination by testing ALL the document names against the filter;
+     * if the document name is NOT in the filter, it means the document no
+     * longer matches the target.
+     * 
+ * + * int32 count = 2; + * + * @param value The count to set. + * @return This builder for chaining. + */ + public Builder setCount(int value) { + + count_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The total count of documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id].
+     *
+     * If different from the count of documents in the client that match, the
+     * client must manually determine which documents no longer match the target.
+     *
+     * The client can use the `unchanged_names` bloom filter to assist with
+     * this determination by testing ALL the document names against the filter;
+     * if the document name is NOT in the filter, it means the document no
+     * longer matches the target.
+     * 
+ * + * int32 count = 2; + * + * @return This builder for chaining. + */ + public Builder clearCount() { + bitField0_ = (bitField0_ & ~0x00000002); + count_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.v1.BloomFilter unchangedNames_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BloomFilter, + com.google.firestore.v1.BloomFilter.Builder, + com.google.firestore.v1.BloomFilterOrBuilder> + unchangedNamesBuilder_; + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return Whether the unchangedNames field is set. + */ + public boolean hasUnchangedNames() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return The unchangedNames. + */ + public com.google.firestore.v1.BloomFilter getUnchangedNames() { + if (unchangedNamesBuilder_ == null) { + return unchangedNames_ == null + ? com.google.firestore.v1.BloomFilter.getDefaultInstance() + : unchangedNames_; + } else { + return unchangedNamesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public Builder setUnchangedNames(com.google.firestore.v1.BloomFilter value) { + if (unchangedNamesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + unchangedNames_ = value; + } else { + unchangedNamesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public Builder setUnchangedNames(com.google.firestore.v1.BloomFilter.Builder builderForValue) { + if (unchangedNamesBuilder_ == null) { + unchangedNames_ = builderForValue.build(); + } else { + unchangedNamesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public Builder mergeUnchangedNames(com.google.firestore.v1.BloomFilter value) { + if (unchangedNamesBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && unchangedNames_ != null + && unchangedNames_ != com.google.firestore.v1.BloomFilter.getDefaultInstance()) { + getUnchangedNamesBuilder().mergeFrom(value); + } else { + unchangedNames_ = value; + } + } else { + unchangedNamesBuilder_.mergeFrom(value); + } + if (unchangedNames_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public Builder clearUnchangedNames() { + bitField0_ = (bitField0_ & ~0x00000004); + unchangedNames_ = null; + if (unchangedNamesBuilder_ != null) { + unchangedNamesBuilder_.dispose(); + unchangedNamesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public com.google.firestore.v1.BloomFilter.Builder getUnchangedNamesBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetUnchangedNamesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + public com.google.firestore.v1.BloomFilterOrBuilder getUnchangedNamesOrBuilder() { + if (unchangedNamesBuilder_ != null) { + return unchangedNamesBuilder_.getMessageOrBuilder(); + } else { + return unchangedNames_ == null + ? com.google.firestore.v1.BloomFilter.getDefaultInstance() + : unchangedNames_; + } + } + + /** + * + * + *
+     * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+     * the resource names of ALL the documents that match
+     * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * This bloom filter may be omitted at the server's discretion, such as if it
+     * is deemed that the client will not make use of it or if it is too
+     * computationally expensive to calculate or transmit. Clients must gracefully
+     * handle this field being absent by falling back to the logic used before
+     * this field existed; that is, re-add the target without a resume token to
+     * figure out which documents in the client's cache are out of sync.
+     * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BloomFilter, + com.google.firestore.v1.BloomFilter.Builder, + com.google.firestore.v1.BloomFilterOrBuilder> + internalGetUnchangedNamesFieldBuilder() { + if (unchangedNamesBuilder_ == null) { + unchangedNamesBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.BloomFilter, + com.google.firestore.v1.BloomFilter.Builder, + com.google.firestore.v1.BloomFilterOrBuilder>( + getUnchangedNames(), getParentForChildren(), isClean()); + unchangedNames_ = null; + } + return unchangedNamesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExistenceFilter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExistenceFilter) + private static final com.google.firestore.v1.ExistenceFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExistenceFilter(); + } + + public static com.google.firestore.v1.ExistenceFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExistenceFilter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilterOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilterOrBuilder.java new file mode 100644 index 000000000000..97a3aacfbcc3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExistenceFilterOrBuilder.java @@ -0,0 +1,130 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExistenceFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExistenceFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The target ID to which this filter applies.
+   * 
+ * + * int32 target_id = 1; + * + * @return The targetId. + */ + int getTargetId(); + + /** + * + * + *
+   * The total count of documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id].
+   *
+   * If different from the count of documents in the client that match, the
+   * client must manually determine which documents no longer match the target.
+   *
+   * The client can use the `unchanged_names` bloom filter to assist with
+   * this determination by testing ALL the document names against the filter;
+   * if the document name is NOT in the filter, it means the document no
+   * longer matches the target.
+   * 
+ * + * int32 count = 2; + * + * @return The count. + */ + int getCount(); + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return Whether the unchangedNames field is set. + */ + boolean hasUnchangedNames(); + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + * + * @return The unchangedNames. + */ + com.google.firestore.v1.BloomFilter getUnchangedNames(); + + /** + * + * + *
+   * A bloom filter that, despite its name, contains the UTF-8 byte encodings of
+   * the resource names of ALL the documents that match
+   * [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * This bloom filter may be omitted at the server's discretion, such as if it
+   * is deemed that the client will not make use of it or if it is too
+   * computationally expensive to calculate or transmit. Clients must gracefully
+   * handle this field being absent by falling back to the logic used before
+   * this field existed; that is, re-add the target without a resume token to
+   * figure out which documents in the client's cache are out of sync.
+   * 
+ * + * .google.firestore.v1.BloomFilter unchanged_names = 3; + */ + com.google.firestore.v1.BloomFilterOrBuilder getUnchangedNamesOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java new file mode 100644 index 000000000000..38876446ffeb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetrics.java @@ -0,0 +1,1004 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Explain metrics for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainMetrics} + */ +@com.google.protobuf.Generated +public final class ExplainMetrics extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExplainMetrics) + ExplainMetricsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExplainMetrics"); + } + + // Use ExplainMetrics.newBuilder() to construct. + private ExplainMetrics(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExplainMetrics() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainMetrics.class, + com.google.firestore.v1.ExplainMetrics.Builder.class); + } + + private int bitField0_; + public static final int PLAN_SUMMARY_FIELD_NUMBER = 1; + private com.google.firestore.v1.PlanSummary planSummary_; + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + @java.lang.Override + public boolean hasPlanSummary() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + @java.lang.Override + public com.google.firestore.v1.PlanSummary getPlanSummary() { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + @java.lang.Override + public com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + + public static final int EXECUTION_STATS_FIELD_NUMBER = 2; + private com.google.firestore.v1.ExecutionStats executionStats_; + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + @java.lang.Override + public boolean hasExecutionStats() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + @java.lang.Override + public com.google.firestore.v1.ExecutionStats getExecutionStats() { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + @java.lang.Override + public com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getPlanSummary()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getExecutionStats()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPlanSummary()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getExecutionStats()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExplainMetrics)) { + return super.equals(obj); + } + com.google.firestore.v1.ExplainMetrics other = (com.google.firestore.v1.ExplainMetrics) obj; + + if (hasPlanSummary() != other.hasPlanSummary()) return false; + if (hasPlanSummary()) { + if (!getPlanSummary().equals(other.getPlanSummary())) return false; + } + if (hasExecutionStats() != other.hasExecutionStats()) return false; + if (hasExecutionStats()) { + if (!getExecutionStats().equals(other.getExecutionStats())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPlanSummary()) { + hash = (37 * hash) + PLAN_SUMMARY_FIELD_NUMBER; + hash = (53 * hash) + getPlanSummary().hashCode(); + } + if (hasExecutionStats()) { + hash = (37 * hash) + EXECUTION_STATS_FIELD_NUMBER; + hash = (53 * hash) + getExecutionStats().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExplainMetrics prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Explain metrics for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainMetrics} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExplainMetrics) + com.google.firestore.v1.ExplainMetricsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainMetrics.class, + com.google.firestore.v1.ExplainMetrics.Builder.class); + } + + // Construct using com.google.firestore.v1.ExplainMetrics.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetPlanSummaryFieldBuilder(); + internalGetExecutionStatsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + planSummary_ = null; + if (planSummaryBuilder_ != null) { + planSummaryBuilder_.dispose(); + planSummaryBuilder_ = null; + } + executionStats_ = null; + if (executionStatsBuilder_ != null) { + executionStatsBuilder_.dispose(); + executionStatsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getDefaultInstanceForType() { + return com.google.firestore.v1.ExplainMetrics.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics build() { + com.google.firestore.v1.ExplainMetrics result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics buildPartial() { + com.google.firestore.v1.ExplainMetrics result = + new com.google.firestore.v1.ExplainMetrics(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExplainMetrics result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.planSummary_ = + planSummaryBuilder_ == null ? planSummary_ : planSummaryBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.executionStats_ = + executionStatsBuilder_ == null ? executionStats_ : executionStatsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExplainMetrics) { + return mergeFrom((com.google.firestore.v1.ExplainMetrics) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExplainMetrics other) { + if (other == com.google.firestore.v1.ExplainMetrics.getDefaultInstance()) return this; + if (other.hasPlanSummary()) { + mergePlanSummary(other.getPlanSummary()); + } + if (other.hasExecutionStats()) { + mergeExecutionStats(other.getExecutionStats()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetPlanSummaryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetExecutionStatsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.PlanSummary planSummary_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder> + planSummaryBuilder_; + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + public boolean hasPlanSummary() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + public com.google.firestore.v1.PlanSummary getPlanSummary() { + if (planSummaryBuilder_ == null) { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } else { + return planSummaryBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.firestore.v1.PlanSummary value) { + if (planSummaryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + planSummary_ = value; + } else { + planSummaryBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.firestore.v1.PlanSummary.Builder builderForValue) { + if (planSummaryBuilder_ == null) { + planSummary_ = builderForValue.build(); + } else { + planSummaryBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder mergePlanSummary(com.google.firestore.v1.PlanSummary value) { + if (planSummaryBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && planSummary_ != null + && planSummary_ != com.google.firestore.v1.PlanSummary.getDefaultInstance()) { + getPlanSummaryBuilder().mergeFrom(value); + } else { + planSummary_ = value; + } + } else { + planSummaryBuilder_.mergeFrom(value); + } + if (planSummary_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public Builder clearPlanSummary() { + bitField0_ = (bitField0_ & ~0x00000001); + planSummary_ = null; + if (planSummaryBuilder_ != null) { + planSummaryBuilder_.dispose(); + planSummaryBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public com.google.firestore.v1.PlanSummary.Builder getPlanSummaryBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetPlanSummaryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + public com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + if (planSummaryBuilder_ != null) { + return planSummaryBuilder_.getMessageOrBuilder(); + } else { + return planSummary_ == null + ? com.google.firestore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder> + internalGetPlanSummaryFieldBuilder() { + if (planSummaryBuilder_ == null) { + planSummaryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.PlanSummary, + com.google.firestore.v1.PlanSummary.Builder, + com.google.firestore.v1.PlanSummaryOrBuilder>( + getPlanSummary(), getParentForChildren(), isClean()); + planSummary_ = null; + } + return planSummaryBuilder_; + } + + private com.google.firestore.v1.ExecutionStats executionStats_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder> + executionStatsBuilder_; + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + public boolean hasExecutionStats() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + public com.google.firestore.v1.ExecutionStats getExecutionStats() { + if (executionStatsBuilder_ == null) { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } else { + return executionStatsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats(com.google.firestore.v1.ExecutionStats value) { + if (executionStatsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + executionStats_ = value; + } else { + executionStatsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats( + com.google.firestore.v1.ExecutionStats.Builder builderForValue) { + if (executionStatsBuilder_ == null) { + executionStats_ = builderForValue.build(); + } else { + executionStatsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder mergeExecutionStats(com.google.firestore.v1.ExecutionStats value) { + if (executionStatsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && executionStats_ != null + && executionStats_ != com.google.firestore.v1.ExecutionStats.getDefaultInstance()) { + getExecutionStatsBuilder().mergeFrom(value); + } else { + executionStats_ = value; + } + } else { + executionStatsBuilder_.mergeFrom(value); + } + if (executionStats_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public Builder clearExecutionStats() { + bitField0_ = (bitField0_ & ~0x00000002); + executionStats_ = null; + if (executionStatsBuilder_ != null) { + executionStatsBuilder_.dispose(); + executionStatsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.firestore.v1.ExecutionStats.Builder getExecutionStatsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetExecutionStatsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + if (executionStatsBuilder_ != null) { + return executionStatsBuilder_.getMessageOrBuilder(); + } else { + return executionStats_ == null + ? com.google.firestore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder> + internalGetExecutionStatsFieldBuilder() { + if (executionStatsBuilder_ == null) { + executionStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExecutionStats, + com.google.firestore.v1.ExecutionStats.Builder, + com.google.firestore.v1.ExecutionStatsOrBuilder>( + getExecutionStats(), getParentForChildren(), isClean()); + executionStats_ = null; + } + return executionStatsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExplainMetrics) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExplainMetrics) + private static final com.google.firestore.v1.ExplainMetrics DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExplainMetrics(); + } + + public static com.google.firestore.v1.ExplainMetrics getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplainMetrics parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java new file mode 100644 index 000000000000..001a68fed7c2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainMetricsOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExplainMetricsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExplainMetrics) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + boolean hasPlanSummary(); + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + com.google.firestore.v1.PlanSummary getPlanSummary(); + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.firestore.v1.PlanSummary plan_summary = 1; + */ + com.google.firestore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return Whether the executionStats field is set. + */ + boolean hasExecutionStats(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + com.google.firestore.v1.ExecutionStats getExecutionStats(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.firestore.v1.ExecutionStats execution_stats = 2; + */ + com.google.firestore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java new file mode 100644 index 000000000000..c1d91b06424b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptions.java @@ -0,0 +1,525 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Explain options for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainOptions} + */ +@com.google.protobuf.Generated +public final class ExplainOptions extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExplainOptions) + ExplainOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExplainOptions"); + } + + // Use ExplainOptions.newBuilder() to construct. + private ExplainOptions(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExplainOptions() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainOptions.class, + com.google.firestore.v1.ExplainOptions.Builder.class); + } + + public static final int ANALYZE_FIELD_NUMBER = 1; + private boolean analyze_ = false; + + /** + * + * + *
+   * Optional. Whether to execute this query.
+   *
+   * When false (the default), the query will be planned, returning only
+   * metrics from the planning stages.
+   *
+   * When true, the query will be planned and executed, returning the full
+   * query results along with both planning and execution stage metrics.
+   * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + @java.lang.Override + public boolean getAnalyze() { + return analyze_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (analyze_ != false) { + output.writeBool(1, analyze_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (analyze_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(1, analyze_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExplainOptions)) { + return super.equals(obj); + } + com.google.firestore.v1.ExplainOptions other = (com.google.firestore.v1.ExplainOptions) obj; + + if (getAnalyze() != other.getAnalyze()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ANALYZE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAnalyze()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExplainOptions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Explain options for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExplainOptions) + com.google.firestore.v1.ExplainOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainOptions.class, + com.google.firestore.v1.ExplainOptions.Builder.class); + } + + // Construct using com.google.firestore.v1.ExplainOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + analyze_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getDefaultInstanceForType() { + return com.google.firestore.v1.ExplainOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions build() { + com.google.firestore.v1.ExplainOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions buildPartial() { + com.google.firestore.v1.ExplainOptions result = + new com.google.firestore.v1.ExplainOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExplainOptions result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.analyze_ = analyze_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExplainOptions) { + return mergeFrom((com.google.firestore.v1.ExplainOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExplainOptions other) { + if (other == com.google.firestore.v1.ExplainOptions.getDefaultInstance()) return this; + if (other.getAnalyze() != false) { + setAnalyze(other.getAnalyze()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + analyze_ = input.readBool(); + bitField0_ |= 0x00000001; + break; + } // case 8 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private boolean analyze_; + + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + @java.lang.Override + public boolean getAnalyze() { + return analyze_; + } + + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The analyze to set. + * @return This builder for chaining. + */ + public Builder setAnalyze(boolean value) { + + analyze_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Whether to execute this query.
+     *
+     * When false (the default), the query will be planned, returning only
+     * metrics from the planning stages.
+     *
+     * When true, the query will be planned and executed, returning the full
+     * query results along with both planning and execution stage metrics.
+     * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearAnalyze() { + bitField0_ = (bitField0_ & ~0x00000001); + analyze_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExplainOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExplainOptions) + private static final com.google.firestore.v1.ExplainOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExplainOptions(); + } + + public static com.google.firestore.v1.ExplainOptions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplainOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java new file mode 100644 index 000000000000..7e2a1fffa3f5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainOptionsOrBuilder.java @@ -0,0 +1,47 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExplainOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExplainOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Optional. Whether to execute this query.
+   *
+   * When false (the default), the query will be planned, returning only
+   * metrics from the planning stages.
+   *
+   * When true, the query will be planned and executed, returning the full
+   * query results along with both planning and execution stage metrics.
+   * 
+ * + * bool analyze = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The analyze. + */ + boolean getAnalyze(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStats.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStats.java new file mode 100644 index 000000000000..3a52ddd7d51e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStats.java @@ -0,0 +1,726 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/explain_stats.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Pipeline explain stats.
+ *
+ * Depending on the explain options in the original request, this can contain
+ * the optimized plan and / or execution stats.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainStats} + */ +@com.google.protobuf.Generated +public final class ExplainStats extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ExplainStats) + ExplainStatsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExplainStats"); + } + + // Use ExplainStats.newBuilder() to construct. + private ExplainStats(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ExplainStats() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.ExplainStatsProto + .internal_static_google_firestore_v1_ExplainStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.ExplainStatsProto + .internal_static_google_firestore_v1_ExplainStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainStats.class, + com.google.firestore.v1.ExplainStats.Builder.class); + } + + private int bitField0_; + public static final int DATA_FIELD_NUMBER = 1; + private com.google.protobuf.Any data_; + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + * + * @return Whether the data field is set. + */ + @java.lang.Override + public boolean hasData() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + * + * @return The data. + */ + @java.lang.Override + public com.google.protobuf.Any getData() { + return data_ == null ? com.google.protobuf.Any.getDefaultInstance() : data_; + } + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + */ + @java.lang.Override + public com.google.protobuf.AnyOrBuilder getDataOrBuilder() { + return data_ == null ? com.google.protobuf.Any.getDefaultInstance() : data_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getData()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getData()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ExplainStats)) { + return super.equals(obj); + } + com.google.firestore.v1.ExplainStats other = (com.google.firestore.v1.ExplainStats) obj; + + if (hasData() != other.hasData()) return false; + if (hasData()) { + if (!getData().equals(other.getData())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasData()) { + hash = (37 * hash) + DATA_FIELD_NUMBER; + hash = (53 * hash) + getData().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ExplainStats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainStats parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainStats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainStats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainStats parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainStats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ExplainStats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ExplainStats prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Pipeline explain stats.
+   *
+   * Depending on the explain options in the original request, this can contain
+   * the optimized plan and / or execution stats.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ExplainStats} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ExplainStats) + com.google.firestore.v1.ExplainStatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.ExplainStatsProto + .internal_static_google_firestore_v1_ExplainStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.ExplainStatsProto + .internal_static_google_firestore_v1_ExplainStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ExplainStats.class, + com.google.firestore.v1.ExplainStats.Builder.class); + } + + // Construct using com.google.firestore.v1.ExplainStats.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDataFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + data_ = null; + if (dataBuilder_ != null) { + dataBuilder_.dispose(); + dataBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.ExplainStatsProto + .internal_static_google_firestore_v1_ExplainStats_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainStats getDefaultInstanceForType() { + return com.google.firestore.v1.ExplainStats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ExplainStats build() { + com.google.firestore.v1.ExplainStats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainStats buildPartial() { + com.google.firestore.v1.ExplainStats result = new com.google.firestore.v1.ExplainStats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ExplainStats result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.data_ = dataBuilder_ == null ? data_ : dataBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ExplainStats) { + return mergeFrom((com.google.firestore.v1.ExplainStats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ExplainStats other) { + if (other == com.google.firestore.v1.ExplainStats.getDefaultInstance()) return this; + if (other.hasData()) { + mergeData(other.getData()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetDataFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Any data_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, + com.google.protobuf.Any.Builder, + com.google.protobuf.AnyOrBuilder> + dataBuilder_; + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + * + * @return Whether the data field is set. + */ + public boolean hasData() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + * + * @return The data. + */ + public com.google.protobuf.Any getData() { + if (dataBuilder_ == null) { + return data_ == null ? com.google.protobuf.Any.getDefaultInstance() : data_; + } else { + return dataBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public Builder setData(com.google.protobuf.Any value) { + if (dataBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + data_ = value; + } else { + dataBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public Builder setData(com.google.protobuf.Any.Builder builderForValue) { + if (dataBuilder_ == null) { + data_ = builderForValue.build(); + } else { + dataBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public Builder mergeData(com.google.protobuf.Any value) { + if (dataBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && data_ != null + && data_ != com.google.protobuf.Any.getDefaultInstance()) { + getDataBuilder().mergeFrom(value); + } else { + data_ = value; + } + } else { + dataBuilder_.mergeFrom(value); + } + if (data_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public Builder clearData() { + bitField0_ = (bitField0_ & ~0x00000001); + data_ = null; + if (dataBuilder_ != null) { + dataBuilder_.dispose(); + dataBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public com.google.protobuf.Any.Builder getDataBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetDataFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + public com.google.protobuf.AnyOrBuilder getDataOrBuilder() { + if (dataBuilder_ != null) { + return dataBuilder_.getMessageOrBuilder(); + } else { + return data_ == null ? com.google.protobuf.Any.getDefaultInstance() : data_; + } + } + + /** + * + * + *
+     * The format depends on the `output_format` options in the request.
+     *
+     * Currently there are two supported options: `TEXT` and `JSON`.
+     * Both supply a `google.protobuf.StringValue`.
+     * 
+ * + * .google.protobuf.Any data = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, + com.google.protobuf.Any.Builder, + com.google.protobuf.AnyOrBuilder> + internalGetDataFieldBuilder() { + if (dataBuilder_ == null) { + dataBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Any, + com.google.protobuf.Any.Builder, + com.google.protobuf.AnyOrBuilder>(getData(), getParentForChildren(), isClean()); + data_ = null; + } + return dataBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ExplainStats) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ExplainStats) + private static final com.google.firestore.v1.ExplainStats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ExplainStats(); + } + + public static com.google.firestore.v1.ExplainStats getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExplainStats parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ExplainStats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsOrBuilder.java new file mode 100644 index 000000000000..16aaf6b8321a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsOrBuilder.java @@ -0,0 +1,74 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/explain_stats.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ExplainStatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ExplainStats) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + * + * @return Whether the data field is set. + */ + boolean hasData(); + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + * + * @return The data. + */ + com.google.protobuf.Any getData(); + + /** + * + * + *
+   * The format depends on the `output_format` options in the request.
+   *
+   * Currently there are two supported options: `TEXT` and `JSON`.
+   * Both supply a `google.protobuf.StringValue`.
+   * 
+ * + * .google.protobuf.Any data = 1; + */ + com.google.protobuf.AnyOrBuilder getDataOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsProto.java new file mode 100644 index 000000000000..06657445ae5f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ExplainStatsProto.java @@ -0,0 +1,84 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/explain_stats.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class ExplainStatsProto extends com.google.protobuf.GeneratedFile { + private ExplainStatsProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ExplainStatsProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExplainStats_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExplainStats_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\'google/firestore/v1/explain_stats.prot" + + "o\022\023google.firestore.v1\032\031google/protobuf/" + + "any.proto\"2\n\014ExplainStats\022\"\n\004data\030\001 \001(\0132" + + "\024.google.protobuf.AnyB\302\001\n\027com.google.fir" + + "estore.v1B\021ExplainStatsProtoP\001Z;cloud.go" + + "ogle.com/go/firestore/apiv1/firestorepb;" + + "firestorepb\252\002\031Google.Cloud.Firestore.V1\312" + + "\002\031Google\\Cloud\\Firestore\\V1\352\002\034Google::Cl" + + "oud::Firestore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.AnyProto.getDescriptor(), + }); + internal_static_google_firestore_v1_ExplainStats_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_ExplainStats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ExplainStats_descriptor, + new java.lang.String[] { + "Data", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.protobuf.AnyProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java new file mode 100644 index 000000000000..428cce5d4010 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FirestoreProto.java @@ -0,0 +1,900 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class FirestoreProto extends com.google.protobuf.GeneratedFile { + private FirestoreProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FirestoreProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_GetDocumentRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_GetDocumentRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListDocumentsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListDocumentsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListDocumentsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_CreateDocumentRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_CreateDocumentRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_UpdateDocumentRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_UpdateDocumentRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DeleteDocumentRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DeleteDocumentRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BatchGetDocumentsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BatchGetDocumentsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BatchGetDocumentsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BatchGetDocumentsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BeginTransactionRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BeginTransactionRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BeginTransactionResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BeginTransactionResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_CommitRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_CommitRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_CommitResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_CommitResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_RollbackRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_RollbackRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_RunQueryRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_RunQueryRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_RunQueryResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_RunQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutePipelineRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExecutePipelineRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutePipelineResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExecutePipelineResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_RunAggregationQueryRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_RunAggregationQueryRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_RunAggregationQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_PartitionQueryRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_PartitionQueryRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_PartitionQueryResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_PartitionQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_WriteRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_WriteRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_WriteRequest_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_WriteRequest_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_WriteResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_WriteResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListenRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListenRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListenRequest_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListenRequest_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListenResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListenResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Target_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Target_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Target_DocumentsTarget_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Target_DocumentsTarget_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Target_QueryTarget_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Target_QueryTarget_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_TargetChange_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_TargetChange_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListCollectionIdsRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListCollectionIdsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ListCollectionIdsResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ListCollectionIdsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BatchWriteRequest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BatchWriteRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BatchWriteRequest_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BatchWriteRequest_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_BatchWriteResponse_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_BatchWriteResponse_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n" + + "#google/firestore/v1/firestore.proto\022\023g" + + "oogle.firestore.v1\032\034google/api/annotatio" + + "ns.proto\032\027google/api/client.proto\032\037googl" + + "e/api/field_behavior.proto\032\030google/api/r" + + "outing.proto\032,google/firestore/v1/aggregation_result.proto\032 google/firestore/v1/" + + "common.proto\032\"google/firestore/v1/docume" + + "nt.proto\032\'google/firestore/v1/explain_st" + + "ats.proto\032\"google/firestore/v1/pipeline." + + "proto\032\037google/firestore/v1/query.proto\032\'" + + "google/firestore/v1/query_profile.proto\032" + + "\037google/firestore/v1/write.proto\032\033google" + + "/protobuf/empty.proto\032\037google/protobuf/t" + + "imestamp.proto\032\036google/protobuf/wrappers.proto\032\027google/rpc/status.proto\"\270\001\n" + + "\022GetDocumentRequest\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022/\n" + + "\004mask\030\002 \001(\0132!.google.firestore.v1.DocumentMask\022\025\n" + + "\013transaction\030\003 \001(\014H\000\022/\n" + + "\tread_time\030\005 \001(\0132\032.google.protobuf.TimestampH\000B\026\n" + + "\024consistency_selector\"\273\002\n" + + "\024ListDocumentsRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022\032\n\r" + + "collection_id\030\002 \001(\tB\003\340A\001\022\026\n" + + "\tpage_size\030\003 \001(\005B\003\340A\001\022\027\n\n" + + "page_token\030\004 \001(\tB\003\340A\001\022\025\n" + + "\010order_by\030\006 \001(\tB\003\340A\001\0224\n" + + "\004mask\030\007 \001(\0132!.google.firestore.v1.DocumentMaskB\003\340A\001\022\025\n" + + "\013transaction\030\010 \001(\014H\000\022/\n" + + "\tread_time\030\n" + + " \001(\0132\032.google.protobuf.TimestampH\000\022\024\n" + + "\014show_missing\030\014 \001(\010B\026\n" + + "\024consistency_selector\"b\n" + + "\025ListDocumentsResponse\0220\n" + + "\tdocuments\030\001 \003(\0132\035.google.firestore.v1.Document\022\027\n" + + "\017next_page_token\030\002 \001(\t\"\304\001\n" + + "\025CreateDocumentRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022\032\n\r" + + "collection_id\030\002 \001(\tB\003\340A\002\022\023\n" + + "\013document_id\030\003 \001(\t\0224\n" + + "\010document\030\004 \001(\0132\035.google.firestore.v1.DocumentB\003\340A\002\022/\n" + + "\004mask\030\005 \001(\0132!.google.firestore.v1.DocumentMask\"\363\001\n" + + "\025UpdateDocumentRequest\0224\n" + + "\010document\030\001 \001(\0132\035.google.firestore.v1.DocumentB\003\340A\002\0226\n" + + "\013update_mask\030\002 \001(\0132!.google.firestore.v1.DocumentMask\022/\n" + + "\004mask\030\003 \001(\0132!.google.firestore.v1.DocumentMask\022;\n" + + "\020current_document\030\004 \001(\0132!.google.firestore.v1.Precondition\"g\n" + + "\025DeleteDocumentRequest\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022;\n" + + "\020current_document\030\002 \001(\0132!.google.firestore.v1.Precondition\"\231\002\n" + + "\030BatchGetDocumentsRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022\021\n" + + "\tdocuments\030\002 \003(\t\022/\n" + + "\004mask\030\003 \001(\0132!.google.firestore.v1.DocumentMask\022\025\n" + + "\013transaction\030\004 \001(\014H\000\022B\n" + + "\017new_transaction\030\005" + + " \001(\0132\'.google.firestore.v1.TransactionOptionsH\000\022/\n" + + "\tread_time\030\007 \001(\0132\032.google.protobuf.TimestampH\000B\026\n" + + "\024consistency_selector\"\254\001\n" + + "\031BatchGetDocumentsResponse\022.\n" + + "\005found\030\001 \001(\0132\035.google.firestore.v1.DocumentH\000\022\021\n" + + "\007missing\030\002 \001(\tH\000\022\023\n" + + "\013transaction\030\003 \001(\014\022-\n" + + "\tread_time\030\004 \001(\0132\032.google.protobuf.TimestampB\010\n" + + "\006result\"j\n" + + "\027BeginTransactionRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\0228\n" + + "\007options\030\002 \001(\0132\'.google.firestore.v1.TransactionOptions\"/\n" + + "\030BeginTransactionResponse\022\023\n" + + "\013transaction\030\001 \001(\014\"g\n\r" + + "CommitRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022*\n" + + "\006writes\030\002 \003(\0132\032.google.firestore.v1.Write\022\023\n" + + "\013transaction\030\003 \001(\014\"z\n" + + "\016CommitResponse\0227\n\r" + + "write_results\030\001 \003(\0132 .google.firestore.v1.WriteResult\022/\n" + + "\013commit_time\030\002 \001(\0132\032.google.protobuf.Timestamp\"B\n" + + "\017RollbackRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022\030\n" + + "\013transaction\030\002 \001(\014B\003\340A\002\"\335\002\n" + + "\017RunQueryRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022@\n" + + "\020structured_query\030\002" + + " \001(\0132$.google.firestore.v1.StructuredQueryH\000\022\025\n" + + "\013transaction\030\005 \001(\014H\001\022B\n" + + "\017new_transaction\030\006" + + " \001(\0132\'.google.firestore.v1.TransactionOptionsH\001\022/\n" + + "\tread_time\030\007 \001(\0132\032.google.protobuf.TimestampH\001\022A\n" + + "\017explain_options\030\n" + + " \001(\0132#.google.firestore.v1.ExplainOptionsB\003\340A\001B\014\n\n" + + "query_typeB\026\n" + + "\024consistency_selector\"\207\002\n" + + "\020RunQueryResponse\022\023\n" + + "\013transaction\030\002 \001(\014\022/\n" + + "\010document\030\001 \001(\0132\035.google.firestore.v1.Document\022-\n" + + "\tread_time\030\003 \001(\0132\032.google.protobuf.Timestamp\022\027\n" + + "\017skipped_results\030\004 \001(\005\022\016\n" + + "\004done\030\006 \001(\010H\000\022<\n" + + "\017explain_metrics\030\013 \001(\0132#.google.firestore.v1.ExplainMetricsB\027\n" + + "\025continuation_selector\"\254\002\n" + + "\026ExecutePipelineRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022F\n" + + "\023structured_pipeline\030\002 \001(\0132\'.g" + + "oogle.firestore.v1.StructuredPipelineH\000\022\025\n" + + "\013transaction\030\005 \001(\014H\001\022B\n" + + "\017new_transaction\030\006" + + " \001(\0132\'.google.firestore.v1.TransactionOptionsH\001\022/\n" + + "\tread_time\030\007 \001(\0132\032.google.protobuf.TimestampH\001B\017\n\r" + + "pipeline_typeB\026\n" + + "\024consistency_selector\"\314\001\n" + + "\027ExecutePipelineResponse\022\023\n" + + "\013transaction\030\001 \001(\014\022.\n" + + "\007results\030\002 \003(\0132\035.google.firestore.v1.Document\0222\n" + + "\016execution_time\030\003 \001(\0132\032.google.protobuf.Timestamp\0228\n\r" + + "explain_stats\030\004 \001(\0132!.google.firestore.v1.ExplainStats\"\377\002\n" + + "\032RunAggregationQueryRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022W\n" + + "\034structured_aggregation_query\030\002 \001(\0132/." + + "google.firestore.v1.StructuredAggregationQueryH\000\022\025\n" + + "\013transaction\030\004 \001(\014H\001\022B\n" + + "\017new_transaction\030\005" + + " \001(\0132\'.google.firestore.v1.TransactionOptionsH\001\022/\n" + + "\tread_time\030\006 \001(\0132\032.google.protobuf.TimestampH\001\022A\n" + + "\017explain_options\030\010" + + " \001(\0132#.google.firestore.v1.ExplainOptionsB\003\340A\001B\014\n\n" + + "query_typeB\026\n" + + "\024consistency_selector\"\327\001\n" + + "\033RunAggregationQueryResponse\0226\n" + + "\006result\030\001 \001(\0132&.google.firestore.v1.AggregationResult\022\023\n" + + "\013transaction\030\002 \001(\014\022-\n" + + "\tread_time\030\003 \001(\0132\032.google.protobuf.Timestamp\022<\n" + + "\017explain_metrics\030\n" + + " \001(\0132#.google.firestore.v1.ExplainMetrics\"\205\002\n" + + "\025PartitionQueryRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022@\n" + + "\020structured_query\030\002" + + " \001(\0132$.google.firestore.v1.StructuredQueryH\000\022\027\n" + + "\017partition_count\030\003 \001(\003\022\022\n\n" + + "page_token\030\004 \001(\t\022\021\n" + + "\tpage_size\030\005 \001(\005\022/\n" + + "\tread_time\030\006 \001(\0132\032.google.protobuf.TimestampH\001B\014\n\n" + + "query_typeB\026\n" + + "\024consistency_selector\"b\n" + + "\026PartitionQueryResponse\022/\n\n" + + "partitions\030\001 \003(\0132\033.google.firestore.v1.Cursor\022\027\n" + + "\017next_page_token\030\002 \001(\t\"\350\001\n" + + "\014WriteRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022\021\n" + + "\tstream_id\030\002 \001(\t\022*\n" + + "\006writes\030\003 \003(\0132\032.google.firestore.v1.Write\022\024\n" + + "\014stream_token\030\004 \001(\014\022=\n" + + "\006labels\030\005 \003(\0132-.google.firestore.v1.WriteRequest.LabelsEntry\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\"\242\001\n\r" + + "WriteResponse\022\021\n" + + "\tstream_id\030\001 \001(\t\022\024\n" + + "\014stream_token\030\002 \001(\014\0227\n\r" + + "write_results\030\003 \003(\0132 .google.firestore.v1.WriteResult\022/\n" + + "\013commit_time\030\004 \001(\0132\032.google.protobuf.Timestamp\"\362\001\n\r" + + "ListenRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\0221\n\n" + + "add_target\030\002 \001(\0132\033.google.firestore.v1.TargetH\000\022\027\n\r" + + "remove_target\030\003 \001(\005H\000\022>\n" + + "\006labels\030\004 \003(\0132..google.firestore.v1.ListenRequest.LabelsEntry\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001B\017\n\r" + + "target_change\"\325\002\n" + + "\016ListenResponse\022:\n\r" + + "target_change\030\002 \001(\0132!.google.firestore.v1.TargetChangeH\000\022>\n" + + "\017document_change\030\003 \001(\0132#.google.firestore.v1.DocumentChangeH\000\022>\n" + + "\017document_delete\030\004 \001(\0132#.google.firestore.v1.DocumentDeleteH\000\022>\n" + + "\017document_remove\030\006 \001(\0132#.google.firestore.v1.DocumentRemoveH\000\0226\n" + + "\006filter\030\005 \001(\0132$.google.firestore.v1.ExistenceFilterH\000B\017\n\r" + + "response_type\"\326\003\n" + + "\006Target\0228\n" + + "\005query\030\002 \001(\0132\'.google.firestore.v1.Target.QueryTargetH\000\022@\n" + + "\tdocuments\030\003 \001(\0132+.googl" + + "e.firestore.v1.Target.DocumentsTargetH\000\022\026\n" + + "\014resume_token\030\004 \001(\014H\001\022/\n" + + "\tread_time\030\013 \001(\0132\032.google.protobuf.TimestampH\001\022\021\n" + + "\ttarget_id\030\005 \001(\005\022\014\n" + + "\004once\030\006 \001(\010\0223\n" + + "\016expected_count\030\014 \001(\0132\033.google.protobuf.Int32Value\032$\n" + + "\017DocumentsTarget\022\021\n" + + "\tdocuments\030\002 \003(\t\032m\n" + + "\013QueryTarget\022\016\n" + + "\006parent\030\001 \001(\t\022@\n" + + "\020structured_query\030\002" + + " \001(\0132$.google.firestore.v1.StructuredQueryH\000B\014\n\n" + + "query_typeB\r\n" + + "\013target_typeB\r\n" + + "\013resume_type\"\252\002\n" + + "\014TargetChange\022N\n" + + "\022target_change_type\030\001" + + " \001(\01622.google.firestore.v1.TargetChange.TargetChangeType\022\022\n\n" + + "target_ids\030\002 \003(\005\022!\n" + + "\005cause\030\003 \001(\0132\022.google.rpc.Status\022\024\n" + + "\014resume_token\030\004 \001(\014\022-\n" + + "\tread_time\030\006 \001(\0132\032.google.protobuf.Timestamp\"N\n" + + "\020TargetChangeType\022\r\n" + + "\tNO_CHANGE\020\000\022\007\n" + + "\003ADD\020\001\022\n\n" + + "\006REMOVE\020\002\022\013\n" + + "\007CURRENT\020\003\022\t\n" + + "\005RESET\020\004\"\237\001\n" + + "\030ListCollectionIdsRequest\022\023\n" + + "\006parent\030\001 \001(\tB\003\340A\002\022\021\n" + + "\tpage_size\030\002 \001(\005\022\022\n\n" + + "page_token\030\003 \001(\t\022/\n" + + "\tread_time\030\004 \001(\0132\032.google.protobuf.TimestampH\000B\026\n" + + "\024consistency_selector\"L\n" + + "\031ListCollectionIdsResponse\022\026\n" + + "\016collection_ids\030\001 \003(\t\022\027\n" + + "\017next_page_token\030\002 \001(\t\"\311\001\n" + + "\021BatchWriteRequest\022\025\n" + + "\010database\030\001 \001(\tB\003\340A\002\022*\n" + + "\006writes\030\002 \003(\0132\032.google.firestore.v1.Write\022B\n" + + "\006labels\030\003" + + " \003(\01322.google.firestore.v1.BatchWriteRequest.LabelsEntry\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\"q\n" + + "\022BatchWriteResponse\0227\n\r" + + "write_results\030\001 \003(\0132 .google.firestore.v1.WriteResult\022\"\n" + + "\006status\030\002 \003(\0132\022.google.rpc.Status2\373\033\n" + + "\tFirestore\022\217\001\n" + + "\013GetDocument\022\'.google.firestore.v1.GetDocumentRequest\032\035.google.fi" + + "restore.v1.Document\"8\202\323\344\223\0022\0220/v1/{name=p" + + "rojects/*/databases/*/documents/*/**}\022\365\001\n\r" + + "ListDocuments\022).google.firestore.v1.ListDocumentsRequest\032*.google.firestore.v1" + + ".ListDocumentsResponse\"\214\001\202\323\344\223\002\205\001\022B/v1/{p" + + "arent=projects/*/databases/*/documents/*/**}/{collection_id}Z?\022=/v1/{parent=proj" + + "ects/*/databases/*/documents}/{collection_id}\022\277\001\n" + + "\016UpdateDocument\022*.google.firestore.v1.UpdateDocumentRequest\032\035.google.fi" + + "restore.v1.Document\"b\332A\024document,update_" + + "mask\202\323\344\223\002E29/v1/{document.name=projects/" + + "*/databases/*/documents/*/**}:\010document\022\225\001\n" + + "\016DeleteDocument\022*.google.firestore.v1" + + ".DeleteDocumentRequest\032\026.google.protobuf" + + ".Empty\"?\332A\004name\202\323\344\223\0022*0/v1/{name=projects/*/databases/*/documents/*/**}\022\271\001\n" + + "\021BatchGetDocuments\022-.google.firestore.v1.Batc" + + "hGetDocumentsRequest\032..google.firestore." + + "v1.BatchGetDocumentsResponse\"C\202\323\344\223\002=\"8/v" + + "1/{database=projects/*/databases/*}/documents:batchGet:\001*0\001\022\307\001\n" + + "\020BeginTransaction\022,.google.firestore.v1.BeginTransactionR" + + "equest\032-.google.firestore.v1.BeginTransa" + + "ctionResponse\"V\332A\010database\202\323\344\223\002E\"@/v1/{d" + + "atabase=projects/*/databases/*}/documents:beginTransaction:\001*\022\246\001\n" + + "\006Commit\022\".google.firestore.v1.CommitRequest\032#.google.fi" + + "restore.v1.CommitResponse\"S\332A\017database,w" + + "rites\202\323\344\223\002;\"6/v1/{database=projects/*/databases/*}/documents:commit:\001*\022\244\001\n" + + "\010Rollback\022$.google.firestore.v1.RollbackReques" + + "t\032\026.google.protobuf.Empty\"Z\332A\024database,t" + + "ransaction\202\323\344\223\002=\"8/v1/{database=projects" + + "/*/databases/*}/documents:rollback:\001*\022\337\001\n" + + "\010RunQuery\022$.google.firestore.v1.RunQuer" + + "yRequest\032%.google.firestore.v1.RunQueryR" + + "esponse\"\203\001\202\323\344\223\002}\"6/v1/{parent=projects/*" + + "/databases/*/documents}:runQuery:\001*Z@\";/" + + "v1/{parent=projects/*/databases/*/documents/*/**}:runQuery:\001*0\001\022\236\002\n" + + "\017ExecutePipeline\022+.google.firestore.v1.ExecutePipelin" + + "eRequest\032,.google.firestore.v1.ExecutePi" + + "pelineResponse\"\255\001\202\323\344\223\002D\"?/v1/{database=p" + + "rojects/*/databases/*}/documents:executePipeline:\001*\212\323\344\223\002]\022&\n" + + "\010database\022\032projects/{project_id=*}/**\0223\n" + + "\010database\022\'projects/*/databases/{database_id=*}/**0\001\022\227\002\n" + + "\023RunAggregationQuery\022/.google.firestore.v1.R" + + "unAggregationQueryRequest\0320.google.fires" + + "tore.v1.RunAggregationQueryResponse\"\232\001\202\323" + + "\344\223\002\223\001\"A/v1/{parent=projects/*/databases/" + + "*/documents}:runAggregationQuery:\001*ZK\"F/" + + "v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery:\001*0\001\022\374\001\n" + + "\016PartitionQuery\022*.google.firestore.v1.Part" + + "itionQueryRequest\032+.google.firestore.v1." + + "PartitionQueryResponse\"\220\001\202\323\344\223\002\211\001\" + * Represents an unevaluated scalar expression. + * + * For example, the expression `like(user_name, "%alice%")` is represented as: + * + * ``` + * name: "like" + * args { field_reference: "user_name" } + * args { string_value: "%alice%" } + * ``` + * + * + * Protobuf type {@code google.firestore.v1.Function} + */ +@com.google.protobuf.Generated +public final class Function extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Function) + FunctionOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Function"); + } + + // Use Function.newBuilder() to construct. + private Function(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Function() { + name_ = ""; + args_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Function.class, com.google.firestore.v1.Function.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ARGS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List args_; + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getArgsList() { + return args_; + } + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getArgsOrBuilderList() { + return args_; + } + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public int getArgsCount() { + return args_.size(); + } + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getArgs(int index) { + return args_.get(index); + } + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + return args_.get(index); + } + + public static final int OPTIONS_FIELD_NUMBER = 3; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + for (int i = 0; i < args_.size(); i++) { + output.writeMessage(2, args_.get(i)); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 3); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + for (int i = 0; i < args_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, args_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Function)) { + return super.equals(obj); + } + com.google.firestore.v1.Function other = (com.google.firestore.v1.Function) obj; + + if (!getName().equals(other.getName())) return false; + if (!getArgsList().equals(other.getArgsList())) return false; + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getArgsCount() > 0) { + hash = (37 * hash) + ARGS_FIELD_NUMBER; + hash = (53 * hash) + getArgsList().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Function parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Function parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Function parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Function prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Represents an unevaluated scalar expression.
+   *
+   * For example, the expression `like(user_name, "%alice%")` is represented as:
+   *
+   * ```
+   * name: "like"
+   * args { field_reference: "user_name" }
+   * args { string_value: "%alice%" }
+   * ```
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Function} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Function) + com.google.firestore.v1.FunctionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Function.class, + com.google.firestore.v1.Function.Builder.class); + } + + // Construct using com.google.firestore.v1.Function.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + } else { + args_ = null; + argsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Function_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Function getDefaultInstanceForType() { + return com.google.firestore.v1.Function.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Function build() { + com.google.firestore.v1.Function result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Function buildPartial() { + com.google.firestore.v1.Function result = new com.google.firestore.v1.Function(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Function result) { + if (argsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + args_ = java.util.Collections.unmodifiableList(args_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.args_ = args_; + } else { + result.args_ = argsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Function result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Function) { + return mergeFrom((com.google.firestore.v1.Function) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Function other) { + if (other == com.google.firestore.v1.Function.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (argsBuilder_ == null) { + if (!other.args_.isEmpty()) { + if (args_.isEmpty()) { + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureArgsIsMutable(); + args_.addAll(other.args_); + } + onChanged(); + } + } else { + if (!other.args_.isEmpty()) { + if (argsBuilder_.isEmpty()) { + argsBuilder_.dispose(); + argsBuilder_ = null; + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + argsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetArgsFieldBuilder() + : null; + } else { + argsBuilder_.addAllMessages(other.args_); + } + } + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000004; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(m); + } else { + argsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The name of the function to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List args_ = java.util.Collections.emptyList(); + + private void ensureArgsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + args_ = new java.util.ArrayList(args_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + argsBuilder_; + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getArgsList() { + if (argsBuilder_ == null) { + return java.util.Collections.unmodifiableList(args_); + } else { + return argsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public int getArgsCount() { + if (argsBuilder_ == null) { + return args_.size(); + } else { + return argsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value getArgs(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.set(index, value); + onChanged(); + } else { + argsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.set(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + } else { + argsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(index, value); + onChanged(); + } else { + argsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAllArgs(java.lang.Iterable values) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, args_); + onChanged(); + } else { + argsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearArgs() { + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + argsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeArgs(int index) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.remove(index); + onChanged(); + } else { + argsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder getArgsBuilder(int index) { + return internalGetArgsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getArgsOrBuilderList() { + if (argsBuilder_ != null) { + return argsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(args_); + } + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder() { + return internalGetArgsFieldBuilder() + .addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder(int index) { + return internalGetArgsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given function expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getArgsBuilderList() { + return internalGetArgsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetArgsFieldBuilder() { + if (argsBuilder_ == null) { + argsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + args_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + args_ = null; + } + return argsBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000004; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableOptions().clear(); + return this; + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000004; + return internalGetMutableOptions().ensureMessageMap(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Function) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Function) + private static final com.google.firestore.v1.Function DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Function(); + } + + public static com.google.firestore.v1.Function getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Function parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Function getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java new file mode 100644 index 000000000000..c0171df41620 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/FunctionOrBuilder.java @@ -0,0 +1,195 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface FunctionOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Function) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. The name of the function to evaluate.
+   *
+   * **Requires:**
+   *
+   * * must be in snake case (lower case with underscore separator).
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getArgsList(); + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.Value getArgs(int index); + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getArgsCount(); + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getArgsOrBuilderList(); + + /** + * + * + *
+   * Optional. Ordered list of arguments the given function expects.
+   * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index); + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getOptionsCount(); + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsOptions(java.lang.String key); + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getOptionsMap(); + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+   * Optional. Optional named arguments that certain functions may support.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java new file mode 100644 index 000000000000..68203b501bd8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequest.java @@ -0,0 +1,1500 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.GetDocumentRequest} + */ +@com.google.protobuf.Generated +public final class GetDocumentRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.GetDocumentRequest) + GetDocumentRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "GetDocumentRequest"); + } + + // Use GetDocumentRequest.newBuilder() to construct. + private GetDocumentRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private GetDocumentRequest() { + name_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_GetDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_GetDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.GetDocumentRequest.class, + com.google.firestore.v1.GetDocumentRequest.Builder.class); + } + + private int bitField0_; + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(3), + READ_TIME(5), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 3: + return TRANSACTION; + case 5: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * Required. The resource name of the Document to get. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The resource name of the Document to get. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MASK_FIELD_NUMBER = 2; + private com.google.firestore.v1.DocumentMask mask_; + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return Whether the mask field is set. + */ + @java.lang.Override + public boolean hasMask() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return The mask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getMask() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + 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; + } + + /** + * + * + *
+   * Reads the document in a transaction.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 3) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int READ_TIME_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getMask()); + } + if (consistencySelectorCase_ == 3) { + output.writeBytes(3, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + output.writeMessage(5, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getMask()); + } + if (consistencySelectorCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 3, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.GetDocumentRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.GetDocumentRequest other = + (com.google.firestore.v1.GetDocumentRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (hasMask() != other.hasMask()) return false; + if (hasMask()) { + if (!getMask().equals(other.getMask())) return false; + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 3: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 5: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasMask()) { + hash = (37 * hash) + MASK_FIELD_NUMBER; + hash = (53 * hash) + getMask().hashCode(); + } + switch (consistencySelectorCase_) { + case 3: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 5: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.GetDocumentRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.GetDocumentRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.GetDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.GetDocumentRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.GetDocumentRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.GetDocumentRequest) + com.google.firestore.v1.GetDocumentRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_GetDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_GetDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.GetDocumentRequest.class, + com.google.firestore.v1.GetDocumentRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.GetDocumentRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_GetDocumentRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.GetDocumentRequest getDefaultInstanceForType() { + return com.google.firestore.v1.GetDocumentRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.GetDocumentRequest build() { + com.google.firestore.v1.GetDocumentRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.GetDocumentRequest buildPartial() { + com.google.firestore.v1.GetDocumentRequest result = + new com.google.firestore.v1.GetDocumentRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.GetDocumentRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.mask_ = maskBuilder_ == null ? mask_ : maskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.GetDocumentRequest result) { + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 5 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.GetDocumentRequest) { + return mergeFrom((com.google.firestore.v1.GetDocumentRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.GetDocumentRequest other) { + if (other == com.google.firestore.v1.GetDocumentRequest.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasMask()) { + mergeMask(other.getMask()); + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 3; + break; + } // case 26 + case 42: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 5; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The resource name of the Document to get. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The resource name of the Document to get. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The resource name of the Document to get. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The resource name of the Document to get. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The resource name of the Document to get. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.firestore.v1.DocumentMask mask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + maskBuilder_; + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return Whether the mask field is set. + */ + public boolean hasMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return The mask. + */ + public com.google.firestore.v1.DocumentMask getMask() { + if (maskBuilder_ == null) { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } else { + return maskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mask_ = value; + } else { + maskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (maskBuilder_ == null) { + mask_ = builderForValue.build(); + } else { + maskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public Builder mergeMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && mask_ != null + && mask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getMaskBuilder().mergeFrom(value); + } else { + mask_ = value; + } + } else { + maskBuilder_.mergeFrom(value); + } + if (mask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public Builder clearMask() { + bitField0_ = (bitField0_ & ~0x00000002); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public com.google.firestore.v1.DocumentMask.Builder getMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + if (maskBuilder_ != null) { + return maskBuilder_.getMessageOrBuilder(); + } else { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetMaskFieldBuilder() { + if (maskBuilder_ == null) { + maskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getMask(), getParentForChildren(), isClean()); + mask_ = null; + } + return maskBuilder_; + } + + /** + * + * + *
+     * Reads the document in a transaction.
+     * 
+ * + * bytes transaction = 3; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 3; + } + + /** + * + * + *
+     * Reads the document in a transaction.
+     * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 3) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Reads the document in a transaction.
+     * 
+ * + * bytes transaction = 3; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 3; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Reads the document in a transaction.
+     * 
+ * + * bytes transaction = 3; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 3) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 5) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 5 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 5) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 5) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads the version of the document at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 5)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 5; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.GetDocumentRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.GetDocumentRequest) + private static final com.google.firestore.v1.GetDocumentRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.GetDocumentRequest(); + } + + public static com.google.firestore.v1.GetDocumentRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetDocumentRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.GetDocumentRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java new file mode 100644 index 000000000000..d931475d8c07 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/GetDocumentRequestOrBuilder.java @@ -0,0 +1,179 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface GetDocumentRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.GetDocumentRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The resource name of the Document to get. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * Required. The resource name of the Document to get. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return Whether the mask field is set. + */ + boolean hasMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + * + * @return The mask. + */ + com.google.firestore.v1.DocumentMask getMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 2; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + + /** + * + * + *
+   * Reads the document in a transaction.
+   * 
+ * + * bytes transaction = 3; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Reads the document in a transaction.
+   * 
+ * + * bytes transaction = 3; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Reads the version of the document at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 5; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.GetDocumentRequest.ConsistencySelectorCase getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequest.java new file mode 100644 index 000000000000..dfbd898841fe --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequest.java @@ -0,0 +1,1348 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListCollectionIdsRequest} + */ +@com.google.protobuf.Generated +public final class ListCollectionIdsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListCollectionIdsRequest) + ListCollectionIdsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListCollectionIdsRequest"); + } + + // Use ListCollectionIdsRequest.newBuilder() to construct. + private ListCollectionIdsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListCollectionIdsRequest() { + parent_ = ""; + pageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListCollectionIdsRequest.class, + com.google.firestore.v1.ListCollectionIdsRequest.Builder.class); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_TIME(4), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 4: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent document. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent document. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_ = 0; + + /** + * + * + *
+   * The maximum number of results to return.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * A page token. Must be a value from
+   * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token. Must be a value from
+   * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int READ_TIME_FIELD_NUMBER = 4; + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 4; + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, pageToken_); + } + if (consistencySelectorCase_ == 4) { + output.writeMessage(4, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, pageToken_); + } + if (consistencySelectorCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListCollectionIdsRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.ListCollectionIdsRequest other = + (com.google.firestore.v1.ListCollectionIdsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 4: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + switch (consistencySelectorCase_) { + case 4: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListCollectionIdsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListCollectionIdsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListCollectionIdsRequest) + com.google.firestore.v1.ListCollectionIdsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListCollectionIdsRequest.class, + com.google.firestore.v1.ListCollectionIdsRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.ListCollectionIdsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + pageSize_ = 0; + pageToken_ = ""; + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsRequest getDefaultInstanceForType() { + return com.google.firestore.v1.ListCollectionIdsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsRequest build() { + com.google.firestore.v1.ListCollectionIdsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsRequest buildPartial() { + com.google.firestore.v1.ListCollectionIdsRequest result = + new com.google.firestore.v1.ListCollectionIdsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ListCollectionIdsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageToken_ = pageToken_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.ListCollectionIdsRequest result) { + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 4 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListCollectionIdsRequest) { + return mergeFrom((com.google.firestore.v1.ListCollectionIdsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListCollectionIdsRequest other) { + if (other == com.google.firestore.v1.ListCollectionIdsRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000004; + onChanged(); + } + switch (other.getConsistencySelectorCase()) { + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + pageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 4; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent document. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent document. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent document. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent document. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent document. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private int pageSize_; + + /** + * + * + *
+     * The maximum number of results to return.
+     * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     * 
+ * + * int32 page_size = 2; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     * 
+ * + * int32 page_size = 2; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000002); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * A page token. Must be a value from
+     * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+     * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token. Must be a value from
+     * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+     * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token. Must be a value from
+     * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+     * 
+ * + * string page_token = 3; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token. Must be a value from
+     * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+     * 
+ * + * string page_token = 3; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token. Must be a value from
+     * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+     * 
+ * + * string page_token = 3; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 4; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 4) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 4) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 4) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 4)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 4; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListCollectionIdsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListCollectionIdsRequest) + private static final com.google.firestore.v1.ListCollectionIdsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListCollectionIdsRequest(); + } + + public static com.google.firestore.v1.ListCollectionIdsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListCollectionIdsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java new file mode 100644 index 000000000000..d962cac25a61 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsRequestOrBuilder.java @@ -0,0 +1,153 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListCollectionIdsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListCollectionIdsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent document. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent document. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * The maximum number of results to return.
+   * 
+ * + * int32 page_size = 2; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * A page token. Must be a value from
+   * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+   * 
+ * + * string page_token = 3; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * A page token. Must be a value from
+   * [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse].
+   * 
+ * + * string page_token = 3; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.ListCollectionIdsRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponse.java new file mode 100644 index 000000000000..81ffce917be2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponse.java @@ -0,0 +1,888 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response from
+ * [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListCollectionIdsResponse} + */ +@com.google.protobuf.Generated +public final class ListCollectionIdsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListCollectionIdsResponse) + ListCollectionIdsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListCollectionIdsResponse"); + } + + // Use ListCollectionIdsResponse.newBuilder() to construct. + private ListCollectionIdsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListCollectionIdsResponse() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + nextPageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListCollectionIdsResponse.class, + com.google.firestore.v1.ListCollectionIdsResponse.Builder.class); + } + + public static final int COLLECTION_IDS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + return collectionIds_; + } + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+   * A page token that may be used to continue the list.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token that may be used to continue the list.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < collectionIds_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, collectionIds_.getRaw(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < collectionIds_.size(); i++) { + dataSize += computeStringSizeNoTag(collectionIds_.getRaw(i)); + } + size += dataSize; + size += 1 * getCollectionIdsList().size(); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListCollectionIdsResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.ListCollectionIdsResponse other = + (com.google.firestore.v1.ListCollectionIdsResponse) obj; + + if (!getCollectionIdsList().equals(other.getCollectionIdsList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getCollectionIdsCount() > 0) { + hash = (37 * hash) + COLLECTION_IDS_FIELD_NUMBER; + hash = (53 * hash) + getCollectionIdsList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListCollectionIdsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response from
+   * [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListCollectionIdsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListCollectionIdsResponse) + com.google.firestore.v1.ListCollectionIdsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListCollectionIdsResponse.class, + com.google.firestore.v1.ListCollectionIdsResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.ListCollectionIdsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListCollectionIdsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsResponse getDefaultInstanceForType() { + return com.google.firestore.v1.ListCollectionIdsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsResponse build() { + com.google.firestore.v1.ListCollectionIdsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsResponse buildPartial() { + com.google.firestore.v1.ListCollectionIdsResponse result = + new com.google.firestore.v1.ListCollectionIdsResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ListCollectionIdsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + collectionIds_.makeImmutable(); + result.collectionIds_ = collectionIds_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListCollectionIdsResponse) { + return mergeFrom((com.google.firestore.v1.ListCollectionIdsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListCollectionIdsResponse other) { + if (other == com.google.firestore.v1.ListCollectionIdsResponse.getDefaultInstance()) + return this; + if (!other.collectionIds_.isEmpty()) { + if (collectionIds_.isEmpty()) { + collectionIds_ = other.collectionIds_; + bitField0_ |= 0x00000001; + } else { + ensureCollectionIdsIsMutable(); + collectionIds_.addAll(other.collectionIds_); + } + onChanged(); + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureCollectionIdsIsMutable(); + collectionIds_.add(s); + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.LazyStringArrayList collectionIds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureCollectionIdsIsMutable() { + if (!collectionIds_.isModifiable()) { + collectionIds_ = new com.google.protobuf.LazyStringArrayList(collectionIds_); + } + bitField0_ |= 0x00000001; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @return A list containing the collectionIds. + */ + public com.google.protobuf.ProtocolStringList getCollectionIdsList() { + collectionIds_.makeImmutable(); + return collectionIds_; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @return The count of collectionIds. + */ + public int getCollectionIdsCount() { + return collectionIds_.size(); + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + public java.lang.String getCollectionIds(int index) { + return collectionIds_.get(index); + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + public com.google.protobuf.ByteString getCollectionIdsBytes(int index) { + return collectionIds_.getByteString(index); + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index to set the value at. + * @param value The collectionIds to set. + * @return This builder for chaining. + */ + public Builder setCollectionIds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param value The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param values The collectionIds to add. + * @return This builder for chaining. + */ + public Builder addAllCollectionIds(java.lang.Iterable values) { + ensureCollectionIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, collectionIds_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @return This builder for chaining. + */ + public Builder clearCollectionIds() { + collectionIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The collection ids.
+     * 
+ * + * repeated string collection_ids = 1; + * + * @param value The bytes of the collectionIds to add. + * @return This builder for chaining. + */ + public Builder addCollectionIdsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureCollectionIdsIsMutable(); + collectionIds_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * A page token that may be used to continue the list.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to continue the list.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to continue the list.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to continue the list.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to continue the list.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListCollectionIdsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListCollectionIdsResponse) + private static final com.google.firestore.v1.ListCollectionIdsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListCollectionIdsResponse(); + } + + public static com.google.firestore.v1.ListCollectionIdsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListCollectionIdsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListCollectionIdsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponseOrBuilder.java new file mode 100644 index 000000000000..892d810a7a40 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListCollectionIdsResponseOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListCollectionIdsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListCollectionIdsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @return A list containing the collectionIds. + */ + java.util.List getCollectionIdsList(); + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @return The count of collectionIds. + */ + int getCollectionIdsCount(); + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the element to return. + * @return The collectionIds at the given index. + */ + java.lang.String getCollectionIds(int index); + + /** + * + * + *
+   * The collection ids.
+   * 
+ * + * repeated string collection_ids = 1; + * + * @param index The index of the value to return. + * @return The bytes of the collectionIds at the given index. + */ + com.google.protobuf.ByteString getCollectionIdsBytes(int index); + + /** + * + * + *
+   * A page token that may be used to continue the list.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * A page token that may be used to continue the list.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java new file mode 100644 index 000000000000..91506f8b0547 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequest.java @@ -0,0 +1,2453 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListDocumentsRequest} + */ +@com.google.protobuf.Generated +public final class ListDocumentsRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListDocumentsRequest) + ListDocumentsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListDocumentsRequest"); + } + + // Use ListDocumentsRequest.newBuilder() to construct. + private ListDocumentsRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListDocumentsRequest() { + parent_ = ""; + collectionId_ = ""; + pageToken_ = ""; + orderBy_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListDocumentsRequest.class, + com.google.firestore.v1.ListDocumentsRequest.Builder.class); + } + + private int bitField0_; + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(8), + READ_TIME(10), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 8: + return TRANSACTION; + case 10: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int COLLECTION_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object collectionId_ = ""; + + /** + * + * + *
+   * Optional. The collection ID, relative to `parent`, to list.
+   *
+   * For example: `chatrooms` or `messages`.
+   *
+   * This is optional, and when not provided, Firestore will list documents
+   * from all collections under the provided `parent`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The collectionId. + */ + @java.lang.Override + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } + } + + /** + * + * + *
+   * Optional. The collection ID, relative to `parent`, to list.
+   *
+   * For example: `chatrooms` or `messages`.
+   *
+   * This is optional, and when not provided, Firestore will list documents
+   * from all collections under the provided `parent`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for collectionId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 3; + private int pageSize_ = 0; + + /** + * + * + *
+   * Optional. The maximum number of documents to return in a single response.
+   *
+   * Firestore may return fewer than this value.
+   * 
+ * + * int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * Optional. A page token, received from a previous `ListDocuments` response.
+   *
+   * Provide this to retrieve the subsequent page. When paginating, all other
+   * parameters (with the exception of `page_size`) must match the values set
+   * in the request that generated the page token.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * Optional. A page token, received from a previous `ListDocuments` response.
+   *
+   * Provide this to retrieve the subsequent page. When paginating, all other
+   * parameters (with the exception of `page_size`) must match the values set
+   * in the request that generated the page token.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ORDER_BY_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private volatile java.lang.Object orderBy_ = ""; + + /** + * + * + *
+   * Optional. The optional ordering of the documents to return.
+   *
+   * For example: `priority desc, __name__ desc`.
+   *
+   * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+   * used in Firestore queries but in a string representation. When absent,
+   * documents are ordered based on `__name__ ASC`.
+   * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The orderBy. + */ + @java.lang.Override + public java.lang.String getOrderBy() { + java.lang.Object ref = orderBy_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + orderBy_ = s; + return s; + } + } + + /** + * + * + *
+   * Optional. The optional ordering of the documents to return.
+   *
+   * For example: `priority desc, __name__ desc`.
+   *
+   * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+   * used in Firestore queries but in a string representation. When absent,
+   * documents are ordered based on `__name__ ASC`.
+   * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for orderBy. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOrderByBytes() { + java.lang.Object ref = orderBy_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + orderBy_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int MASK_FIELD_NUMBER = 7; + private com.google.firestore.v1.DocumentMask mask_; + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the mask field is set. + */ + @java.lang.Override + public boolean hasMask() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getMask() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + public static final int TRANSACTION_FIELD_NUMBER = 8; + + /** + * + * + *
+   * Perform the read as part of an already active transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 8; + } + + /** + * + * + *
+   * Perform the read as part of an already active transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 8) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int READ_TIME_FIELD_NUMBER = 10; + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 10; + } + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 10) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 10) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + public static final int SHOW_MISSING_FIELD_NUMBER = 12; + private boolean showMissing_ = false; + + /** + * + * + *
+   * If the list should show missing documents.
+   *
+   * A document is missing if it does not exist, but there are sub-documents
+   * nested underneath it. When true, such missing documents will be returned
+   * with a key but will not have fields,
+   * [`create_time`][google.firestore.v1.Document.create_time], or
+   * [`update_time`][google.firestore.v1.Document.update_time] set.
+   *
+   * Requests with `show_missing` may not specify `where` or `order_by`.
+   * 
+ * + * bool show_missing = 12; + * + * @return The showMissing. + */ + @java.lang.Override + public boolean getShowMissing() { + return showMissing_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionId_); + } + if (pageSize_ != 0) { + output.writeInt32(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, pageToken_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(orderBy_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 6, orderBy_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(7, getMask()); + } + if (consistencySelectorCase_ == 8) { + output.writeBytes(8, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 10) { + output.writeMessage(10, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (showMissing_ != false) { + output.writeBool(12, showMissing_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, collectionId_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(3, pageSize_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pageToken_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(orderBy_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(6, orderBy_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getMask()); + } + if (consistencySelectorCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 8, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 10) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 10, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (showMissing_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(12, showMissing_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListDocumentsRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.ListDocumentsRequest other = + (com.google.firestore.v1.ListDocumentsRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getCollectionId().equals(other.getCollectionId())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!getOrderBy().equals(other.getOrderBy())) return false; + if (hasMask() != other.hasMask()) return false; + if (hasMask()) { + if (!getMask().equals(other.getMask())) return false; + } + if (getShowMissing() != other.getShowMissing()) return false; + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 8: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 10: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + COLLECTION_ID_FIELD_NUMBER; + hash = (53 * hash) + getCollectionId().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (37 * hash) + ORDER_BY_FIELD_NUMBER; + hash = (53 * hash) + getOrderBy().hashCode(); + if (hasMask()) { + hash = (37 * hash) + MASK_FIELD_NUMBER; + hash = (53 * hash) + getMask().hashCode(); + } + hash = (37 * hash) + SHOW_MISSING_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getShowMissing()); + switch (consistencySelectorCase_) { + case 8: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 10: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListDocumentsRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListDocumentsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListDocumentsRequest) + com.google.firestore.v1.ListDocumentsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListDocumentsRequest.class, + com.google.firestore.v1.ListDocumentsRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.ListDocumentsRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + collectionId_ = ""; + pageSize_ = 0; + pageToken_ = ""; + orderBy_ = ""; + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + showMissing_ = false; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsRequest getDefaultInstanceForType() { + return com.google.firestore.v1.ListDocumentsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsRequest build() { + com.google.firestore.v1.ListDocumentsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsRequest buildPartial() { + com.google.firestore.v1.ListDocumentsRequest result = + new com.google.firestore.v1.ListDocumentsRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ListDocumentsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.collectionId_ = collectionId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.pageToken_ = pageToken_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.orderBy_ = orderBy_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000020) != 0)) { + result.mask_ = maskBuilder_ == null ? mask_ : maskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.showMissing_ = showMissing_; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.ListDocumentsRequest result) { + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 10 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListDocumentsRequest) { + return mergeFrom((com.google.firestore.v1.ListDocumentsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListDocumentsRequest other) { + if (other == com.google.firestore.v1.ListDocumentsRequest.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getCollectionId().isEmpty()) { + collectionId_ = other.collectionId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (!other.getOrderBy().isEmpty()) { + orderBy_ = other.orderBy_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (other.hasMask()) { + mergeMask(other.getMask()); + } + if (other.getShowMissing() != false) { + setShowMissing(other.getShowMissing()); + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + collectionId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + pageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 50: + { + orderBy_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 50 + case 58: + { + input.readMessage(internalGetMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 58 + case 66: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 8; + break; + } // case 66 + case 82: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 10; + break; + } // case 82 + case 96: + { + showMissing_ = input.readBool(); + bitField0_ |= 0x00000100; + break; + } // case 96 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     *
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object collectionId_ = ""; + + /** + * + * + *
+     * Optional. The collection ID, relative to `parent`, to list.
+     *
+     * For example: `chatrooms` or `messages`.
+     *
+     * This is optional, and when not provided, Firestore will list documents
+     * from all collections under the provided `parent`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The collectionId. + */ + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Optional. The collection ID, relative to `parent`, to list.
+     *
+     * For example: `chatrooms` or `messages`.
+     *
+     * This is optional, and when not provided, Firestore will list documents
+     * from all collections under the provided `parent`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for collectionId. + */ + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Optional. The collection ID, relative to `parent`, to list.
+     *
+     * For example: `chatrooms` or `messages`.
+     *
+     * This is optional, and when not provided, Firestore will list documents
+     * from all collections under the provided `parent`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + collectionId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The collection ID, relative to `parent`, to list.
+     *
+     * For example: `chatrooms` or `messages`.
+     *
+     * This is optional, and when not provided, Firestore will list documents
+     * from all collections under the provided `parent`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearCollectionId() { + collectionId_ = getDefaultInstance().getCollectionId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The collection ID, relative to `parent`, to list.
+     *
+     * For example: `chatrooms` or `messages`.
+     *
+     * This is optional, and when not provided, Firestore will list documents
+     * from all collections under the provided `parent`.
+     * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + collectionId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private int pageSize_; + + /** + * + * + *
+     * Optional. The maximum number of documents to return in a single response.
+     *
+     * Firestore may return fewer than this value.
+     * 
+ * + * int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * Optional. The maximum number of documents to return in a single response.
+     *
+     * Firestore may return fewer than this value.
+     * 
+ * + * int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The maximum number of documents to return in a single response.
+     *
+     * Firestore may return fewer than this value.
+     * 
+ * + * int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000004); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * Optional. A page token, received from a previous `ListDocuments` response.
+     *
+     * Provide this to retrieve the subsequent page. When paginating, all other
+     * parameters (with the exception of `page_size`) must match the values set
+     * in the request that generated the page token.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Optional. A page token, received from a previous `ListDocuments` response.
+     *
+     * Provide this to retrieve the subsequent page. When paginating, all other
+     * parameters (with the exception of `page_size`) must match the values set
+     * in the request that generated the page token.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Optional. A page token, received from a previous `ListDocuments` response.
+     *
+     * Provide this to retrieve the subsequent page. When paginating, all other
+     * parameters (with the exception of `page_size`) must match the values set
+     * in the request that generated the page token.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. A page token, received from a previous `ListDocuments` response.
+     *
+     * Provide this to retrieve the subsequent page. When paginating, all other
+     * parameters (with the exception of `page_size`) must match the values set
+     * in the request that generated the page token.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. A page token, received from a previous `ListDocuments` response.
+     *
+     * Provide this to retrieve the subsequent page. When paginating, all other
+     * parameters (with the exception of `page_size`) must match the values set
+     * in the request that generated the page token.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private java.lang.Object orderBy_ = ""; + + /** + * + * + *
+     * Optional. The optional ordering of the documents to return.
+     *
+     * For example: `priority desc, __name__ desc`.
+     *
+     * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+     * used in Firestore queries but in a string representation. When absent,
+     * documents are ordered based on `__name__ ASC`.
+     * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The orderBy. + */ + public java.lang.String getOrderBy() { + java.lang.Object ref = orderBy_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + orderBy_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Optional. The optional ordering of the documents to return.
+     *
+     * For example: `priority desc, __name__ desc`.
+     *
+     * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+     * used in Firestore queries but in a string representation. When absent,
+     * documents are ordered based on `__name__ ASC`.
+     * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for orderBy. + */ + public com.google.protobuf.ByteString getOrderByBytes() { + java.lang.Object ref = orderBy_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + orderBy_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Optional. The optional ordering of the documents to return.
+     *
+     * For example: `priority desc, __name__ desc`.
+     *
+     * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+     * used in Firestore queries but in a string representation. When absent,
+     * documents are ordered based on `__name__ ASC`.
+     * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The orderBy to set. + * @return This builder for chaining. + */ + public Builder setOrderBy(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + orderBy_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The optional ordering of the documents to return.
+     *
+     * For example: `priority desc, __name__ desc`.
+     *
+     * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+     * used in Firestore queries but in a string representation. When absent,
+     * documents are ordered based on `__name__ ASC`.
+     * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearOrderBy() { + orderBy_ = getDefaultInstance().getOrderBy(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The optional ordering of the documents to return.
+     *
+     * For example: `priority desc, __name__ desc`.
+     *
+     * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+     * used in Firestore queries but in a string representation. When absent,
+     * documents are ordered based on `__name__ ASC`.
+     * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for orderBy to set. + * @return This builder for chaining. + */ + public Builder setOrderByBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + orderBy_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.firestore.v1.DocumentMask mask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + maskBuilder_; + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the mask field is set. + */ + public boolean hasMask() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mask. + */ + public com.google.firestore.v1.DocumentMask getMask() { + if (maskBuilder_ == null) { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } else { + return maskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mask_ = value; + } else { + maskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (maskBuilder_ == null) { + mask_ = builderForValue.build(); + } else { + maskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && mask_ != null + && mask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getMaskBuilder().mergeFrom(value); + } else { + mask_ = value; + } + } else { + maskBuilder_.mergeFrom(value); + } + if (mask_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearMask() { + bitField0_ = (bitField0_ & ~0x00000020); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.DocumentMask.Builder getMaskBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + if (maskBuilder_ != null) { + return maskBuilder_.getMessageOrBuilder(); + } else { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + } + + /** + * + * + *
+     * Optional. The fields to return. If not set, returns all fields.
+     *
+     * If a document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetMaskFieldBuilder() { + if (maskBuilder_ == null) { + maskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getMask(), getParentForChildren(), isClean()); + mask_ = null; + } + return maskBuilder_; + } + + /** + * + * + *
+     * Perform the read as part of an already active transaction.
+     * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 8; + } + + /** + * + * + *
+     * Perform the read as part of an already active transaction.
+     * 
+ * + * bytes transaction = 8; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 8) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Perform the read as part of an already active transaction.
+     * 
+ * + * bytes transaction = 8; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 8; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Perform the read as part of an already active transaction.
+     * 
+ * + * bytes transaction = 8; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 8) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 10; + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 10) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 10) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 10 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 10) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 10) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 10) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 10) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 10) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Perform the read at the provided time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 10)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 10; + onChanged(); + return readTimeBuilder_; + } + + private boolean showMissing_; + + /** + * + * + *
+     * If the list should show missing documents.
+     *
+     * A document is missing if it does not exist, but there are sub-documents
+     * nested underneath it. When true, such missing documents will be returned
+     * with a key but will not have fields,
+     * [`create_time`][google.firestore.v1.Document.create_time], or
+     * [`update_time`][google.firestore.v1.Document.update_time] set.
+     *
+     * Requests with `show_missing` may not specify `where` or `order_by`.
+     * 
+ * + * bool show_missing = 12; + * + * @return The showMissing. + */ + @java.lang.Override + public boolean getShowMissing() { + return showMissing_; + } + + /** + * + * + *
+     * If the list should show missing documents.
+     *
+     * A document is missing if it does not exist, but there are sub-documents
+     * nested underneath it. When true, such missing documents will be returned
+     * with a key but will not have fields,
+     * [`create_time`][google.firestore.v1.Document.create_time], or
+     * [`update_time`][google.firestore.v1.Document.update_time] set.
+     *
+     * Requests with `show_missing` may not specify `where` or `order_by`.
+     * 
+ * + * bool show_missing = 12; + * + * @param value The showMissing to set. + * @return This builder for chaining. + */ + public Builder setShowMissing(boolean value) { + + showMissing_ = value; + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * If the list should show missing documents.
+     *
+     * A document is missing if it does not exist, but there are sub-documents
+     * nested underneath it. When true, such missing documents will be returned
+     * with a key but will not have fields,
+     * [`create_time`][google.firestore.v1.Document.create_time], or
+     * [`update_time`][google.firestore.v1.Document.update_time] set.
+     *
+     * Requests with `show_missing` may not specify `where` or `order_by`.
+     * 
+ * + * bool show_missing = 12; + * + * @return This builder for chaining. + */ + public Builder clearShowMissing() { + bitField0_ = (bitField0_ & ~0x00000100); + showMissing_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListDocumentsRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListDocumentsRequest) + private static final com.google.firestore.v1.ListDocumentsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListDocumentsRequest(); + } + + public static com.google.firestore.v1.ListDocumentsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListDocumentsRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java new file mode 100644 index 000000000000..66ca1c55f909 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsRequestOrBuilder.java @@ -0,0 +1,336 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListDocumentsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListDocumentsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   *
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Optional. The collection ID, relative to `parent`, to list.
+   *
+   * For example: `chatrooms` or `messages`.
+   *
+   * This is optional, and when not provided, Firestore will list documents
+   * from all collections under the provided `parent`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The collectionId. + */ + java.lang.String getCollectionId(); + + /** + * + * + *
+   * Optional. The collection ID, relative to `parent`, to list.
+   *
+   * For example: `chatrooms` or `messages`.
+   *
+   * This is optional, and when not provided, Firestore will list documents
+   * from all collections under the provided `parent`.
+   * 
+ * + * string collection_id = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for collectionId. + */ + com.google.protobuf.ByteString getCollectionIdBytes(); + + /** + * + * + *
+   * Optional. The maximum number of documents to return in a single response.
+   *
+   * Firestore may return fewer than this value.
+   * 
+ * + * int32 page_size = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * Optional. A page token, received from a previous `ListDocuments` response.
+   *
+   * Provide this to retrieve the subsequent page. When paginating, all other
+   * parameters (with the exception of `page_size`) must match the values set
+   * in the request that generated the page token.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * Optional. A page token, received from a previous `ListDocuments` response.
+   *
+   * Provide this to retrieve the subsequent page. When paginating, all other
+   * parameters (with the exception of `page_size`) must match the values set
+   * in the request that generated the page token.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); + + /** + * + * + *
+   * Optional. The optional ordering of the documents to return.
+   *
+   * For example: `priority desc, __name__ desc`.
+   *
+   * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+   * used in Firestore queries but in a string representation. When absent,
+   * documents are ordered based on `__name__ ASC`.
+   * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The orderBy. + */ + java.lang.String getOrderBy(); + + /** + * + * + *
+   * Optional. The optional ordering of the documents to return.
+   *
+   * For example: `priority desc, __name__ desc`.
+   *
+   * This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by]
+   * used in Firestore queries but in a string representation. When absent,
+   * documents are ordered based on `__name__ ASC`.
+   * 
+ * + * string order_by = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for orderBy. + */ + com.google.protobuf.ByteString getOrderByBytes(); + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the mask field is set. + */ + boolean hasMask(); + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The mask. + */ + com.google.firestore.v1.DocumentMask getMask(); + + /** + * + * + *
+   * Optional. The fields to return. If not set, returns all fields.
+   *
+   * If a document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + + /** + * + * + *
+   * Perform the read as part of an already active transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Perform the read as part of an already active transaction.
+   * 
+ * + * bytes transaction = 8; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Perform the read at the provided time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 10; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * If the list should show missing documents.
+   *
+   * A document is missing if it does not exist, but there are sub-documents
+   * nested underneath it. When true, such missing documents will be returned
+   * with a key but will not have fields,
+   * [`create_time`][google.firestore.v1.Document.create_time], or
+   * [`update_time`][google.firestore.v1.Document.update_time] set.
+   *
+   * Requests with `show_missing` may not specify `where` or `order_by`.
+   * 
+ * + * bool show_missing = 12; + * + * @return The showMissing. + */ + boolean getShowMissing(); + + com.google.firestore.v1.ListDocumentsRequest.ConsistencySelectorCase getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponse.java new file mode 100644 index 000000000000..4a1624fe4046 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponse.java @@ -0,0 +1,1123 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for
+ * [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListDocumentsResponse} + */ +@com.google.protobuf.Generated +public final class ListDocumentsResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListDocumentsResponse) + ListDocumentsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListDocumentsResponse"); + } + + // Use ListDocumentsResponse.newBuilder() to construct. + private ListDocumentsResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListDocumentsResponse() { + documents_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListDocumentsResponse.class, + com.google.firestore.v1.ListDocumentsResponse.Builder.class); + } + + public static final int DOCUMENTS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List documents_; + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + @java.lang.Override + public java.util.List getDocumentsList() { + return documents_; + } + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + @java.lang.Override + public java.util.List + getDocumentsOrBuilderList() { + return documents_; + } + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + @java.lang.Override + public int getDocumentsCount() { + return documents_.size(); + } + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocuments(int index) { + return documents_.get(index); + } + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentsOrBuilder(int index) { + return documents_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+   * A token to retrieve the next page of documents.
+   *
+   * If this field is omitted, there are no subsequent pages.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A token to retrieve the next page of documents.
+   *
+   * If this field is omitted, there are no subsequent pages.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < documents_.size(); i++) { + output.writeMessage(1, documents_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < documents_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, documents_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListDocumentsResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.ListDocumentsResponse other = + (com.google.firestore.v1.ListDocumentsResponse) obj; + + if (!getDocumentsList().equals(other.getDocumentsList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDocumentsCount() > 0) { + hash = (37 * hash) + DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getDocumentsList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListDocumentsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListDocumentsResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListDocumentsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListDocumentsResponse) + com.google.firestore.v1.ListDocumentsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListDocumentsResponse.class, + com.google.firestore.v1.ListDocumentsResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.ListDocumentsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (documentsBuilder_ == null) { + documents_ = java.util.Collections.emptyList(); + } else { + documents_ = null; + documentsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListDocumentsResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsResponse getDefaultInstanceForType() { + return com.google.firestore.v1.ListDocumentsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsResponse build() { + com.google.firestore.v1.ListDocumentsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsResponse buildPartial() { + com.google.firestore.v1.ListDocumentsResponse result = + new com.google.firestore.v1.ListDocumentsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.ListDocumentsResponse result) { + if (documentsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + documents_ = java.util.Collections.unmodifiableList(documents_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.documents_ = documents_; + } else { + result.documents_ = documentsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.ListDocumentsResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListDocumentsResponse) { + return mergeFrom((com.google.firestore.v1.ListDocumentsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListDocumentsResponse other) { + if (other == com.google.firestore.v1.ListDocumentsResponse.getDefaultInstance()) return this; + if (documentsBuilder_ == null) { + if (!other.documents_.isEmpty()) { + if (documents_.isEmpty()) { + documents_ = other.documents_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureDocumentsIsMutable(); + documents_.addAll(other.documents_); + } + onChanged(); + } + } else { + if (!other.documents_.isEmpty()) { + if (documentsBuilder_.isEmpty()) { + documentsBuilder_.dispose(); + documentsBuilder_ = null; + documents_ = other.documents_; + bitField0_ = (bitField0_ & ~0x00000001); + documentsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetDocumentsFieldBuilder() + : null; + } else { + documentsBuilder_.addAllMessages(other.documents_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Document m = + input.readMessage(com.google.firestore.v1.Document.parser(), extensionRegistry); + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + documents_.add(m); + } else { + documentsBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List documents_ = + java.util.Collections.emptyList(); + + private void ensureDocumentsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + documents_ = new java.util.ArrayList(documents_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentsBuilder_; + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public java.util.List getDocumentsList() { + if (documentsBuilder_ == null) { + return java.util.Collections.unmodifiableList(documents_); + } else { + return documentsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public int getDocumentsCount() { + if (documentsBuilder_ == null) { + return documents_.size(); + } else { + return documentsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public com.google.firestore.v1.Document getDocuments(int index) { + if (documentsBuilder_ == null) { + return documents_.get(index); + } else { + return documentsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder setDocuments(int index, com.google.firestore.v1.Document value) { + if (documentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.set(index, value); + onChanged(); + } else { + documentsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder setDocuments( + int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + documents_.set(index, builderForValue.build()); + onChanged(); + } else { + documentsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder addDocuments(com.google.firestore.v1.Document value) { + if (documentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.add(value); + onChanged(); + } else { + documentsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder addDocuments(int index, com.google.firestore.v1.Document value) { + if (documentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.add(index, value); + onChanged(); + } else { + documentsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder addDocuments(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + documents_.add(builderForValue.build()); + onChanged(); + } else { + documentsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder addDocuments( + int index, com.google.firestore.v1.Document.Builder builderForValue) { + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + documents_.add(index, builderForValue.build()); + onChanged(); + } else { + documentsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder addAllDocuments( + java.lang.Iterable values) { + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documents_); + onChanged(); + } else { + documentsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder clearDocuments() { + if (documentsBuilder_ == null) { + documents_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + documentsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public Builder removeDocuments(int index) { + if (documentsBuilder_ == null) { + ensureDocumentsIsMutable(); + documents_.remove(index); + onChanged(); + } else { + documentsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public com.google.firestore.v1.Document.Builder getDocumentsBuilder(int index) { + return internalGetDocumentsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public com.google.firestore.v1.DocumentOrBuilder getDocumentsOrBuilder(int index) { + if (documentsBuilder_ == null) { + return documents_.get(index); + } else { + return documentsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public java.util.List + getDocumentsOrBuilderList() { + if (documentsBuilder_ != null) { + return documentsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(documents_); + } + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public com.google.firestore.v1.Document.Builder addDocumentsBuilder() { + return internalGetDocumentsFieldBuilder() + .addBuilder(com.google.firestore.v1.Document.getDefaultInstance()); + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public com.google.firestore.v1.Document.Builder addDocumentsBuilder(int index) { + return internalGetDocumentsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Document.getDefaultInstance()); + } + + /** + * + * + *
+     * The Documents found.
+     * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + public java.util.List getDocumentsBuilderList() { + return internalGetDocumentsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentsFieldBuilder() { + if (documentsBuilder_ == null) { + documentsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + documents_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + documents_ = null; + } + return documentsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * A token to retrieve the next page of documents.
+     *
+     * If this field is omitted, there are no subsequent pages.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A token to retrieve the next page of documents.
+     *
+     * If this field is omitted, there are no subsequent pages.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A token to retrieve the next page of documents.
+     *
+     * If this field is omitted, there are no subsequent pages.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A token to retrieve the next page of documents.
+     *
+     * If this field is omitted, there are no subsequent pages.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * A token to retrieve the next page of documents.
+     *
+     * If this field is omitted, there are no subsequent pages.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListDocumentsResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListDocumentsResponse) + private static final com.google.firestore.v1.ListDocumentsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListDocumentsResponse(); + } + + public static com.google.firestore.v1.ListDocumentsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListDocumentsResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListDocumentsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponseOrBuilder.java new file mode 100644 index 000000000000..4befbd04fa44 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListDocumentsResponseOrBuilder.java @@ -0,0 +1,113 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListDocumentsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListDocumentsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + java.util.List getDocumentsList(); + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + com.google.firestore.v1.Document getDocuments(int index); + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + int getDocumentsCount(); + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + java.util.List getDocumentsOrBuilderList(); + + /** + * + * + *
+   * The Documents found.
+   * 
+ * + * repeated .google.firestore.v1.Document documents = 1; + */ + com.google.firestore.v1.DocumentOrBuilder getDocumentsOrBuilder(int index); + + /** + * + * + *
+   * A token to retrieve the next page of documents.
+   *
+   * If this field is omitted, there are no subsequent pages.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * A token to retrieve the next page of documents.
+   *
+   * If this field is omitted, there are no subsequent pages.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java new file mode 100644 index 000000000000..d508dda2e694 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequest.java @@ -0,0 +1,1474 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen]
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListenRequest} + */ +@com.google.protobuf.Generated +public final class ListenRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListenRequest) + ListenRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListenRequest"); + } + + // Use ListenRequest.newBuilder() to construct. + private ListenRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListenRequest() { + database_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 4: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListenRequest.class, + com.google.firestore.v1.ListenRequest.Builder.class); + } + + private int targetChangeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object targetChange_; + + public enum TargetChangeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + ADD_TARGET(2), + REMOVE_TARGET(3), + TARGETCHANGE_NOT_SET(0); + private final int value; + + private TargetChangeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TargetChangeCase valueOf(int value) { + return forNumber(value); + } + + public static TargetChangeCase forNumber(int value) { + switch (value) { + case 2: + return ADD_TARGET; + case 3: + return REMOVE_TARGET; + case 0: + return TARGETCHANGE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TargetChangeCase getTargetChangeCase() { + return TargetChangeCase.forNumber(targetChangeCase_); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ADD_TARGET_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return Whether the addTarget field is set. + */ + @java.lang.Override + public boolean hasAddTarget() { + return targetChangeCase_ == 2; + } + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return The addTarget. + */ + @java.lang.Override + public com.google.firestore.v1.Target getAddTarget() { + if (targetChangeCase_ == 2) { + return (com.google.firestore.v1.Target) targetChange_; + } + return com.google.firestore.v1.Target.getDefaultInstance(); + } + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TargetOrBuilder getAddTargetOrBuilder() { + if (targetChangeCase_ == 2) { + return (com.google.firestore.v1.Target) targetChange_; + } + return com.google.firestore.v1.Target.getDefaultInstance(); + } + + 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; + } + + /** + * + * + *
+   * The ID of a target to remove from this stream.
+   * 
+ * + * int32 remove_target = 3; + * + * @return The removeTarget. + */ + @java.lang.Override + public int getRemoveTarget() { + if (targetChangeCase_ == 3) { + return (java.lang.Integer) targetChange_; + } + return 0; + } + + public static final int LABELS_FIELD_NUMBER = 4; + + private static final class LabelsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_LabelsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (targetChangeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.Target) targetChange_); + } + if (targetChangeCase_ == 3) { + output.writeInt32(3, (int) ((java.lang.Integer) targetChange_)); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 4); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (targetChangeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.Target) targetChange_); + } + if (targetChangeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeInt32Size( + 3, (int) ((java.lang.Integer) targetChange_)); + } + for (java.util.Map.Entry entry : + internalGetLabels().getMap().entrySet()) { + com.google.protobuf.MapEntry labels__ = + LabelsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, labels__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListenRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.ListenRequest other = (com.google.firestore.v1.ListenRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) return false; + if (!getTargetChangeCase().equals(other.getTargetChangeCase())) return false; + switch (targetChangeCase_) { + case 2: + if (!getAddTarget().equals(other.getAddTarget())) return false; + break; + case 3: + if (getRemoveTarget() != other.getRemoveTarget()) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + switch (targetChangeCase_) { + case 2: + hash = (37 * hash) + ADD_TARGET_FIELD_NUMBER; + hash = (53 * hash) + getAddTarget().hashCode(); + break; + case 3: + hash = (37 * hash) + REMOVE_TARGET_FIELD_NUMBER; + hash = (53 * hash) + getRemoveTarget(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListenRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenRequest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListenRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListenRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen]
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListenRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListenRequest) + com.google.firestore.v1.ListenRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 4: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 4: + return internalGetMutableLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListenRequest.class, + com.google.firestore.v1.ListenRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.ListenRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + if (addTargetBuilder_ != null) { + addTargetBuilder_.clear(); + } + internalGetMutableLabels().clear(); + targetChangeCase_ = 0; + targetChange_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListenRequest getDefaultInstanceForType() { + return com.google.firestore.v1.ListenRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListenRequest build() { + com.google.firestore.v1.ListenRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListenRequest buildPartial() { + com.google.firestore.v1.ListenRequest result = + new com.google.firestore.v1.ListenRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ListenRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + } + + private void buildPartialOneofs(com.google.firestore.v1.ListenRequest result) { + result.targetChangeCase_ = targetChangeCase_; + result.targetChange_ = this.targetChange_; + if (targetChangeCase_ == 2 && addTargetBuilder_ != null) { + result.targetChange_ = addTargetBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListenRequest) { + return mergeFrom((com.google.firestore.v1.ListenRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListenRequest other) { + if (other == com.google.firestore.v1.ListenRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000008; + switch (other.getTargetChangeCase()) { + case ADD_TARGET: + { + mergeAddTarget(other.getAddTarget()); + break; + } + case REMOVE_TARGET: + { + setRemoveTarget(other.getRemoveTarget()); + break; + } + case TARGETCHANGE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetAddTargetFieldBuilder().getBuilder(), extensionRegistry); + targetChangeCase_ = 2; + break; + } // case 18 + case 24: + { + targetChange_ = input.readInt32(); + targetChangeCase_ = 3; + break; + } // case 24 + case 34: + { + com.google.protobuf.MapEntry labels__ = + input.readMessage( + LabelsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableLabels() + .getMutableMap() + .put(labels__.getKey(), labels__.getValue()); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int targetChangeCase_ = 0; + private java.lang.Object targetChange_; + + public TargetChangeCase getTargetChangeCase() { + return TargetChangeCase.forNumber(targetChangeCase_); + } + + public Builder clearTargetChange() { + targetChangeCase_ = 0; + targetChange_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target, + com.google.firestore.v1.Target.Builder, + com.google.firestore.v1.TargetOrBuilder> + addTargetBuilder_; + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return Whether the addTarget field is set. + */ + @java.lang.Override + public boolean hasAddTarget() { + return targetChangeCase_ == 2; + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return The addTarget. + */ + @java.lang.Override + public com.google.firestore.v1.Target getAddTarget() { + if (addTargetBuilder_ == null) { + if (targetChangeCase_ == 2) { + return (com.google.firestore.v1.Target) targetChange_; + } + return com.google.firestore.v1.Target.getDefaultInstance(); + } else { + if (targetChangeCase_ == 2) { + return addTargetBuilder_.getMessage(); + } + return com.google.firestore.v1.Target.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + public Builder setAddTarget(com.google.firestore.v1.Target value) { + if (addTargetBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + targetChange_ = value; + onChanged(); + } else { + addTargetBuilder_.setMessage(value); + } + targetChangeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + public Builder setAddTarget(com.google.firestore.v1.Target.Builder builderForValue) { + if (addTargetBuilder_ == null) { + targetChange_ = builderForValue.build(); + onChanged(); + } else { + addTargetBuilder_.setMessage(builderForValue.build()); + } + targetChangeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + public Builder mergeAddTarget(com.google.firestore.v1.Target value) { + if (addTargetBuilder_ == null) { + if (targetChangeCase_ == 2 + && targetChange_ != com.google.firestore.v1.Target.getDefaultInstance()) { + targetChange_ = + com.google.firestore.v1.Target.newBuilder( + (com.google.firestore.v1.Target) targetChange_) + .mergeFrom(value) + .buildPartial(); + } else { + targetChange_ = value; + } + onChanged(); + } else { + if (targetChangeCase_ == 2) { + addTargetBuilder_.mergeFrom(value); + } else { + addTargetBuilder_.setMessage(value); + } + } + targetChangeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + public Builder clearAddTarget() { + if (addTargetBuilder_ == null) { + if (targetChangeCase_ == 2) { + targetChangeCase_ = 0; + targetChange_ = null; + onChanged(); + } + } else { + if (targetChangeCase_ == 2) { + targetChangeCase_ = 0; + targetChange_ = null; + } + addTargetBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + public com.google.firestore.v1.Target.Builder getAddTargetBuilder() { + return internalGetAddTargetFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TargetOrBuilder getAddTargetOrBuilder() { + if ((targetChangeCase_ == 2) && (addTargetBuilder_ != null)) { + return addTargetBuilder_.getMessageOrBuilder(); + } else { + if (targetChangeCase_ == 2) { + return (com.google.firestore.v1.Target) targetChange_; + } + return com.google.firestore.v1.Target.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target to add to this stream.
+     * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target, + com.google.firestore.v1.Target.Builder, + com.google.firestore.v1.TargetOrBuilder> + internalGetAddTargetFieldBuilder() { + if (addTargetBuilder_ == null) { + if (!(targetChangeCase_ == 2)) { + targetChange_ = com.google.firestore.v1.Target.getDefaultInstance(); + } + addTargetBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target, + com.google.firestore.v1.Target.Builder, + com.google.firestore.v1.TargetOrBuilder>( + (com.google.firestore.v1.Target) targetChange_, getParentForChildren(), isClean()); + targetChange_ = null; + } + targetChangeCase_ = 2; + onChanged(); + 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; + } + + /** + * + * + *
+     * The ID of a target to remove from this stream.
+     * 
+ * + * int32 remove_target = 3; + * + * @return The removeTarget. + */ + public int getRemoveTarget() { + if (targetChangeCase_ == 3) { + return (java.lang.Integer) targetChange_; + } + return 0; + } + + /** + * + * + *
+     * The ID of a target to remove from this stream.
+     * 
+ * + * int32 remove_target = 3; + * + * @param value The removeTarget to set. + * @return This builder for chaining. + */ + public Builder setRemoveTarget(int value) { + + targetChangeCase_ = 3; + targetChange_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of a target to remove from this stream.
+     * 
+ * + * int32 remove_target = 3; + * + * @return This builder for chaining. + */ + public Builder clearRemoveTarget() { + if (targetChangeCase_ == 3) { + targetChangeCase_ = 0; + targetChange_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + private com.google.protobuf.MapField + internalGetMutableLabels() { + if (labels_ == null) { + labels_ = com.google.protobuf.MapField.newMapField(LabelsDefaultEntryHolder.defaultEntry); + } + if (!labels_.isMutable()) { + labels_ = labels_.copy(); + } + bitField0_ |= 0x00000008; + onChanged(); + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLabels() { + bitField0_ = (bitField0_ & ~0x00000008); + internalGetMutableLabels().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + public Builder removeLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableLabels().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableLabels() { + bitField0_ |= 0x00000008; + return internalGetMutableLabels().getMutableMap(); + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + public Builder putLabels(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableLabels().getMutableMap().put(key, value); + bitField0_ |= 0x00000008; + return this; + } + + /** + * + * + *
+     * Labels associated with this target change.
+     * 
+ * + * map<string, string> labels = 4; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000008; + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListenRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListenRequest) + private static final com.google.firestore.v1.ListenRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListenRequest(); + } + + public static com.google.firestore.v1.ListenRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListenRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListenRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java new file mode 100644 index 000000000000..f68a9dcd4fd2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenRequestOrBuilder.java @@ -0,0 +1,184 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListenRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListenRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return Whether the addTarget field is set. + */ + boolean hasAddTarget(); + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + * + * @return The addTarget. + */ + com.google.firestore.v1.Target getAddTarget(); + + /** + * + * + *
+   * A target to add to this stream.
+   * 
+ * + * .google.firestore.v1.Target add_target = 2; + */ + 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(); + + /** + * + * + *
+   * The ID of a target to remove from this stream.
+   * 
+ * + * int32 remove_target = 3; + * + * @return The removeTarget. + */ + int getRemoveTarget(); + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + int getLabelsCount(); + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Labels associated with this target change.
+   * 
+ * + * map<string, string> labels = 4; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); + + com.google.firestore.v1.ListenRequest.TargetChangeCase getTargetChangeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponse.java new file mode 100644 index 000000000000..598fa1f80771 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponse.java @@ -0,0 +1,2082 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.ListenResponse} + */ +@com.google.protobuf.Generated +public final class ListenResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.ListenResponse) + ListenResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ListenResponse"); + } + + // Use ListenResponse.newBuilder() to construct. + private ListenResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ListenResponse() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListenResponse.class, + com.google.firestore.v1.ListenResponse.Builder.class); + } + + private int responseTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object responseType_; + + public enum ResponseTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TARGET_CHANGE(2), + DOCUMENT_CHANGE(3), + DOCUMENT_DELETE(4), + DOCUMENT_REMOVE(6), + FILTER(5), + RESPONSETYPE_NOT_SET(0); + private final int value; + + private ResponseTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ResponseTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ResponseTypeCase forNumber(int value) { + switch (value) { + case 2: + return TARGET_CHANGE; + case 3: + return DOCUMENT_CHANGE; + case 4: + return DOCUMENT_DELETE; + case 6: + return DOCUMENT_REMOVE; + case 5: + return FILTER; + case 0: + return RESPONSETYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ResponseTypeCase getResponseTypeCase() { + return ResponseTypeCase.forNumber(responseTypeCase_); + } + + public static final int TARGET_CHANGE_FIELD_NUMBER = 2; + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return Whether the targetChange field is set. + */ + @java.lang.Override + public boolean hasTargetChange() { + return responseTypeCase_ == 2; + } + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return The targetChange. + */ + @java.lang.Override + public com.google.firestore.v1.TargetChange getTargetChange() { + if (responseTypeCase_ == 2) { + return (com.google.firestore.v1.TargetChange) responseType_; + } + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TargetChangeOrBuilder getTargetChangeOrBuilder() { + if (responseTypeCase_ == 2) { + return (com.google.firestore.v1.TargetChange) responseType_; + } + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + + public static final int DOCUMENT_CHANGE_FIELD_NUMBER = 3; + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return Whether the documentChange field is set. + */ + @java.lang.Override + public boolean hasDocumentChange() { + return responseTypeCase_ == 3; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return The documentChange. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentChange getDocumentChange() { + if (responseTypeCase_ == 3) { + return (com.google.firestore.v1.DocumentChange) responseType_; + } + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentChangeOrBuilder getDocumentChangeOrBuilder() { + if (responseTypeCase_ == 3) { + return (com.google.firestore.v1.DocumentChange) responseType_; + } + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + + public static final int DOCUMENT_DELETE_FIELD_NUMBER = 4; + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return Whether the documentDelete field is set. + */ + @java.lang.Override + public boolean hasDocumentDelete() { + return responseTypeCase_ == 4; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return The documentDelete. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentDelete getDocumentDelete() { + if (responseTypeCase_ == 4) { + return (com.google.firestore.v1.DocumentDelete) responseType_; + } + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentDeleteOrBuilder getDocumentDeleteOrBuilder() { + if (responseTypeCase_ == 4) { + return (com.google.firestore.v1.DocumentDelete) responseType_; + } + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + + public static final int DOCUMENT_REMOVE_FIELD_NUMBER = 6; + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return Whether the documentRemove field is set. + */ + @java.lang.Override + public boolean hasDocumentRemove() { + return responseTypeCase_ == 6; + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return The documentRemove. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentRemove getDocumentRemove() { + if (responseTypeCase_ == 6) { + return (com.google.firestore.v1.DocumentRemove) responseType_; + } + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentRemoveOrBuilder getDocumentRemoveOrBuilder() { + if (responseTypeCase_ == 6) { + return (com.google.firestore.v1.DocumentRemove) responseType_; + } + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + + public static final int FILTER_FIELD_NUMBER = 5; + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return Whether the filter field is set. + */ + @java.lang.Override + public boolean hasFilter() { + return responseTypeCase_ == 5; + } + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return The filter. + */ + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter getFilter() { + if (responseTypeCase_ == 5) { + return (com.google.firestore.v1.ExistenceFilter) responseType_; + } + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + @java.lang.Override + public com.google.firestore.v1.ExistenceFilterOrBuilder getFilterOrBuilder() { + if (responseTypeCase_ == 5) { + return (com.google.firestore.v1.ExistenceFilter) responseType_; + } + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (responseTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.TargetChange) responseType_); + } + if (responseTypeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.v1.DocumentChange) responseType_); + } + if (responseTypeCase_ == 4) { + output.writeMessage(4, (com.google.firestore.v1.DocumentDelete) responseType_); + } + if (responseTypeCase_ == 5) { + output.writeMessage(5, (com.google.firestore.v1.ExistenceFilter) responseType_); + } + if (responseTypeCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.DocumentRemove) responseType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (responseTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.TargetChange) responseType_); + } + if (responseTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.DocumentChange) responseType_); + } + if (responseTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.firestore.v1.DocumentDelete) responseType_); + } + if (responseTypeCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.firestore.v1.ExistenceFilter) responseType_); + } + if (responseTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.DocumentRemove) responseType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.ListenResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.ListenResponse other = (com.google.firestore.v1.ListenResponse) obj; + + if (!getResponseTypeCase().equals(other.getResponseTypeCase())) return false; + switch (responseTypeCase_) { + case 2: + if (!getTargetChange().equals(other.getTargetChange())) return false; + break; + case 3: + if (!getDocumentChange().equals(other.getDocumentChange())) return false; + break; + case 4: + if (!getDocumentDelete().equals(other.getDocumentDelete())) return false; + break; + case 6: + if (!getDocumentRemove().equals(other.getDocumentRemove())) return false; + break; + case 5: + if (!getFilter().equals(other.getFilter())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (responseTypeCase_) { + case 2: + hash = (37 * hash) + TARGET_CHANGE_FIELD_NUMBER; + hash = (53 * hash) + getTargetChange().hashCode(); + break; + case 3: + hash = (37 * hash) + DOCUMENT_CHANGE_FIELD_NUMBER; + hash = (53 * hash) + getDocumentChange().hashCode(); + break; + case 4: + hash = (37 * hash) + DOCUMENT_DELETE_FIELD_NUMBER; + hash = (53 * hash) + getDocumentDelete().hashCode(); + break; + case 6: + hash = (37 * hash) + DOCUMENT_REMOVE_FIELD_NUMBER; + hash = (53 * hash) + getDocumentRemove().hashCode(); + break; + case 5: + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.ListenResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.ListenResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListenResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.ListenResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.ListenResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.ListenResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.ListenResponse) + com.google.firestore.v1.ListenResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.ListenResponse.class, + com.google.firestore.v1.ListenResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.ListenResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (targetChangeBuilder_ != null) { + targetChangeBuilder_.clear(); + } + if (documentChangeBuilder_ != null) { + documentChangeBuilder_.clear(); + } + if (documentDeleteBuilder_ != null) { + documentDeleteBuilder_.clear(); + } + if (documentRemoveBuilder_ != null) { + documentRemoveBuilder_.clear(); + } + if (filterBuilder_ != null) { + filterBuilder_.clear(); + } + responseTypeCase_ = 0; + responseType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_ListenResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.ListenResponse getDefaultInstanceForType() { + return com.google.firestore.v1.ListenResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.ListenResponse build() { + com.google.firestore.v1.ListenResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.ListenResponse buildPartial() { + com.google.firestore.v1.ListenResponse result = + new com.google.firestore.v1.ListenResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.ListenResponse result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.ListenResponse result) { + result.responseTypeCase_ = responseTypeCase_; + result.responseType_ = this.responseType_; + if (responseTypeCase_ == 2 && targetChangeBuilder_ != null) { + result.responseType_ = targetChangeBuilder_.build(); + } + if (responseTypeCase_ == 3 && documentChangeBuilder_ != null) { + result.responseType_ = documentChangeBuilder_.build(); + } + if (responseTypeCase_ == 4 && documentDeleteBuilder_ != null) { + result.responseType_ = documentDeleteBuilder_.build(); + } + if (responseTypeCase_ == 6 && documentRemoveBuilder_ != null) { + result.responseType_ = documentRemoveBuilder_.build(); + } + if (responseTypeCase_ == 5 && filterBuilder_ != null) { + result.responseType_ = filterBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.ListenResponse) { + return mergeFrom((com.google.firestore.v1.ListenResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.ListenResponse other) { + if (other == com.google.firestore.v1.ListenResponse.getDefaultInstance()) return this; + switch (other.getResponseTypeCase()) { + case TARGET_CHANGE: + { + mergeTargetChange(other.getTargetChange()); + break; + } + case DOCUMENT_CHANGE: + { + mergeDocumentChange(other.getDocumentChange()); + break; + } + case DOCUMENT_DELETE: + { + mergeDocumentDelete(other.getDocumentDelete()); + break; + } + case DOCUMENT_REMOVE: + { + mergeDocumentRemove(other.getDocumentRemove()); + break; + } + case FILTER: + { + mergeFilter(other.getFilter()); + break; + } + case RESPONSETYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + input.readMessage( + internalGetTargetChangeFieldBuilder().getBuilder(), extensionRegistry); + responseTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetDocumentChangeFieldBuilder().getBuilder(), extensionRegistry); + responseTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetDocumentDeleteFieldBuilder().getBuilder(), extensionRegistry); + responseTypeCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage(internalGetFilterFieldBuilder().getBuilder(), extensionRegistry); + responseTypeCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetDocumentRemoveFieldBuilder().getBuilder(), extensionRegistry); + responseTypeCase_ = 6; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int responseTypeCase_ = 0; + private java.lang.Object responseType_; + + public ResponseTypeCase getResponseTypeCase() { + return ResponseTypeCase.forNumber(responseTypeCase_); + } + + public Builder clearResponseType() { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TargetChange, + com.google.firestore.v1.TargetChange.Builder, + com.google.firestore.v1.TargetChangeOrBuilder> + targetChangeBuilder_; + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return Whether the targetChange field is set. + */ + @java.lang.Override + public boolean hasTargetChange() { + return responseTypeCase_ == 2; + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return The targetChange. + */ + @java.lang.Override + public com.google.firestore.v1.TargetChange getTargetChange() { + if (targetChangeBuilder_ == null) { + if (responseTypeCase_ == 2) { + return (com.google.firestore.v1.TargetChange) responseType_; + } + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } else { + if (responseTypeCase_ == 2) { + return targetChangeBuilder_.getMessage(); + } + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + public Builder setTargetChange(com.google.firestore.v1.TargetChange value) { + if (targetChangeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + responseType_ = value; + onChanged(); + } else { + targetChangeBuilder_.setMessage(value); + } + responseTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + public Builder setTargetChange(com.google.firestore.v1.TargetChange.Builder builderForValue) { + if (targetChangeBuilder_ == null) { + responseType_ = builderForValue.build(); + onChanged(); + } else { + targetChangeBuilder_.setMessage(builderForValue.build()); + } + responseTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + public Builder mergeTargetChange(com.google.firestore.v1.TargetChange value) { + if (targetChangeBuilder_ == null) { + if (responseTypeCase_ == 2 + && responseType_ != com.google.firestore.v1.TargetChange.getDefaultInstance()) { + responseType_ = + com.google.firestore.v1.TargetChange.newBuilder( + (com.google.firestore.v1.TargetChange) responseType_) + .mergeFrom(value) + .buildPartial(); + } else { + responseType_ = value; + } + onChanged(); + } else { + if (responseTypeCase_ == 2) { + targetChangeBuilder_.mergeFrom(value); + } else { + targetChangeBuilder_.setMessage(value); + } + } + responseTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + public Builder clearTargetChange() { + if (targetChangeBuilder_ == null) { + if (responseTypeCase_ == 2) { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + } + } else { + if (responseTypeCase_ == 2) { + responseTypeCase_ = 0; + responseType_ = null; + } + targetChangeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + public com.google.firestore.v1.TargetChange.Builder getTargetChangeBuilder() { + return internalGetTargetChangeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TargetChangeOrBuilder getTargetChangeOrBuilder() { + if ((responseTypeCase_ == 2) && (targetChangeBuilder_ != null)) { + return targetChangeBuilder_.getMessageOrBuilder(); + } else { + if (responseTypeCase_ == 2) { + return (com.google.firestore.v1.TargetChange) responseType_; + } + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Targets have changed.
+     * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TargetChange, + com.google.firestore.v1.TargetChange.Builder, + com.google.firestore.v1.TargetChangeOrBuilder> + internalGetTargetChangeFieldBuilder() { + if (targetChangeBuilder_ == null) { + if (!(responseTypeCase_ == 2)) { + responseType_ = com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + targetChangeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TargetChange, + com.google.firestore.v1.TargetChange.Builder, + com.google.firestore.v1.TargetChangeOrBuilder>( + (com.google.firestore.v1.TargetChange) responseType_, + getParentForChildren(), + isClean()); + responseType_ = null; + } + responseTypeCase_ = 2; + onChanged(); + return targetChangeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentChange, + com.google.firestore.v1.DocumentChange.Builder, + com.google.firestore.v1.DocumentChangeOrBuilder> + documentChangeBuilder_; + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return Whether the documentChange field is set. + */ + @java.lang.Override + public boolean hasDocumentChange() { + return responseTypeCase_ == 3; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return The documentChange. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentChange getDocumentChange() { + if (documentChangeBuilder_ == null) { + if (responseTypeCase_ == 3) { + return (com.google.firestore.v1.DocumentChange) responseType_; + } + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } else { + if (responseTypeCase_ == 3) { + return documentChangeBuilder_.getMessage(); + } + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + public Builder setDocumentChange(com.google.firestore.v1.DocumentChange value) { + if (documentChangeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + responseType_ = value; + onChanged(); + } else { + documentChangeBuilder_.setMessage(value); + } + responseTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + public Builder setDocumentChange( + com.google.firestore.v1.DocumentChange.Builder builderForValue) { + if (documentChangeBuilder_ == null) { + responseType_ = builderForValue.build(); + onChanged(); + } else { + documentChangeBuilder_.setMessage(builderForValue.build()); + } + responseTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + public Builder mergeDocumentChange(com.google.firestore.v1.DocumentChange value) { + if (documentChangeBuilder_ == null) { + if (responseTypeCase_ == 3 + && responseType_ != com.google.firestore.v1.DocumentChange.getDefaultInstance()) { + responseType_ = + com.google.firestore.v1.DocumentChange.newBuilder( + (com.google.firestore.v1.DocumentChange) responseType_) + .mergeFrom(value) + .buildPartial(); + } else { + responseType_ = value; + } + onChanged(); + } else { + if (responseTypeCase_ == 3) { + documentChangeBuilder_.mergeFrom(value); + } else { + documentChangeBuilder_.setMessage(value); + } + } + responseTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + public Builder clearDocumentChange() { + if (documentChangeBuilder_ == null) { + if (responseTypeCase_ == 3) { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + } + } else { + if (responseTypeCase_ == 3) { + responseTypeCase_ = 0; + responseType_ = null; + } + documentChangeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + public com.google.firestore.v1.DocumentChange.Builder getDocumentChangeBuilder() { + return internalGetDocumentChangeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentChangeOrBuilder getDocumentChangeOrBuilder() { + if ((responseTypeCase_ == 3) && (documentChangeBuilder_ != null)) { + return documentChangeBuilder_.getMessageOrBuilder(); + } else { + if (responseTypeCase_ == 3) { + return (com.google.firestore.v1.DocumentChange) responseType_; + } + return com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has changed.
+     * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentChange, + com.google.firestore.v1.DocumentChange.Builder, + com.google.firestore.v1.DocumentChangeOrBuilder> + internalGetDocumentChangeFieldBuilder() { + if (documentChangeBuilder_ == null) { + if (!(responseTypeCase_ == 3)) { + responseType_ = com.google.firestore.v1.DocumentChange.getDefaultInstance(); + } + documentChangeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentChange, + com.google.firestore.v1.DocumentChange.Builder, + com.google.firestore.v1.DocumentChangeOrBuilder>( + (com.google.firestore.v1.DocumentChange) responseType_, + getParentForChildren(), + isClean()); + responseType_ = null; + } + responseTypeCase_ = 3; + onChanged(); + return documentChangeBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentDelete, + com.google.firestore.v1.DocumentDelete.Builder, + com.google.firestore.v1.DocumentDeleteOrBuilder> + documentDeleteBuilder_; + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return Whether the documentDelete field is set. + */ + @java.lang.Override + public boolean hasDocumentDelete() { + return responseTypeCase_ == 4; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return The documentDelete. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentDelete getDocumentDelete() { + if (documentDeleteBuilder_ == null) { + if (responseTypeCase_ == 4) { + return (com.google.firestore.v1.DocumentDelete) responseType_; + } + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } else { + if (responseTypeCase_ == 4) { + return documentDeleteBuilder_.getMessage(); + } + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + public Builder setDocumentDelete(com.google.firestore.v1.DocumentDelete value) { + if (documentDeleteBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + responseType_ = value; + onChanged(); + } else { + documentDeleteBuilder_.setMessage(value); + } + responseTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + public Builder setDocumentDelete( + com.google.firestore.v1.DocumentDelete.Builder builderForValue) { + if (documentDeleteBuilder_ == null) { + responseType_ = builderForValue.build(); + onChanged(); + } else { + documentDeleteBuilder_.setMessage(builderForValue.build()); + } + responseTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + public Builder mergeDocumentDelete(com.google.firestore.v1.DocumentDelete value) { + if (documentDeleteBuilder_ == null) { + if (responseTypeCase_ == 4 + && responseType_ != com.google.firestore.v1.DocumentDelete.getDefaultInstance()) { + responseType_ = + com.google.firestore.v1.DocumentDelete.newBuilder( + (com.google.firestore.v1.DocumentDelete) responseType_) + .mergeFrom(value) + .buildPartial(); + } else { + responseType_ = value; + } + onChanged(); + } else { + if (responseTypeCase_ == 4) { + documentDeleteBuilder_.mergeFrom(value); + } else { + documentDeleteBuilder_.setMessage(value); + } + } + responseTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + public Builder clearDocumentDelete() { + if (documentDeleteBuilder_ == null) { + if (responseTypeCase_ == 4) { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + } + } else { + if (responseTypeCase_ == 4) { + responseTypeCase_ = 0; + responseType_ = null; + } + documentDeleteBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + public com.google.firestore.v1.DocumentDelete.Builder getDocumentDeleteBuilder() { + return internalGetDocumentDeleteFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentDeleteOrBuilder getDocumentDeleteOrBuilder() { + if ((responseTypeCase_ == 4) && (documentDeleteBuilder_ != null)) { + return documentDeleteBuilder_.getMessageOrBuilder(); + } else { + if (responseTypeCase_ == 4) { + return (com.google.firestore.v1.DocumentDelete) responseType_; + } + return com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been deleted.
+     * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentDelete, + com.google.firestore.v1.DocumentDelete.Builder, + com.google.firestore.v1.DocumentDeleteOrBuilder> + internalGetDocumentDeleteFieldBuilder() { + if (documentDeleteBuilder_ == null) { + if (!(responseTypeCase_ == 4)) { + responseType_ = com.google.firestore.v1.DocumentDelete.getDefaultInstance(); + } + documentDeleteBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentDelete, + com.google.firestore.v1.DocumentDelete.Builder, + com.google.firestore.v1.DocumentDeleteOrBuilder>( + (com.google.firestore.v1.DocumentDelete) responseType_, + getParentForChildren(), + isClean()); + responseType_ = null; + } + responseTypeCase_ = 4; + onChanged(); + return documentDeleteBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentRemove, + com.google.firestore.v1.DocumentRemove.Builder, + com.google.firestore.v1.DocumentRemoveOrBuilder> + documentRemoveBuilder_; + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return Whether the documentRemove field is set. + */ + @java.lang.Override + public boolean hasDocumentRemove() { + return responseTypeCase_ == 6; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return The documentRemove. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentRemove getDocumentRemove() { + if (documentRemoveBuilder_ == null) { + if (responseTypeCase_ == 6) { + return (com.google.firestore.v1.DocumentRemove) responseType_; + } + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } else { + if (responseTypeCase_ == 6) { + return documentRemoveBuilder_.getMessage(); + } + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + public Builder setDocumentRemove(com.google.firestore.v1.DocumentRemove value) { + if (documentRemoveBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + responseType_ = value; + onChanged(); + } else { + documentRemoveBuilder_.setMessage(value); + } + responseTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + public Builder setDocumentRemove( + com.google.firestore.v1.DocumentRemove.Builder builderForValue) { + if (documentRemoveBuilder_ == null) { + responseType_ = builderForValue.build(); + onChanged(); + } else { + documentRemoveBuilder_.setMessage(builderForValue.build()); + } + responseTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + public Builder mergeDocumentRemove(com.google.firestore.v1.DocumentRemove value) { + if (documentRemoveBuilder_ == null) { + if (responseTypeCase_ == 6 + && responseType_ != com.google.firestore.v1.DocumentRemove.getDefaultInstance()) { + responseType_ = + com.google.firestore.v1.DocumentRemove.newBuilder( + (com.google.firestore.v1.DocumentRemove) responseType_) + .mergeFrom(value) + .buildPartial(); + } else { + responseType_ = value; + } + onChanged(); + } else { + if (responseTypeCase_ == 6) { + documentRemoveBuilder_.mergeFrom(value); + } else { + documentRemoveBuilder_.setMessage(value); + } + } + responseTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + public Builder clearDocumentRemove() { + if (documentRemoveBuilder_ == null) { + if (responseTypeCase_ == 6) { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + } + } else { + if (responseTypeCase_ == 6) { + responseTypeCase_ = 0; + responseType_ = null; + } + documentRemoveBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + public com.google.firestore.v1.DocumentRemove.Builder getDocumentRemoveBuilder() { + return internalGetDocumentRemoveFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentRemoveOrBuilder getDocumentRemoveOrBuilder() { + if ((responseTypeCase_ == 6) && (documentRemoveBuilder_ != null)) { + return documentRemoveBuilder_.getMessageOrBuilder(); + } else { + if (responseTypeCase_ == 6) { + return (com.google.firestore.v1.DocumentRemove) responseType_; + } + return com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A [Document][google.firestore.v1.Document] has been removed from a target
+     * (because it is no longer relevant to that target).
+     * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentRemove, + com.google.firestore.v1.DocumentRemove.Builder, + com.google.firestore.v1.DocumentRemoveOrBuilder> + internalGetDocumentRemoveFieldBuilder() { + if (documentRemoveBuilder_ == null) { + if (!(responseTypeCase_ == 6)) { + responseType_ = com.google.firestore.v1.DocumentRemove.getDefaultInstance(); + } + documentRemoveBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentRemove, + com.google.firestore.v1.DocumentRemove.Builder, + com.google.firestore.v1.DocumentRemoveOrBuilder>( + (com.google.firestore.v1.DocumentRemove) responseType_, + getParentForChildren(), + isClean()); + responseType_ = null; + } + responseTypeCase_ = 6; + onChanged(); + return documentRemoveBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExistenceFilter, + com.google.firestore.v1.ExistenceFilter.Builder, + com.google.firestore.v1.ExistenceFilterOrBuilder> + filterBuilder_; + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return Whether the filter field is set. + */ + @java.lang.Override + public boolean hasFilter() { + return responseTypeCase_ == 5; + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return The filter. + */ + @java.lang.Override + public com.google.firestore.v1.ExistenceFilter getFilter() { + if (filterBuilder_ == null) { + if (responseTypeCase_ == 5) { + return (com.google.firestore.v1.ExistenceFilter) responseType_; + } + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } else { + if (responseTypeCase_ == 5) { + return filterBuilder_.getMessage(); + } + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + public Builder setFilter(com.google.firestore.v1.ExistenceFilter value) { + if (filterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + responseType_ = value; + onChanged(); + } else { + filterBuilder_.setMessage(value); + } + responseTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + public Builder setFilter(com.google.firestore.v1.ExistenceFilter.Builder builderForValue) { + if (filterBuilder_ == null) { + responseType_ = builderForValue.build(); + onChanged(); + } else { + filterBuilder_.setMessage(builderForValue.build()); + } + responseTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + public Builder mergeFilter(com.google.firestore.v1.ExistenceFilter value) { + if (filterBuilder_ == null) { + if (responseTypeCase_ == 5 + && responseType_ != com.google.firestore.v1.ExistenceFilter.getDefaultInstance()) { + responseType_ = + com.google.firestore.v1.ExistenceFilter.newBuilder( + (com.google.firestore.v1.ExistenceFilter) responseType_) + .mergeFrom(value) + .buildPartial(); + } else { + responseType_ = value; + } + onChanged(); + } else { + if (responseTypeCase_ == 5) { + filterBuilder_.mergeFrom(value); + } else { + filterBuilder_.setMessage(value); + } + } + responseTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + public Builder clearFilter() { + if (filterBuilder_ == null) { + if (responseTypeCase_ == 5) { + responseTypeCase_ = 0; + responseType_ = null; + onChanged(); + } + } else { + if (responseTypeCase_ == 5) { + responseTypeCase_ = 0; + responseType_ = null; + } + filterBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + public com.google.firestore.v1.ExistenceFilter.Builder getFilterBuilder() { + return internalGetFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + @java.lang.Override + public com.google.firestore.v1.ExistenceFilterOrBuilder getFilterOrBuilder() { + if ((responseTypeCase_ == 5) && (filterBuilder_ != null)) { + return filterBuilder_.getMessageOrBuilder(); + } else { + if (responseTypeCase_ == 5) { + return (com.google.firestore.v1.ExistenceFilter) responseType_; + } + return com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A filter to apply to the set of documents previously returned for the
+     * given target.
+     *
+     * Returned when documents may have been removed from the given target, but
+     * the exact documents are unknown.
+     * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExistenceFilter, + com.google.firestore.v1.ExistenceFilter.Builder, + com.google.firestore.v1.ExistenceFilterOrBuilder> + internalGetFilterFieldBuilder() { + if (filterBuilder_ == null) { + if (!(responseTypeCase_ == 5)) { + responseType_ = com.google.firestore.v1.ExistenceFilter.getDefaultInstance(); + } + filterBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExistenceFilter, + com.google.firestore.v1.ExistenceFilter.Builder, + com.google.firestore.v1.ExistenceFilterOrBuilder>( + (com.google.firestore.v1.ExistenceFilter) responseType_, + getParentForChildren(), + isClean()); + responseType_ = null; + } + responseTypeCase_ = 5; + onChanged(); + return filterBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.ListenResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.ListenResponse) + private static final com.google.firestore.v1.ListenResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.ListenResponse(); + } + + public static com.google.firestore.v1.ListenResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListenResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.ListenResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponseOrBuilder.java new file mode 100644 index 000000000000..ccdb879e139d --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ListenResponseOrBuilder.java @@ -0,0 +1,230 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ListenResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.ListenResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return Whether the targetChange field is set. + */ + boolean hasTargetChange(); + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + * + * @return The targetChange. + */ + com.google.firestore.v1.TargetChange getTargetChange(); + + /** + * + * + *
+   * Targets have changed.
+   * 
+ * + * .google.firestore.v1.TargetChange target_change = 2; + */ + com.google.firestore.v1.TargetChangeOrBuilder getTargetChangeOrBuilder(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return Whether the documentChange field is set. + */ + boolean hasDocumentChange(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + * + * @return The documentChange. + */ + com.google.firestore.v1.DocumentChange getDocumentChange(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has changed.
+   * 
+ * + * .google.firestore.v1.DocumentChange document_change = 3; + */ + com.google.firestore.v1.DocumentChangeOrBuilder getDocumentChangeOrBuilder(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return Whether the documentDelete field is set. + */ + boolean hasDocumentDelete(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + * + * @return The documentDelete. + */ + com.google.firestore.v1.DocumentDelete getDocumentDelete(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been deleted.
+   * 
+ * + * .google.firestore.v1.DocumentDelete document_delete = 4; + */ + com.google.firestore.v1.DocumentDeleteOrBuilder getDocumentDeleteOrBuilder(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return Whether the documentRemove field is set. + */ + boolean hasDocumentRemove(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + * + * @return The documentRemove. + */ + com.google.firestore.v1.DocumentRemove getDocumentRemove(); + + /** + * + * + *
+   * A [Document][google.firestore.v1.Document] has been removed from a target
+   * (because it is no longer relevant to that target).
+   * 
+ * + * .google.firestore.v1.DocumentRemove document_remove = 6; + */ + com.google.firestore.v1.DocumentRemoveOrBuilder getDocumentRemoveOrBuilder(); + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return Whether the filter field is set. + */ + boolean hasFilter(); + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + * + * @return The filter. + */ + com.google.firestore.v1.ExistenceFilter getFilter(); + + /** + * + * + *
+   * A filter to apply to the set of documents previously returned for the
+   * given target.
+   *
+   * Returned when documents may have been removed from the given target, but
+   * the exact documents are unknown.
+   * 
+ * + * .google.firestore.v1.ExistenceFilter filter = 5; + */ + com.google.firestore.v1.ExistenceFilterOrBuilder getFilterOrBuilder(); + + com.google.firestore.v1.ListenResponse.ResponseTypeCase getResponseTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValue.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValue.java new file mode 100644 index 000000000000..dd1e61acf152 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValue.java @@ -0,0 +1,882 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A map value.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.MapValue} + */ +@com.google.protobuf.Generated +public final class MapValue extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.MapValue) + MapValueOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "MapValue"); + } + + // Use MapValue.newBuilder() to construct. + private MapValue(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private MapValue() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 1: + return internalGetFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.MapValue.class, com.google.firestore.v1.MapValue.Builder.class); + } + + public static final int FIELDS_FIELD_NUMBER = 1; + + private static final class FieldsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_FieldsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField fields_; + + private com.google.protobuf.MapField + internalGetFields() { + if (fields_ == null) { + return com.google.protobuf.MapField.emptyMapField(FieldsDefaultEntryHolder.defaultEntry); + } + return fields_; + } + + public int getFieldsCount() { + return internalGetFields().getMap().size(); + } + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public boolean containsFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetFields().getMap().containsKey(key); + } + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getFields() { + return getFieldsMap(); + } + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public java.util.Map getFieldsMap() { + return internalGetFields().getMap(); + } + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetFields().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetFields().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetFields(), FieldsDefaultEntryHolder.defaultEntry, 1); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (java.util.Map.Entry entry : + internalGetFields().getMap().entrySet()) { + com.google.protobuf.MapEntry fields__ = + FieldsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, fields__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.MapValue)) { + return super.equals(obj); + } + com.google.firestore.v1.MapValue other = (com.google.firestore.v1.MapValue) obj; + + if (!internalGetFields().equals(other.internalGetFields())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (!internalGetFields().getMap().isEmpty()) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + internalGetFields().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.MapValue parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.MapValue parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.MapValue parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.MapValue parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.MapValue parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.MapValue parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.MapValue parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.MapValue parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.MapValue parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.MapValue parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.MapValue parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.MapValue parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.MapValue prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A map value.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.MapValue} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.MapValue) + com.google.firestore.v1.MapValueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 1: + return internalGetFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 1: + return internalGetMutableFields(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.MapValue.class, + com.google.firestore.v1.MapValue.Builder.class); + } + + // Construct using com.google.firestore.v1.MapValue.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + internalGetMutableFields().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_MapValue_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.MapValue getDefaultInstanceForType() { + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.MapValue build() { + com.google.firestore.v1.MapValue result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.MapValue buildPartial() { + com.google.firestore.v1.MapValue result = new com.google.firestore.v1.MapValue(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.MapValue result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.fields_ = internalGetFields().build(FieldsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.MapValue) { + return mergeFrom((com.google.firestore.v1.MapValue) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.MapValue other) { + if (other == com.google.firestore.v1.MapValue.getDefaultInstance()) return this; + internalGetMutableFields().mergeFrom(other.internalGetFields()); + bitField0_ |= 0x00000001; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.protobuf.MapEntry + fields__ = + input.readMessage( + FieldsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableFields() + .ensureBuilderMap() + .put(fields__.getKey(), fields__.getValue()); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private static final class FieldsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return FieldsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final FieldsConverter fieldsConverter = new FieldsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + fields_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetFields() { + if (fields_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(fieldsConverter); + } + return fields_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableFields() { + if (fields_ == null) { + fields_ = new com.google.protobuf.MapFieldBuilder<>(fieldsConverter); + } + bitField0_ |= 0x00000001; + onChanged(); + return fields_; + } + + public int getFieldsCount() { + return internalGetFields().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public boolean containsFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetFields().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getFields() { + return getFieldsMap(); + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public java.util.Map getFieldsMap() { + return internalGetFields().getImmutableMap(); + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableFields().ensureBuilderMap(); + return map.containsKey(key) ? fieldsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableFields().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return fieldsConverter.build(map.get(key)); + } + + public Builder clearFields() { + bitField0_ = (bitField0_ & ~0x00000001); + internalGetMutableFields().clear(); + return this; + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + public Builder removeFields(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableFields().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableFields() { + bitField0_ |= 0x00000001; + return internalGetMutableFields().ensureMessageMap(); + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + public Builder putFields(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableFields().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + public Builder putAllFields( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableFields().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The map's fields.
+     *
+     * The map keys represent field names. Field names matching the regular
+     * expression `__.*__` are reserved. Reserved field names are forbidden except
+     * in certain documented contexts. The map keys, represented as UTF-8, must
+     * not exceed 1,500 bytes and cannot be empty.
+     * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + public com.google.firestore.v1.Value.Builder putFieldsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableFields().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.MapValue) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.MapValue) + private static final com.google.firestore.v1.MapValue DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.MapValue(); + } + + public static com.google.firestore.v1.MapValue getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MapValue parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.MapValue getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValueOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValueOrBuilder.java new file mode 100644 index 000000000000..2d916020d2d7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/MapValueOrBuilder.java @@ -0,0 +1,116 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface MapValueOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.MapValue) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + int getFieldsCount(); + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + boolean containsFields(java.lang.String key); + + /** Use {@link #getFieldsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getFields(); + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + java.util.Map getFieldsMap(); + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + /* nullable */ + com.google.firestore.v1.Value getFieldsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+   * The map's fields.
+   *
+   * The map keys represent field names. Field names matching the regular
+   * expression `__.*__` are reserved. Reserved field names are forbidden except
+   * in certain documented contexts. The map keys, represented as UTF-8, must
+   * not exceed 1,500 bytes and cannot be empty.
+   * 
+ * + * map<string, .google.firestore.v1.Value> fields = 1; + */ + com.google.firestore.v1.Value getFieldsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java new file mode 100644 index 000000000000..aa1328c52eef --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequest.java @@ -0,0 +1,1994 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.PartitionQueryRequest} + */ +@com.google.protobuf.Generated +public final class PartitionQueryRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.PartitionQueryRequest) + PartitionQueryRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PartitionQueryRequest"); + } + + // Use PartitionQueryRequest.newBuilder() to construct. + private PartitionQueryRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private PartitionQueryRequest() { + parent_ = ""; + pageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PartitionQueryRequest.class, + com.google.firestore.v1.PartitionQueryRequest.Builder.class); + } + + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_QUERY(2), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_TIME(6), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 6: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents`.
+   * Document resource names are not supported; only database resource names
+   * can be specified.
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents`.
+   * Document resource names are not supported; only database resource names
+   * can be specified.
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + public static final int PARTITION_COUNT_FIELD_NUMBER = 3; + private long partitionCount_ = 0L; + + /** + * + * + *
+   * The desired maximum number of partition points.
+   * The partitions may be returned across multiple pages of results.
+   * The number must be positive. The actual number of partitions
+   * returned may be fewer.
+   *
+   * For example, this may be set to one fewer than the number of parallel
+   * queries to be run, or in running a data pipeline job, one fewer than the
+   * number of workers or compute instances available.
+   * 
+ * + * int64 partition_count = 3; + * + * @return The partitionCount. + */ + @java.lang.Override + public long getPartitionCount() { + return partitionCount_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * The `next_page_token` value returned from a previous call to
+   * PartitionQuery that may be used to get an additional set of results.
+   * There are no ordering guarantees between sets of results. Thus, using
+   * multiple sets of results will require merging the different result sets.
+   *
+   * For example, two subsequent calls using a page_token may return:
+   *
+   * * cursor B, cursor M, cursor Q
+   * * cursor A, cursor U, cursor W
+   *
+   * To obtain a complete result set ordered with respect to the results of the
+   * query supplied to PartitionQuery, the results sets should be merged:
+   * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * The `next_page_token` value returned from a previous call to
+   * PartitionQuery that may be used to get an additional set of results.
+   * There are no ordering guarantees between sets of results. Thus, using
+   * multiple sets of results will require merging the different result sets.
+   *
+   * For example, two subsequent calls using a page_token may return:
+   *
+   * * cursor B, cursor M, cursor Q
+   * * cursor A, cursor U, cursor W
+   *
+   * To obtain a complete result set ordered with respect to the results of the
+   * query supplied to PartitionQuery, the results sets should be merged:
+   * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 5; + private int pageSize_ = 0; + + /** + * + * + *
+   * The maximum number of partitions to return in this call, subject to
+   * `partition_count`.
+   *
+   * For example, if `partition_count` = 10 and `page_size` = 8, the first call
+   * to PartitionQuery will return up to 8 partitions and a `next_page_token`
+   * if more results exist. A second call to PartitionQuery will return up to
+   * 2 partitions, to complete the total of 10 specified in `partition_count`.
+   * 
+ * + * int32 page_size = 5; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int READ_TIME_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (queryTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (partitionCount_ != 0L) { + output.writeInt64(3, partitionCount_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, pageToken_); + } + if (pageSize_ != 0) { + output.writeInt32(5, pageSize_); + } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (queryTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (partitionCount_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(3, partitionCount_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, pageToken_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(5, pageSize_); + } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.PartitionQueryRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.PartitionQueryRequest other = + (com.google.firestore.v1.PartitionQueryRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPartitionCount() != other.getPartitionCount()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 2: + if (!getStructuredQuery().equals(other.getStructuredQuery())) return false; + break; + case 0: + default: + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 6: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + PARTITION_COUNT_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getPartitionCount()); + hash = (37 * hash) + PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getPageToken().hashCode(); + hash = (37 * hash) + PAGE_SIZE_FIELD_NUMBER; + hash = (53 * hash) + getPageSize(); + switch (queryTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredQuery().hashCode(); + break; + case 0: + default: + } + switch (consistencySelectorCase_) { + case 6: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.PartitionQueryRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.PartitionQueryRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.PartitionQueryRequest) + com.google.firestore.v1.PartitionQueryRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PartitionQueryRequest.class, + com.google.firestore.v1.PartitionQueryRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.PartitionQueryRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + if (structuredQueryBuilder_ != null) { + structuredQueryBuilder_.clear(); + } + partitionCount_ = 0L; + pageToken_ = ""; + pageSize_ = 0; + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + queryTypeCase_ = 0; + queryType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryRequest getDefaultInstanceForType() { + return com.google.firestore.v1.PartitionQueryRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryRequest build() { + com.google.firestore.v1.PartitionQueryRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryRequest buildPartial() { + com.google.firestore.v1.PartitionQueryRequest result = + new com.google.firestore.v1.PartitionQueryRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.PartitionQueryRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.partitionCount_ = partitionCount_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.pageToken_ = pageToken_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.pageSize_ = pageSize_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.PartitionQueryRequest result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 2 && structuredQueryBuilder_ != null) { + result.queryType_ = structuredQueryBuilder_.build(); + } + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 6 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.PartitionQueryRequest) { + return mergeFrom((com.google.firestore.v1.PartitionQueryRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.PartitionQueryRequest other) { + if (other == com.google.firestore.v1.PartitionQueryRequest.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getPartitionCount() != 0L) { + setPartitionCount(other.getPartitionCount()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000008; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_QUERY: + { + mergeStructuredQuery(other.getStructuredQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + switch (other.getConsistencySelectorCase()) { + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 2; + break; + } // case 18 + case 24: + { + partitionCount_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + pageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 40: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 50: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 6; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents`.
+     * Document resource names are not supported; only database resource names
+     * can be specified.
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents`.
+     * Document resource names are not supported; only database resource names
+     * can be specified.
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents`.
+     * Document resource names are not supported; only database resource names
+     * can be specified.
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents`.
+     * Document resource names are not supported; only database resource names
+     * can be specified.
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents`.
+     * Document resource names are not supported; only database resource names
+     * can be specified.
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + structuredQueryBuilder_; + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 2) { + return structuredQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery( + com.google.firestore.v1.StructuredQuery.Builder builderForValue) { + if (structuredQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder mergeStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2 + && queryType_ != com.google.firestore.v1.StructuredQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredQuery.newBuilder( + (com.google.firestore.v1.StructuredQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 2) { + structuredQueryBuilder_.mergeFrom(value); + } else { + structuredQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder clearStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public com.google.firestore.v1.StructuredQuery.Builder getStructuredQueryBuilder() { + return internalGetStructuredQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if ((queryTypeCase_ == 2) && (structuredQueryBuilder_ != null)) { + return structuredQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * Query must specify collection with all descendants and be ordered by name
+     * ascending. Other filters, order bys, limits, offsets, and start/end
+     * cursors are not supported.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + internalGetStructuredQueryFieldBuilder() { + if (structuredQueryBuilder_ == null) { + if (!(queryTypeCase_ == 2)) { + queryType_ = com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + structuredQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder>( + (com.google.firestore.v1.StructuredQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 2; + onChanged(); + return structuredQueryBuilder_; + } + + private long partitionCount_; + + /** + * + * + *
+     * The desired maximum number of partition points.
+     * The partitions may be returned across multiple pages of results.
+     * The number must be positive. The actual number of partitions
+     * returned may be fewer.
+     *
+     * For example, this may be set to one fewer than the number of parallel
+     * queries to be run, or in running a data pipeline job, one fewer than the
+     * number of workers or compute instances available.
+     * 
+ * + * int64 partition_count = 3; + * + * @return The partitionCount. + */ + @java.lang.Override + public long getPartitionCount() { + return partitionCount_; + } + + /** + * + * + *
+     * The desired maximum number of partition points.
+     * The partitions may be returned across multiple pages of results.
+     * The number must be positive. The actual number of partitions
+     * returned may be fewer.
+     *
+     * For example, this may be set to one fewer than the number of parallel
+     * queries to be run, or in running a data pipeline job, one fewer than the
+     * number of workers or compute instances available.
+     * 
+ * + * int64 partition_count = 3; + * + * @param value The partitionCount to set. + * @return This builder for chaining. + */ + public Builder setPartitionCount(long value) { + + partitionCount_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The desired maximum number of partition points.
+     * The partitions may be returned across multiple pages of results.
+     * The number must be positive. The actual number of partitions
+     * returned may be fewer.
+     *
+     * For example, this may be set to one fewer than the number of parallel
+     * queries to be run, or in running a data pipeline job, one fewer than the
+     * number of workers or compute instances available.
+     * 
+ * + * int64 partition_count = 3; + * + * @return This builder for chaining. + */ + public Builder clearPartitionCount() { + bitField0_ = (bitField0_ & ~0x00000004); + partitionCount_ = 0L; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * The `next_page_token` value returned from a previous call to
+     * PartitionQuery that may be used to get an additional set of results.
+     * There are no ordering guarantees between sets of results. Thus, using
+     * multiple sets of results will require merging the different result sets.
+     *
+     * For example, two subsequent calls using a page_token may return:
+     *
+     * * cursor B, cursor M, cursor Q
+     * * cursor A, cursor U, cursor W
+     *
+     * To obtain a complete result set ordered with respect to the results of the
+     * query supplied to PartitionQuery, the results sets should be merged:
+     * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+     * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The `next_page_token` value returned from a previous call to
+     * PartitionQuery that may be used to get an additional set of results.
+     * There are no ordering guarantees between sets of results. Thus, using
+     * multiple sets of results will require merging the different result sets.
+     *
+     * For example, two subsequent calls using a page_token may return:
+     *
+     * * cursor B, cursor M, cursor Q
+     * * cursor A, cursor U, cursor W
+     *
+     * To obtain a complete result set ordered with respect to the results of the
+     * query supplied to PartitionQuery, the results sets should be merged:
+     * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+     * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The `next_page_token` value returned from a previous call to
+     * PartitionQuery that may be used to get an additional set of results.
+     * There are no ordering guarantees between sets of results. Thus, using
+     * multiple sets of results will require merging the different result sets.
+     *
+     * For example, two subsequent calls using a page_token may return:
+     *
+     * * cursor B, cursor M, cursor Q
+     * * cursor A, cursor U, cursor W
+     *
+     * To obtain a complete result set ordered with respect to the results of the
+     * query supplied to PartitionQuery, the results sets should be merged:
+     * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+     * 
+ * + * string page_token = 4; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The `next_page_token` value returned from a previous call to
+     * PartitionQuery that may be used to get an additional set of results.
+     * There are no ordering guarantees between sets of results. Thus, using
+     * multiple sets of results will require merging the different result sets.
+     *
+     * For example, two subsequent calls using a page_token may return:
+     *
+     * * cursor B, cursor M, cursor Q
+     * * cursor A, cursor U, cursor W
+     *
+     * To obtain a complete result set ordered with respect to the results of the
+     * query supplied to PartitionQuery, the results sets should be merged:
+     * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+     * 
+ * + * string page_token = 4; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * The `next_page_token` value returned from a previous call to
+     * PartitionQuery that may be used to get an additional set of results.
+     * There are no ordering guarantees between sets of results. Thus, using
+     * multiple sets of results will require merging the different result sets.
+     *
+     * For example, two subsequent calls using a page_token may return:
+     *
+     * * cursor B, cursor M, cursor Q
+     * * cursor A, cursor U, cursor W
+     *
+     * To obtain a complete result set ordered with respect to the results of the
+     * query supplied to PartitionQuery, the results sets should be merged:
+     * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+     * 
+ * + * string page_token = 4; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + private int pageSize_; + + /** + * + * + *
+     * The maximum number of partitions to return in this call, subject to
+     * `partition_count`.
+     *
+     * For example, if `partition_count` = 10 and `page_size` = 8, the first call
+     * to PartitionQuery will return up to 8 partitions and a `next_page_token`
+     * if more results exist. A second call to PartitionQuery will return up to
+     * 2 partitions, to complete the total of 10 specified in `partition_count`.
+     * 
+ * + * int32 page_size = 5; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * The maximum number of partitions to return in this call, subject to
+     * `partition_count`.
+     *
+     * For example, if `partition_count` = 10 and `page_size` = 8, the first call
+     * to PartitionQuery will return up to 8 partitions and a `next_page_token`
+     * if more results exist. A second call to PartitionQuery will return up to
+     * 2 partitions, to complete the total of 10 specified in `partition_count`.
+     * 
+ * + * int32 page_size = 5; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of partitions to return in this call, subject to
+     * `partition_count`.
+     *
+     * For example, if `partition_count` = 10 and `page_size` = 8, the first call
+     * to PartitionQuery will return up to 8 partitions and a `next_page_token`
+     * if more results exist. A second call to PartitionQuery will return up to
+     * 2 partitions, to complete the total of 10 specified in `partition_count`.
+     * 
+ * + * int32 page_size = 5; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000010); + pageSize_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 6) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.PartitionQueryRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.PartitionQueryRequest) + private static final com.google.firestore.v1.PartitionQueryRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.PartitionQueryRequest(); + } + + public static com.google.firestore.v1.PartitionQueryRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PartitionQueryRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java new file mode 100644 index 000000000000..d94353c3b0fc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryRequestOrBuilder.java @@ -0,0 +1,249 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface PartitionQueryRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.PartitionQueryRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents`.
+   * Document resource names are not supported; only database resource names
+   * can be specified.
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents`.
+   * Document resource names are not supported; only database resource names
+   * can be specified.
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + boolean hasStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + com.google.firestore.v1.StructuredQuery getStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * Query must specify collection with all descendants and be ordered by name
+   * ascending. Other filters, order bys, limits, offsets, and start/end
+   * cursors are not supported.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + + /** + * + * + *
+   * The desired maximum number of partition points.
+   * The partitions may be returned across multiple pages of results.
+   * The number must be positive. The actual number of partitions
+   * returned may be fewer.
+   *
+   * For example, this may be set to one fewer than the number of parallel
+   * queries to be run, or in running a data pipeline job, one fewer than the
+   * number of workers or compute instances available.
+   * 
+ * + * int64 partition_count = 3; + * + * @return The partitionCount. + */ + long getPartitionCount(); + + /** + * + * + *
+   * The `next_page_token` value returned from a previous call to
+   * PartitionQuery that may be used to get an additional set of results.
+   * There are no ordering guarantees between sets of results. Thus, using
+   * multiple sets of results will require merging the different result sets.
+   *
+   * For example, two subsequent calls using a page_token may return:
+   *
+   * * cursor B, cursor M, cursor Q
+   * * cursor A, cursor U, cursor W
+   *
+   * To obtain a complete result set ordered with respect to the results of the
+   * query supplied to PartitionQuery, the results sets should be merged:
+   * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+   * 
+ * + * string page_token = 4; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * The `next_page_token` value returned from a previous call to
+   * PartitionQuery that may be used to get an additional set of results.
+   * There are no ordering guarantees between sets of results. Thus, using
+   * multiple sets of results will require merging the different result sets.
+   *
+   * For example, two subsequent calls using a page_token may return:
+   *
+   * * cursor B, cursor M, cursor Q
+   * * cursor A, cursor U, cursor W
+   *
+   * To obtain a complete result set ordered with respect to the results of the
+   * query supplied to PartitionQuery, the results sets should be merged:
+   * cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W
+   * 
+ * + * string page_token = 4; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); + + /** + * + * + *
+   * The maximum number of partitions to return in this call, subject to
+   * `partition_count`.
+   *
+   * For example, if `partition_count` = 10 and `page_size` = 8, the first call
+   * to PartitionQuery will return up to 8 partitions and a `next_page_token`
+   * if more results exist. A second call to PartitionQuery will return up to
+   * 2 partitions, to complete the total of 10 specified in `partition_count`.
+   * 
+ * + * int32 page_size = 5; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.PartitionQueryRequest.QueryTypeCase getQueryTypeCase(); + + com.google.firestore.v1.PartitionQueryRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponse.java new file mode 100644 index 000000000000..eb5f2316cad7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponse.java @@ -0,0 +1,1491 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for
+ * [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.PartitionQueryResponse} + */ +@com.google.protobuf.Generated +public final class PartitionQueryResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.PartitionQueryResponse) + PartitionQueryResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PartitionQueryResponse"); + } + + // Use PartitionQueryResponse.newBuilder() to construct. + private PartitionQueryResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private PartitionQueryResponse() { + partitions_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PartitionQueryResponse.class, + com.google.firestore.v1.PartitionQueryResponse.Builder.class); + } + + public static final int PARTITIONS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List partitions_; + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + @java.lang.Override + public java.util.List getPartitionsList() { + return partitions_; + } + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + @java.lang.Override + public java.util.List + getPartitionsOrBuilderList() { + return partitions_; + } + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + @java.lang.Override + public int getPartitionsCount() { + return partitions_.size(); + } + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + @java.lang.Override + public com.google.firestore.v1.Cursor getPartitions(int index) { + return partitions_.get(index); + } + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + @java.lang.Override + public com.google.firestore.v1.CursorOrBuilder getPartitionsOrBuilder(int index) { + return partitions_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+   * A page token that may be used to request an additional set of results, up
+   * to the number specified by `partition_count` in the PartitionQuery request.
+   * If blank, there are no more results.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + @java.lang.Override + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } + } + + /** + * + * + *
+   * A page token that may be used to request an additional set of results, up
+   * to the number specified by `partition_count` in the PartitionQuery request.
+   * If blank, there are no more results.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < partitions_.size(); i++) { + output.writeMessage(1, partitions_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, nextPageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < partitions_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, partitions_.get(i)); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, nextPageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.PartitionQueryResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.PartitionQueryResponse other = + (com.google.firestore.v1.PartitionQueryResponse) obj; + + if (!getPartitionsList().equals(other.getPartitionsList())) return false; + if (!getNextPageToken().equals(other.getNextPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getPartitionsCount() > 0) { + hash = (37 * hash) + PARTITIONS_FIELD_NUMBER; + hash = (53 * hash) + getPartitionsList().hashCode(); + } + hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getNextPageToken().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PartitionQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.PartitionQueryResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.PartitionQueryResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.PartitionQueryResponse) + com.google.firestore.v1.PartitionQueryResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PartitionQueryResponse.class, + com.google.firestore.v1.PartitionQueryResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.PartitionQueryResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (partitionsBuilder_ == null) { + partitions_ = java.util.Collections.emptyList(); + } else { + partitions_ = null; + partitionsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_PartitionQueryResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryResponse getDefaultInstanceForType() { + return com.google.firestore.v1.PartitionQueryResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryResponse build() { + com.google.firestore.v1.PartitionQueryResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryResponse buildPartial() { + com.google.firestore.v1.PartitionQueryResponse result = + new com.google.firestore.v1.PartitionQueryResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.PartitionQueryResponse result) { + if (partitionsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + partitions_ = java.util.Collections.unmodifiableList(partitions_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.partitions_ = partitions_; + } else { + result.partitions_ = partitionsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.PartitionQueryResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.PartitionQueryResponse) { + return mergeFrom((com.google.firestore.v1.PartitionQueryResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.PartitionQueryResponse other) { + if (other == com.google.firestore.v1.PartitionQueryResponse.getDefaultInstance()) return this; + if (partitionsBuilder_ == null) { + if (!other.partitions_.isEmpty()) { + if (partitions_.isEmpty()) { + partitions_ = other.partitions_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensurePartitionsIsMutable(); + partitions_.addAll(other.partitions_); + } + onChanged(); + } + } else { + if (!other.partitions_.isEmpty()) { + if (partitionsBuilder_.isEmpty()) { + partitionsBuilder_.dispose(); + partitionsBuilder_ = null; + partitions_ = other.partitions_; + bitField0_ = (bitField0_ & ~0x00000001); + partitionsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetPartitionsFieldBuilder() + : null; + } else { + partitionsBuilder_.addAllMessages(other.partitions_); + } + } + } + if (!other.getNextPageToken().isEmpty()) { + nextPageToken_ = other.nextPageToken_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Cursor m = + input.readMessage(com.google.firestore.v1.Cursor.parser(), extensionRegistry); + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + partitions_.add(m); + } else { + partitionsBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + nextPageToken_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List partitions_ = + java.util.Collections.emptyList(); + + private void ensurePartitionsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + partitions_ = new java.util.ArrayList(partitions_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + partitionsBuilder_; + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public java.util.List getPartitionsList() { + if (partitionsBuilder_ == null) { + return java.util.Collections.unmodifiableList(partitions_); + } else { + return partitionsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public int getPartitionsCount() { + if (partitionsBuilder_ == null) { + return partitions_.size(); + } else { + return partitionsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public com.google.firestore.v1.Cursor getPartitions(int index) { + if (partitionsBuilder_ == null) { + return partitions_.get(index); + } else { + return partitionsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder setPartitions(int index, com.google.firestore.v1.Cursor value) { + if (partitionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePartitionsIsMutable(); + partitions_.set(index, value); + onChanged(); + } else { + partitionsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder setPartitions( + int index, com.google.firestore.v1.Cursor.Builder builderForValue) { + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + partitions_.set(index, builderForValue.build()); + onChanged(); + } else { + partitionsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder addPartitions(com.google.firestore.v1.Cursor value) { + if (partitionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePartitionsIsMutable(); + partitions_.add(value); + onChanged(); + } else { + partitionsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder addPartitions(int index, com.google.firestore.v1.Cursor value) { + if (partitionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePartitionsIsMutable(); + partitions_.add(index, value); + onChanged(); + } else { + partitionsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder addPartitions(com.google.firestore.v1.Cursor.Builder builderForValue) { + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + partitions_.add(builderForValue.build()); + onChanged(); + } else { + partitionsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder addPartitions( + int index, com.google.firestore.v1.Cursor.Builder builderForValue) { + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + partitions_.add(index, builderForValue.build()); + onChanged(); + } else { + partitionsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder addAllPartitions( + java.lang.Iterable values) { + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, partitions_); + onChanged(); + } else { + partitionsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder clearPartitions() { + if (partitionsBuilder_ == null) { + partitions_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + partitionsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public Builder removePartitions(int index) { + if (partitionsBuilder_ == null) { + ensurePartitionsIsMutable(); + partitions_.remove(index); + onChanged(); + } else { + partitionsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public com.google.firestore.v1.Cursor.Builder getPartitionsBuilder(int index) { + return internalGetPartitionsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public com.google.firestore.v1.CursorOrBuilder getPartitionsOrBuilder(int index) { + if (partitionsBuilder_ == null) { + return partitions_.get(index); + } else { + return partitionsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public java.util.List + getPartitionsOrBuilderList() { + if (partitionsBuilder_ != null) { + return partitionsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(partitions_); + } + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public com.google.firestore.v1.Cursor.Builder addPartitionsBuilder() { + return internalGetPartitionsFieldBuilder() + .addBuilder(com.google.firestore.v1.Cursor.getDefaultInstance()); + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public com.google.firestore.v1.Cursor.Builder addPartitionsBuilder(int index) { + return internalGetPartitionsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Cursor.getDefaultInstance()); + } + + /** + * + * + *
+     * Partition results.
+     * Each partition is a split point that can be used by RunQuery as a starting
+     * or end point for the query results. The RunQuery requests must be made with
+     * the same query supplied to this PartitionQuery request. The partition
+     * cursors will be ordered according to same ordering as the results of the
+     * query supplied to PartitionQuery.
+     *
+     * For example, if a PartitionQuery request returns partition cursors A and B,
+     * running the following three queries will return the entire result set of
+     * the original query:
+     *
+     * * query, end_at A
+     * * query, start_at A, end_at B
+     * * query, start_at B
+     *
+     * An empty result may indicate that the query has too few results to be
+     * partitioned, or that the query is not yet supported for partitioning.
+     * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + public java.util.List getPartitionsBuilderList() { + return internalGetPartitionsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + internalGetPartitionsFieldBuilder() { + if (partitionsBuilder_ == null) { + partitionsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder>( + partitions_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + partitions_ = null; + } + return partitionsBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * A page token that may be used to request an additional set of results, up
+     * to the number specified by `partition_count` in the PartitionQuery request.
+     * If blank, there are no more results.
+     * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + public java.lang.String getNextPageToken() { + java.lang.Object ref = nextPageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nextPageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request an additional set of results, up
+     * to the number specified by `partition_count` in the PartitionQuery request.
+     * If blank, there are no more results.
+     * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + public com.google.protobuf.ByteString getNextPageTokenBytes() { + java.lang.Object ref = nextPageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + nextPageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A page token that may be used to request an additional set of results, up
+     * to the number specified by `partition_count` in the PartitionQuery request.
+     * If blank, there are no more results.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request an additional set of results, up
+     * to the number specified by `partition_count` in the PartitionQuery request.
+     * If blank, there are no more results.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * A page token that may be used to request an additional set of results, up
+     * to the number specified by `partition_count` in the PartitionQuery request.
+     * If blank, there are no more results.
+     * 
+ * + * string next_page_token = 2; + * + * @param value The bytes for nextPageToken to set. + * @return This builder for chaining. + */ + public Builder setNextPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + nextPageToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.PartitionQueryResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.PartitionQueryResponse) + private static final com.google.firestore.v1.PartitionQueryResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.PartitionQueryResponse(); + } + + public static com.google.firestore.v1.PartitionQueryResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PartitionQueryResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.PartitionQueryResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponseOrBuilder.java new file mode 100644 index 000000000000..bb134db6c200 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PartitionQueryResponseOrBuilder.java @@ -0,0 +1,193 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface PartitionQueryResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.PartitionQueryResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + java.util.List getPartitionsList(); + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + com.google.firestore.v1.Cursor getPartitions(int index); + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + int getPartitionsCount(); + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + java.util.List getPartitionsOrBuilderList(); + + /** + * + * + *
+   * Partition results.
+   * Each partition is a split point that can be used by RunQuery as a starting
+   * or end point for the query results. The RunQuery requests must be made with
+   * the same query supplied to this PartitionQuery request. The partition
+   * cursors will be ordered according to same ordering as the results of the
+   * query supplied to PartitionQuery.
+   *
+   * For example, if a PartitionQuery request returns partition cursors A and B,
+   * running the following three queries will return the entire result set of
+   * the original query:
+   *
+   * * query, end_at A
+   * * query, start_at A, end_at B
+   * * query, start_at B
+   *
+   * An empty result may indicate that the query has too few results to be
+   * partitioned, or that the query is not yet supported for partitioning.
+   * 
+ * + * repeated .google.firestore.v1.Cursor partitions = 1; + */ + com.google.firestore.v1.CursorOrBuilder getPartitionsOrBuilder(int index); + + /** + * + * + *
+   * A page token that may be used to request an additional set of results, up
+   * to the number specified by `partition_count` in the PartitionQuery request.
+   * If blank, there are no more results.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * A page token that may be used to request an additional set of results, up
+   * to the number specified by `partition_count` in the PartitionQuery request.
+   * If blank, there are no more results.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java new file mode 100644 index 000000000000..5c9cad85cef3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Pipeline.java @@ -0,0 +1,2766 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore query represented as an ordered list of operations / stages.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline} + */ +@com.google.protobuf.Generated +public final class Pipeline extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Pipeline) + PipelineOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Pipeline"); + } + + // Use Pipeline.newBuilder() to construct. + private Pipeline(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Pipeline() { + stages_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.class, com.google.firestore.v1.Pipeline.Builder.class); + } + + public interface StageOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Pipeline.Stage) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Required. The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+     * Required. The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getArgsList(); + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.Value getArgs(int index); + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getArgsCount(); + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getArgsOrBuilderList(); + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index); + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getOptionsCount(); + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsOptions(java.lang.String key); + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getOptionsMap(); + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); + } + + /** + * + * + *
+   * A single operation within a pipeline.
+   *
+   * A stage is made up of a unique name, and a list of arguments. The exact
+   * number of arguments & types is dependent on the stage type.
+   *
+   * To give an example, the stage `filter(state = "MD")` would be encoded as:
+   *
+   * ```
+   * name: "filter"
+   * args {
+   * function_value {
+   * name: "eq"
+   * args { field_reference_value: "state" }
+   * args { string_value: "MD" }
+   * }
+   * }
+   * ```
+   *
+   * See public documentation for the full list.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline.Stage} + */ + public static final class Stage extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Pipeline.Stage) + StageOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Stage"); + } + + // Use Stage.newBuilder() to construct. + private Stage(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Stage() { + name_ = ""; + args_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.Stage.class, + com.google.firestore.v1.Pipeline.Stage.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + + /** + * + * + *
+     * Required. The name of the stage to evaluate.
+     *
+     * **Requires:**
+     *
+     * * must be in snake case (lower case with underscore separator).
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ARGS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List args_; + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getArgsList() { + return args_; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getArgsOrBuilderList() { + return args_; + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public int getArgsCount() { + return args_.size(); + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getArgs(int index) { + return args_.get(index); + } + + /** + * + * + *
+     * Optional. Ordered list of arguments the given stage expects.
+     * 
+ * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + return args_.get(index); + } + + public static final int OPTIONS_FIELD_NUMBER = 3; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Optional. Optional named arguments that certain functions may support.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, name_); + } + for (int i = 0; i < args_.size(); i++) { + output.writeMessage(2, args_.get(i)); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 3); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, name_); + } + for (int i = 0; i < args_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, args_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Pipeline.Stage)) { + return super.equals(obj); + } + com.google.firestore.v1.Pipeline.Stage other = (com.google.firestore.v1.Pipeline.Stage) obj; + + if (!getName().equals(other.getName())) return false; + if (!getArgsList().equals(other.getArgsList())) return false; + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (getArgsCount() > 0) { + hash = (37 * hash) + ARGS_FIELD_NUMBER; + hash = (53 * hash) + getArgsList().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline.Stage parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Pipeline.Stage prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A single operation within a pipeline.
+     *
+     * A stage is made up of a unique name, and a list of arguments. The exact
+     * number of arguments & types is dependent on the stage type.
+     *
+     * To give an example, the stage `filter(state = "MD")` would be encoded as:
+     *
+     * ```
+     * name: "filter"
+     * args {
+     * function_value {
+     * name: "eq"
+     * args { field_reference_value: "state" }
+     * args { string_value: "MD" }
+     * }
+     * }
+     * ```
+     *
+     * See public documentation for the full list.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline.Stage} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Pipeline.Stage) + com.google.firestore.v1.Pipeline.StageOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.Stage.class, + com.google.firestore.v1.Pipeline.Stage.Builder.class); + } + + // Construct using com.google.firestore.v1.Pipeline.Stage.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + } else { + args_ = null; + argsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_Stage_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getDefaultInstanceForType() { + return com.google.firestore.v1.Pipeline.Stage.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage build() { + com.google.firestore.v1.Pipeline.Stage result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage buildPartial() { + com.google.firestore.v1.Pipeline.Stage result = + new com.google.firestore.v1.Pipeline.Stage(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Pipeline.Stage result) { + if (argsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + args_ = java.util.Collections.unmodifiableList(args_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.args_ = args_; + } else { + result.args_ = argsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Pipeline.Stage result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Pipeline.Stage) { + return mergeFrom((com.google.firestore.v1.Pipeline.Stage) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Pipeline.Stage other) { + if (other == com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()) return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (argsBuilder_ == null) { + if (!other.args_.isEmpty()) { + if (args_.isEmpty()) { + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureArgsIsMutable(); + args_.addAll(other.args_); + } + onChanged(); + } + } else { + if (!other.args_.isEmpty()) { + if (argsBuilder_.isEmpty()) { + argsBuilder_.dispose(); + argsBuilder_ = null; + args_ = other.args_; + bitField0_ = (bitField0_ & ~0x00000002); + argsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetArgsFieldBuilder() + : null; + } else { + argsBuilder_.addAllMessages(other.args_); + } + } + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000004; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(m); + } else { + argsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + + /** + * + * + *
+       * Required. The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Required. The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Required. The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The name of the stage to evaluate.
+       *
+       * **Requires:**
+       *
+       * * must be in snake case (lower case with underscore separator).
+       * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.util.List args_ = + java.util.Collections.emptyList(); + + private void ensureArgsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + args_ = new java.util.ArrayList(args_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + argsBuilder_; + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getArgsList() { + if (argsBuilder_ == null) { + return java.util.Collections.unmodifiableList(args_); + } else { + return argsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public int getArgsCount() { + if (argsBuilder_ == null) { + return args_.size(); + } else { + return argsBuilder_.getCount(); + } + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value getArgs(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.set(index, value); + onChanged(); + } else { + argsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.set(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(value); + onChanged(); + } else { + argsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(int index, com.google.firestore.v1.Value value) { + if (argsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureArgsIsMutable(); + args_.add(index, value); + onChanged(); + } else { + argsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addArgs(int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.add(index, builderForValue.build()); + onChanged(); + } else { + argsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAllArgs( + java.lang.Iterable values) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, args_); + onChanged(); + } else { + argsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearArgs() { + if (argsBuilder_ == null) { + args_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + argsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeArgs(int index) { + if (argsBuilder_ == null) { + ensureArgsIsMutable(); + args_.remove(index); + onChanged(); + } else { + argsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder getArgsBuilder(int index) { + return internalGetArgsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ValueOrBuilder getArgsOrBuilder(int index) { + if (argsBuilder_ == null) { + return args_.get(index); + } else { + return argsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getArgsOrBuilderList() { + if (argsBuilder_ != null) { + return argsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(args_); + } + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder() { + return internalGetArgsFieldBuilder() + .addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder addArgsBuilder(int index) { + return internalGetArgsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+       * Optional. Ordered list of arguments the given stage expects.
+       * 
+ * + * + * repeated .google.firestore.v1.Value args = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getArgsBuilderList() { + return internalGetArgsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetArgsFieldBuilder() { + if (argsBuilder_ == null) { + argsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + args_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + args_ = null; + } + return argsBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000004; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableOptions().clear(); + return this; + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000004; + return internalGetMutableOptions().ensureMessageMap(); + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+       * Optional. Optional named arguments that certain functions may support.
+       * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Pipeline.Stage) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Pipeline.Stage) + private static final com.google.firestore.v1.Pipeline.Stage DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Pipeline.Stage(); + } + + public static com.google.firestore.v1.Pipeline.Stage getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Stage parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int STAGES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List stages_; + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getStagesList() { + return stages_; + } + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List + getStagesOrBuilderList() { + return stages_; + } + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public int getStagesCount() { + return stages_.size(); + } + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline.Stage getStages(int index) { + return stages_.get(index); + } + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index) { + return stages_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < stages_.size(); i++) { + output.writeMessage(1, stages_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < stages_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, stages_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Pipeline)) { + return super.equals(obj); + } + com.google.firestore.v1.Pipeline other = (com.google.firestore.v1.Pipeline) obj; + + if (!getStagesList().equals(other.getStagesList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getStagesCount() > 0) { + hash = (37 * hash) + STAGES_FIELD_NUMBER; + hash = (53 * hash) + getStagesList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Pipeline parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Pipeline parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Pipeline prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Firestore query represented as an ordered list of operations / stages.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Pipeline} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Pipeline) + com.google.firestore.v1.PipelineOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Pipeline.class, + com.google.firestore.v1.Pipeline.Builder.class); + } + + // Construct using com.google.firestore.v1.Pipeline.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (stagesBuilder_ == null) { + stages_ = java.util.Collections.emptyList(); + } else { + stages_ = null; + stagesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Pipeline_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline getDefaultInstanceForType() { + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline build() { + com.google.firestore.v1.Pipeline result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline buildPartial() { + com.google.firestore.v1.Pipeline result = new com.google.firestore.v1.Pipeline(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Pipeline result) { + if (stagesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + stages_ = java.util.Collections.unmodifiableList(stages_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.stages_ = stages_; + } else { + result.stages_ = stagesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Pipeline result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Pipeline) { + return mergeFrom((com.google.firestore.v1.Pipeline) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Pipeline other) { + if (other == com.google.firestore.v1.Pipeline.getDefaultInstance()) return this; + if (stagesBuilder_ == null) { + if (!other.stages_.isEmpty()) { + if (stages_.isEmpty()) { + stages_ = other.stages_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureStagesIsMutable(); + stages_.addAll(other.stages_); + } + onChanged(); + } + } else { + if (!other.stages_.isEmpty()) { + if (stagesBuilder_.isEmpty()) { + stagesBuilder_.dispose(); + stagesBuilder_ = null; + stages_ = other.stages_; + bitField0_ = (bitField0_ & ~0x00000001); + stagesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetStagesFieldBuilder() + : null; + } else { + stagesBuilder_.addAllMessages(other.stages_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.firestore.v1.Pipeline.Stage m = + input.readMessage( + com.google.firestore.v1.Pipeline.Stage.parser(), extensionRegistry); + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(m); + } else { + stagesBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List stages_ = + java.util.Collections.emptyList(); + + private void ensureStagesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + stages_ = new java.util.ArrayList(stages_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder> + stagesBuilder_; + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getStagesList() { + if (stagesBuilder_ == null) { + return java.util.Collections.unmodifiableList(stages_); + } else { + return stagesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public int getStagesCount() { + if (stagesBuilder_ == null) { + return stages_.size(); + } else { + return stagesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.Stage getStages(int index) { + if (stagesBuilder_ == null) { + return stages_.get(index); + } else { + return stagesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setStages(int index, com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.set(index, value); + onChanged(); + } else { + stagesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setStages( + int index, com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.set(index, builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addStages(com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.add(value); + onChanged(); + } else { + stagesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addStages(int index, com.google.firestore.v1.Pipeline.Stage value) { + if (stagesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStagesIsMutable(); + stages_.add(index, value); + onChanged(); + } else { + stagesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addStages(com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addStages( + int index, com.google.firestore.v1.Pipeline.Stage.Builder builderForValue) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.add(index, builderForValue.build()); + onChanged(); + } else { + stagesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addAllStages( + java.lang.Iterable values) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, stages_); + onChanged(); + } else { + stagesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearStages() { + if (stagesBuilder_ == null) { + stages_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + stagesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder removeStages(int index) { + if (stagesBuilder_ == null) { + ensureStagesIsMutable(); + stages_.remove(index); + onChanged(); + } else { + stagesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.Stage.Builder getStagesBuilder(int index) { + return internalGetStagesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index) { + if (stagesBuilder_ == null) { + return stages_.get(index); + } else { + return stagesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List + getStagesOrBuilderList() { + if (stagesBuilder_ != null) { + return stagesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(stages_); + } + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.Stage.Builder addStagesBuilder() { + return internalGetStagesFieldBuilder() + .addBuilder(com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.Stage.Builder addStagesBuilder(int index) { + return internalGetStagesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Pipeline.Stage.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. Ordered list of stages to evaluate.
+     * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getStagesBuilderList() { + return internalGetStagesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder> + internalGetStagesFieldBuilder() { + if (stagesBuilder_ == null) { + stagesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Pipeline.Stage, + com.google.firestore.v1.Pipeline.Stage.Builder, + com.google.firestore.v1.Pipeline.StageOrBuilder>( + stages_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + stages_ = null; + } + return stagesBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Pipeline) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Pipeline) + private static final com.google.firestore.v1.Pipeline DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Pipeline(); + } + + public static com.google.firestore.v1.Pipeline getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Pipeline parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Pipeline getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java new file mode 100644 index 000000000000..8247a1399cfe --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineOrBuilder.java @@ -0,0 +1,94 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface PipelineOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Pipeline) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getStagesList(); + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.Pipeline.Stage getStages(int index); + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + int getStagesCount(); + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List + getStagesOrBuilderList(); + + /** + * + * + *
+   * Required. Ordered list of stages to evaluate.
+   * 
+ * + * + * repeated .google.firestore.v1.Pipeline.Stage stages = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.Pipeline.StageOrBuilder getStagesOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java new file mode 100644 index 000000000000..e2391bc0bddc --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PipelineProto.java @@ -0,0 +1,110 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/pipeline.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class PipelineProto extends com.google.protobuf.GeneratedFile { + private PipelineProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PipelineProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredPipeline_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\"google/firestore/v1/pipeline.proto\022\023go" + + "ogle.firestore.v1\032\037google/api/field_beha" + + "vior.proto\032\"google/firestore/v1/document" + + ".proto\"\342\001\n\022StructuredPipeline\0224\n\010pipelin" + + "e\030\001 \001(\0132\035.google.firestore.v1.PipelineB\003" + + "\340A\002\022J\n\007options\030\002 \003(\01324.google.firestore." + + "v1.StructuredPipeline.OptionsEntryB\003\340A\001\032" + + "J\n\014OptionsEntry\022\013\n\003key\030\001 \001(\t\022)\n\005value\030\002 " + + "\001(\0132\032.google.firestore.v1.Value:\0028\001B\305\001\n\027" + + "com.google.firestore.v1B\rPipelineProtoP\001" + + "Z;cloud.google.com/go/firestore/apiv1/fi" + + "restorepb;firestorepb\242\002\004GCFS\252\002\031Google.Cl" + + "oud.Firestore.V1\312\002\031Google\\Cloud\\Firestor" + + "e\\V1\352\002\034Google::Cloud::Firestore::V1b\006pro" + + "to3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.firestore.v1.DocumentProto.getDescriptor(), + }); + internal_static_google_firestore_v1_StructuredPipeline_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredPipeline_descriptor, + new java.lang.String[] { + "Pipeline", "Options", + }); + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor = + internal_static_google_firestore_v1_StructuredPipeline_descriptor.getNestedType(0); + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.firestore.v1.DocumentProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java new file mode 100644 index 000000000000..4765e4520296 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummary.java @@ -0,0 +1,1005 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Planning phase information for the query.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.PlanSummary} + */ +@com.google.protobuf.Generated +public final class PlanSummary extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.PlanSummary) + PlanSummaryOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "PlanSummary"); + } + + // Use PlanSummary.newBuilder() to construct. + private PlanSummary(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private PlanSummary() { + indexesUsed_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PlanSummary.class, + com.google.firestore.v1.PlanSummary.Builder.class); + } + + public static final int INDEXES_USED_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List indexesUsed_; + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public java.util.List getIndexesUsedList() { + return indexesUsed_; + } + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public java.util.List + getIndexesUsedOrBuilderList() { + return indexesUsed_; + } + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public int getIndexesUsedCount() { + return indexesUsed_.size(); + } + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public com.google.protobuf.Struct getIndexesUsed(int index) { + return indexesUsed_.get(index); + } + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + @java.lang.Override + public com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index) { + return indexesUsed_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < indexesUsed_.size(); i++) { + output.writeMessage(1, indexesUsed_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < indexesUsed_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, indexesUsed_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.PlanSummary)) { + return super.equals(obj); + } + com.google.firestore.v1.PlanSummary other = (com.google.firestore.v1.PlanSummary) obj; + + if (!getIndexesUsedList().equals(other.getIndexesUsedList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getIndexesUsedCount() > 0) { + hash = (37 * hash) + INDEXES_USED_FIELD_NUMBER; + hash = (53 * hash) + getIndexesUsedList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.PlanSummary parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.PlanSummary prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.PlanSummary} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.PlanSummary) + com.google.firestore.v1.PlanSummaryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.PlanSummary.class, + com.google.firestore.v1.PlanSummary.Builder.class); + } + + // Construct using com.google.firestore.v1.PlanSummary.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (indexesUsedBuilder_ == null) { + indexesUsed_ = java.util.Collections.emptyList(); + } else { + indexesUsed_ = null; + indexesUsedBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProfileProto + .internal_static_google_firestore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary getDefaultInstanceForType() { + return com.google.firestore.v1.PlanSummary.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary build() { + com.google.firestore.v1.PlanSummary result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary buildPartial() { + com.google.firestore.v1.PlanSummary result = new com.google.firestore.v1.PlanSummary(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.PlanSummary result) { + if (indexesUsedBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + indexesUsed_ = java.util.Collections.unmodifiableList(indexesUsed_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.indexesUsed_ = indexesUsed_; + } else { + result.indexesUsed_ = indexesUsedBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.PlanSummary result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.PlanSummary) { + return mergeFrom((com.google.firestore.v1.PlanSummary) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.PlanSummary other) { + if (other == com.google.firestore.v1.PlanSummary.getDefaultInstance()) return this; + if (indexesUsedBuilder_ == null) { + if (!other.indexesUsed_.isEmpty()) { + if (indexesUsed_.isEmpty()) { + indexesUsed_ = other.indexesUsed_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureIndexesUsedIsMutable(); + indexesUsed_.addAll(other.indexesUsed_); + } + onChanged(); + } + } else { + if (!other.indexesUsed_.isEmpty()) { + if (indexesUsedBuilder_.isEmpty()) { + indexesUsedBuilder_.dispose(); + indexesUsedBuilder_ = null; + indexesUsed_ = other.indexesUsed_; + bitField0_ = (bitField0_ & ~0x00000001); + indexesUsedBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetIndexesUsedFieldBuilder() + : null; + } else { + indexesUsedBuilder_.addAllMessages(other.indexesUsed_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + com.google.protobuf.Struct m = + input.readMessage(com.google.protobuf.Struct.parser(), extensionRegistry); + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(m); + } else { + indexesUsedBuilder_.addMessage(m); + } + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List indexesUsed_ = + java.util.Collections.emptyList(); + + private void ensureIndexesUsedIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + indexesUsed_ = new java.util.ArrayList(indexesUsed_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + indexesUsedBuilder_; + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List getIndexesUsedList() { + if (indexesUsedBuilder_ == null) { + return java.util.Collections.unmodifiableList(indexesUsed_); + } else { + return indexesUsedBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public int getIndexesUsedCount() { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.size(); + } else { + return indexesUsedBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct getIndexesUsed(int index) { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.get(index); + } else { + return indexesUsedBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder setIndexesUsed(int index, com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.set(index, value); + onChanged(); + } else { + indexesUsedBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder setIndexesUsed(int index, com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.set(index, builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.add(value); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(int index, com.google.protobuf.Struct value) { + if (indexesUsedBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureIndexesUsedIsMutable(); + indexesUsed_.add(index, value); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addIndexesUsed(int index, com.google.protobuf.Struct.Builder builderForValue) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.add(index, builderForValue.build()); + onChanged(); + } else { + indexesUsedBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder addAllIndexesUsed( + java.lang.Iterable values) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, indexesUsed_); + onChanged(); + } else { + indexesUsedBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder clearIndexesUsed() { + if (indexesUsedBuilder_ == null) { + indexesUsed_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + indexesUsedBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public Builder removeIndexesUsed(int index) { + if (indexesUsedBuilder_ == null) { + ensureIndexesUsedIsMutable(); + indexesUsed_.remove(index); + onChanged(); + } else { + indexesUsedBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder getIndexesUsedBuilder(int index) { + return internalGetIndexesUsedFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index) { + if (indexesUsedBuilder_ == null) { + return indexesUsed_.get(index); + } else { + return indexesUsedBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List + getIndexesUsedOrBuilderList() { + if (indexesUsedBuilder_ != null) { + return indexesUsedBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(indexesUsed_); + } + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder addIndexesUsedBuilder() { + return internalGetIndexesUsedFieldBuilder() + .addBuilder(com.google.protobuf.Struct.getDefaultInstance()); + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public com.google.protobuf.Struct.Builder addIndexesUsedBuilder(int index) { + return internalGetIndexesUsedFieldBuilder() + .addBuilder(index, com.google.protobuf.Struct.getDefaultInstance()); + } + + /** + * + * + *
+     * The indexes selected for the query. For example:
+     * [
+     * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+     * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+     * ]
+     * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + public java.util.List getIndexesUsedBuilderList() { + return internalGetIndexesUsedFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + internalGetIndexesUsedFieldBuilder() { + if (indexesUsedBuilder_ == null) { + indexesUsedBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + indexesUsed_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexesUsed_ = null; + } + return indexesUsedBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.PlanSummary) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.PlanSummary) + private static final com.google.firestore.v1.PlanSummary DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.PlanSummary(); + } + + public static com.google.firestore.v1.PlanSummary getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PlanSummary parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.PlanSummary getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java new file mode 100644 index 000000000000..a2995972dba8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PlanSummaryOrBuilder.java @@ -0,0 +1,103 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface PlanSummaryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.PlanSummary) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + java.util.List getIndexesUsedList(); + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + com.google.protobuf.Struct getIndexesUsed(int index); + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + int getIndexesUsedCount(); + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + java.util.List getIndexesUsedOrBuilderList(); + + /** + * + * + *
+   * The indexes selected for the query. For example:
+   * [
+   * {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"},
+   * {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"}
+   * ]
+   * 
+ * + * repeated .google.protobuf.Struct indexes_used = 1; + */ + com.google.protobuf.StructOrBuilder getIndexesUsedOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java new file mode 100644 index 000000000000..34862ea30266 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Precondition.java @@ -0,0 +1,945 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A precondition on a document, used for conditional operations.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Precondition} + */ +@com.google.protobuf.Generated +public final class Precondition extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Precondition) + PreconditionOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Precondition"); + } + + // Use Precondition.newBuilder() to construct. + private Precondition(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Precondition() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_Precondition_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_Precondition_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Precondition.class, + com.google.firestore.v1.Precondition.Builder.class); + } + + private int conditionTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object conditionType_; + + public enum ConditionTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + EXISTS(1), + UPDATE_TIME(2), + CONDITIONTYPE_NOT_SET(0); + private final int value; + + private ConditionTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConditionTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ConditionTypeCase forNumber(int value) { + switch (value) { + case 1: + return EXISTS; + case 2: + return UPDATE_TIME; + case 0: + return CONDITIONTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConditionTypeCase getConditionTypeCase() { + return ConditionTypeCase.forNumber(conditionTypeCase_); + } + + 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; + } + + /** + * + * + *
+   * When set to `true`, the target document must exist.
+   * When set to `false`, the target document must not exist.
+   * 
+ * + * bool exists = 1; + * + * @return The exists. + */ + @java.lang.Override + public boolean getExists() { + if (conditionTypeCase_ == 1) { + return (java.lang.Boolean) conditionType_; + } + return false; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 2; + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return conditionTypeCase_ == 2; + } + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + if (conditionTypeCase_ == 2) { + return (com.google.protobuf.Timestamp) conditionType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (conditionTypeCase_ == 2) { + return (com.google.protobuf.Timestamp) conditionType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (conditionTypeCase_ == 1) { + output.writeBool(1, (boolean) ((java.lang.Boolean) conditionType_)); + } + if (conditionTypeCase_ == 2) { + output.writeMessage(2, (com.google.protobuf.Timestamp) conditionType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (conditionTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 1, (boolean) ((java.lang.Boolean) conditionType_)); + } + if (conditionTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.protobuf.Timestamp) conditionType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Precondition)) { + return super.equals(obj); + } + com.google.firestore.v1.Precondition other = (com.google.firestore.v1.Precondition) obj; + + if (!getConditionTypeCase().equals(other.getConditionTypeCase())) return false; + switch (conditionTypeCase_) { + case 1: + if (getExists() != other.getExists()) return false; + break; + case 2: + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (conditionTypeCase_) { + case 1: + hash = (37 * hash) + EXISTS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getExists()); + break; + case 2: + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Precondition parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Precondition parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Precondition parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Precondition parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Precondition parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Precondition parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Precondition parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Precondition parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Precondition parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Precondition parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Precondition parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Precondition parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Precondition prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A precondition on a document, used for conditional operations.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Precondition} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Precondition) + com.google.firestore.v1.PreconditionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_Precondition_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_Precondition_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Precondition.class, + com.google.firestore.v1.Precondition.Builder.class); + } + + // Construct using com.google.firestore.v1.Precondition.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.clear(); + } + conditionTypeCase_ = 0; + conditionType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_Precondition_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Precondition getDefaultInstanceForType() { + return com.google.firestore.v1.Precondition.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Precondition build() { + com.google.firestore.v1.Precondition result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Precondition buildPartial() { + com.google.firestore.v1.Precondition result = new com.google.firestore.v1.Precondition(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Precondition result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.Precondition result) { + result.conditionTypeCase_ = conditionTypeCase_; + result.conditionType_ = this.conditionType_; + if (conditionTypeCase_ == 2 && updateTimeBuilder_ != null) { + result.conditionType_ = updateTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Precondition) { + return mergeFrom((com.google.firestore.v1.Precondition) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Precondition other) { + if (other == com.google.firestore.v1.Precondition.getDefaultInstance()) return this; + switch (other.getConditionTypeCase()) { + case EXISTS: + { + setExists(other.getExists()); + break; + } + case UPDATE_TIME: + { + mergeUpdateTime(other.getUpdateTime()); + break; + } + case CONDITIONTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + conditionType_ = input.readBool(); + conditionTypeCase_ = 1; + break; + } // case 8 + case 18: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + conditionTypeCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int conditionTypeCase_ = 0; + private java.lang.Object conditionType_; + + public ConditionTypeCase getConditionTypeCase() { + return ConditionTypeCase.forNumber(conditionTypeCase_); + } + + public Builder clearConditionType() { + conditionTypeCase_ = 0; + conditionType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + /** + * + * + *
+     * 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; + } + + /** + * + * + *
+     * When set to `true`, the target document must exist.
+     * When set to `false`, the target document must not exist.
+     * 
+ * + * bool exists = 1; + * + * @return The exists. + */ + public boolean getExists() { + if (conditionTypeCase_ == 1) { + return (java.lang.Boolean) conditionType_; + } + return false; + } + + /** + * + * + *
+     * When set to `true`, the target document must exist.
+     * When set to `false`, the target document must not exist.
+     * 
+ * + * bool exists = 1; + * + * @param value The exists to set. + * @return This builder for chaining. + */ + public Builder setExists(boolean value) { + + conditionTypeCase_ = 1; + conditionType_ = value; + onChanged(); + 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 This builder for chaining. + */ + public Builder clearExists() { + if (conditionTypeCase_ == 1) { + conditionTypeCase_ = 0; + conditionType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return conditionTypeCase_ == 2; + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + if (conditionTypeCase_ == 2) { + return (com.google.protobuf.Timestamp) conditionType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (conditionTypeCase_ == 2) { + return updateTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + conditionType_ = value; + onChanged(); + } else { + updateTimeBuilder_.setMessage(value); + } + conditionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + conditionType_ = builderForValue.build(); + onChanged(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + conditionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (conditionTypeCase_ == 2 + && conditionType_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + conditionType_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) conditionType_) + .mergeFrom(value) + .buildPartial(); + } else { + conditionType_ = value; + } + onChanged(); + } else { + if (conditionTypeCase_ == 2) { + updateTimeBuilder_.mergeFrom(value); + } else { + updateTimeBuilder_.setMessage(value); + } + } + conditionTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + public Builder clearUpdateTime() { + if (updateTimeBuilder_ == null) { + if (conditionTypeCase_ == 2) { + conditionTypeCase_ = 0; + conditionType_ = null; + onChanged(); + } + } else { + if (conditionTypeCase_ == 2) { + conditionTypeCase_ = 0; + conditionType_ = null; + } + updateTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if ((conditionTypeCase_ == 2) && (updateTimeBuilder_ != null)) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + if (conditionTypeCase_ == 2) { + return (com.google.protobuf.Timestamp) conditionType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * When set, the target document must exist and have been last updated at
+     * that time. Timestamp must be microsecond aligned.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + if (!(conditionTypeCase_ == 2)) { + conditionType_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) conditionType_, getParentForChildren(), isClean()); + conditionType_ = null; + } + conditionTypeCase_ = 2; + onChanged(); + return updateTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Precondition) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Precondition) + private static final com.google.firestore.v1.Precondition DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Precondition(); + } + + public static com.google.firestore.v1.Precondition getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Precondition parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Precondition getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java new file mode 100644 index 000000000000..7d788837d9cb --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/PreconditionOrBuilder.java @@ -0,0 +1,98 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface PreconditionOrBuilder + extends + // @@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(); + + /** + * + * + *
+   * When set to `true`, the target document must exist.
+   * When set to `false`, the target document must not exist.
+   * 
+ * + * bool exists = 1; + * + * @return The exists. + */ + boolean getExists(); + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * When set, the target document must exist and have been last updated at
+   * that time. Timestamp must be microsecond aligned.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + com.google.firestore.v1.Precondition.ConditionTypeCase getConditionTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java new file mode 100644 index 000000000000..81c220a6f2d0 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProfileProto.java @@ -0,0 +1,140 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query_profile.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class QueryProfileProto extends com.google.protobuf.GeneratedFile { + private QueryProfileProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "QueryProfileProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExplainOptions_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExplainMetrics_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_PlanSummary_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExecutionStats_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\'google/firestore/v1/query_profile.prot" + + "o\022\023google.firestore.v1\032\037google/api/field" + + "_behavior.proto\032\036google/protobuf/duratio" + + "n.proto\032\034google/protobuf/struct.proto\"&\n" + + "\016ExplainOptions\022\024\n\007analyze\030\001 \001(\010B\003\340A\001\"\206\001" + + "\n\016ExplainMetrics\0226\n\014plan_summary\030\001 \001(\0132 " + + ".google.firestore.v1.PlanSummary\022<\n\017exec" + + "ution_stats\030\002 \001(\0132#.google.firestore.v1." + + "ExecutionStats\"<\n\013PlanSummary\022-\n\014indexes" + + "_used\030\001 \003(\0132\027.google.protobuf.Struct\"\250\001\n" + + "\016ExecutionStats\022\030\n\020results_returned\030\001 \001(" + + "\003\0225\n\022execution_duration\030\003 \001(\0132\031.google.p" + + "rotobuf.Duration\022\027\n\017read_operations\030\004 \001(" + + "\003\022,\n\013debug_stats\030\005 \001(\0132\027.google.protobuf" + + ".StructB\311\001\n\027com.google.firestore.v1B\021Que" + + "ryProfileProtoP\001Z;cloud.google.com/go/fi" + + "restore/apiv1/firestorepb;firestorepb\242\002\004" + + "GCFS\252\002\031Google.Cloud.Firestore.V1\312\002\031Googl" + + "e\\Cloud\\Firestore\\V1\352\002\034Google::Cloud::Fi" + + "restore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.StructProto.getDescriptor(), + }); + internal_static_google_firestore_v1_ExplainOptions_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_ExplainOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ExplainOptions_descriptor, + new java.lang.String[] { + "Analyze", + }); + internal_static_google_firestore_v1_ExplainMetrics_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_ExplainMetrics_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ExplainMetrics_descriptor, + new java.lang.String[] { + "PlanSummary", "ExecutionStats", + }); + internal_static_google_firestore_v1_PlanSummary_descriptor = getDescriptor().getMessageType(2); + internal_static_google_firestore_v1_PlanSummary_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_PlanSummary_descriptor, + new java.lang.String[] { + "IndexesUsed", + }); + internal_static_google_firestore_v1_ExecutionStats_descriptor = + getDescriptor().getMessageType(3); + internal_static_google_firestore_v1_ExecutionStats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ExecutionStats_descriptor, + new java.lang.String[] { + "ResultsReturned", "ExecutionDuration", "ReadOperations", "DebugStats", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.StructProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java new file mode 100644 index 000000000000..9757e328fdf7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/QueryProto.java @@ -0,0 +1,373 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class QueryProto extends com.google.protobuf.GeneratedFile { + private QueryProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "QueryProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_Filter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_FieldFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_Order_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_Order_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_FieldReference_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_Projection_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredAggregationQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Cursor_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Cursor_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\037google/firestore/v1/query.proto\022\023googl" + + "e.firestore.v1\032\037google/api/field_behavio" + + "r.proto\032\"google/firestore/v1/document.pr" + + "oto\032\036google/protobuf/wrappers.proto\"\370\023\n\017" + + "StructuredQuery\022?\n\006select\030\001 \001(\0132/.google" + + ".firestore.v1.StructuredQuery.Projection" + + "\022E\n\004from\030\002 \003(\01327.google.firestore.v1.Str" + + "ucturedQuery.CollectionSelector\022:\n\005where" + + "\030\003 \001(\0132+.google.firestore.v1.StructuredQ" + + "uery.Filter\022<\n\010order_by\030\004 \003(\0132*.google.f" + + "irestore.v1.StructuredQuery.Order\022-\n\010sta" + + "rt_at\030\007 \001(\0132\033.google.firestore.v1.Cursor" + + "\022+\n\006end_at\030\010 \001(\0132\033.google.firestore.v1.C" + + "ursor\022\016\n\006offset\030\006 \001(\005\022*\n\005limit\030\005 \001(\0132\033.g" + + "oogle.protobuf.Int32Value\022K\n\014find_neares" + + "t\030\t \001(\01320.google.firestore.v1.Structured" + + "Query.FindNearestB\003\340A\001\032D\n\022CollectionSele" + + "ctor\022\025\n\rcollection_id\030\002 \001(\t\022\027\n\017all_desce" + + "ndants\030\003 \001(\010\032\375\001\n\006Filter\022P\n\020composite_fil" + + "ter\030\001 \001(\01324.google.firestore.v1.Structur" + + "edQuery.CompositeFilterH\000\022H\n\014field_filte" + + "r\030\002 \001(\01320.google.firestore.v1.Structured" + + "Query.FieldFilterH\000\022H\n\014unary_filter\030\003 \001(" + + "\01320.google.firestore.v1.StructuredQuery." + + "UnaryFilterH\000B\r\n\013filter_type\032\321\001\n\017Composi" + + "teFilter\022I\n\002op\030\001 \001(\0162=.google.firestore." + + "v1.StructuredQuery.CompositeFilter.Opera" + + "tor\022<\n\007filters\030\002 \003(\0132+.google.firestore." + + "v1.StructuredQuery.Filter\"5\n\010Operator\022\030\n" + + "\024OPERATOR_UNSPECIFIED\020\000\022\007\n\003AND\020\001\022\006\n\002OR\020\002" + + "\032\230\003\n\013FieldFilter\022B\n\005field\030\001 \001(\01323.google" + + ".firestore.v1.StructuredQuery.FieldRefer" + + "ence\022E\n\002op\030\002 \001(\01629.google.firestore.v1.S" + + "tructuredQuery.FieldFilter.Operator\022)\n\005v" + + "alue\030\003 \001(\0132\032.google.firestore.v1.Value\"\322" + + "\001\n\010Operator\022\030\n\024OPERATOR_UNSPECIFIED\020\000\022\r\n" + + "\tLESS_THAN\020\001\022\026\n\022LESS_THAN_OR_EQUAL\020\002\022\020\n\014" + + "GREATER_THAN\020\003\022\031\n\025GREATER_THAN_OR_EQUAL\020" + + "\004\022\t\n\005EQUAL\020\005\022\r\n\tNOT_EQUAL\020\006\022\022\n\016ARRAY_CON" + + "TAINS\020\007\022\006\n\002IN\020\010\022\026\n\022ARRAY_CONTAINS_ANY\020\t\022" + + "\n\n\006NOT_IN\020\n\032\212\002\n\013UnaryFilter\022E\n\002op\030\001 \001(\0162" + + "9.google.firestore.v1.StructuredQuery.Un" + + "aryFilter.Operator\022D\n\005field\030\002 \001(\01323.goog" + + "le.firestore.v1.StructuredQuery.FieldRef" + + "erenceH\000\"^\n\010Operator\022\030\n\024OPERATOR_UNSPECI" + + "FIED\020\000\022\n\n\006IS_NAN\020\002\022\013\n\007IS_NULL\020\003\022\016\n\nIS_NO" + + "T_NAN\020\004\022\017\n\013IS_NOT_NULL\020\005B\016\n\014operand_type" + + "\032\216\001\n\005Order\022B\n\005field\030\001 \001(\01323.google.fires" + + "tore.v1.StructuredQuery.FieldReference\022A" + + "\n\tdirection\030\002 \001(\0162..google.firestore.v1." + + "StructuredQuery.Direction\032$\n\016FieldRefere" + + "nce\022\022\n\nfield_path\030\002 \001(\t\032Q\n\nProjection\022C\n" + + "\006fields\030\002 \003(\01323.google.firestore.v1.Stru" + + "cturedQuery.FieldReference\032\352\003\n\013FindNeare" + + "st\022N\n\014vector_field\030\001 \001(\01323.google.firest" + + "ore.v1.StructuredQuery.FieldReferenceB\003\340" + + "A\002\0225\n\014query_vector\030\002 \001(\0132\032.google.firest" + + "ore.v1.ValueB\003\340A\002\022_\n\020distance_measure\030\003 " + + "\001(\0162@.google.firestore.v1.StructuredQuer" + + "y.FindNearest.DistanceMeasureB\003\340A\002\022/\n\005li" + + "mit\030\004 \001(\0132\033.google.protobuf.Int32ValueB\003" + + "\340A\002\022\"\n\025distance_result_field\030\005 \001(\tB\003\340A\001\022" + + "=\n\022distance_threshold\030\006 \001(\0132\034.google.pro" + + "tobuf.DoubleValueB\003\340A\001\"_\n\017DistanceMeasur" + + "e\022 \n\034DISTANCE_MEASURE_UNSPECIFIED\020\000\022\r\n\tE" + + "UCLIDEAN\020\001\022\n\n\006COSINE\020\002\022\017\n\013DOT_PRODUCT\020\003\"" + + "E\n\tDirection\022\031\n\025DIRECTION_UNSPECIFIED\020\000\022" + + "\r\n\tASCENDING\020\001\022\016\n\nDESCENDING\020\002\"\270\005\n\032Struc" + + "turedAggregationQuery\022@\n\020structured_quer" + + "y\030\001 \001(\0132$.google.firestore.v1.Structured" + + "QueryH\000\022V\n\014aggregations\030\003 \003(\0132;.google.f" + + "irestore.v1.StructuredAggregationQuery.A" + + "ggregationB\003\340A\001\032\361\003\n\013Aggregation\022R\n\005count" + + "\030\001 \001(\0132A.google.firestore.v1.StructuredA" + + "ggregationQuery.Aggregation.CountH\000\022N\n\003s" + + "um\030\002 \001(\0132?.google.firestore.v1.Structure" + + "dAggregationQuery.Aggregation.SumH\000\022N\n\003a" + + "vg\030\003 \001(\0132?.google.firestore.v1.Structure" + + "dAggregationQuery.Aggregation.AvgH\000\022\022\n\005a" + + "lias\030\007 \001(\tB\003\340A\001\0328\n\005Count\022/\n\005up_to\030\001 \001(\0132" + + "\033.google.protobuf.Int64ValueB\003\340A\001\032I\n\003Sum" + + "\022B\n\005field\030\001 \001(\01323.google.firestore.v1.St" + + "ructuredQuery.FieldReference\032I\n\003Avg\022B\n\005f" + + "ield\030\001 \001(\01323.google.firestore.v1.Structu" + + "redQuery.FieldReferenceB\n\n\010operatorB\014\n\nq" + + "uery_type\"D\n\006Cursor\022*\n\006values\030\001 \003(\0132\032.go" + + "ogle.firestore.v1.Value\022\016\n\006before\030\002 \001(\010B" + + "\302\001\n\027com.google.firestore.v1B\nQueryProtoP" + + "\001Z;cloud.google.com/go/firestore/apiv1/f" + + "irestorepb;firestorepb\242\002\004GCFS\252\002\031Google.C" + + "loud.Firestore.V1\312\002\031Google\\Cloud\\Firesto" + + "re\\V1\352\002\034Google::Cloud::Firestore::V1b\006pr" + + "oto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.firestore.v1.DocumentProto.getDescriptor(), + com.google.protobuf.WrappersProto.getDescriptor(), + }); + internal_static_google_firestore_v1_StructuredQuery_descriptor = + getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_StructuredQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_descriptor, + new java.lang.String[] { + "Select", + "From", + "Where", + "OrderBy", + "StartAt", + "EndAt", + "Offset", + "Limit", + "FindNearest", + }); + internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(0); + internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor, + new java.lang.String[] { + "CollectionId", "AllDescendants", + }); + internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(1); + internal_static_google_firestore_v1_StructuredQuery_Filter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor, + new java.lang.String[] { + "CompositeFilter", "FieldFilter", "UnaryFilter", "FilterType", + }); + internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(2); + internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor, + new java.lang.String[] { + "Op", "Filters", + }); + internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(3); + internal_static_google_firestore_v1_StructuredQuery_FieldFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor, + new java.lang.String[] { + "Field", "Op", "Value", + }); + internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(4); + internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor, + new java.lang.String[] { + "Op", "Field", "OperandType", + }); + internal_static_google_firestore_v1_StructuredQuery_Order_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(5); + internal_static_google_firestore_v1_StructuredQuery_Order_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_Order_descriptor, + new java.lang.String[] { + "Field", "Direction", + }); + internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(6); + internal_static_google_firestore_v1_StructuredQuery_FieldReference_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor, + new java.lang.String[] { + "FieldPath", + }); + internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(7); + internal_static_google_firestore_v1_StructuredQuery_Projection_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor, + new java.lang.String[] { + "Fields", + }); + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor = + internal_static_google_firestore_v1_StructuredQuery_descriptor.getNestedType(8); + internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor, + new java.lang.String[] { + "VectorField", + "QueryVector", + "DistanceMeasure", + "Limit", + "DistanceResultField", + "DistanceThreshold", + }); + internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_StructuredAggregationQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor, + new java.lang.String[] { + "StructuredQuery", "Aggregations", "QueryType", + }); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor = + internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor.getNestedType(0); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor, + new java.lang.String[] { + "Count", "Sum", "Avg", "Alias", "Operator", + }); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor = + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor + .getNestedType(0); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor, + new java.lang.String[] { + "UpTo", + }); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor = + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor + .getNestedType(1); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor, + new java.lang.String[] { + "Field", + }); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor = + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor + .getNestedType(2); + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor, + new java.lang.String[] { + "Field", + }); + internal_static_google_firestore_v1_Cursor_descriptor = getDescriptor().getMessageType(2); + internal_static_google_firestore_v1_Cursor_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Cursor_descriptor, + new java.lang.String[] { + "Values", "Before", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.firestore.v1.DocumentProto.getDescriptor(); + com.google.protobuf.WrappersProto.getDescriptor(); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequest.java new file mode 100644 index 000000000000..2eec9972e522 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequest.java @@ -0,0 +1,701 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.RollbackRequest} + */ +@com.google.protobuf.Generated +public final class RollbackRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.RollbackRequest) + RollbackRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RollbackRequest"); + } + + // Use RollbackRequest.newBuilder() to construct. + private RollbackRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RollbackRequest() { + database_ = ""; + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RollbackRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RollbackRequest.class, + com.google.firestore.v1.RollbackRequest.Builder.class); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TRANSACTION_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * Required. The transaction to roll back.
+   * 
+ * + * bytes transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (!transaction_.isEmpty()) { + output.writeBytes(2, transaction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, transaction_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.RollbackRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.RollbackRequest other = (com.google.firestore.v1.RollbackRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getTransaction().equals(other.getTransaction())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.RollbackRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RollbackRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RollbackRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RollbackRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.RollbackRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.RollbackRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.RollbackRequest) + com.google.firestore.v1.RollbackRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RollbackRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RollbackRequest.class, + com.google.firestore.v1.RollbackRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.RollbackRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + transaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.RollbackRequest getDefaultInstanceForType() { + return com.google.firestore.v1.RollbackRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.RollbackRequest build() { + com.google.firestore.v1.RollbackRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.RollbackRequest buildPartial() { + com.google.firestore.v1.RollbackRequest result = + new com.google.firestore.v1.RollbackRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.RollbackRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.transaction_ = transaction_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.RollbackRequest) { + return mergeFrom((com.google.firestore.v1.RollbackRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.RollbackRequest other) { + if (other == com.google.firestore.v1.RollbackRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * Required. The transaction to roll back.
+     * 
+ * + * bytes transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * Required. The transaction to roll back.
+     * 
+ * + * bytes transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The transaction to roll back.
+     * 
+ * + * bytes transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000002); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.RollbackRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.RollbackRequest) + private static final com.google.firestore.v1.RollbackRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.RollbackRequest(); + } + + public static com.google.firestore.v1.RollbackRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RollbackRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.RollbackRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequestOrBuilder.java new file mode 100644 index 000000000000..51ac517d2168 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RollbackRequestOrBuilder.java @@ -0,0 +1,69 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface RollbackRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.RollbackRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * Required. The transaction to roll back.
+   * 
+ * + * bytes transaction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequest.java new file mode 100644 index 000000000000..87dfcd5e2b4f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequest.java @@ -0,0 +1,2299 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.RunAggregationQueryRequest} + */ +@com.google.protobuf.Generated +public final class RunAggregationQueryRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.RunAggregationQueryRequest) + RunAggregationQueryRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RunAggregationQueryRequest"); + } + + // Use RunAggregationQueryRequest.newBuilder() to construct. + private RunAggregationQueryRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RunAggregationQueryRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunAggregationQueryRequest.class, + com.google.firestore.v1.RunAggregationQueryRequest.Builder.class); + } + + private int bitField0_; + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_AGGREGATION_QUERY(2), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_AGGREGATION_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(4), + NEW_TRANSACTION(5), + READ_TIME(6), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 4: + return TRANSACTION; + case 5: + return NEW_TRANSACTION; + case 6: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_AGGREGATION_QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * @return Whether the structuredAggregationQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredAggregationQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * @return The structuredAggregationQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery getStructuredAggregationQuery() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery) queryType_; + } + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQueryOrBuilder + getStructuredAggregationQueryOrBuilder() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery) queryType_; + } + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 4; + + /** + * + * + *
+   * Run the aggregation within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 4; + } + + /** + * + * + *
+   * Run the aggregation within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + public static final int EXPLAIN_OPTIONS_FIELD_NUMBER = 8; + private com.google.firestore.v1.ExplainOptions explainOptions_; + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + @java.lang.Override + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getExplainOptions() { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (queryTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredAggregationQuery) queryType_); + } + if (consistencySelectorCase_ == 4) { + output.writeBytes(4, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + output.writeMessage(5, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(8, getExplainOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (queryTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredAggregationQuery) queryType_); + } + if (consistencySelectorCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 4, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getExplainOptions()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.RunAggregationQueryRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.RunAggregationQueryRequest other = + (com.google.firestore.v1.RunAggregationQueryRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasExplainOptions() != other.hasExplainOptions()) return false; + if (hasExplainOptions()) { + if (!getExplainOptions().equals(other.getExplainOptions())) return false; + } + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 2: + if (!getStructuredAggregationQuery().equals(other.getStructuredAggregationQuery())) + return false; + break; + case 0: + default: + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 4: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 5: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + case 6: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasExplainOptions()) { + hash = (37 * hash) + EXPLAIN_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getExplainOptions().hashCode(); + } + switch (queryTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_AGGREGATION_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredAggregationQuery().hashCode(); + break; + case 0: + default: + } + switch (consistencySelectorCase_) { + case 4: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 5: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + case 6: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.RunAggregationQueryRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.RunAggregationQueryRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.RunAggregationQueryRequest) + com.google.firestore.v1.RunAggregationQueryRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunAggregationQueryRequest.class, + com.google.firestore.v1.RunAggregationQueryRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.RunAggregationQueryRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetExplainOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + if (structuredAggregationQueryBuilder_ != null) { + structuredAggregationQueryBuilder_.clear(); + } + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + queryTypeCase_ = 0; + queryType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryRequest getDefaultInstanceForType() { + return com.google.firestore.v1.RunAggregationQueryRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryRequest build() { + com.google.firestore.v1.RunAggregationQueryRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryRequest buildPartial() { + com.google.firestore.v1.RunAggregationQueryRequest result = + new com.google.firestore.v1.RunAggregationQueryRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.RunAggregationQueryRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000020) != 0)) { + result.explainOptions_ = + explainOptionsBuilder_ == null ? explainOptions_ : explainOptionsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.RunAggregationQueryRequest result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 2 && structuredAggregationQueryBuilder_ != null) { + result.queryType_ = structuredAggregationQueryBuilder_.build(); + } + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 5 && newTransactionBuilder_ != null) { + result.consistencySelector_ = newTransactionBuilder_.build(); + } + if (consistencySelectorCase_ == 6 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.RunAggregationQueryRequest) { + return mergeFrom((com.google.firestore.v1.RunAggregationQueryRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.RunAggregationQueryRequest other) { + if (other == com.google.firestore.v1.RunAggregationQueryRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasExplainOptions()) { + mergeExplainOptions(other.getExplainOptions()); + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_AGGREGATION_QUERY: + { + mergeStructuredAggregationQuery(other.getStructuredAggregationQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredAggregationQueryFieldBuilder().getBuilder(), + extensionRegistry); + queryTypeCase_ = 2; + break; + } // case 18 + case 34: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage( + internalGetNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 6; + break; + } // case 50 + case 66: + { + input.readMessage( + internalGetExplainOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 66 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery, + com.google.firestore.v1.StructuredAggregationQuery.Builder, + com.google.firestore.v1.StructuredAggregationQueryOrBuilder> + structuredAggregationQueryBuilder_; + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * + * @return Whether the structuredAggregationQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredAggregationQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * + * @return The structuredAggregationQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery getStructuredAggregationQuery() { + if (structuredAggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery) queryType_; + } + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 2) { + return structuredAggregationQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + public Builder setStructuredAggregationQuery( + com.google.firestore.v1.StructuredAggregationQuery value) { + if (structuredAggregationQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredAggregationQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + public Builder setStructuredAggregationQuery( + com.google.firestore.v1.StructuredAggregationQuery.Builder builderForValue) { + if (structuredAggregationQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredAggregationQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + public Builder mergeStructuredAggregationQuery( + com.google.firestore.v1.StructuredAggregationQuery value) { + if (structuredAggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 2 + && queryType_ + != com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredAggregationQuery.newBuilder( + (com.google.firestore.v1.StructuredAggregationQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 2) { + structuredAggregationQueryBuilder_.mergeFrom(value); + } else { + structuredAggregationQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + public Builder clearStructuredAggregationQuery() { + if (structuredAggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredAggregationQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.Builder + getStructuredAggregationQueryBuilder() { + return internalGetStructuredAggregationQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQueryOrBuilder + getStructuredAggregationQueryOrBuilder() { + if ((queryTypeCase_ == 2) && (structuredAggregationQueryBuilder_ != null)) { + return structuredAggregationQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery) queryType_; + } + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An aggregation query.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery, + com.google.firestore.v1.StructuredAggregationQuery.Builder, + com.google.firestore.v1.StructuredAggregationQueryOrBuilder> + internalGetStructuredAggregationQueryFieldBuilder() { + if (structuredAggregationQueryBuilder_ == null) { + if (!(queryTypeCase_ == 2)) { + queryType_ = com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + structuredAggregationQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery, + com.google.firestore.v1.StructuredAggregationQuery.Builder, + com.google.firestore.v1.StructuredAggregationQueryOrBuilder>( + (com.google.firestore.v1.StructuredAggregationQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 2; + onChanged(); + return structuredAggregationQueryBuilder_; + } + + /** + * + * + *
+     * Run the aggregation within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 4; + } + + /** + * + * + *
+     * Run the aggregation within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 4) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Run the aggregation within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 4; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 4; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Run the aggregation within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 4; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 4) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 5) { + return newTransactionBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder setNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder setNewTransaction( + com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder mergeNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5 + && consistencySelector_ + != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + consistencySelector_ = + com.google.firestore.v1.TransactionOptions.newBuilder( + (com.google.firestore.v1.TransactionOptions) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 5) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 5; + return this; + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + public com.google.firestore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return internalGetNewTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencySelectorCase_ == 5) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 5) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction as part of the query, defaulting to read-only.
+     *
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + internalGetNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencySelectorCase_ == 5)) { + consistencySelector_ = com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + (com.google.firestore.v1.TransactionOptions) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 5; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 6) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Executes the query at the given timestamp.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + return readTimeBuilder_; + } + + private com.google.firestore.v1.ExplainOptions explainOptions_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder> + explainOptionsBuilder_; + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + public com.google.firestore.v1.ExplainOptions getExplainOptions() { + if (explainOptionsBuilder_ == null) { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } else { + return explainOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions(com.google.firestore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainOptions_ = value; + } else { + explainOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions( + com.google.firestore.v1.ExplainOptions.Builder builderForValue) { + if (explainOptionsBuilder_ == null) { + explainOptions_ = builderForValue.build(); + } else { + explainOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeExplainOptions(com.google.firestore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && explainOptions_ != null + && explainOptions_ != com.google.firestore.v1.ExplainOptions.getDefaultInstance()) { + getExplainOptionsBuilder().mergeFrom(value); + } else { + explainOptions_ = value; + } + } else { + explainOptionsBuilder_.mergeFrom(value); + } + if (explainOptions_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearExplainOptions() { + bitField0_ = (bitField0_ & ~0x00000020); + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ExplainOptions.Builder getExplainOptionsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetExplainOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + if (explainOptionsBuilder_ != null) { + return explainOptionsBuilder_.getMessageOrBuilder(); + } else { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder> + internalGetExplainOptionsFieldBuilder() { + if (explainOptionsBuilder_ == null) { + explainOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder>( + getExplainOptions(), getParentForChildren(), isClean()); + explainOptions_ = null; + } + return explainOptionsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.RunAggregationQueryRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.RunAggregationQueryRequest) + private static final com.google.firestore.v1.RunAggregationQueryRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.RunAggregationQueryRequest(); + } + + public static com.google.firestore.v1.RunAggregationQueryRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RunAggregationQueryRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequestOrBuilder.java new file mode 100644 index 000000000000..681eda3f5741 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryRequestOrBuilder.java @@ -0,0 +1,278 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface RunAggregationQueryRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.RunAggregationQueryRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * @return Whether the structuredAggregationQuery field is set. + */ + boolean hasStructuredAggregationQuery(); + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + * + * @return The structuredAggregationQuery. + */ + com.google.firestore.v1.StructuredAggregationQuery getStructuredAggregationQuery(); + + /** + * + * + *
+   * An aggregation query.
+   * 
+ * + * .google.firestore.v1.StructuredAggregationQuery structured_aggregation_query = 2; + */ + com.google.firestore.v1.StructuredAggregationQueryOrBuilder + getStructuredAggregationQueryOrBuilder(); + + /** + * + * + *
+   * Run the aggregation within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 4; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Run the aggregation within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 4; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + * + * @return The newTransaction. + */ + com.google.firestore.v1.TransactionOptions getNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction as part of the query, defaulting to read-only.
+   *
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 5; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Executes the query at the given timestamp.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + boolean hasExplainOptions(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + com.google.firestore.v1.ExplainOptions getExplainOptions(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 8 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder(); + + com.google.firestore.v1.RunAggregationQueryRequest.QueryTypeCase getQueryTypeCase(); + + com.google.firestore.v1.RunAggregationQueryRequest.ConsistencySelectorCase + getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponse.java new file mode 100644 index 000000000000..ff380b87685c --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponse.java @@ -0,0 +1,1500 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for
+ * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.RunAggregationQueryResponse} + */ +@com.google.protobuf.Generated +public final class RunAggregationQueryResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.RunAggregationQueryResponse) + RunAggregationQueryResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RunAggregationQueryResponse"); + } + + // Use RunAggregationQueryResponse.newBuilder() to construct. + private RunAggregationQueryResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RunAggregationQueryResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunAggregationQueryResponse.class, + com.google.firestore.v1.RunAggregationQueryResponse.Builder.class); + } + + private int bitField0_; + public static final int RESULT_FIELD_NUMBER = 1; + private com.google.firestore.v1.AggregationResult result_; + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return Whether the result field is set. + */ + @java.lang.Override + public boolean hasResult() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return The result. + */ + @java.lang.Override + public com.google.firestore.v1.AggregationResult getResult() { + return result_ == null + ? com.google.firestore.v1.AggregationResult.getDefaultInstance() + : result_; + } + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + @java.lang.Override + public com.google.firestore.v1.AggregationResultOrBuilder getResultOrBuilder() { + return result_ == null + ? com.google.firestore.v1.AggregationResult.getDefaultInstance() + : result_; + } + + public static final int TRANSACTION_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   *
+   * Only present on the first response when the request requested to start
+   * a new transaction.
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int READ_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + public static final int EXPLAIN_METRICS_FIELD_NUMBER = 10; + private com.google.firestore.v1.ExplainMetrics explainMetrics_; + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return Whether the explainMetrics field is set. + */ + @java.lang.Override + public boolean hasExplainMetrics() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return The explainMetrics. + */ + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getExplainMetrics() { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + @java.lang.Override + public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getResult()); + } + if (!transaction_.isEmpty()) { + output.writeBytes(2, transaction_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getReadTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(10, getExplainMetrics()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getResult()); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, transaction_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getReadTime()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getExplainMetrics()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.RunAggregationQueryResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.RunAggregationQueryResponse other = + (com.google.firestore.v1.RunAggregationQueryResponse) obj; + + if (hasResult() != other.hasResult()) return false; + if (hasResult()) { + if (!getResult().equals(other.getResult())) return false; + } + if (!getTransaction().equals(other.getTransaction())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (hasExplainMetrics() != other.hasExplainMetrics()) return false; + if (hasExplainMetrics()) { + if (!getExplainMetrics().equals(other.getExplainMetrics())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasResult()) { + hash = (37 * hash) + RESULT_FIELD_NUMBER; + hash = (53 * hash) + getResult().hashCode(); + } + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + if (hasExplainMetrics()) { + hash = (37 * hash) + EXPLAIN_METRICS_FIELD_NUMBER; + hash = (53 * hash) + getExplainMetrics().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.RunAggregationQueryResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.RunAggregationQueryResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.RunAggregationQueryResponse) + com.google.firestore.v1.RunAggregationQueryResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunAggregationQueryResponse.class, + com.google.firestore.v1.RunAggregationQueryResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.RunAggregationQueryResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetResultFieldBuilder(); + internalGetReadTimeFieldBuilder(); + internalGetExplainMetricsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + result_ = null; + if (resultBuilder_ != null) { + resultBuilder_.dispose(); + resultBuilder_ = null; + } + transaction_ = com.google.protobuf.ByteString.EMPTY; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryResponse getDefaultInstanceForType() { + return com.google.firestore.v1.RunAggregationQueryResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryResponse build() { + com.google.firestore.v1.RunAggregationQueryResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryResponse buildPartial() { + com.google.firestore.v1.RunAggregationQueryResponse result = + new com.google.firestore.v1.RunAggregationQueryResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.RunAggregationQueryResponse result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.result_ = resultBuilder_ == null ? result_ : resultBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.transaction_ = transaction_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.explainMetrics_ = + explainMetricsBuilder_ == null ? explainMetrics_ : explainMetricsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.RunAggregationQueryResponse) { + return mergeFrom((com.google.firestore.v1.RunAggregationQueryResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.RunAggregationQueryResponse other) { + if (other == com.google.firestore.v1.RunAggregationQueryResponse.getDefaultInstance()) + return this; + if (other.hasResult()) { + mergeResult(other.getResult()); + } + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + if (other.hasExplainMetrics()) { + mergeExplainMetrics(other.getExplainMetrics()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetResultFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 82: + { + input.readMessage( + internalGetExplainMetricsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 82 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.AggregationResult result_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.AggregationResult, + com.google.firestore.v1.AggregationResult.Builder, + com.google.firestore.v1.AggregationResultOrBuilder> + resultBuilder_; + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return Whether the result field is set. + */ + public boolean hasResult() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return The result. + */ + public com.google.firestore.v1.AggregationResult getResult() { + if (resultBuilder_ == null) { + return result_ == null + ? com.google.firestore.v1.AggregationResult.getDefaultInstance() + : result_; + } else { + return resultBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public Builder setResult(com.google.firestore.v1.AggregationResult value) { + if (resultBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + result_ = value; + } else { + resultBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public Builder setResult(com.google.firestore.v1.AggregationResult.Builder builderForValue) { + if (resultBuilder_ == null) { + result_ = builderForValue.build(); + } else { + resultBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public Builder mergeResult(com.google.firestore.v1.AggregationResult value) { + if (resultBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && result_ != null + && result_ != com.google.firestore.v1.AggregationResult.getDefaultInstance()) { + getResultBuilder().mergeFrom(value); + } else { + result_ = value; + } + } else { + resultBuilder_.mergeFrom(value); + } + if (result_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public Builder clearResult() { + bitField0_ = (bitField0_ & ~0x00000001); + result_ = null; + if (resultBuilder_ != null) { + resultBuilder_.dispose(); + resultBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public com.google.firestore.v1.AggregationResult.Builder getResultBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetResultFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + public com.google.firestore.v1.AggregationResultOrBuilder getResultOrBuilder() { + if (resultBuilder_ != null) { + return resultBuilder_.getMessageOrBuilder(); + } else { + return result_ == null + ? com.google.firestore.v1.AggregationResult.getDefaultInstance() + : result_; + } + } + + /** + * + * + *
+     * A single aggregation result.
+     *
+     * Not present when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.AggregationResult, + com.google.firestore.v1.AggregationResult.Builder, + com.google.firestore.v1.AggregationResultOrBuilder> + internalGetResultFieldBuilder() { + if (resultBuilder_ == null) { + resultBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.AggregationResult, + com.google.firestore.v1.AggregationResult.Builder, + com.google.firestore.v1.AggregationResultOrBuilder>( + getResult(), getParentForChildren(), isClean()); + result_ = null; + } + return resultBuilder_; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     *
+     * Only present on the first response when the request requested to start
+     * a new transaction.
+     * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     *
+     * Only present on the first response when the request requested to start
+     * a new transaction.
+     * 
+ * + * bytes transaction = 2; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     *
+     * Only present on the first response when the request requested to start
+     * a new transaction.
+     * 
+ * + * bytes transaction = 2; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000002); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The time at which the aggregate result was computed. This is always
+     * monotonically increasing; in this case, the previous AggregationResult in
+     * the result stream are guaranteed not to have changed between their
+     * `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `result` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + private com.google.firestore.v1.ExplainMetrics explainMetrics_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder> + explainMetricsBuilder_; + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return Whether the explainMetrics field is set. + */ + public boolean hasExplainMetrics() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return The explainMetrics. + */ + public com.google.firestore.v1.ExplainMetrics getExplainMetrics() { + if (explainMetricsBuilder_ == null) { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } else { + return explainMetricsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public Builder setExplainMetrics(com.google.firestore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainMetrics_ = value; + } else { + explainMetricsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public Builder setExplainMetrics( + com.google.firestore.v1.ExplainMetrics.Builder builderForValue) { + if (explainMetricsBuilder_ == null) { + explainMetrics_ = builderForValue.build(); + } else { + explainMetricsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public Builder mergeExplainMetrics(com.google.firestore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && explainMetrics_ != null + && explainMetrics_ != com.google.firestore.v1.ExplainMetrics.getDefaultInstance()) { + getExplainMetricsBuilder().mergeFrom(value); + } else { + explainMetrics_ = value; + } + } else { + explainMetricsBuilder_.mergeFrom(value); + } + if (explainMetrics_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public Builder clearExplainMetrics() { + bitField0_ = (bitField0_ & ~0x00000008); + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public com.google.firestore.v1.ExplainMetrics.Builder getExplainMetricsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetExplainMetricsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + if (explainMetricsBuilder_ != null) { + return explainMetricsBuilder_.getMessageOrBuilder(); + } else { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder> + internalGetExplainMetricsFieldBuilder() { + if (explainMetricsBuilder_ == null) { + explainMetricsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder>( + getExplainMetrics(), getParentForChildren(), isClean()); + explainMetrics_ = null; + } + return explainMetricsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.RunAggregationQueryResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.RunAggregationQueryResponse) + private static final com.google.firestore.v1.RunAggregationQueryResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.RunAggregationQueryResponse(); + } + + public static com.google.firestore.v1.RunAggregationQueryResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RunAggregationQueryResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.RunAggregationQueryResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponseOrBuilder.java new file mode 100644 index 000000000000..8b9b8a0db2d8 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunAggregationQueryResponseOrBuilder.java @@ -0,0 +1,188 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface RunAggregationQueryResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.RunAggregationQueryResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return Whether the result field is set. + */ + boolean hasResult(); + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + * + * @return The result. + */ + com.google.firestore.v1.AggregationResult getResult(); + + /** + * + * + *
+   * A single aggregation result.
+   *
+   * Not present when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.AggregationResult result = 1; + */ + com.google.firestore.v1.AggregationResultOrBuilder getResultOrBuilder(); + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   *
+   * Only present on the first response when the request requested to start
+   * a new transaction.
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The time at which the aggregate result was computed. This is always
+   * monotonically increasing; in this case, the previous AggregationResult in
+   * the result stream are guaranteed not to have changed between their
+   * `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `result` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return Whether the explainMetrics field is set. + */ + boolean hasExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + * + * @return The explainMetrics. + */ + com.google.firestore.v1.ExplainMetrics getExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 10; + */ + com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java new file mode 100644 index 000000000000..adf307ea4b9e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequest.java @@ -0,0 +1,2278 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.RunQueryRequest} + */ +@com.google.protobuf.Generated +public final class RunQueryRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.RunQueryRequest) + RunQueryRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RunQueryRequest"); + } + + // Use RunQueryRequest.newBuilder() to construct. + private RunQueryRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RunQueryRequest() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunQueryRequest.class, + com.google.firestore.v1.RunQueryRequest.Builder.class); + } + + private int bitField0_; + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_QUERY(2), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(5), + NEW_TRANSACTION(6), + READ_TIME(7), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 5: + return TRANSACTION; + case 6: + return NEW_TRANSACTION; + case 7: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 7; + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + public static final int EXPLAIN_OPTIONS_FIELD_NUMBER = 10; + private com.google.firestore.v1.ExplainOptions explainOptions_; + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + @java.lang.Override + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + @java.lang.Override + public com.google.firestore.v1.ExplainOptions getExplainOptions() { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (queryTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (consistencySelectorCase_ == 5) { + output.writeBytes(5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + output.writeMessage(7, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(10, getExplainOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (queryTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + if (consistencySelectorCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 5, (com.google.protobuf.ByteString) consistencySelector_); + } + if (consistencySelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.TransactionOptions) consistencySelector_); + } + if (consistencySelectorCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.protobuf.Timestamp) consistencySelector_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getExplainOptions()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.RunQueryRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.RunQueryRequest other = (com.google.firestore.v1.RunQueryRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (hasExplainOptions() != other.hasExplainOptions()) return false; + if (hasExplainOptions()) { + if (!getExplainOptions().equals(other.getExplainOptions())) return false; + } + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 2: + if (!getStructuredQuery().equals(other.getStructuredQuery())) return false; + break; + case 0: + default: + } + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 5: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 6: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + case 7: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + if (hasExplainOptions()) { + hash = (37 * hash) + EXPLAIN_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getExplainOptions().hashCode(); + } + switch (queryTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredQuery().hashCode(); + break; + case 0: + default: + } + switch (consistencySelectorCase_) { + case 5: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 6: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + case 7: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.RunQueryRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.RunQueryRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.RunQueryRequest) + com.google.firestore.v1.RunQueryRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunQueryRequest.class, + com.google.firestore.v1.RunQueryRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.RunQueryRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetExplainOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + if (structuredQueryBuilder_ != null) { + structuredQueryBuilder_.clear(); + } + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + queryTypeCase_ = 0; + queryType_ = null; + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryRequest getDefaultInstanceForType() { + return com.google.firestore.v1.RunQueryRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryRequest build() { + com.google.firestore.v1.RunQueryRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryRequest buildPartial() { + com.google.firestore.v1.RunQueryRequest result = + new com.google.firestore.v1.RunQueryRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.RunQueryRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000020) != 0)) { + result.explainOptions_ = + explainOptionsBuilder_ == null ? explainOptions_ : explainOptionsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.RunQueryRequest result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 2 && structuredQueryBuilder_ != null) { + result.queryType_ = structuredQueryBuilder_.build(); + } + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 6 && newTransactionBuilder_ != null) { + result.consistencySelector_ = newTransactionBuilder_.build(); + } + if (consistencySelectorCase_ == 7 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.RunQueryRequest) { + return mergeFrom((com.google.firestore.v1.RunQueryRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.RunQueryRequest other) { + if (other == com.google.firestore.v1.RunQueryRequest.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasExplainOptions()) { + mergeExplainOptions(other.getExplainOptions()); + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_QUERY: + { + mergeStructuredQuery(other.getStructuredQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + switch (other.getConsistencySelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 2; + break; + } // case 18 + case 42: + { + consistencySelector_ = input.readBytes(); + consistencySelectorCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 7; + break; + } // case 58 + case 82: + { + input.readMessage( + internalGetExplainOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 82 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + structuredQueryBuilder_; + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 2) { + return structuredQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery( + com.google.firestore.v1.StructuredQuery.Builder builderForValue) { + if (structuredQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder mergeStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2 + && queryType_ != com.google.firestore.v1.StructuredQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredQuery.newBuilder( + (com.google.firestore.v1.StructuredQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 2) { + structuredQueryBuilder_.mergeFrom(value); + } else { + structuredQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder clearStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public com.google.firestore.v1.StructuredQuery.Builder getStructuredQueryBuilder() { + return internalGetStructuredQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if ((queryTypeCase_ == 2) && (structuredQueryBuilder_ != null)) { + return structuredQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + internalGetStructuredQueryFieldBuilder() { + if (structuredQueryBuilder_ == null) { + if (!(queryTypeCase_ == 2)) { + queryType_ = com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + structuredQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder>( + (com.google.firestore.v1.StructuredQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 2; + onChanged(); + return structuredQueryBuilder_; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencySelectorCase_ == 5; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencySelectorCase_ == 5) { + return (com.google.protobuf.ByteString) consistencySelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelectorCase_ = 5; + consistencySelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Run the query within an already active transaction.
+     *
+     * The value here is the opaque transaction ID to execute the query in.
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencySelectorCase_ == 5) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencySelectorCase_ == 6; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 6) { + return newTransactionBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder setNewTransaction( + com.google.firestore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder mergeNewTransaction(com.google.firestore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6 + && consistencySelector_ + != com.google.firestore.v1.TransactionOptions.getDefaultInstance()) { + consistencySelector_ = + com.google.firestore.v1.TransactionOptions.newBuilder( + (com.google.firestore.v1.TransactionOptions) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 6) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 6; + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 6) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + public com.google.firestore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return internalGetNewTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencySelectorCase_ == 6) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 6) { + return (com.google.firestore.v1.TransactionOptions) consistencySelector_; + } + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Starts a new transaction and reads the documents.
+     * Defaults to a read-only transaction.
+     * The new transaction ID will be returned as the first response in the
+     * stream.
+     * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder> + internalGetNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencySelectorCase_ == 6)) { + consistencySelector_ = com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions, + com.google.firestore.v1.TransactionOptions.Builder, + com.google.firestore.v1.TransactionOptionsOrBuilder>( + (com.google.firestore.v1.TransactionOptions) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 6; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 7; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 7) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 7) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 7; + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 7) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 7) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 7) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads documents as they were at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one hour,
+     * or if Point-in-Time Recovery is enabled, can additionally be a whole
+     * minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 7)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 7; + onChanged(); + return readTimeBuilder_; + } + + private com.google.firestore.v1.ExplainOptions explainOptions_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder> + explainOptionsBuilder_; + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + public com.google.firestore.v1.ExplainOptions getExplainOptions() { + if (explainOptionsBuilder_ == null) { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } else { + return explainOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions(com.google.firestore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainOptions_ = value; + } else { + explainOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions( + com.google.firestore.v1.ExplainOptions.Builder builderForValue) { + if (explainOptionsBuilder_ == null) { + explainOptions_ = builderForValue.build(); + } else { + explainOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeExplainOptions(com.google.firestore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && explainOptions_ != null + && explainOptions_ != com.google.firestore.v1.ExplainOptions.getDefaultInstance()) { + getExplainOptionsBuilder().mergeFrom(value); + } else { + explainOptions_ = value; + } + } else { + explainOptionsBuilder_.mergeFrom(value); + } + if (explainOptions_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearExplainOptions() { + bitField0_ = (bitField0_ & ~0x00000020); + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ExplainOptions.Builder getExplainOptionsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetExplainOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + if (explainOptionsBuilder_ != null) { + return explainOptionsBuilder_.getMessageOrBuilder(); + } else { + return explainOptions_ == null + ? com.google.firestore.v1.ExplainOptions.getDefaultInstance() + : explainOptions_; + } + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder> + internalGetExplainOptionsFieldBuilder() { + if (explainOptionsBuilder_ == null) { + explainOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainOptions, + com.google.firestore.v1.ExplainOptions.Builder, + com.google.firestore.v1.ExplainOptionsOrBuilder>( + getExplainOptions(), getParentForChildren(), isClean()); + explainOptions_ = null; + } + return explainOptionsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.RunQueryRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.RunQueryRequest) + private static final com.google.firestore.v1.RunQueryRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.RunQueryRequest(); + } + + public static com.google.firestore.v1.RunQueryRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RunQueryRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java new file mode 100644 index 000000000000..0de211a15046 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryRequestOrBuilder.java @@ -0,0 +1,276 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface RunQueryRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.RunQueryRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+   * Required. The parent resource name. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents` or
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * For example:
+   * `projects/my-project/databases/my-database/documents` or
+   * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+   * 
+ * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + boolean hasStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + com.google.firestore.v1.StructuredQuery getStructuredQuery(); + + /** + * + * + *
+   * A structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * Run the query within an already active transaction.
+   *
+   * The value here is the opaque transaction ID to execute the query in.
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + * + * @return The newTransaction. + */ + com.google.firestore.v1.TransactionOptions getNewTransaction(); + + /** + * + * + *
+   * Starts a new transaction and reads the documents.
+   * Defaults to a read-only transaction.
+   * The new transaction ID will be returned as the first response in the
+   * stream.
+   * 
+ * + * .google.firestore.v1.TransactionOptions new_transaction = 6; + */ + com.google.firestore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Reads documents as they were at the given time.
+   *
+   * This must be a microsecond precision timestamp within the past one hour,
+   * or if Point-in-Time Recovery is enabled, can additionally be a whole
+   * minute timestamp within the past 7 days.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + boolean hasExplainOptions(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + com.google.firestore.v1.ExplainOptions getExplainOptions(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.firestore.v1.ExplainOptions explain_options = 10 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder(); + + com.google.firestore.v1.RunQueryRequest.QueryTypeCase getQueryTypeCase(); + + com.google.firestore.v1.RunQueryRequest.ConsistencySelectorCase getConsistencySelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponse.java new file mode 100644 index 000000000000..53b03ffe4a18 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponse.java @@ -0,0 +1,1790 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for
+ * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.RunQueryResponse} + */ +@com.google.protobuf.Generated +public final class RunQueryResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.RunQueryResponse) + RunQueryResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "RunQueryResponse"); + } + + // Use RunQueryResponse.newBuilder() to construct. + private RunQueryResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private RunQueryResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunQueryResponse.class, + com.google.firestore.v1.RunQueryResponse.Builder.class); + } + + private int bitField0_; + private int continuationSelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object continuationSelector_; + + public enum ContinuationSelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + DONE(6), + CONTINUATIONSELECTOR_NOT_SET(0); + private final int value; + + private ContinuationSelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ContinuationSelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ContinuationSelectorCase forNumber(int value) { + switch (value) { + case 6: + return DONE; + case 0: + return CONTINUATIONSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ContinuationSelectorCase getContinuationSelectorCase() { + return ContinuationSelectorCase.forNumber(continuationSelectorCase_); + } + + public static final int TRANSACTION_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   * Can only be set in the first response, and only if
+   * [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
+   * was set in the request. If set, no other fields will be set in this
+   * response.
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int DOCUMENT_FIELD_NUMBER = 1; + private com.google.firestore.v1.Document document_; + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + public static final int READ_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + public static final int SKIPPED_RESULTS_FIELD_NUMBER = 4; + private int skippedResults_ = 0; + + /** + * + * + *
+   * The number of results that have been skipped due to an offset between
+   * the last response and the current response.
+   * 
+ * + * int32 skipped_results = 4; + * + * @return The skippedResults. + */ + @java.lang.Override + public int getSkippedResults() { + return skippedResults_; + } + + public static final int DONE_FIELD_NUMBER = 6; + + /** + * + * + *
+   * If present, Firestore has completely finished the request and no more
+   * documents will be returned.
+   * 
+ * + * bool done = 6; + * + * @return Whether the done field is set. + */ + @java.lang.Override + public boolean hasDone() { + return continuationSelectorCase_ == 6; + } + + /** + * + * + *
+   * If present, Firestore has completely finished the request and no more
+   * documents will be returned.
+   * 
+ * + * bool done = 6; + * + * @return The done. + */ + @java.lang.Override + public boolean getDone() { + if (continuationSelectorCase_ == 6) { + return (java.lang.Boolean) continuationSelector_; + } + return false; + } + + public static final int EXPLAIN_METRICS_FIELD_NUMBER = 11; + private com.google.firestore.v1.ExplainMetrics explainMetrics_; + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return Whether the explainMetrics field is set. + */ + @java.lang.Override + public boolean hasExplainMetrics() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return The explainMetrics. + */ + @java.lang.Override + public com.google.firestore.v1.ExplainMetrics getExplainMetrics() { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + @java.lang.Override + public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getDocument()); + } + if (!transaction_.isEmpty()) { + output.writeBytes(2, transaction_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getReadTime()); + } + if (skippedResults_ != 0) { + output.writeInt32(4, skippedResults_); + } + if (continuationSelectorCase_ == 6) { + output.writeBool(6, (boolean) ((java.lang.Boolean) continuationSelector_)); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(11, getExplainMetrics()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDocument()); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, transaction_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getReadTime()); + } + if (skippedResults_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, skippedResults_); + } + if (continuationSelectorCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 6, (boolean) ((java.lang.Boolean) continuationSelector_)); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(11, getExplainMetrics()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.RunQueryResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.RunQueryResponse other = (com.google.firestore.v1.RunQueryResponse) obj; + + if (!getTransaction().equals(other.getTransaction())) return false; + if (hasDocument() != other.hasDocument()) return false; + if (hasDocument()) { + if (!getDocument().equals(other.getDocument())) return false; + } + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (getSkippedResults() != other.getSkippedResults()) return false; + if (hasExplainMetrics() != other.hasExplainMetrics()) return false; + if (hasExplainMetrics()) { + if (!getExplainMetrics().equals(other.getExplainMetrics())) return false; + } + if (!getContinuationSelectorCase().equals(other.getContinuationSelectorCase())) return false; + switch (continuationSelectorCase_) { + case 6: + if (getDone() != other.getDone()) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + if (hasDocument()) { + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + } + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (37 * hash) + SKIPPED_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getSkippedResults(); + if (hasExplainMetrics()) { + hash = (37 * hash) + EXPLAIN_METRICS_FIELD_NUMBER; + hash = (53 * hash) + getExplainMetrics().hashCode(); + } + switch (continuationSelectorCase_) { + case 6: + hash = (37 * hash) + DONE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getDone()); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.RunQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.RunQueryResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.RunQueryResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.RunQueryResponse) + com.google.firestore.v1.RunQueryResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.RunQueryResponse.class, + com.google.firestore.v1.RunQueryResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.RunQueryResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDocumentFieldBuilder(); + internalGetReadTimeFieldBuilder(); + internalGetExplainMetricsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + transaction_ = com.google.protobuf.ByteString.EMPTY; + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + skippedResults_ = 0; + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + continuationSelectorCase_ = 0; + continuationSelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryResponse getDefaultInstanceForType() { + return com.google.firestore.v1.RunQueryResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryResponse build() { + com.google.firestore.v1.RunQueryResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryResponse buildPartial() { + com.google.firestore.v1.RunQueryResponse result = + new com.google.firestore.v1.RunQueryResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.RunQueryResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.transaction_ = transaction_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.document_ = documentBuilder_ == null ? document_ : documentBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.skippedResults_ = skippedResults_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.explainMetrics_ = + explainMetricsBuilder_ == null ? explainMetrics_ : explainMetricsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.RunQueryResponse result) { + result.continuationSelectorCase_ = continuationSelectorCase_; + result.continuationSelector_ = this.continuationSelector_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.RunQueryResponse) { + return mergeFrom((com.google.firestore.v1.RunQueryResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.RunQueryResponse other) { + if (other == com.google.firestore.v1.RunQueryResponse.getDefaultInstance()) return this; + if (!other.getTransaction().isEmpty()) { + setTransaction(other.getTransaction()); + } + if (other.hasDocument()) { + mergeDocument(other.getDocument()); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + if (other.getSkippedResults() != 0) { + setSkippedResults(other.getSkippedResults()); + } + if (other.hasExplainMetrics()) { + mergeExplainMetrics(other.getExplainMetrics()); + } + switch (other.getContinuationSelectorCase()) { + case DONE: + { + setDone(other.getDone()); + break; + } + case CONTINUATIONSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 10 + case 18: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 32: + { + skippedResults_ = input.readInt32(); + bitField0_ |= 0x00000008; + break; + } // case 32 + case 48: + { + continuationSelector_ = input.readBool(); + continuationSelectorCase_ = 6; + break; + } // case 48 + case 90: + { + input.readMessage( + internalGetExplainMetricsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 90 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int continuationSelectorCase_ = 0; + private java.lang.Object continuationSelector_; + + public ContinuationSelectorCase getContinuationSelectorCase() { + return ContinuationSelectorCase.forNumber(continuationSelectorCase_); + } + + public Builder clearContinuationSelector() { + continuationSelectorCase_ = 0; + continuationSelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Can only be set in the first response, and only if
+     * [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
+     * was set in the request. If set, no other fields will be set in this
+     * response.
+     * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Can only be set in the first response, and only if
+     * [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
+     * was set in the request. If set, no other fields will be set in this
+     * response.
+     * 
+ * + * bytes transaction = 2; + * + * @param value The transaction to set. + * @return This builder for chaining. + */ + public Builder setTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + transaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction that was started as part of this request.
+     * Can only be set in the first response, and only if
+     * [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
+     * was set in the request. If set, no other fields will be set in this
+     * response.
+     * 
+ * + * bytes transaction = 2; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.firestore.v1.Document document_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentBuilder_; + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + public boolean hasDocument() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + public com.google.firestore.v1.Document getDocument() { + if (documentBuilder_ == null) { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } else { + return documentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder setDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + } else { + documentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder setDocument(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentBuilder_ == null) { + document_ = builderForValue.build(); + } else { + documentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder mergeDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && document_ != null + && document_ != com.google.firestore.v1.Document.getDefaultInstance()) { + getDocumentBuilder().mergeFrom(value); + } else { + document_ = value; + } + } else { + documentBuilder_.mergeFrom(value); + } + if (document_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public Builder clearDocument() { + bitField0_ = (bitField0_ & ~0x00000002); + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public com.google.firestore.v1.Document.Builder getDocumentBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if (documentBuilder_ != null) { + return documentBuilder_.getMessageOrBuilder(); + } else { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } + } + + /** + * + * + *
+     * A query result, not set when reporting partial progress.
+     * 
+ * + * .google.firestore.v1.Document document = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentFieldBuilder() { + if (documentBuilder_ == null) { + documentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + getDocument(), getParentForChildren(), isClean()); + document_ = null; + } + return documentBuilder_; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The time at which the document was read. This may be monotonically
+     * increasing; in this case, the previous documents in the result stream are
+     * guaranteed not to have changed between their `read_time` and this one.
+     *
+     * If the query returns no results, a response with `read_time` and no
+     * `document` will be sent, and this represents the time at which the query
+     * was run.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + private int skippedResults_; + + /** + * + * + *
+     * The number of results that have been skipped due to an offset between
+     * the last response and the current response.
+     * 
+ * + * int32 skipped_results = 4; + * + * @return The skippedResults. + */ + @java.lang.Override + public int getSkippedResults() { + return skippedResults_; + } + + /** + * + * + *
+     * The number of results that have been skipped due to an offset between
+     * the last response and the current response.
+     * 
+ * + * int32 skipped_results = 4; + * + * @param value The skippedResults to set. + * @return This builder for chaining. + */ + public Builder setSkippedResults(int value) { + + skippedResults_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of results that have been skipped due to an offset between
+     * the last response and the current response.
+     * 
+ * + * int32 skipped_results = 4; + * + * @return This builder for chaining. + */ + public Builder clearSkippedResults() { + bitField0_ = (bitField0_ & ~0x00000008); + skippedResults_ = 0; + onChanged(); + return this; + } + + /** + * + * + *
+     * If present, Firestore has completely finished the request and no more
+     * documents will be returned.
+     * 
+ * + * bool done = 6; + * + * @return Whether the done field is set. + */ + public boolean hasDone() { + return continuationSelectorCase_ == 6; + } + + /** + * + * + *
+     * If present, Firestore has completely finished the request and no more
+     * documents will be returned.
+     * 
+ * + * bool done = 6; + * + * @return The done. + */ + public boolean getDone() { + if (continuationSelectorCase_ == 6) { + return (java.lang.Boolean) continuationSelector_; + } + return false; + } + + /** + * + * + *
+     * If present, Firestore has completely finished the request and no more
+     * documents will be returned.
+     * 
+ * + * bool done = 6; + * + * @param value The done to set. + * @return This builder for chaining. + */ + public Builder setDone(boolean value) { + + continuationSelectorCase_ = 6; + continuationSelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * If present, Firestore has completely finished the request and no more
+     * documents will be returned.
+     * 
+ * + * bool done = 6; + * + * @return This builder for chaining. + */ + public Builder clearDone() { + if (continuationSelectorCase_ == 6) { + continuationSelectorCase_ = 0; + continuationSelector_ = null; + onChanged(); + } + return this; + } + + private com.google.firestore.v1.ExplainMetrics explainMetrics_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder> + explainMetricsBuilder_; + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return Whether the explainMetrics field is set. + */ + public boolean hasExplainMetrics() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return The explainMetrics. + */ + public com.google.firestore.v1.ExplainMetrics getExplainMetrics() { + if (explainMetricsBuilder_ == null) { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } else { + return explainMetricsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public Builder setExplainMetrics(com.google.firestore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainMetrics_ = value; + } else { + explainMetricsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public Builder setExplainMetrics( + com.google.firestore.v1.ExplainMetrics.Builder builderForValue) { + if (explainMetricsBuilder_ == null) { + explainMetrics_ = builderForValue.build(); + } else { + explainMetricsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public Builder mergeExplainMetrics(com.google.firestore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && explainMetrics_ != null + && explainMetrics_ != com.google.firestore.v1.ExplainMetrics.getDefaultInstance()) { + getExplainMetricsBuilder().mergeFrom(value); + } else { + explainMetrics_ = value; + } + } else { + explainMetricsBuilder_.mergeFrom(value); + } + if (explainMetrics_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public Builder clearExplainMetrics() { + bitField0_ = (bitField0_ & ~0x00000020); + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public com.google.firestore.v1.ExplainMetrics.Builder getExplainMetricsBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetExplainMetricsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + public com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + if (explainMetricsBuilder_ != null) { + return explainMetricsBuilder_.getMessageOrBuilder(); + } else { + return explainMetrics_ == null + ? com.google.firestore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder> + internalGetExplainMetricsFieldBuilder() { + if (explainMetricsBuilder_ == null) { + explainMetricsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ExplainMetrics, + com.google.firestore.v1.ExplainMetrics.Builder, + com.google.firestore.v1.ExplainMetricsOrBuilder>( + getExplainMetrics(), getParentForChildren(), isClean()); + explainMetrics_ = null; + } + return explainMetricsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.RunQueryResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.RunQueryResponse) + private static final com.google.firestore.v1.RunQueryResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.RunQueryResponse(); + } + + public static com.google.firestore.v1.RunQueryResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RunQueryResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.RunQueryResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponseOrBuilder.java new file mode 100644 index 000000000000..59ad535e99c2 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/RunQueryResponseOrBuilder.java @@ -0,0 +1,224 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface RunQueryResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.RunQueryResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The transaction that was started as part of this request.
+   * Can only be set in the first response, and only if
+   * [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction]
+   * was set in the request. If set, no other fields will be set in this
+   * response.
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return Whether the document field is set. + */ + boolean hasDocument(); + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + * + * @return The document. + */ + com.google.firestore.v1.Document getDocument(); + + /** + * + * + *
+   * A query result, not set when reporting partial progress.
+   * 
+ * + * .google.firestore.v1.Document document = 1; + */ + com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder(); + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The time at which the document was read. This may be monotonically
+   * increasing; in this case, the previous documents in the result stream are
+   * guaranteed not to have changed between their `read_time` and this one.
+   *
+   * If the query returns no results, a response with `read_time` and no
+   * `document` will be sent, and this represents the time at which the query
+   * was run.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * The number of results that have been skipped due to an offset between
+   * the last response and the current response.
+   * 
+ * + * int32 skipped_results = 4; + * + * @return The skippedResults. + */ + int getSkippedResults(); + + /** + * + * + *
+   * If present, Firestore has completely finished the request and no more
+   * documents will be returned.
+   * 
+ * + * bool done = 6; + * + * @return Whether the done field is set. + */ + boolean hasDone(); + + /** + * + * + *
+   * If present, Firestore has completely finished the request and no more
+   * documents will be returned.
+   * 
+ * + * bool done = 6; + * + * @return The done. + */ + boolean getDone(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return Whether the explainMetrics field is set. + */ + boolean hasExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + * + * @return The explainMetrics. + */ + com.google.firestore.v1.ExplainMetrics getExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.firestore.v1.ExplainMetrics explain_metrics = 11; + */ + com.google.firestore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder(); + + com.google.firestore.v1.RunQueryResponse.ContinuationSelectorCase getContinuationSelectorCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQuery.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQuery.java new file mode 100644 index 000000000000..c94d6a34a290 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQuery.java @@ -0,0 +1,6119 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Firestore query for running an aggregation over a
+ * [StructuredQuery][google.firestore.v1.StructuredQuery].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery} + */ +@com.google.protobuf.Generated +public final class StructuredAggregationQuery extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredAggregationQuery) + StructuredAggregationQueryOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "StructuredAggregationQuery"); + } + + // Use StructuredAggregationQuery.newBuilder() to construct. + private StructuredAggregationQuery(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private StructuredAggregationQuery() { + aggregations_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.class, + com.google.firestore.v1.StructuredAggregationQuery.Builder.class); + } + + public interface AggregationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredAggregationQuery.Aggregation) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + boolean hasCount(); + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count getCount(); + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder + getCountOrBuilder(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + boolean hasSum(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum getSum(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder getSumOrBuilder(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + boolean hasAvg(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg getAvg(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder getAvgOrBuilder(); + + /** + * + * + *
+     * Optional. Optional name of the field to store the result of the
+     * aggregation into.
+     *
+     * If not provided, Firestore will pick a default name following the format
+     * `field_<incremental_id++>`. For example:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2),
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*)
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * becomes:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2) AS field_1,
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*) AS field_2
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The alias. + */ + java.lang.String getAlias(); + + /** + * + * + *
+     * Optional. Optional name of the field to store the result of the
+     * aggregation into.
+     *
+     * If not provided, Firestore will pick a default name following the format
+     * `field_<incremental_id++>`. For example:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2),
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*)
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * becomes:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2) AS field_1,
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*) AS field_2
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for alias. + */ + com.google.protobuf.ByteString getAliasBytes(); + + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.OperatorCase getOperatorCase(); + } + + /** + * + * + *
+   * Defines an aggregation that produces a single result.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation} + */ + public static final class Aggregation extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation) + AggregationOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Aggregation"); + } + + // Use Aggregation.newBuilder() to construct. + private Aggregation(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Aggregation() { + alias_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder.class); + } + + public interface CountOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the upTo field is set. + */ + boolean hasUpTo(); + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The upTo. + */ + com.google.protobuf.Int64Value getUpTo(); + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.protobuf.Int64ValueOrBuilder getUpToOrBuilder(); + } + + /** + * + * + *
+     * Count of documents that match the query.
+     *
+     * The `COUNT(*)` aggregation function operates on the entire document
+     * so it does not require a field reference.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Count} + */ + public static final class Count extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + CountOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Count"); + } + + // Use Count.newBuilder() to construct. + private Count(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Count() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder.class); + } + + private int bitField0_; + public static final int UP_TO_FIELD_NUMBER = 1; + private com.google.protobuf.Int64Value upTo_; + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the upTo field is set. + */ + @java.lang.Override + public boolean hasUpTo() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The upTo. + */ + @java.lang.Override + public com.google.protobuf.Int64Value getUpTo() { + return upTo_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : upTo_; + } + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of documents to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of documents
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be greater than zero when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.protobuf.Int64ValueOrBuilder getUpToOrBuilder() { + return upTo_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : upTo_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getUpTo()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getUpTo()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj + instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count other = + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) obj; + + if (hasUpTo() != other.hasUpTo()) return false; + if (hasUpTo()) { + if (!getUpTo().equals(other.getUpTo())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasUpTo()) { + hash = (37 * hash) + UP_TO_FIELD_NUMBER; + hash = (53 * hash) + getUpTo().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Count of documents that match the query.
+       *
+       * The `COUNT(*)` aggregation function operates on the entire document
+       * so it does not require a field reference.
+       * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Count} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder + .class); + } + + // Construct using + // com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetUpToFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + upTo_ = null; + if (upToBuilder_ != null) { + upToBuilder_.dispose(); + upToBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count build() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count buildPartial() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count result = + new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.upTo_ = upToBuilder_ == null ? upTo_ : upToBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) { + return mergeFrom( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count other) { + if (other + == com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance()) return this; + if (other.hasUpTo()) { + mergeUpTo(other.getUpTo()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetUpToFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Int64Value upTo_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder> + upToBuilder_; + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the upTo field is set. + */ + public boolean hasUpTo() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The upTo. + */ + public com.google.protobuf.Int64Value getUpTo() { + if (upToBuilder_ == null) { + return upTo_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : upTo_; + } else { + return upToBuilder_.getMessage(); + } + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setUpTo(com.google.protobuf.Int64Value value) { + if (upToBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + upTo_ = value; + } else { + upToBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setUpTo(com.google.protobuf.Int64Value.Builder builderForValue) { + if (upToBuilder_ == null) { + upTo_ = builderForValue.build(); + } else { + upToBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeUpTo(com.google.protobuf.Int64Value value) { + if (upToBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && upTo_ != null + && upTo_ != com.google.protobuf.Int64Value.getDefaultInstance()) { + getUpToBuilder().mergeFrom(value); + } else { + upTo_ = value; + } + } else { + upToBuilder_.mergeFrom(value); + } + if (upTo_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearUpTo() { + bitField0_ = (bitField0_ & ~0x00000001); + upTo_ = null; + if (upToBuilder_ != null) { + upToBuilder_.dispose(); + upToBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.Int64Value.Builder getUpToBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetUpToFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.Int64ValueOrBuilder getUpToOrBuilder() { + if (upToBuilder_ != null) { + return upToBuilder_.getMessageOrBuilder(); + } else { + return upTo_ == null ? com.google.protobuf.Int64Value.getDefaultInstance() : upTo_; + } + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of documents to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of documents
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be greater than zero when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder> + internalGetUpToFieldBuilder() { + if (upToBuilder_ == null) { + upToBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder>( + getUpTo(), getParentForChildren(), isClean()); + upTo_ = null; + } + return upToBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + private static final com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count(); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Count parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface SumOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getField(); + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder(); + } + + /** + * + * + *
+     * Sum of the values of the requested field.
+     *
+     * * Only numeric values will be aggregated. All non-numeric values
+     * including `NULL` are skipped.
+     *
+     * * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
+     * follows IEEE-754 standards.
+     *
+     * * If the aggregated value set is empty, returns 0.
+     *
+     * * Returns a 64-bit integer if all aggregated numbers are integers and the
+     * sum result does not overflow. Otherwise, the result is returned as a
+     * double. Note that even if all the aggregated values are integers, the
+     * result is returned as a double if it cannot fit within a 64-bit signed
+     * integer. When this occurs, the returned value will lose precision.
+     *
+     * * When underflow occurs, floating-point aggregation is non-deterministic.
+     * This means that running the same query repeatedly without any changes to
+     * the underlying values could produce slightly different results each
+     * time. In those cases, values should be stored as integers over
+     * floating-point numbers.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum} + */ + public static final class Sum extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + SumOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Sum"); + } + + // Use Sum.newBuilder() to construct. + private Sum(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Sum() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder.class); + } + + private int bitField0_; + public static final int FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getField()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getField()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum other = + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) obj; + + if (hasField() != other.hasField()) return false; + if (hasField()) { + if (!getField().equals(other.getField())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasField()) { + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Sum of the values of the requested field.
+       *
+       * * Only numeric values will be aggregated. All non-numeric values
+       * including `NULL` are skipped.
+       *
+       * * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
+       * follows IEEE-754 standards.
+       *
+       * * If the aggregated value set is empty, returns 0.
+       *
+       * * Returns a 64-bit integer if all aggregated numbers are integers and the
+       * sum result does not overflow. Otherwise, the result is returned as a
+       * double. Note that even if all the aggregated values are integers, the
+       * result is returned as a double if it cannot fit within a 64-bit signed
+       * integer. When this occurs, the returned value will lose precision.
+       *
+       * * When underflow occurs, floating-point aggregation is non-deterministic.
+       * This means that running the same query repeatedly without any changes to
+       * the underlying values could produce slightly different results each
+       * time. In those cases, values should be stored as integers over
+       * floating-point numbers.
+       * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder.class); + } + + // Construct using + // com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetFieldFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum build() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum buildPartial() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum result = + new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = fieldBuilder_ == null ? field_ : fieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) { + return mergeFrom( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum other) { + if (other + == com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance()) return this; + if (other.hasField()) { + mergeField(other.getField()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldBuilder_; + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (fieldBuilder_ == null) { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } else { + return fieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + } else { + fieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldBuilder_ == null) { + field_ = builderForValue.build(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder mergeField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && field_ != null + && field_ + != com.google.firestore.v1.StructuredQuery.FieldReference + .getDefaultInstance()) { + getFieldBuilder().mergeFrom(value); + } else { + field_ = value; + } + } else { + fieldBuilder_.mergeFrom(value); + } + if (field_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder clearField() { + bitField0_ = (bitField0_ & ~0x00000001); + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if (fieldBuilder_ != null) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getField(), getParentForChildren(), isClean()); + field_ = null; + } + return fieldBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + private static final com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum(); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Sum parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface AvgOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getField(); + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder(); + } + + /** + * + * + *
+     * Average of the values of the requested field.
+     *
+     * * Only numeric values will be aggregated. All non-numeric values
+     * including `NULL` are skipped.
+     *
+     * * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
+     * follows IEEE-754 standards.
+     *
+     * * If the aggregated value set is empty, returns `NULL`.
+     *
+     * * Always returns the result as a double.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg} + */ + public static final class Avg extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + AvgOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Avg"); + } + + // Use Avg.newBuilder() to construct. + private Avg(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Avg() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder.class); + } + + private int bitField0_; + public static final int FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + /** + * + * + *
+       * The field to aggregate on.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getField()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getField()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg other = + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) obj; + + if (hasField() != other.hasField()) return false; + if (hasField()) { + if (!getField().equals(other.getField())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasField()) { + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Average of the values of the requested field.
+       *
+       * * Only numeric values will be aggregated. All non-numeric values
+       * including `NULL` are skipped.
+       *
+       * * If the aggregated values contain `NaN`, returns `NaN`. Infinity math
+       * follows IEEE-754 standards.
+       *
+       * * If the aggregated value set is empty, returns `NULL`.
+       *
+       * * Always returns the result as a double.
+       * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder.class); + } + + // Construct using + // com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetFieldFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg build() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg buildPartial() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg result = + new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = fieldBuilder_ == null ? field_ : fieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) { + return mergeFrom( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg other) { + if (other + == com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance()) return this; + if (other.hasField()) { + mergeField(other.getField()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldBuilder_; + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (fieldBuilder_ == null) { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } else { + return fieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + } else { + fieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldBuilder_ == null) { + field_ = builderForValue.build(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder mergeField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && field_ != null + && field_ + != com.google.firestore.v1.StructuredQuery.FieldReference + .getDefaultInstance()) { + getFieldBuilder().mergeFrom(value); + } else { + field_ = value; + } + } else { + fieldBuilder_.mergeFrom(value); + } + if (field_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder clearField() { + bitField0_ = (bitField0_ & ~0x00000001); + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if (fieldBuilder_ != null) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + } + + /** + * + * + *
+         * The field to aggregate on.
+         * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getField(), getParentForChildren(), isClean()); + field_ = null; + } + return fieldBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + private static final com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg(); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Avg parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int operatorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object operator_; + + public enum OperatorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + COUNT(1), + SUM(2), + AVG(3), + OPERATOR_NOT_SET(0); + private final int value; + + private OperatorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static OperatorCase valueOf(int value) { + return forNumber(value); + } + + public static OperatorCase forNumber(int value) { + switch (value) { + case 1: + return COUNT; + case 2: + return SUM; + case 3: + return AVG; + case 0: + return OPERATOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public OperatorCase getOperatorCase() { + return OperatorCase.forNumber(operatorCase_); + } + + public static final int COUNT_FIELD_NUMBER = 1; + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + @java.lang.Override + public boolean hasCount() { + return operatorCase_ == 1; + } + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count getCount() { + if (operatorCase_ == 1) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder + getCountOrBuilder() { + if (operatorCase_ == 1) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + + public static final int SUM_FIELD_NUMBER = 2; + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + @java.lang.Override + public boolean hasSum() { + return operatorCase_ == 2; + } + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum getSum() { + if (operatorCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder + getSumOrBuilder() { + if (operatorCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + + public static final int AVG_FIELD_NUMBER = 3; + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + @java.lang.Override + public boolean hasAvg() { + return operatorCase_ == 3; + } + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg getAvg() { + if (operatorCase_ == 3) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder + getAvgOrBuilder() { + if (operatorCase_ == 3) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + + public static final int ALIAS_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object alias_ = ""; + + /** + * + * + *
+     * Optional. Optional name of the field to store the result of the
+     * aggregation into.
+     *
+     * If not provided, Firestore will pick a default name following the format
+     * `field_<incremental_id++>`. For example:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2),
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*)
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * becomes:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2) AS field_1,
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*) AS field_2
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The alias. + */ + @java.lang.Override + public java.lang.String getAlias() { + java.lang.Object ref = alias_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + alias_ = s; + return s; + } + } + + /** + * + * + *
+     * Optional. Optional name of the field to store the result of the
+     * aggregation into.
+     *
+     * If not provided, Firestore will pick a default name following the format
+     * `field_<incremental_id++>`. For example:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2),
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*)
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * becomes:
+     *
+     * ```
+     * AGGREGATE
+     * COUNT_UP_TO(1) AS count_up_to_1,
+     * COUNT_UP_TO(2) AS field_1,
+     * COUNT_UP_TO(3) AS count_up_to_3,
+     * COUNT(*) AS field_2
+     * OVER (
+     * ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for alias. + */ + @java.lang.Override + public com.google.protobuf.ByteString getAliasBytes() { + java.lang.Object ref = alias_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + alias_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (operatorCase_ == 1) { + output.writeMessage( + 1, (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_); + } + if (operatorCase_ == 2) { + output.writeMessage( + 2, (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_); + } + if (operatorCase_ == 3) { + output.writeMessage( + 3, (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(alias_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 7, alias_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (operatorCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_); + } + if (operatorCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_); + } + if (operatorCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(alias_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(7, alias_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredAggregationQuery.Aggregation other = + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation) obj; + + if (!getAlias().equals(other.getAlias())) return false; + if (!getOperatorCase().equals(other.getOperatorCase())) return false; + switch (operatorCase_) { + case 1: + if (!getCount().equals(other.getCount())) return false; + break; + case 2: + if (!getSum().equals(other.getSum())) return false; + break; + case 3: + if (!getAvg().equals(other.getAvg())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + ALIAS_FIELD_NUMBER; + hash = (53 * hash) + getAlias().hashCode(); + switch (operatorCase_) { + case 1: + hash = (37 * hash) + COUNT_FIELD_NUMBER; + hash = (53 * hash) + getCount().hashCode(); + break; + case 2: + hash = (37 * hash) + SUM_FIELD_NUMBER; + hash = (53 * hash) + getSum().hashCode(); + break; + case 3: + hash = (37 * hash) + AVG_FIELD_NUMBER; + hash = (53 * hash) + getAvg().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Defines an aggregation that produces a single result.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery.Aggregation} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredAggregationQuery.Aggregation) + com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.class, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredAggregationQuery.Aggregation.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (countBuilder_ != null) { + countBuilder_.clear(); + } + if (sumBuilder_ != null) { + sumBuilder_.clear(); + } + if (avgBuilder_ != null) { + avgBuilder_.clear(); + } + alias_ = ""; + operatorCase_ = 0; + operator_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation + getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation build() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation buildPartial() { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation result = + new com.google.firestore.v1.StructuredAggregationQuery.Aggregation(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.alias_ = alias_; + } + } + + private void buildPartialOneofs( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation result) { + result.operatorCase_ = operatorCase_; + result.operator_ = this.operator_; + if (operatorCase_ == 1 && countBuilder_ != null) { + result.operator_ = countBuilder_.build(); + } + if (operatorCase_ == 2 && sumBuilder_ != null) { + result.operator_ = sumBuilder_.build(); + } + if (operatorCase_ == 3 && avgBuilder_ != null) { + result.operator_ = avgBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredAggregationQuery.Aggregation) { + return mergeFrom((com.google.firestore.v1.StructuredAggregationQuery.Aggregation) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation other) { + if (other + == com.google.firestore.v1.StructuredAggregationQuery.Aggregation.getDefaultInstance()) + return this; + if (!other.getAlias().isEmpty()) { + alias_ = other.alias_; + bitField0_ |= 0x00000008; + onChanged(); + } + switch (other.getOperatorCase()) { + case COUNT: + { + mergeCount(other.getCount()); + break; + } + case SUM: + { + mergeSum(other.getSum()); + break; + } + case AVG: + { + mergeAvg(other.getAvg()); + break; + } + case OPERATOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetCountFieldBuilder().getBuilder(), extensionRegistry); + operatorCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage(internalGetSumFieldBuilder().getBuilder(), extensionRegistry); + operatorCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage(internalGetAvgFieldBuilder().getBuilder(), extensionRegistry); + operatorCase_ = 3; + break; + } // case 26 + case 58: + { + alias_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000008; + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int operatorCase_ = 0; + private java.lang.Object operator_; + + public OperatorCase getOperatorCase() { + return OperatorCase.forNumber(operatorCase_); + } + + public Builder clearOperator() { + operatorCase_ = 0; + operator_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder> + countBuilder_; + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + @java.lang.Override + public boolean hasCount() { + return operatorCase_ == 1; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count getCount() { + if (countBuilder_ == null) { + if (operatorCase_ == 1) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } else { + if (operatorCase_ == 1) { + return countBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + public Builder setCount( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count value) { + if (countBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operator_ = value; + onChanged(); + } else { + countBuilder_.setMessage(value); + } + operatorCase_ = 1; + return this; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + public Builder setCount( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder + builderForValue) { + if (countBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + countBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 1; + return this; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + public Builder mergeCount( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count value) { + if (countBuilder_ == null) { + if (operatorCase_ == 1 + && operator_ + != com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance()) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.newBuilder( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) + operator_) + .mergeFrom(value) + .buildPartial(); + } else { + operator_ = value; + } + onChanged(); + } else { + if (operatorCase_ == 1) { + countBuilder_.mergeFrom(value); + } else { + countBuilder_.setMessage(value); + } + } + operatorCase_ = 1; + return this; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + public Builder clearCount() { + if (countBuilder_ == null) { + if (operatorCase_ == 1) { + operatorCase_ = 0; + operator_ = null; + onChanged(); + } + } else { + if (operatorCase_ == 1) { + operatorCase_ = 0; + operator_ = null; + } + countBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder + getCountBuilder() { + return internalGetCountFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder + getCountOrBuilder() { + if ((operatorCase_ == 1) && (countBuilder_ != null)) { + return countBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 1) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Count count = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder> + internalGetCountFieldBuilder() { + if (countBuilder_ == null) { + if (!(operatorCase_ == 1)) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count + .getDefaultInstance(); + } + countBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.CountOrBuilder>( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Count) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 1; + onChanged(); + return countBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder> + sumBuilder_; + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + @java.lang.Override + public boolean hasSum() { + return operatorCase_ == 2; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum getSum() { + if (sumBuilder_ == null) { + if (operatorCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } else { + if (operatorCase_ == 2) { + return sumBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder setSum( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum value) { + if (sumBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operator_ = value; + onChanged(); + } else { + sumBuilder_.setMessage(value); + } + operatorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder setSum( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder + builderForValue) { + if (sumBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + sumBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder mergeSum( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum value) { + if (sumBuilder_ == null) { + if (operatorCase_ == 2 + && operator_ + != com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance()) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.newBuilder( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) + operator_) + .mergeFrom(value) + .buildPartial(); + } else { + operator_ = value; + } + onChanged(); + } else { + if (operatorCase_ == 2) { + sumBuilder_.mergeFrom(value); + } else { + sumBuilder_.setMessage(value); + } + } + operatorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder clearSum() { + if (sumBuilder_ == null) { + if (operatorCase_ == 2) { + operatorCase_ = 0; + operator_ = null; + onChanged(); + } + } else { + if (operatorCase_ == 2) { + operatorCase_ = 0; + operator_ = null; + } + sumBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder + getSumBuilder() { + return internalGetSumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder + getSumOrBuilder() { + if ((operatorCase_ == 2) && (sumBuilder_ != null)) { + return sumBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 2) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum sum = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder> + internalGetSumFieldBuilder() { + if (sumBuilder_ == null) { + if (!(operatorCase_ == 2)) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum + .getDefaultInstance(); + } + sumBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.SumOrBuilder>( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Sum) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 2; + onChanged(); + return sumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder> + avgBuilder_; + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + @java.lang.Override + public boolean hasAvg() { + return operatorCase_ == 3; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg getAvg() { + if (avgBuilder_ == null) { + if (operatorCase_ == 3) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } else { + if (operatorCase_ == 3) { + return avgBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder setAvg( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg value) { + if (avgBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operator_ = value; + onChanged(); + } else { + avgBuilder_.setMessage(value); + } + operatorCase_ = 3; + return this; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder setAvg( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder + builderForValue) { + if (avgBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + avgBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 3; + return this; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder mergeAvg( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg value) { + if (avgBuilder_ == null) { + if (operatorCase_ == 3 + && operator_ + != com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance()) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.newBuilder( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) + operator_) + .mergeFrom(value) + .buildPartial(); + } else { + operator_ = value; + } + onChanged(); + } else { + if (operatorCase_ == 3) { + avgBuilder_.mergeFrom(value); + } else { + avgBuilder_.setMessage(value); + } + } + operatorCase_ = 3; + return this; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder clearAvg() { + if (avgBuilder_ == null) { + if (operatorCase_ == 3) { + operatorCase_ = 0; + operator_ = null; + onChanged(); + } + } else { + if (operatorCase_ == 3) { + operatorCase_ = 0; + operator_ = null; + } + avgBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder + getAvgBuilder() { + return internalGetAvgFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder + getAvgOrBuilder() { + if ((operatorCase_ == 3) && (avgBuilder_ != null)) { + return avgBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 3) { + return (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_; + } + return com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg avg = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder> + internalGetAvgFieldBuilder() { + if (avgBuilder_ == null) { + if (!(operatorCase_ == 3)) { + operator_ = + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg + .getDefaultInstance(); + } + avgBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg.Builder, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.AvgOrBuilder>( + (com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Avg) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 3; + onChanged(); + return avgBuilder_; + } + + private java.lang.Object alias_ = ""; + + /** + * + * + *
+       * Optional. Optional name of the field to store the result of the
+       * aggregation into.
+       *
+       * If not provided, Firestore will pick a default name following the format
+       * `field_<incremental_id++>`. For example:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2),
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*)
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * becomes:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2) AS field_1,
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*) AS field_2
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The alias. + */ + public java.lang.String getAlias() { + java.lang.Object ref = alias_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + alias_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Optional. Optional name of the field to store the result of the
+       * aggregation into.
+       *
+       * If not provided, Firestore will pick a default name following the format
+       * `field_<incremental_id++>`. For example:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2),
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*)
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * becomes:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2) AS field_1,
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*) AS field_2
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for alias. + */ + public com.google.protobuf.ByteString getAliasBytes() { + java.lang.Object ref = alias_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + alias_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Optional. Optional name of the field to store the result of the
+       * aggregation into.
+       *
+       * If not provided, Firestore will pick a default name following the format
+       * `field_<incremental_id++>`. For example:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2),
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*)
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * becomes:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2) AS field_1,
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*) AS field_2
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The alias to set. + * @return This builder for chaining. + */ + public Builder setAlias(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + alias_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Optional name of the field to store the result of the
+       * aggregation into.
+       *
+       * If not provided, Firestore will pick a default name following the format
+       * `field_<incremental_id++>`. For example:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2),
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*)
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * becomes:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2) AS field_1,
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*) AS field_2
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearAlias() { + alias_ = getDefaultInstance().getAlias(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Optional name of the field to store the result of the
+       * aggregation into.
+       *
+       * If not provided, Firestore will pick a default name following the format
+       * `field_<incremental_id++>`. For example:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2),
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*)
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * becomes:
+       *
+       * ```
+       * AGGREGATE
+       * COUNT_UP_TO(1) AS count_up_to_1,
+       * COUNT_UP_TO(2) AS field_1,
+       * COUNT_UP_TO(3) AS count_up_to_3,
+       * COUNT(*) AS field_2
+       * OVER (
+       * ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for alias to set. + * @return This builder for chaining. + */ + public Builder setAliasBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + alias_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredAggregationQuery.Aggregation) + private static final com.google.firestore.v1.StructuredAggregationQuery.Aggregation + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredAggregationQuery.Aggregation(); + } + + public static com.google.firestore.v1.StructuredAggregationQuery.Aggregation + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Aggregation parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_QUERY(1), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 1: + return STRUCTURED_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public static final int STRUCTURED_QUERY_FIELD_NUMBER = 1; + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 1; + } + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (queryTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if (queryTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + public static final int AGGREGATIONS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List + aggregations_; + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List + getAggregationsList() { + return aggregations_; + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List< + ? extends com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder> + getAggregationsOrBuilderList() { + return aggregations_; + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public int getAggregationsCount() { + return aggregations_.size(); + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation getAggregations(int index) { + return aggregations_.get(index); + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder + getAggregationsOrBuilder(int index) { + return aggregations_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (queryTypeCase_ == 1) { + output.writeMessage(1, (com.google.firestore.v1.StructuredQuery) queryType_); + } + for (int i = 0; i < aggregations_.size(); i++) { + output.writeMessage(3, aggregations_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (queryTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.v1.StructuredQuery) queryType_); + } + for (int i = 0; i < aggregations_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, aggregations_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredAggregationQuery)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredAggregationQuery other = + (com.google.firestore.v1.StructuredAggregationQuery) obj; + + if (!getAggregationsList().equals(other.getAggregationsList())) return false; + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 1: + if (!getStructuredQuery().equals(other.getStructuredQuery())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getAggregationsCount() > 0) { + hash = (37 * hash) + AGGREGATIONS_FIELD_NUMBER; + hash = (53 * hash) + getAggregationsList().hashCode(); + } + switch (queryTypeCase_) { + case 1: + hash = (37 * hash) + STRUCTURED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredAggregationQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredAggregationQuery prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Firestore query for running an aggregation over a
+   * [StructuredQuery][google.firestore.v1.StructuredQuery].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredAggregationQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredAggregationQuery) + com.google.firestore.v1.StructuredAggregationQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredAggregationQuery.class, + com.google.firestore.v1.StructuredAggregationQuery.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredAggregationQuery.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (structuredQueryBuilder_ != null) { + structuredQueryBuilder_.clear(); + } + if (aggregationsBuilder_ == null) { + aggregations_ = java.util.Collections.emptyList(); + } else { + aggregations_ = null; + aggregationsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + queryTypeCase_ = 0; + queryType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredAggregationQuery_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery build() { + com.google.firestore.v1.StructuredAggregationQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery buildPartial() { + com.google.firestore.v1.StructuredAggregationQuery result = + new com.google.firestore.v1.StructuredAggregationQuery(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.v1.StructuredAggregationQuery result) { + if (aggregationsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + aggregations_ = java.util.Collections.unmodifiableList(aggregations_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.aggregations_ = aggregations_; + } else { + result.aggregations_ = aggregationsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.StructuredAggregationQuery result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.StructuredAggregationQuery result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 1 && structuredQueryBuilder_ != null) { + result.queryType_ = structuredQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredAggregationQuery) { + return mergeFrom((com.google.firestore.v1.StructuredAggregationQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredAggregationQuery other) { + if (other == com.google.firestore.v1.StructuredAggregationQuery.getDefaultInstance()) + return this; + if (aggregationsBuilder_ == null) { + if (!other.aggregations_.isEmpty()) { + if (aggregations_.isEmpty()) { + aggregations_ = other.aggregations_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureAggregationsIsMutable(); + aggregations_.addAll(other.aggregations_); + } + onChanged(); + } + } else { + if (!other.aggregations_.isEmpty()) { + if (aggregationsBuilder_.isEmpty()) { + aggregationsBuilder_.dispose(); + aggregationsBuilder_ = null; + aggregations_ = other.aggregations_; + bitField0_ = (bitField0_ & ~0x00000002); + aggregationsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetAggregationsFieldBuilder() + : null; + } else { + aggregationsBuilder_.addAllMessages(other.aggregations_); + } + } + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_QUERY: + { + mergeStructuredQuery(other.getStructuredQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetStructuredQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 1; + break; + } // case 10 + case 26: + { + com.google.firestore.v1.StructuredAggregationQuery.Aggregation m = + input.readMessage( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.parser(), + extensionRegistry); + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + aggregations_.add(m); + } else { + aggregationsBuilder_.addMessage(m); + } + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + structuredQueryBuilder_; + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 1; + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 1) { + return structuredQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + public Builder setStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + public Builder setStructuredQuery( + com.google.firestore.v1.StructuredQuery.Builder builderForValue) { + if (structuredQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + public Builder mergeStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 1 + && queryType_ != com.google.firestore.v1.StructuredQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredQuery.newBuilder( + (com.google.firestore.v1.StructuredQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 1) { + structuredQueryBuilder_.mergeFrom(value); + } else { + structuredQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + public Builder clearStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 1) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 1) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + public com.google.firestore.v1.StructuredQuery.Builder getStructuredQueryBuilder() { + return internalGetStructuredQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if ((queryTypeCase_ == 1) && (structuredQueryBuilder_ != null)) { + return structuredQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Nested structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + internalGetStructuredQueryFieldBuilder() { + if (structuredQueryBuilder_ == null) { + if (!(queryTypeCase_ == 1)) { + queryType_ = com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + structuredQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder>( + (com.google.firestore.v1.StructuredQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 1; + onChanged(); + return structuredQueryBuilder_; + } + + private java.util.List + aggregations_ = java.util.Collections.emptyList(); + + private void ensureAggregationsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + aggregations_ = + new java.util.ArrayList( + aggregations_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder, + com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder> + aggregationsBuilder_; + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getAggregationsList() { + if (aggregationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(aggregations_); + } else { + return aggregationsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public int getAggregationsCount() { + if (aggregationsBuilder_ == null) { + return aggregations_.size(); + } else { + return aggregationsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation getAggregations( + int index) { + if (aggregationsBuilder_ == null) { + return aggregations_.get(index); + } else { + return aggregationsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setAggregations( + int index, com.google.firestore.v1.StructuredAggregationQuery.Aggregation value) { + if (aggregationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationsIsMutable(); + aggregations_.set(index, value); + onChanged(); + } else { + aggregationsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setAggregations( + int index, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder builderForValue) { + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + aggregations_.set(index, builderForValue.build()); + onChanged(); + } else { + aggregationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation value) { + if (aggregationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationsIsMutable(); + aggregations_.add(value); + onChanged(); + } else { + aggregationsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + int index, com.google.firestore.v1.StructuredAggregationQuery.Aggregation value) { + if (aggregationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationsIsMutable(); + aggregations_.add(index, value); + onChanged(); + } else { + aggregationsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder builderForValue) { + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + aggregations_.add(builderForValue.build()); + onChanged(); + } else { + aggregationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + int index, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder builderForValue) { + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + aggregations_.add(index, builderForValue.build()); + onChanged(); + } else { + aggregationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAllAggregations( + java.lang.Iterable + values) { + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, aggregations_); + onChanged(); + } else { + aggregationsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearAggregations() { + if (aggregationsBuilder_ == null) { + aggregations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + aggregationsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeAggregations(int index) { + if (aggregationsBuilder_ == null) { + ensureAggregationsIsMutable(); + aggregations_.remove(index); + onChanged(); + } else { + aggregationsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder + getAggregationsBuilder(int index) { + return internalGetAggregationsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder + getAggregationsOrBuilder(int index) { + if (aggregationsBuilder_ == null) { + return aggregations_.get(index); + } else { + return aggregationsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List< + ? extends com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder> + getAggregationsOrBuilderList() { + if (aggregationsBuilder_ != null) { + return aggregationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(aggregations_); + } + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder + addAggregationsBuilder() { + return internalGetAggregationsFieldBuilder() + .addBuilder( + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder + addAggregationsBuilder(int index) { + return internalGetAggregationsFieldBuilder() + .addBuilder( + index, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `structured_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getAggregationsBuilderList() { + return internalGetAggregationsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder, + com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder> + internalGetAggregationsFieldBuilder() { + if (aggregationsBuilder_ == null) { + aggregationsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredAggregationQuery.Aggregation, + com.google.firestore.v1.StructuredAggregationQuery.Aggregation.Builder, + com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder>( + aggregations_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + aggregations_ = null; + } + return aggregationsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredAggregationQuery) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredAggregationQuery) + private static final com.google.firestore.v1.StructuredAggregationQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredAggregationQuery(); + } + + public static com.google.firestore.v1.StructuredAggregationQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StructuredAggregationQuery parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredAggregationQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQueryOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQueryOrBuilder.java new file mode 100644 index 000000000000..c2b8231231c3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredAggregationQueryOrBuilder.java @@ -0,0 +1,160 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface StructuredAggregationQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredAggregationQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return Whether the structuredQuery field is set. + */ + boolean hasStructuredQuery(); + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + * + * @return The structuredQuery. + */ + com.google.firestore.v1.StructuredQuery getStructuredQuery(); + + /** + * + * + *
+   * Nested structured query.
+   * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 1; + */ + com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List + getAggregationsList(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.StructuredAggregationQuery.Aggregation getAggregations(int index); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getAggregationsCount(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List + getAggregationsOrBuilderList(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `structured_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.firestore.v1.StructuredAggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.StructuredAggregationQuery.AggregationOrBuilder getAggregationsOrBuilder( + int index); + + com.google.firestore.v1.StructuredAggregationQuery.QueryTypeCase getQueryTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java new file mode 100644 index 000000000000..b2e41634ec0e --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipeline.java @@ -0,0 +1,1158 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/pipeline.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore query represented as an ordered list of operations / stages.
+ *
+ * This is considered the top-level function which plans and executes a query.
+ * It is logically equivalent to `query(stages, options)`, but prevents the
+ * client from having to build a function wrapper.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredPipeline} + */ +@com.google.protobuf.Generated +public final class StructuredPipeline extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredPipeline) + StructuredPipelineOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "StructuredPipeline"); + } + + // Use StructuredPipeline.newBuilder() to construct. + private StructuredPipeline(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private StructuredPipeline() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredPipeline.class, + com.google.firestore.v1.StructuredPipeline.Builder.class); + } + + private int bitField0_; + public static final int PIPELINE_FIELD_NUMBER = 1; + private com.google.firestore.v1.Pipeline pipeline_; + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pipeline field is set. + */ + @java.lang.Override + public boolean hasPipeline() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pipeline. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipeline() { + return pipeline_ == null ? com.google.firestore.v1.Pipeline.getDefaultInstance() : pipeline_; + } + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder() { + return pipeline_ == null ? com.google.firestore.v1.Pipeline.getDefaultInstance() : pipeline_; + } + + public static final int OPTIONS_FIELD_NUMBER = 2; + + private static final class OptionsDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_OptionsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.firestore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField options_; + + private com.google.protobuf.MapField + internalGetOptions() { + if (options_ == null) { + return com.google.protobuf.MapField.emptyMapField(OptionsDefaultEntryHolder.defaultEntry); + } + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().getMap().size(); + } + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().getMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getMap(); + } + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetOptions().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getPipeline()); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetOptions(), OptionsDefaultEntryHolder.defaultEntry, 2); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPipeline()); + } + for (java.util.Map.Entry entry : + internalGetOptions().getMap().entrySet()) { + com.google.protobuf.MapEntry options__ = + OptionsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, options__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredPipeline)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredPipeline other = + (com.google.firestore.v1.StructuredPipeline) obj; + + if (hasPipeline() != other.hasPipeline()) return false; + if (hasPipeline()) { + if (!getPipeline().equals(other.getPipeline())) return false; + } + if (!internalGetOptions().equals(other.internalGetOptions())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasPipeline()) { + hash = (37 * hash) + PIPELINE_FIELD_NUMBER; + hash = (53 * hash) + getPipeline().hashCode(); + } + if (!internalGetOptions().getMap().isEmpty()) { + hash = (37 * hash) + OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + internalGetOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredPipeline parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredPipeline prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Firestore query represented as an ordered list of operations / stages.
+   *
+   * This is considered the top-level function which plans and executes a query.
+   * It is logically equivalent to `query(stages, options)`, but prevents the
+   * client from having to build a function wrapper.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredPipeline} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredPipeline) + com.google.firestore.v1.StructuredPipelineOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableOptions(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredPipeline.class, + com.google.firestore.v1.StructuredPipeline.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredPipeline.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetPipelineFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + pipeline_ = null; + if (pipelineBuilder_ != null) { + pipelineBuilder_.dispose(); + pipelineBuilder_ = null; + } + internalGetMutableOptions().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.PipelineProto + .internal_static_google_firestore_v1_StructuredPipeline_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredPipeline.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline build() { + com.google.firestore.v1.StructuredPipeline result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline buildPartial() { + com.google.firestore.v1.StructuredPipeline result = + new com.google.firestore.v1.StructuredPipeline(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredPipeline result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.pipeline_ = pipelineBuilder_ == null ? pipeline_ : pipelineBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.options_ = internalGetOptions().build(OptionsDefaultEntryHolder.defaultEntry); + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredPipeline) { + return mergeFrom((com.google.firestore.v1.StructuredPipeline) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredPipeline other) { + if (other == com.google.firestore.v1.StructuredPipeline.getDefaultInstance()) return this; + if (other.hasPipeline()) { + mergePipeline(other.getPipeline()); + } + internalGetMutableOptions().mergeFrom(other.internalGetOptions()); + bitField0_ |= 0x00000002; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetPipelineFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.protobuf.MapEntry + options__ = + input.readMessage( + OptionsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableOptions() + .ensureBuilderMap() + .put(options__.getKey(), options__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.Pipeline pipeline_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + pipelineBuilder_; + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pipeline field is set. + */ + public boolean hasPipeline() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pipeline. + */ + public com.google.firestore.v1.Pipeline getPipeline() { + if (pipelineBuilder_ == null) { + return pipeline_ == null + ? com.google.firestore.v1.Pipeline.getDefaultInstance() + : pipeline_; + } else { + return pipelineBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPipeline(com.google.firestore.v1.Pipeline value) { + if (pipelineBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + pipeline_ = value; + } else { + pipelineBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setPipeline(com.google.firestore.v1.Pipeline.Builder builderForValue) { + if (pipelineBuilder_ == null) { + pipeline_ = builderForValue.build(); + } else { + pipelineBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergePipeline(com.google.firestore.v1.Pipeline value) { + if (pipelineBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && pipeline_ != null + && pipeline_ != com.google.firestore.v1.Pipeline.getDefaultInstance()) { + getPipelineBuilder().mergeFrom(value); + } else { + pipeline_ = value; + } + } else { + pipelineBuilder_.mergeFrom(value); + } + if (pipeline_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearPipeline() { + bitField0_ = (bitField0_ & ~0x00000001); + pipeline_ = null; + if (pipelineBuilder_ != null) { + pipelineBuilder_.dispose(); + pipelineBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Pipeline.Builder getPipelineBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetPipelineFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder() { + if (pipelineBuilder_ != null) { + return pipelineBuilder_.getMessageOrBuilder(); + } else { + return pipeline_ == null + ? com.google.firestore.v1.Pipeline.getDefaultInstance() + : pipeline_; + } + } + + /** + * + * + *
+     * Required. The pipeline query to execute.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + internalGetPipelineFieldBuilder() { + if (pipelineBuilder_ == null) { + pipelineBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder>( + getPipeline(), getParentForChildren(), isClean()); + pipeline_ = null; + } + return pipelineBuilder_; + } + + private static final class OptionsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value> { + @java.lang.Override + public com.google.firestore.v1.Value build(com.google.firestore.v1.ValueOrBuilder val) { + if (val instanceof com.google.firestore.v1.Value) { + return (com.google.firestore.v1.Value) val; + } + return ((com.google.firestore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return OptionsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final OptionsConverter optionsConverter = new OptionsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + options_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetOptions() { + if (options_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + return options_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.firestore.v1.ValueOrBuilder, + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder> + internalGetMutableOptions() { + if (options_ == null) { + options_ = new com.google.protobuf.MapFieldBuilder<>(optionsConverter); + } + bitField0_ |= 0x00000002; + onChanged(); + return options_; + } + + public int getOptionsCount() { + return internalGetOptions().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public boolean containsOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetOptions().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getOptions() { + return getOptionsMap(); + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.Map getOptionsMap() { + return internalGetOptions().getImmutableMap(); + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public /* nullable */ com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + return map.containsKey(key) ? optionsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableOptions().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return optionsConverter.build(map.get(key)); + } + + public Builder clearOptions() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableOptions().clear(); + return this; + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removeOptions(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableOptions().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableOptions() { + bitField0_ |= 0x00000002; + return internalGetMutableOptions().ensureMessageMap(); + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putOptions(java.lang.String key, com.google.firestore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableOptions().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder putAllOptions( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableOptions().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * Optional. Optional query-level arguments.
+     * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.Value.Builder putOptionsBuilderIfAbsent(java.lang.String key) { + java.util.Map builderMap = + internalGetMutableOptions().ensureBuilderMap(); + com.google.firestore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.firestore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.firestore.v1.Value) { + entry = ((com.google.firestore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.firestore.v1.Value.Builder) entry; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredPipeline) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredPipeline) + private static final com.google.firestore.v1.StructuredPipeline DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredPipeline(); + } + + public static com.google.firestore.v1.StructuredPipeline getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StructuredPipeline parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredPipeline getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java new file mode 100644 index 000000000000..bc42453777e9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredPipelineOrBuilder.java @@ -0,0 +1,141 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/pipeline.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface StructuredPipelineOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredPipeline) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the pipeline field is set. + */ + boolean hasPipeline(); + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The pipeline. + */ + com.google.firestore.v1.Pipeline getPipeline(); + + /** + * + * + *
+   * Required. The pipeline query to execute.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.PipelineOrBuilder getPipelineOrBuilder(); + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getOptionsCount(); + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + boolean containsOptions(java.lang.String key); + + /** Use {@link #getOptionsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getOptions(); + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.Map getOptionsMap(); + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + /* nullable */ + com.google.firestore.v1.Value getOptionsOrDefault( + java.lang.String key, + /* nullable */ + com.google.firestore.v1.Value defaultValue); + + /** + * + * + *
+   * Optional. Optional query-level arguments.
+   * 
+ * + * + * map<string, .google.firestore.v1.Value> options = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.Value getOptionsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java new file mode 100644 index 000000000000..c9ce6ece25b1 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQuery.java @@ -0,0 +1,16377 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A Firestore query.
+ *
+ * The query stages are executed in the following order:
+ * 1. from
+ * 2. where
+ * 3. select
+ * 4. order_by + start_at + end_at
+ * 5. offset
+ * 6. limit
+ * 7. find_nearest
+ * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery} + */ +@com.google.protobuf.Generated +public final class StructuredQuery extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery) + StructuredQueryOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "StructuredQuery"); + } + + // Use StructuredQuery.newBuilder() to construct. + private StructuredQuery(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private StructuredQuery() { + from_ = java.util.Collections.emptyList(); + orderBy_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.class, + com.google.firestore.v1.StructuredQuery.Builder.class); + } + + /** + * + * + *
+   * A sort direction.
+   * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.Direction} + */ + public enum Direction implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * DIRECTION_UNSPECIFIED = 0; + */ + DIRECTION_UNSPECIFIED(0), + /** + * + * + *
+     * Ascending.
+     * 
+ * + * ASCENDING = 1; + */ + ASCENDING(1), + /** + * + * + *
+     * Descending.
+     * 
+ * + * DESCENDING = 2; + */ + DESCENDING(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Direction"); + } + + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * DIRECTION_UNSPECIFIED = 0; + */ + public static final int DIRECTION_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Ascending.
+     * 
+ * + * ASCENDING = 1; + */ + public static final int ASCENDING_VALUE = 1; + + /** + * + * + *
+     * Descending.
+     * 
+ * + * DESCENDING = 2; + */ + public static final int DESCENDING_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Direction valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Direction forNumber(int value) { + switch (value) { + case 0: + return DIRECTION_UNSPECIFIED; + case 1: + return ASCENDING; + case 2: + return DESCENDING; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Direction findValueByNumber(int number) { + return Direction.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.getDescriptor().getEnumTypes().get(0); + } + + private static final Direction[] VALUES = values(); + + public static Direction valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Direction(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.Direction) + } + + public interface CollectionSelectorOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.CollectionSelector) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The collection ID.
+     * When set, selects only collections with this ID.
+     * 
+ * + * string collection_id = 2; + * + * @return The collectionId. + */ + java.lang.String getCollectionId(); + + /** + * + * + *
+     * The collection ID.
+     * When set, selects only collections with this ID.
+     * 
+ * + * string collection_id = 2; + * + * @return The bytes for collectionId. + */ + com.google.protobuf.ByteString getCollectionIdBytes(); + + /** + * + * + *
+     * When false, selects only collections that are immediate children of
+     * the `parent` specified in the containing `RunQueryRequest`.
+     * When true, selects all descendant collections.
+     * 
+ * + * bool all_descendants = 3; + * + * @return The allDescendants. + */ + boolean getAllDescendants(); + } + + /** + * + * + *
+   * A selection of a collection, such as `messages as m1`.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.CollectionSelector} + */ + public static final class CollectionSelector extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.CollectionSelector) + CollectionSelectorOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CollectionSelector"); + } + + // Use CollectionSelector.newBuilder() to construct. + private CollectionSelector(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CollectionSelector() { + collectionId_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.CollectionSelector.class, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder.class); + } + + public static final int COLLECTION_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object collectionId_ = ""; + + /** + * + * + *
+     * The collection ID.
+     * When set, selects only collections with this ID.
+     * 
+ * + * string collection_id = 2; + * + * @return The collectionId. + */ + @java.lang.Override + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } + } + + /** + * + * + *
+     * The collection ID.
+     * When set, selects only collections with this ID.
+     * 
+ * + * string collection_id = 2; + * + * @return The bytes for collectionId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ALL_DESCENDANTS_FIELD_NUMBER = 3; + private boolean allDescendants_ = false; + + /** + * + * + *
+     * When false, selects only collections that are immediate children of
+     * the `parent` specified in the containing `RunQueryRequest`.
+     * When true, selects all descendant collections.
+     * 
+ * + * bool all_descendants = 3; + * + * @return The allDescendants. + */ + @java.lang.Override + public boolean getAllDescendants() { + return allDescendants_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, collectionId_); + } + if (allDescendants_ != false) { + output.writeBool(3, allDescendants_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(collectionId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, collectionId_); + } + if (allDescendants_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(3, allDescendants_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.CollectionSelector)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.CollectionSelector other = + (com.google.firestore.v1.StructuredQuery.CollectionSelector) obj; + + if (!getCollectionId().equals(other.getCollectionId())) return false; + if (getAllDescendants() != other.getAllDescendants()) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + COLLECTION_ID_FIELD_NUMBER; + hash = (53 * hash) + getCollectionId().hashCode(); + hash = (37 * hash) + ALL_DESCENDANTS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAllDescendants()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.CollectionSelector prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A selection of a collection, such as `messages as m1`.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.CollectionSelector} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.CollectionSelector) + com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.CollectionSelector.class, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.CollectionSelector.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + collectionId_ = ""; + allDescendants_ = false; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CollectionSelector_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelector + getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.CollectionSelector.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelector build() { + com.google.firestore.v1.StructuredQuery.CollectionSelector result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelector buildPartial() { + com.google.firestore.v1.StructuredQuery.CollectionSelector result = + new com.google.firestore.v1.StructuredQuery.CollectionSelector(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.firestore.v1.StructuredQuery.CollectionSelector result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.collectionId_ = collectionId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.allDescendants_ = allDescendants_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.CollectionSelector) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.CollectionSelector) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.CollectionSelector other) { + if (other + == com.google.firestore.v1.StructuredQuery.CollectionSelector.getDefaultInstance()) + return this; + if (!other.getCollectionId().isEmpty()) { + collectionId_ = other.collectionId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getAllDescendants() != false) { + setAllDescendants(other.getAllDescendants()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + collectionId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 18 + case 24: + { + allDescendants_ = input.readBool(); + bitField0_ |= 0x00000002; + break; + } // case 24 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object collectionId_ = ""; + + /** + * + * + *
+       * The collection ID.
+       * When set, selects only collections with this ID.
+       * 
+ * + * string collection_id = 2; + * + * @return The collectionId. + */ + public java.lang.String getCollectionId() { + java.lang.Object ref = collectionId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + collectionId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The collection ID.
+       * When set, selects only collections with this ID.
+       * 
+ * + * string collection_id = 2; + * + * @return The bytes for collectionId. + */ + public com.google.protobuf.ByteString getCollectionIdBytes() { + java.lang.Object ref = collectionId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + collectionId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The collection ID.
+       * When set, selects only collections with this ID.
+       * 
+ * + * string collection_id = 2; + * + * @param value The collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + collectionId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The collection ID.
+       * When set, selects only collections with this ID.
+       * 
+ * + * string collection_id = 2; + * + * @return This builder for chaining. + */ + public Builder clearCollectionId() { + collectionId_ = getDefaultInstance().getCollectionId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * The collection ID.
+       * When set, selects only collections with this ID.
+       * 
+ * + * string collection_id = 2; + * + * @param value The bytes for collectionId to set. + * @return This builder for chaining. + */ + public Builder setCollectionIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + collectionId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private boolean allDescendants_; + + /** + * + * + *
+       * When false, selects only collections that are immediate children of
+       * the `parent` specified in the containing `RunQueryRequest`.
+       * When true, selects all descendant collections.
+       * 
+ * + * bool all_descendants = 3; + * + * @return The allDescendants. + */ + @java.lang.Override + public boolean getAllDescendants() { + return allDescendants_; + } + + /** + * + * + *
+       * When false, selects only collections that are immediate children of
+       * the `parent` specified in the containing `RunQueryRequest`.
+       * When true, selects all descendant collections.
+       * 
+ * + * bool all_descendants = 3; + * + * @param value The allDescendants to set. + * @return This builder for chaining. + */ + public Builder setAllDescendants(boolean value) { + + allDescendants_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * When false, selects only collections that are immediate children of
+       * the `parent` specified in the containing `RunQueryRequest`.
+       * When true, selects all descendant collections.
+       * 
+ * + * bool all_descendants = 3; + * + * @return This builder for chaining. + */ + public Builder clearAllDescendants() { + bitField0_ = (bitField0_ & ~0x00000002); + allDescendants_ = false; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.CollectionSelector) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.CollectionSelector) + private static final com.google.firestore.v1.StructuredQuery.CollectionSelector + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.CollectionSelector(); + } + + public static com.google.firestore.v1.StructuredQuery.CollectionSelector getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CollectionSelector parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelector getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface FilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.Filter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + boolean hasCompositeFilter(); + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + com.google.firestore.v1.StructuredQuery.CompositeFilter getCompositeFilter(); + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder getCompositeFilterOrBuilder(); + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return Whether the fieldFilter field is set. + */ + boolean hasFieldFilter(); + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return The fieldFilter. + */ + com.google.firestore.v1.StructuredQuery.FieldFilter getFieldFilter(); + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder getFieldFilterOrBuilder(); + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return Whether the unaryFilter field is set. + */ + boolean hasUnaryFilter(); + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return The unaryFilter. + */ + com.google.firestore.v1.StructuredQuery.UnaryFilter getUnaryFilter(); + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder getUnaryFilterOrBuilder(); + + com.google.firestore.v1.StructuredQuery.Filter.FilterTypeCase getFilterTypeCase(); + } + + /** + * + * + *
+   * A filter.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Filter} + */ + public static final class Filter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.Filter) + FilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Filter"); + } + + // Use Filter.newBuilder() to construct. + private Filter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Filter() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Filter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Filter.class, + com.google.firestore.v1.StructuredQuery.Filter.Builder.class); + } + + private int filterTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object filterType_; + + public enum FilterTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + COMPOSITE_FILTER(1), + FIELD_FILTER(2), + UNARY_FILTER(3), + FILTERTYPE_NOT_SET(0); + private final int value; + + private FilterTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static FilterTypeCase valueOf(int value) { + return forNumber(value); + } + + public static FilterTypeCase forNumber(int value) { + switch (value) { + case 1: + return COMPOSITE_FILTER; + case 2: + return FIELD_FILTER; + case 3: + return UNARY_FILTER; + case 0: + return FILTERTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public FilterTypeCase getFilterTypeCase() { + return FilterTypeCase.forNumber(filterTypeCase_); + } + + public static final int COMPOSITE_FILTER_FIELD_NUMBER = 1; + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + @java.lang.Override + public boolean hasCompositeFilter() { + return filterTypeCase_ == 1; + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter getCompositeFilter() { + if (filterTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder + getCompositeFilterOrBuilder() { + if (filterTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + + public static final int FIELD_FILTER_FIELD_NUMBER = 2; + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return Whether the fieldFilter field is set. + */ + @java.lang.Override + public boolean hasFieldFilter() { + return filterTypeCase_ == 2; + } + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return The fieldFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter getFieldFilter() { + if (filterTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + + /** + * + * + *
+     * A filter on a document field.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder getFieldFilterOrBuilder() { + if (filterTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + + public static final int UNARY_FILTER_FIELD_NUMBER = 3; + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return Whether the unaryFilter field is set. + */ + @java.lang.Override + public boolean hasUnaryFilter() { + return filterTypeCase_ == 3; + } + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return The unaryFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter getUnaryFilter() { + if (filterTypeCase_ == 3) { + return (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + + /** + * + * + *
+     * A filter that takes exactly one argument.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder getUnaryFilterOrBuilder() { + if (filterTypeCase_ == 3) { + return (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (filterTypeCase_ == 1) { + output.writeMessage( + 1, (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_); + } + if (filterTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_); + } + if (filterTypeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (filterTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_); + } + if (filterTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_); + } + if (filterTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.Filter)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.Filter other = + (com.google.firestore.v1.StructuredQuery.Filter) obj; + + if (!getFilterTypeCase().equals(other.getFilterTypeCase())) return false; + switch (filterTypeCase_) { + case 1: + if (!getCompositeFilter().equals(other.getCompositeFilter())) return false; + break; + case 2: + if (!getFieldFilter().equals(other.getFieldFilter())) return false; + break; + case 3: + if (!getUnaryFilter().equals(other.getUnaryFilter())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (filterTypeCase_) { + case 1: + hash = (37 * hash) + COMPOSITE_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getCompositeFilter().hashCode(); + break; + case 2: + hash = (37 * hash) + FIELD_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFieldFilter().hashCode(); + break; + case 3: + hash = (37 * hash) + UNARY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getUnaryFilter().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Filter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredQuery.Filter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A filter.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Filter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.Filter) + com.google.firestore.v1.StructuredQuery.FilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Filter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Filter.class, + com.google.firestore.v1.StructuredQuery.Filter.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.Filter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (compositeFilterBuilder_ != null) { + compositeFilterBuilder_.clear(); + } + if (fieldFilterBuilder_ != null) { + fieldFilterBuilder_.clear(); + } + if (unaryFilterBuilder_ != null) { + unaryFilterBuilder_.clear(); + } + filterTypeCase_ = 0; + filterType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Filter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter build() { + com.google.firestore.v1.StructuredQuery.Filter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter buildPartial() { + com.google.firestore.v1.StructuredQuery.Filter result = + new com.google.firestore.v1.StructuredQuery.Filter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.Filter result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.StructuredQuery.Filter result) { + result.filterTypeCase_ = filterTypeCase_; + result.filterType_ = this.filterType_; + if (filterTypeCase_ == 1 && compositeFilterBuilder_ != null) { + result.filterType_ = compositeFilterBuilder_.build(); + } + if (filterTypeCase_ == 2 && fieldFilterBuilder_ != null) { + result.filterType_ = fieldFilterBuilder_.build(); + } + if (filterTypeCase_ == 3 && unaryFilterBuilder_ != null) { + result.filterType_ = unaryFilterBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.Filter) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.Filter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.Filter other) { + if (other == com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance()) + return this; + switch (other.getFilterTypeCase()) { + case COMPOSITE_FILTER: + { + mergeCompositeFilter(other.getCompositeFilter()); + break; + } + case FIELD_FILTER: + { + mergeFieldFilter(other.getFieldFilter()); + break; + } + case UNARY_FILTER: + { + mergeUnaryFilter(other.getUnaryFilter()); + break; + } + case FILTERTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetCompositeFilterFieldBuilder().getBuilder(), extensionRegistry); + filterTypeCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetFieldFilterFieldBuilder().getBuilder(), extensionRegistry); + filterTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetUnaryFilterFieldBuilder().getBuilder(), extensionRegistry); + filterTypeCase_ = 3; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int filterTypeCase_ = 0; + private java.lang.Object filterType_; + + public FilterTypeCase getFilterTypeCase() { + return FilterTypeCase.forNumber(filterTypeCase_); + } + + public Builder clearFilterType() { + filterTypeCase_ = 0; + filterType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.CompositeFilter, + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder, + com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder> + compositeFilterBuilder_; + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + @java.lang.Override + public boolean hasCompositeFilter() { + return filterTypeCase_ == 1; + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter getCompositeFilter() { + if (compositeFilterBuilder_ == null) { + if (filterTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } else { + if (filterTypeCase_ == 1) { + return compositeFilterBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + public Builder setCompositeFilter( + com.google.firestore.v1.StructuredQuery.CompositeFilter value) { + if (compositeFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filterType_ = value; + onChanged(); + } else { + compositeFilterBuilder_.setMessage(value); + } + filterTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + public Builder setCompositeFilter( + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder builderForValue) { + if (compositeFilterBuilder_ == null) { + filterType_ = builderForValue.build(); + onChanged(); + } else { + compositeFilterBuilder_.setMessage(builderForValue.build()); + } + filterTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + public Builder mergeCompositeFilter( + com.google.firestore.v1.StructuredQuery.CompositeFilter value) { + if (compositeFilterBuilder_ == null) { + if (filterTypeCase_ == 1 + && filterType_ + != com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance()) { + filterType_ = + com.google.firestore.v1.StructuredQuery.CompositeFilter.newBuilder( + (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_) + .mergeFrom(value) + .buildPartial(); + } else { + filterType_ = value; + } + onChanged(); + } else { + if (filterTypeCase_ == 1) { + compositeFilterBuilder_.mergeFrom(value); + } else { + compositeFilterBuilder_.setMessage(value); + } + } + filterTypeCase_ = 1; + return this; + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + public Builder clearCompositeFilter() { + if (compositeFilterBuilder_ == null) { + if (filterTypeCase_ == 1) { + filterTypeCase_ = 0; + filterType_ = null; + onChanged(); + } + } else { + if (filterTypeCase_ == 1) { + filterTypeCase_ = 0; + filterType_ = null; + } + compositeFilterBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + public com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder + getCompositeFilterBuilder() { + return internalGetCompositeFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder + getCompositeFilterOrBuilder() { + if ((filterTypeCase_ == 1) && (compositeFilterBuilder_ != null)) { + return compositeFilterBuilder_.getMessageOrBuilder(); + } else { + if (filterTypeCase_ == 1) { + return (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A composite filter.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter composite_filter = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.CompositeFilter, + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder, + com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder> + internalGetCompositeFilterFieldBuilder() { + if (compositeFilterBuilder_ == null) { + if (!(filterTypeCase_ == 1)) { + filterType_ = + com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + compositeFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.CompositeFilter, + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder, + com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder>( + (com.google.firestore.v1.StructuredQuery.CompositeFilter) filterType_, + getParentForChildren(), + isClean()); + filterType_ = null; + } + filterTypeCase_ = 1; + onChanged(); + return compositeFilterBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldFilter, + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder, + com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder> + fieldFilterBuilder_; + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return Whether the fieldFilter field is set. + */ + @java.lang.Override + public boolean hasFieldFilter() { + return filterTypeCase_ == 2; + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + * + * @return The fieldFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter getFieldFilter() { + if (fieldFilterBuilder_ == null) { + if (filterTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } else { + if (filterTypeCase_ == 2) { + return fieldFilterBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + public Builder setFieldFilter(com.google.firestore.v1.StructuredQuery.FieldFilter value) { + if (fieldFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filterType_ = value; + onChanged(); + } else { + fieldFilterBuilder_.setMessage(value); + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + public Builder setFieldFilter( + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder builderForValue) { + if (fieldFilterBuilder_ == null) { + filterType_ = builderForValue.build(); + onChanged(); + } else { + fieldFilterBuilder_.setMessage(builderForValue.build()); + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + public Builder mergeFieldFilter(com.google.firestore.v1.StructuredQuery.FieldFilter value) { + if (fieldFilterBuilder_ == null) { + if (filterTypeCase_ == 2 + && filterType_ + != com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance()) { + filterType_ = + com.google.firestore.v1.StructuredQuery.FieldFilter.newBuilder( + (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_) + .mergeFrom(value) + .buildPartial(); + } else { + filterType_ = value; + } + onChanged(); + } else { + if (filterTypeCase_ == 2) { + fieldFilterBuilder_.mergeFrom(value); + } else { + fieldFilterBuilder_.setMessage(value); + } + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + public Builder clearFieldFilter() { + if (fieldFilterBuilder_ == null) { + if (filterTypeCase_ == 2) { + filterTypeCase_ = 0; + filterType_ = null; + onChanged(); + } + } else { + if (filterTypeCase_ == 2) { + filterTypeCase_ = 0; + filterType_ = null; + } + fieldFilterBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldFilter.Builder getFieldFilterBuilder() { + return internalGetFieldFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder + getFieldFilterOrBuilder() { + if ((filterTypeCase_ == 2) && (fieldFilterBuilder_ != null)) { + return fieldFilterBuilder_.getMessageOrBuilder(); + } else { + if (filterTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A filter on a document field.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter field_filter = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldFilter, + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder, + com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder> + internalGetFieldFilterFieldBuilder() { + if (fieldFilterBuilder_ == null) { + if (!(filterTypeCase_ == 2)) { + filterType_ = com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + fieldFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldFilter, + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder, + com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder>( + (com.google.firestore.v1.StructuredQuery.FieldFilter) filterType_, + getParentForChildren(), + isClean()); + filterType_ = null; + } + filterTypeCase_ = 2; + onChanged(); + return fieldFilterBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.UnaryFilter, + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder, + com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder> + unaryFilterBuilder_; + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return Whether the unaryFilter field is set. + */ + @java.lang.Override + public boolean hasUnaryFilter() { + return filterTypeCase_ == 3; + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + * + * @return The unaryFilter. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter getUnaryFilter() { + if (unaryFilterBuilder_ == null) { + if (filterTypeCase_ == 3) { + return (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } else { + if (filterTypeCase_ == 3) { + return unaryFilterBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + public Builder setUnaryFilter(com.google.firestore.v1.StructuredQuery.UnaryFilter value) { + if (unaryFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filterType_ = value; + onChanged(); + } else { + unaryFilterBuilder_.setMessage(value); + } + filterTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + public Builder setUnaryFilter( + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder builderForValue) { + if (unaryFilterBuilder_ == null) { + filterType_ = builderForValue.build(); + onChanged(); + } else { + unaryFilterBuilder_.setMessage(builderForValue.build()); + } + filterTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + public Builder mergeUnaryFilter(com.google.firestore.v1.StructuredQuery.UnaryFilter value) { + if (unaryFilterBuilder_ == null) { + if (filterTypeCase_ == 3 + && filterType_ + != com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance()) { + filterType_ = + com.google.firestore.v1.StructuredQuery.UnaryFilter.newBuilder( + (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_) + .mergeFrom(value) + .buildPartial(); + } else { + filterType_ = value; + } + onChanged(); + } else { + if (filterTypeCase_ == 3) { + unaryFilterBuilder_.mergeFrom(value); + } else { + unaryFilterBuilder_.setMessage(value); + } + } + filterTypeCase_ = 3; + return this; + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + public Builder clearUnaryFilter() { + if (unaryFilterBuilder_ == null) { + if (filterTypeCase_ == 3) { + filterTypeCase_ = 0; + filterType_ = null; + onChanged(); + } + } else { + if (filterTypeCase_ == 3) { + filterTypeCase_ = 0; + filterType_ = null; + } + unaryFilterBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + public com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder getUnaryFilterBuilder() { + return internalGetUnaryFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder + getUnaryFilterOrBuilder() { + if ((filterTypeCase_ == 3) && (unaryFilterBuilder_ != null)) { + return unaryFilterBuilder_.getMessageOrBuilder(); + } else { + if (filterTypeCase_ == 3) { + return (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_; + } + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A filter that takes exactly one argument.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter unary_filter = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.UnaryFilter, + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder, + com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder> + internalGetUnaryFilterFieldBuilder() { + if (unaryFilterBuilder_ == null) { + if (!(filterTypeCase_ == 3)) { + filterType_ = com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + unaryFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.UnaryFilter, + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder, + com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder>( + (com.google.firestore.v1.StructuredQuery.UnaryFilter) filterType_, + getParentForChildren(), + isClean()); + filterType_ = null; + } + filterTypeCase_ = 3; + onChanged(); + return unaryFilterBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.Filter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.Filter) + private static final com.google.firestore.v1.StructuredQuery.Filter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.Filter(); + } + + public static com.google.firestore.v1.StructuredQuery.Filter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Filter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface CompositeFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.CompositeFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + int getOpValue(); + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator getOp(); + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + java.util.List getFiltersList(); + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + com.google.firestore.v1.StructuredQuery.Filter getFilters(int index); + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + int getFiltersCount(); + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + java.util.List + getFiltersOrBuilderList(); + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + com.google.firestore.v1.StructuredQuery.FilterOrBuilder getFiltersOrBuilder(int index); + } + + /** + * + * + *
+   * A filter that merges multiple other filters using the given operator.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.CompositeFilter} + */ + public static final class CompositeFilter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.CompositeFilter) + CompositeFilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "CompositeFilter"); + } + + // Use CompositeFilter.newBuilder() to construct. + private CompositeFilter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private CompositeFilter() { + op_ = 0; + filters_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.CompositeFilter.class, + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder.class); + } + + /** + * + * + *
+     * A composite filter operator.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.CompositeFilter.Operator} + */ + public enum Operator implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + OPERATOR_UNSPECIFIED(0), + /** + * + * + *
+       * Documents are required to satisfy all of the combined filters.
+       * 
+ * + * AND = 1; + */ + AND(1), + /** + * + * + *
+       * Documents are required to satisfy at least one of the combined filters.
+       * 
+ * + * OR = 2; + */ + OR(2), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Operator"); + } + + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + public static final int OPERATOR_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * Documents are required to satisfy all of the combined filters.
+       * 
+ * + * AND = 1; + */ + public static final int AND_VALUE = 1; + + /** + * + * + *
+       * Documents are required to satisfy at least one of the combined filters.
+       * 
+ * + * OR = 2; + */ + public static final int OR_VALUE = 2; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Operator valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Operator forNumber(int value) { + switch (value) { + case 0: + return OPERATOR_UNSPECIFIED; + case 1: + return AND; + case 2: + return OR; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Operator findValueByNumber(int number) { + return Operator.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final Operator[] VALUES = values(); + + public static Operator valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Operator(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.CompositeFilter.Operator) + } + + public static final int OP_FIELD_NUMBER = 1; + private int op_ = 0; + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator result = + com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.UNRECOGNIZED + : result; + } + + public static final int FILTERS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List filters_; + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + @java.lang.Override + public java.util.List getFiltersList() { + return filters_; + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + @java.lang.Override + public java.util.List + getFiltersOrBuilderList() { + return filters_; + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + @java.lang.Override + public int getFiltersCount() { + return filters_.size(); + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter getFilters(int index) { + return filters_.get(index); + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FilterOrBuilder getFiltersOrBuilder(int index) { + return filters_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (op_ + != com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, op_); + } + for (int i = 0; i < filters_.size(); i++) { + output.writeMessage(2, filters_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (op_ + != com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, op_); + } + for (int i = 0; i < filters_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, filters_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.CompositeFilter)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.CompositeFilter other = + (com.google.firestore.v1.StructuredQuery.CompositeFilter) obj; + + if (op_ != other.op_) return false; + if (!getFiltersList().equals(other.getFiltersList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OP_FIELD_NUMBER; + hash = (53 * hash) + op_; + if (getFiltersCount() > 0) { + hash = (37 * hash) + FILTERS_FIELD_NUMBER; + hash = (53 * hash) + getFiltersList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.CompositeFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A filter that merges multiple other filters using the given operator.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.CompositeFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.CompositeFilter) + com.google.firestore.v1.StructuredQuery.CompositeFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.CompositeFilter.class, + com.google.firestore.v1.StructuredQuery.CompositeFilter.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.CompositeFilter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + op_ = 0; + if (filtersBuilder_ == null) { + filters_ = java.util.Collections.emptyList(); + } else { + filters_ = null; + filtersBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_CompositeFilter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter build() { + com.google.firestore.v1.StructuredQuery.CompositeFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter buildPartial() { + com.google.firestore.v1.StructuredQuery.CompositeFilter result = + new com.google.firestore.v1.StructuredQuery.CompositeFilter(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.v1.StructuredQuery.CompositeFilter result) { + if (filtersBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + filters_ = java.util.Collections.unmodifiableList(filters_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.filters_ = filters_; + } else { + result.filters_ = filtersBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.CompositeFilter result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.op_ = op_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.CompositeFilter) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.CompositeFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.CompositeFilter other) { + if (other == com.google.firestore.v1.StructuredQuery.CompositeFilter.getDefaultInstance()) + return this; + if (other.op_ != 0) { + setOpValue(other.getOpValue()); + } + if (filtersBuilder_ == null) { + if (!other.filters_.isEmpty()) { + if (filters_.isEmpty()) { + filters_ = other.filters_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureFiltersIsMutable(); + filters_.addAll(other.filters_); + } + onChanged(); + } + } else { + if (!other.filters_.isEmpty()) { + if (filtersBuilder_.isEmpty()) { + filtersBuilder_.dispose(); + filtersBuilder_ = null; + filters_ = other.filters_; + bitField0_ = (bitField0_ & ~0x00000002); + filtersBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFiltersFieldBuilder() + : null; + } else { + filtersBuilder_.addAllMessages(other.filters_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + op_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + com.google.firestore.v1.StructuredQuery.Filter m = + input.readMessage( + com.google.firestore.v1.StructuredQuery.Filter.parser(), + extensionRegistry); + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + filters_.add(m); + } else { + filtersBuilder_.addMessage(m); + } + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int op_ = 0; + + /** + * + * + *
+       * The operator for combining multiple filters.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+       * The operator for combining multiple filters.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @param value The enum numeric value on the wire for op to set. + * @return This builder for chaining. + */ + public Builder setOpValue(int value) { + op_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The operator for combining multiple filters.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator result = + com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * The operator for combining multiple filters.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @param value The op to set. + * @return This builder for chaining. + */ + public Builder setOp(com.google.firestore.v1.StructuredQuery.CompositeFilter.Operator value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + op_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * The operator for combining multiple filters.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.CompositeFilter.Operator op = 1; + * + * @return This builder for chaining. + */ + public Builder clearOp() { + bitField0_ = (bitField0_ & ~0x00000001); + op_ = 0; + onChanged(); + return this; + } + + private java.util.List filters_ = + java.util.Collections.emptyList(); + + private void ensureFiltersIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + filters_ = + new java.util.ArrayList(filters_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder> + filtersBuilder_; + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public java.util.List getFiltersList() { + if (filtersBuilder_ == null) { + return java.util.Collections.unmodifiableList(filters_); + } else { + return filtersBuilder_.getMessageList(); + } + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public int getFiltersCount() { + if (filtersBuilder_ == null) { + return filters_.size(); + } else { + return filtersBuilder_.getCount(); + } + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public com.google.firestore.v1.StructuredQuery.Filter getFilters(int index) { + if (filtersBuilder_ == null) { + return filters_.get(index); + } else { + return filtersBuilder_.getMessage(index); + } + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder setFilters(int index, com.google.firestore.v1.StructuredQuery.Filter value) { + if (filtersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFiltersIsMutable(); + filters_.set(index, value); + onChanged(); + } else { + filtersBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder setFilters( + int index, com.google.firestore.v1.StructuredQuery.Filter.Builder builderForValue) { + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + filters_.set(index, builderForValue.build()); + onChanged(); + } else { + filtersBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder addFilters(com.google.firestore.v1.StructuredQuery.Filter value) { + if (filtersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFiltersIsMutable(); + filters_.add(value); + onChanged(); + } else { + filtersBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder addFilters(int index, com.google.firestore.v1.StructuredQuery.Filter value) { + if (filtersBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFiltersIsMutable(); + filters_.add(index, value); + onChanged(); + } else { + filtersBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder addFilters( + com.google.firestore.v1.StructuredQuery.Filter.Builder builderForValue) { + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + filters_.add(builderForValue.build()); + onChanged(); + } else { + filtersBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder addFilters( + int index, com.google.firestore.v1.StructuredQuery.Filter.Builder builderForValue) { + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + filters_.add(index, builderForValue.build()); + onChanged(); + } else { + filtersBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder addAllFilters( + java.lang.Iterable values) { + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, filters_); + onChanged(); + } else { + filtersBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder clearFilters() { + if (filtersBuilder_ == null) { + filters_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + filtersBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public Builder removeFilters(int index) { + if (filtersBuilder_ == null) { + ensureFiltersIsMutable(); + filters_.remove(index); + onChanged(); + } else { + filtersBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public com.google.firestore.v1.StructuredQuery.Filter.Builder getFiltersBuilder(int index) { + return internalGetFiltersFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public com.google.firestore.v1.StructuredQuery.FilterOrBuilder getFiltersOrBuilder( + int index) { + if (filtersBuilder_ == null) { + return filters_.get(index); + } else { + return filtersBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public java.util.List + getFiltersOrBuilderList() { + if (filtersBuilder_ != null) { + return filtersBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(filters_); + } + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public com.google.firestore.v1.StructuredQuery.Filter.Builder addFiltersBuilder() { + return internalGetFiltersFieldBuilder() + .addBuilder(com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance()); + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public com.google.firestore.v1.StructuredQuery.Filter.Builder addFiltersBuilder(int index) { + return internalGetFiltersFieldBuilder() + .addBuilder(index, com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance()); + } + + /** + * + * + *
+       * The list of filters to combine.
+       *
+       * Requires:
+       *
+       * * At least one filter is present.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Filter filters = 2; + */ + public java.util.List + getFiltersBuilderList() { + return internalGetFiltersFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder> + internalGetFiltersFieldBuilder() { + if (filtersBuilder_ == null) { + filtersBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder>( + filters_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + filters_ = null; + } + return filtersBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.CompositeFilter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.CompositeFilter) + private static final com.google.firestore.v1.StructuredQuery.CompositeFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.CompositeFilter(); + } + + public static com.google.firestore.v1.StructuredQuery.CompositeFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CompositeFilter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CompositeFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface FieldFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.FieldFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getField(); + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder(); + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The enum numeric value on the wire for op. + */ + int getOpValue(); + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The op. + */ + com.google.firestore.v1.StructuredQuery.FieldFilter.Operator getOp(); + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return Whether the value field is set. + */ + boolean hasValue(); + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return The value. + */ + com.google.firestore.v1.Value getValue(); + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + */ + com.google.firestore.v1.ValueOrBuilder getValueOrBuilder(); + } + + /** + * + * + *
+   * A filter on a specific field.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FieldFilter} + */ + public static final class FieldFilter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.FieldFilter) + FieldFilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FieldFilter"); + } + + // Use FieldFilter.newBuilder() to construct. + private FieldFilter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FieldFilter() { + op_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FieldFilter.class, + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder.class); + } + + /** + * + * + *
+     * A field filter operator.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.FieldFilter.Operator} + */ + public enum Operator implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + OPERATOR_UNSPECIFIED(0), + /** + * + * + *
+       * The given `field` is less than the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * LESS_THAN = 1; + */ + LESS_THAN(1), + /** + * + * + *
+       * The given `field` is less than or equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * LESS_THAN_OR_EQUAL = 2; + */ + LESS_THAN_OR_EQUAL(2), + /** + * + * + *
+       * The given `field` is greater than the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * GREATER_THAN = 3; + */ + GREATER_THAN(3), + /** + * + * + *
+       * The given `field` is greater than or equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * GREATER_THAN_OR_EQUAL = 4; + */ + GREATER_THAN_OR_EQUAL(4), + /** + * + * + *
+       * The given `field` is equal to the given `value`.
+       * 
+ * + * EQUAL = 5; + */ + EQUAL(5), + /** + * + * + *
+       * The given `field` is not equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * NOT_EQUAL = 6; + */ + NOT_EQUAL(6), + /** + * + * + *
+       * The given `field` is an array that contains the given `value`.
+       * 
+ * + * ARRAY_CONTAINS = 7; + */ + ARRAY_CONTAINS(7), + /** + * + * + *
+       * The given `field` is equal to at least one value in the given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue`, subject to disjunction
+       * limits.
+       * * No `NOT_IN` filters in the same query.
+       * 
+ * + * IN = 8; + */ + IN(8), + /** + * + * + *
+       * The given `field` is an array that contains any of the values in the
+       * given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue`, subject to disjunction
+       * limits.
+       * * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction.
+       * * No `NOT_IN` filters in the same query.
+       * 
+ * + * ARRAY_CONTAINS_ANY = 9; + */ + ARRAY_CONTAINS_ANY(9), + /** + * + * + *
+       * The value of the `field` is not in the given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue` with at most 10 values.
+       * * No other `OR`, `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`,
+       * `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * NOT_IN = 10; + */ + NOT_IN(10), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Operator"); + } + + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + public static final int OPERATOR_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The given `field` is less than the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * LESS_THAN = 1; + */ + public static final int LESS_THAN_VALUE = 1; + + /** + * + * + *
+       * The given `field` is less than or equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * LESS_THAN_OR_EQUAL = 2; + */ + public static final int LESS_THAN_OR_EQUAL_VALUE = 2; + + /** + * + * + *
+       * The given `field` is greater than the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * GREATER_THAN = 3; + */ + public static final int GREATER_THAN_VALUE = 3; + + /** + * + * + *
+       * The given `field` is greater than or equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * That `field` come first in `order_by`.
+       * 
+ * + * GREATER_THAN_OR_EQUAL = 4; + */ + public static final int GREATER_THAN_OR_EQUAL_VALUE = 4; + + /** + * + * + *
+       * The given `field` is equal to the given `value`.
+       * 
+ * + * EQUAL = 5; + */ + public static final int EQUAL_VALUE = 5; + + /** + * + * + *
+       * The given `field` is not equal to the given `value`.
+       *
+       * Requires:
+       *
+       * * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * NOT_EQUAL = 6; + */ + public static final int NOT_EQUAL_VALUE = 6; + + /** + * + * + *
+       * The given `field` is an array that contains the given `value`.
+       * 
+ * + * ARRAY_CONTAINS = 7; + */ + public static final int ARRAY_CONTAINS_VALUE = 7; + + /** + * + * + *
+       * The given `field` is equal to at least one value in the given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue`, subject to disjunction
+       * limits.
+       * * No `NOT_IN` filters in the same query.
+       * 
+ * + * IN = 8; + */ + public static final int IN_VALUE = 8; + + /** + * + * + *
+       * The given `field` is an array that contains any of the values in the
+       * given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue`, subject to disjunction
+       * limits.
+       * * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction.
+       * * No `NOT_IN` filters in the same query.
+       * 
+ * + * ARRAY_CONTAINS_ANY = 9; + */ + public static final int ARRAY_CONTAINS_ANY_VALUE = 9; + + /** + * + * + *
+       * The value of the `field` is not in the given array.
+       *
+       * Requires:
+       *
+       * * That `value` is a non-empty `ArrayValue` with at most 10 values.
+       * * No other `OR`, `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`,
+       * `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * NOT_IN = 10; + */ + public static final int NOT_IN_VALUE = 10; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Operator valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Operator forNumber(int value) { + switch (value) { + case 0: + return OPERATOR_UNSPECIFIED; + case 1: + return LESS_THAN; + case 2: + return LESS_THAN_OR_EQUAL; + case 3: + return GREATER_THAN; + case 4: + return GREATER_THAN_OR_EQUAL; + case 5: + return EQUAL; + case 6: + return NOT_EQUAL; + case 7: + return ARRAY_CONTAINS; + case 8: + return IN; + case 9: + return ARRAY_CONTAINS_ANY; + case 10: + return NOT_IN; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Operator findValueByNumber(int number) { + return Operator.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final Operator[] VALUES = values(); + + public static Operator valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Operator(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.FieldFilter.Operator) + } + + private int bitField0_; + public static final int FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + /** + * + * + *
+     * The field to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + public static final int OP_FIELD_NUMBER = 2; + private int op_ = 0; + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.FieldFilter.Operator result = + com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.UNRECOGNIZED + : result; + } + + public static final int VALUE_FIELD_NUMBER = 3; + private com.google.firestore.v1.Value value_; + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return Whether the value field is set. + */ + @java.lang.Override + public boolean hasValue() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return The value. + */ + @java.lang.Override + public com.google.firestore.v1.Value getValue() { + return value_ == null ? com.google.firestore.v1.Value.getDefaultInstance() : value_; + } + + /** + * + * + *
+     * The value to compare to.
+     * 
+ * + * .google.firestore.v1.Value value = 3; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getValueOrBuilder() { + return value_ == null ? com.google.firestore.v1.Value.getDefaultInstance() : value_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getField()); + } + if (op_ + != com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + output.writeEnum(2, op_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getValue()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getField()); + } + if (op_ + != com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, op_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getValue()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.FieldFilter)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.FieldFilter other = + (com.google.firestore.v1.StructuredQuery.FieldFilter) obj; + + if (hasField() != other.hasField()) return false; + if (hasField()) { + if (!getField().equals(other.getField())) return false; + } + if (op_ != other.op_) return false; + if (hasValue() != other.hasValue()) return false; + if (hasValue()) { + if (!getValue().equals(other.getValue())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasField()) { + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + } + hash = (37 * hash) + OP_FIELD_NUMBER; + hash = (53 * hash) + op_; + if (hasValue()) { + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.FieldFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A filter on a specific field.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FieldFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.FieldFilter) + com.google.firestore.v1.StructuredQuery.FieldFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FieldFilter.class, + com.google.firestore.v1.StructuredQuery.FieldFilter.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.FieldFilter.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetFieldFieldBuilder(); + internalGetValueFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + op_ = 0; + value_ = null; + if (valueBuilder_ != null) { + valueBuilder_.dispose(); + valueBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldFilter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter build() { + com.google.firestore.v1.StructuredQuery.FieldFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter buildPartial() { + com.google.firestore.v1.StructuredQuery.FieldFilter result = + new com.google.firestore.v1.StructuredQuery.FieldFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.FieldFilter result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = fieldBuilder_ == null ? field_ : fieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.op_ = op_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.value_ = valueBuilder_ == null ? value_ : valueBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.FieldFilter) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.FieldFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.FieldFilter other) { + if (other == com.google.firestore.v1.StructuredQuery.FieldFilter.getDefaultInstance()) + return this; + if (other.hasField()) { + mergeField(other.getField()); + } + if (other.op_ != 0) { + setOpValue(other.getOpValue()); + } + if (other.hasValue()) { + mergeValue(other.getValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + op_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + input.readMessage(internalGetValueFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldBuilder_; + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (fieldBuilder_ == null) { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } else { + return fieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + } else { + fieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldBuilder_ == null) { + field_ = builderForValue.build(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder mergeField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && field_ != null + && field_ + != com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) { + getFieldBuilder().mergeFrom(value); + } else { + field_ = value; + } + } else { + fieldBuilder_.mergeFrom(value); + } + if (field_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder clearField() { + bitField0_ = (bitField0_ & ~0x00000001); + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if (fieldBuilder_ != null) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + } + + /** + * + * + *
+       * The field to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getField(), getParentForChildren(), isClean()); + field_ = null; + } + return fieldBuilder_; + } + + private int op_ = 0; + + /** + * + * + *
+       * The operator to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+       * The operator to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @param value The enum numeric value on the wire for op to set. + * @return This builder for chaining. + */ + public Builder setOpValue(int value) { + op_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * The operator to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.FieldFilter.Operator result = + com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FieldFilter.Operator.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * The operator to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @param value The op to set. + * @return This builder for chaining. + */ + public Builder setOp(com.google.firestore.v1.StructuredQuery.FieldFilter.Operator value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + op_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * The operator to filter by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldFilter.Operator op = 2; + * + * @return This builder for chaining. + */ + public Builder clearOp() { + bitField0_ = (bitField0_ & ~0x00000002); + op_ = 0; + onChanged(); + return this; + } + + private com.google.firestore.v1.Value value_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + valueBuilder_; + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return Whether the value field is set. + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + * + * @return The value. + */ + public com.google.firestore.v1.Value getValue() { + if (valueBuilder_ == null) { + return value_ == null ? com.google.firestore.v1.Value.getDefaultInstance() : value_; + } else { + return valueBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public Builder setValue(com.google.firestore.v1.Value value) { + if (valueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + value_ = value; + } else { + valueBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public Builder setValue(com.google.firestore.v1.Value.Builder builderForValue) { + if (valueBuilder_ == null) { + value_ = builderForValue.build(); + } else { + valueBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public Builder mergeValue(com.google.firestore.v1.Value value) { + if (valueBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && value_ != null + && value_ != com.google.firestore.v1.Value.getDefaultInstance()) { + getValueBuilder().mergeFrom(value); + } else { + value_ = value; + } + } else { + valueBuilder_.mergeFrom(value); + } + if (value_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public Builder clearValue() { + bitField0_ = (bitField0_ & ~0x00000004); + value_ = null; + if (valueBuilder_ != null) { + valueBuilder_.dispose(); + valueBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public com.google.firestore.v1.Value.Builder getValueBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + public com.google.firestore.v1.ValueOrBuilder getValueOrBuilder() { + if (valueBuilder_ != null) { + return valueBuilder_.getMessageOrBuilder(); + } else { + return value_ == null ? com.google.firestore.v1.Value.getDefaultInstance() : value_; + } + } + + /** + * + * + *
+       * The value to compare to.
+       * 
+ * + * .google.firestore.v1.Value value = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetValueFieldBuilder() { + if (valueBuilder_ == null) { + valueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + getValue(), getParentForChildren(), isClean()); + value_ = null; + } + return valueBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.FieldFilter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.FieldFilter) + private static final com.google.firestore.v1.StructuredQuery.FieldFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.FieldFilter(); + } + + public static com.google.firestore.v1.StructuredQuery.FieldFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FieldFilter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface UnaryFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.UnaryFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The unary operator to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + int getOpValue(); + + /** + * + * + *
+     * The unary operator to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The op. + */ + com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator getOp(); + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return The field. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getField(); + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder(); + + com.google.firestore.v1.StructuredQuery.UnaryFilter.OperandTypeCase getOperandTypeCase(); + } + + /** + * + * + *
+   * A filter with a single operand.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.UnaryFilter} + */ + public static final class UnaryFilter extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.UnaryFilter) + UnaryFilterOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UnaryFilter"); + } + + // Use UnaryFilter.newBuilder() to construct. + private UnaryFilter(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UnaryFilter() { + op_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.UnaryFilter.class, + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder.class); + } + + /** + * + * + *
+     * A unary operator.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.UnaryFilter.Operator} + */ + public enum Operator implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + OPERATOR_UNSPECIFIED(0), + /** + * + * + *
+       * The given `field` is equal to `NaN`.
+       * 
+ * + * IS_NAN = 2; + */ + IS_NAN(2), + /** + * + * + *
+       * The given `field` is equal to `NULL`.
+       * 
+ * + * IS_NULL = 3; + */ + IS_NULL(3), + /** + * + * + *
+       * The given `field` is not equal to `NaN`.
+       *
+       * Requires:
+       *
+       * * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * IS_NOT_NAN = 4; + */ + IS_NOT_NAN(4), + /** + * + * + *
+       * The given `field` is not equal to `NULL`.
+       *
+       * Requires:
+       *
+       * * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * IS_NOT_NULL = 5; + */ + IS_NOT_NULL(5), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Operator"); + } + + /** + * + * + *
+       * Unspecified. This value must not be used.
+       * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + public static final int OPERATOR_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * The given `field` is equal to `NaN`.
+       * 
+ * + * IS_NAN = 2; + */ + public static final int IS_NAN_VALUE = 2; + + /** + * + * + *
+       * The given `field` is equal to `NULL`.
+       * 
+ * + * IS_NULL = 3; + */ + public static final int IS_NULL_VALUE = 3; + + /** + * + * + *
+       * The given `field` is not equal to `NaN`.
+       *
+       * Requires:
+       *
+       * * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * IS_NOT_NAN = 4; + */ + public static final int IS_NOT_NAN_VALUE = 4; + + /** + * + * + *
+       * The given `field` is not equal to `NULL`.
+       *
+       * Requires:
+       *
+       * * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`.
+       * * That `field` comes first in the `order_by`.
+       * 
+ * + * IS_NOT_NULL = 5; + */ + public static final int IS_NOT_NULL_VALUE = 5; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static Operator valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static Operator forNumber(int value) { + switch (value) { + case 0: + return OPERATOR_UNSPECIFIED; + case 2: + return IS_NAN; + case 3: + return IS_NULL; + case 4: + return IS_NOT_NAN; + case 5: + return IS_NOT_NULL; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public Operator findValueByNumber(int number) { + return Operator.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final Operator[] VALUES = values(); + + public static Operator valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private Operator(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.UnaryFilter.Operator) + } + + private int operandTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object operandType_; + + public enum OperandTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + FIELD(2), + OPERANDTYPE_NOT_SET(0); + private final int value; + + private OperandTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static OperandTypeCase valueOf(int value) { + return forNumber(value); + } + + public static OperandTypeCase forNumber(int value) { + switch (value) { + case 2: + return FIELD; + case 0: + return OPERANDTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public OperandTypeCase getOperandTypeCase() { + return OperandTypeCase.forNumber(operandTypeCase_); + } + + public static final int OP_FIELD_NUMBER = 1; + private int op_ = 0; + + /** + * + * + *
+     * The unary operator to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+     * The unary operator to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator result = + com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.UNRECOGNIZED + : result; + } + + public static final int FIELD_FIELD_NUMBER = 2; + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return operandTypeCase_ == 2; + } + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (operandTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_; + } + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + + /** + * + * + *
+     * The field to which to apply the operator.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if (operandTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_; + } + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (op_ + != com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, op_); + } + if (operandTypeCase_ == 2) { + output.writeMessage( + 2, (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (op_ + != com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.OPERATOR_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, op_); + } + if (operandTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.UnaryFilter)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.UnaryFilter other = + (com.google.firestore.v1.StructuredQuery.UnaryFilter) obj; + + if (op_ != other.op_) return false; + if (!getOperandTypeCase().equals(other.getOperandTypeCase())) return false; + switch (operandTypeCase_) { + case 2: + if (!getField().equals(other.getField())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + OP_FIELD_NUMBER; + hash = (53 * hash) + op_; + switch (operandTypeCase_) { + case 2: + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.UnaryFilter prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A filter with a single operand.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.UnaryFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.UnaryFilter) + com.google.firestore.v1.StructuredQuery.UnaryFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.UnaryFilter.class, + com.google.firestore.v1.StructuredQuery.UnaryFilter.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.UnaryFilter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + op_ = 0; + if (fieldBuilder_ != null) { + fieldBuilder_.clear(); + } + operandTypeCase_ = 0; + operandType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_UnaryFilter_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter build() { + com.google.firestore.v1.StructuredQuery.UnaryFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter buildPartial() { + com.google.firestore.v1.StructuredQuery.UnaryFilter result = + new com.google.firestore.v1.StructuredQuery.UnaryFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.UnaryFilter result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.op_ = op_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.StructuredQuery.UnaryFilter result) { + result.operandTypeCase_ = operandTypeCase_; + result.operandType_ = this.operandType_; + if (operandTypeCase_ == 2 && fieldBuilder_ != null) { + result.operandType_ = fieldBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.UnaryFilter) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.UnaryFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.UnaryFilter other) { + if (other == com.google.firestore.v1.StructuredQuery.UnaryFilter.getDefaultInstance()) + return this; + if (other.op_ != 0) { + setOpValue(other.getOpValue()); + } + switch (other.getOperandTypeCase()) { + case FIELD: + { + mergeField(other.getField()); + break; + } + case OPERANDTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + op_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + input.readMessage(internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + operandTypeCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int operandTypeCase_ = 0; + private java.lang.Object operandType_; + + public OperandTypeCase getOperandTypeCase() { + return OperandTypeCase.forNumber(operandTypeCase_); + } + + public Builder clearOperandType() { + operandTypeCase_ = 0; + operandType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private int op_ = 0; + + /** + * + * + *
+       * The unary operator to apply.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + @java.lang.Override + public int getOpValue() { + return op_; + } + + /** + * + * + *
+       * The unary operator to apply.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @param value The enum numeric value on the wire for op to set. + * @return This builder for chaining. + */ + public Builder setOpValue(int value) { + op_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The unary operator to apply.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator getOp() { + com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator result = + com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.forNumber(op_); + return result == null + ? com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * The unary operator to apply.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @param value The op to set. + * @return This builder for chaining. + */ + public Builder setOp(com.google.firestore.v1.StructuredQuery.UnaryFilter.Operator value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + op_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * The unary operator to apply.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.UnaryFilter.Operator op = 1; + * + * @return This builder for chaining. + */ + public Builder clearOp() { + bitField0_ = (bitField0_ & ~0x00000001); + op_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldBuilder_; + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return operandTypeCase_ == 2; + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (fieldBuilder_ == null) { + if (operandTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_; + } + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } else { + if (operandTypeCase_ == 2) { + return fieldBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + public Builder setField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operandType_ = value; + onChanged(); + } else { + fieldBuilder_.setMessage(value); + } + operandTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + public Builder setField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldBuilder_ == null) { + operandType_ = builderForValue.build(); + onChanged(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + operandTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + public Builder mergeField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (operandTypeCase_ == 2 + && operandType_ + != com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) { + operandType_ = + com.google.firestore.v1.StructuredQuery.FieldReference.newBuilder( + (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_) + .mergeFrom(value) + .buildPartial(); + } else { + operandType_ = value; + } + onChanged(); + } else { + if (operandTypeCase_ == 2) { + fieldBuilder_.mergeFrom(value); + } else { + fieldBuilder_.setMessage(value); + } + } + operandTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + public Builder clearField() { + if (fieldBuilder_ == null) { + if (operandTypeCase_ == 2) { + operandTypeCase_ = 0; + operandType_ = null; + onChanged(); + } + } else { + if (operandTypeCase_ == 2) { + operandTypeCase_ = 0; + operandType_ = null; + } + fieldBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldBuilder() { + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if ((operandTypeCase_ == 2) && (fieldBuilder_ != null)) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + if (operandTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_; + } + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + } + + /** + * + * + *
+       * The field to which to apply the operator.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + if (!(operandTypeCase_ == 2)) { + operandType_ = + com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + (com.google.firestore.v1.StructuredQuery.FieldReference) operandType_, + getParentForChildren(), + isClean()); + operandType_ = null; + } + operandTypeCase_ = 2; + onChanged(); + return fieldBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.UnaryFilter) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.UnaryFilter) + private static final com.google.firestore.v1.StructuredQuery.UnaryFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.UnaryFilter(); + } + + public static com.google.firestore.v1.StructuredQuery.UnaryFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UnaryFilter parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.UnaryFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface OrderOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.Order) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + boolean hasField(); + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getField(); + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder(); + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The enum numeric value on the wire for direction. + */ + int getDirectionValue(); + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The direction. + */ + com.google.firestore.v1.StructuredQuery.Direction getDirection(); + } + + /** + * + * + *
+   * An order on a field.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Order} + */ + public static final class Order extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.Order) + OrderOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Order"); + } + + // Use Order.newBuilder() to construct. + private Order(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Order() { + direction_ = 0; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Order_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Order_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Order.class, + com.google.firestore.v1.StructuredQuery.Order.Builder.class); + } + + private int bitField0_; + public static final int FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + @java.lang.Override + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + /** + * + * + *
+     * The field to order by.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + + public static final int DIRECTION_FIELD_NUMBER = 2; + private int direction_ = 0; + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The enum numeric value on the wire for direction. + */ + @java.lang.Override + public int getDirectionValue() { + return direction_; + } + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The direction. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Direction getDirection() { + com.google.firestore.v1.StructuredQuery.Direction result = + com.google.firestore.v1.StructuredQuery.Direction.forNumber(direction_); + return result == null + ? com.google.firestore.v1.StructuredQuery.Direction.UNRECOGNIZED + : result; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getField()); + } + if (direction_ + != com.google.firestore.v1.StructuredQuery.Direction.DIRECTION_UNSPECIFIED.getNumber()) { + output.writeEnum(2, direction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getField()); + } + if (direction_ + != com.google.firestore.v1.StructuredQuery.Direction.DIRECTION_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, direction_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.Order)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.Order other = + (com.google.firestore.v1.StructuredQuery.Order) obj; + + if (hasField() != other.hasField()) return false; + if (hasField()) { + if (!getField().equals(other.getField())) return false; + } + if (direction_ != other.direction_) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasField()) { + hash = (37 * hash) + FIELD_FIELD_NUMBER; + hash = (53 * hash) + getField().hashCode(); + } + hash = (37 * hash) + DIRECTION_FIELD_NUMBER; + hash = (53 * hash) + direction_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Order parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredQuery.Order prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * An order on a field.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Order} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.Order) + com.google.firestore.v1.StructuredQuery.OrderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Order_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Order_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Order.class, + com.google.firestore.v1.StructuredQuery.Order.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.Order.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetFieldFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + direction_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Order_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Order getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.Order.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Order build() { + com.google.firestore.v1.StructuredQuery.Order result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Order buildPartial() { + com.google.firestore.v1.StructuredQuery.Order result = + new com.google.firestore.v1.StructuredQuery.Order(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.Order result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.field_ = fieldBuilder_ == null ? field_ : fieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.direction_ = direction_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.Order) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.Order) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.Order other) { + if (other == com.google.firestore.v1.StructuredQuery.Order.getDefaultInstance()) + return this; + if (other.hasField()) { + mergeField(other.getField()); + } + if (other.direction_ != 0) { + setDirectionValue(other.getDirectionValue()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + direction_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference field_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldBuilder_; + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return Whether the field field is set. + */ + public boolean hasField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + * + * @return The field. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getField() { + if (fieldBuilder_ == null) { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } else { + return fieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + field_ = value; + } else { + fieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder setField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldBuilder_ == null) { + field_ = builderForValue.build(); + } else { + fieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder mergeField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && field_ != null + && field_ + != com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) { + getFieldBuilder().mergeFrom(value); + } else { + field_ = value; + } + } else { + fieldBuilder_.mergeFrom(value); + } + if (field_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public Builder clearField() { + bitField0_ = (bitField0_ & ~0x00000001); + field_ = null; + if (fieldBuilder_ != null) { + fieldBuilder_.dispose(); + fieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldOrBuilder() { + if (fieldBuilder_ != null) { + return fieldBuilder_.getMessageOrBuilder(); + } else { + return field_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : field_; + } + } + + /** + * + * + *
+       * The field to order by.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.FieldReference field = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldFieldBuilder() { + if (fieldBuilder_ == null) { + fieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getField(), getParentForChildren(), isClean()); + field_ = null; + } + return fieldBuilder_; + } + + private int direction_ = 0; + + /** + * + * + *
+       * The direction to order by. Defaults to `ASCENDING`.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The enum numeric value on the wire for direction. + */ + @java.lang.Override + public int getDirectionValue() { + return direction_; + } + + /** + * + * + *
+       * The direction to order by. Defaults to `ASCENDING`.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @param value The enum numeric value on the wire for direction to set. + * @return This builder for chaining. + */ + public Builder setDirectionValue(int value) { + direction_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * The direction to order by. Defaults to `ASCENDING`.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return The direction. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Direction getDirection() { + com.google.firestore.v1.StructuredQuery.Direction result = + com.google.firestore.v1.StructuredQuery.Direction.forNumber(direction_); + return result == null + ? com.google.firestore.v1.StructuredQuery.Direction.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * The direction to order by. Defaults to `ASCENDING`.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @param value The direction to set. + * @return This builder for chaining. + */ + public Builder setDirection(com.google.firestore.v1.StructuredQuery.Direction value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + direction_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * The direction to order by. Defaults to `ASCENDING`.
+       * 
+ * + * .google.firestore.v1.StructuredQuery.Direction direction = 2; + * + * @return This builder for chaining. + */ + public Builder clearDirection() { + bitField0_ = (bitField0_ & ~0x00000002); + direction_ = 0; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.Order) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.Order) + private static final com.google.firestore.v1.StructuredQuery.Order DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.Order(); + } + + public static com.google.firestore.v1.StructuredQuery.Order getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Order parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Order getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface FieldReferenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.FieldReference) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * A reference to a field in a document.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string field_path = 2; + * + * @return The fieldPath. + */ + java.lang.String getFieldPath(); + + /** + * + * + *
+     * A reference to a field in a document.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string field_path = 2; + * + * @return The bytes for fieldPath. + */ + com.google.protobuf.ByteString getFieldPathBytes(); + } + + /** + * + * + *
+   * A reference to a field in a document, ex: `stats.operations`.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FieldReference} + */ + public static final class FieldReference extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.FieldReference) + FieldReferenceOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FieldReference"); + } + + // Use FieldReference.newBuilder() to construct. + private FieldReference(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FieldReference() { + fieldPath_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FieldReference.class, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder.class); + } + + public static final int FIELD_PATH_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+     * A reference to a field in a document.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string field_path = 2; + * + * @return The fieldPath. + */ + @java.lang.Override + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } + } + + /** + * + * + *
+     * A reference to a field in a document.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [document field name][google.firestore.v1.Document.fields]
+     * limitations.
+     * 
+ * + * string field_path = 2; + * + * @return The bytes for fieldPath. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, fieldPath_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(fieldPath_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, fieldPath_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.FieldReference)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.FieldReference other = + (com.google.firestore.v1.StructuredQuery.FieldReference) obj; + + if (!getFieldPath().equals(other.getFieldPath())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + FIELD_PATH_FIELD_NUMBER; + hash = (53 * hash) + getFieldPath().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.FieldReference prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A reference to a field in a document, ex: `stats.operations`.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FieldReference} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.FieldReference) + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FieldReference.class, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.FieldReference.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + fieldPath_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FieldReference_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference build() { + com.google.firestore.v1.StructuredQuery.FieldReference result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference buildPartial() { + com.google.firestore.v1.StructuredQuery.FieldReference result = + new com.google.firestore.v1.StructuredQuery.FieldReference(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.FieldReference result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.fieldPath_ = fieldPath_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.FieldReference) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.FieldReference) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.FieldReference other) { + if (other == com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) + return this; + if (!other.getFieldPath().isEmpty()) { + fieldPath_ = other.fieldPath_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + fieldPath_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object fieldPath_ = ""; + + /** + * + * + *
+       * A reference to a field in a document.
+       *
+       * Requires:
+       *
+       * * MUST be a dot-delimited (`.`) string of segments, where each segment
+       * conforms to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string field_path = 2; + * + * @return The fieldPath. + */ + public java.lang.String getFieldPath() { + java.lang.Object ref = fieldPath_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + fieldPath_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * A reference to a field in a document.
+       *
+       * Requires:
+       *
+       * * MUST be a dot-delimited (`.`) string of segments, where each segment
+       * conforms to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string field_path = 2; + * + * @return The bytes for fieldPath. + */ + public com.google.protobuf.ByteString getFieldPathBytes() { + java.lang.Object ref = fieldPath_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + fieldPath_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * A reference to a field in a document.
+       *
+       * Requires:
+       *
+       * * MUST be a dot-delimited (`.`) string of segments, where each segment
+       * conforms to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string field_path = 2; + * + * @param value The fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPath(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * A reference to a field in a document.
+       *
+       * Requires:
+       *
+       * * MUST be a dot-delimited (`.`) string of segments, where each segment
+       * conforms to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string field_path = 2; + * + * @return This builder for chaining. + */ + public Builder clearFieldPath() { + fieldPath_ = getDefaultInstance().getFieldPath(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * A reference to a field in a document.
+       *
+       * Requires:
+       *
+       * * MUST be a dot-delimited (`.`) string of segments, where each segment
+       * conforms to [document field name][google.firestore.v1.Document.fields]
+       * limitations.
+       * 
+ * + * string field_path = 2; + * + * @param value The bytes for fieldPath to set. + * @return This builder for chaining. + */ + public Builder setFieldPathBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + fieldPath_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.FieldReference) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.FieldReference) + private static final com.google.firestore.v1.StructuredQuery.FieldReference DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.FieldReference(); + } + + public static com.google.firestore.v1.StructuredQuery.FieldReference getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FieldReference parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface ProjectionOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.Projection) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + java.util.List getFieldsList(); + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + com.google.firestore.v1.StructuredQuery.FieldReference getFields(int index); + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + int getFieldsCount(); + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + java.util.List + getFieldsOrBuilderList(); + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldsOrBuilder(int index); + } + + /** + * + * + *
+   * The projection of document's fields to return.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Projection} + */ + public static final class Projection extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.Projection) + ProjectionOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Projection"); + } + + // Use Projection.newBuilder() to construct. + private Projection(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Projection() { + fields_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Projection_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Projection.class, + com.google.firestore.v1.StructuredQuery.Projection.Builder.class); + } + + public static final int FIELDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List fields_; + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + @java.lang.Override + public java.util.List getFieldsList() { + return fields_; + } + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + @java.lang.Override + public java.util.List + getFieldsOrBuilderList() { + return fields_; + } + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + @java.lang.Override + public int getFieldsCount() { + return fields_.size(); + } + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getFields(int index) { + return fields_.get(index); + } + + /** + * + * + *
+     * The fields to return.
+     *
+     * If empty, all fields are returned. To only return the name
+     * of the document, use `['__name__']`.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldsOrBuilder( + int index) { + return fields_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < fields_.size(); i++) { + output.writeMessage(2, fields_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < fields_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, fields_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.Projection)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.Projection other = + (com.google.firestore.v1.StructuredQuery.Projection) obj; + + if (!getFieldsList().equals(other.getFieldsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getFieldsCount() > 0) { + hash = (37 * hash) + FIELDS_FIELD_NUMBER; + hash = (53 * hash) + getFieldsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.Projection parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredQuery.Projection prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * The projection of document's fields to return.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.Projection} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.Projection) + com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Projection_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.Projection.class, + com.google.firestore.v1.StructuredQuery.Projection.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.Projection.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + } else { + fields_ = null; + fieldsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_Projection_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Projection getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Projection build() { + com.google.firestore.v1.StructuredQuery.Projection result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Projection buildPartial() { + com.google.firestore.v1.StructuredQuery.Projection result = + new com.google.firestore.v1.StructuredQuery.Projection(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.firestore.v1.StructuredQuery.Projection result) { + if (fieldsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + fields_ = java.util.Collections.unmodifiableList(fields_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.fields_ = fields_; + } else { + result.fields_ = fieldsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.Projection result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.Projection) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.Projection) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.Projection other) { + if (other == com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance()) + return this; + if (fieldsBuilder_ == null) { + if (!other.fields_.isEmpty()) { + if (fields_.isEmpty()) { + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFieldsIsMutable(); + fields_.addAll(other.fields_); + } + onChanged(); + } + } else { + if (!other.fields_.isEmpty()) { + if (fieldsBuilder_.isEmpty()) { + fieldsBuilder_.dispose(); + fieldsBuilder_ = null; + fields_ = other.fields_; + bitField0_ = (bitField0_ & ~0x00000001); + fieldsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFieldsFieldBuilder() + : null; + } else { + fieldsBuilder_.addAllMessages(other.fields_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + com.google.firestore.v1.StructuredQuery.FieldReference m = + input.readMessage( + com.google.firestore.v1.StructuredQuery.FieldReference.parser(), + extensionRegistry); + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(m); + } else { + fieldsBuilder_.addMessage(m); + } + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.util.List fields_ = + java.util.Collections.emptyList(); + + private void ensureFieldsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + fields_ = + new java.util.ArrayList( + fields_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + fieldsBuilder_; + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public java.util.List + getFieldsList() { + if (fieldsBuilder_ == null) { + return java.util.Collections.unmodifiableList(fields_); + } else { + return fieldsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public int getFieldsCount() { + if (fieldsBuilder_ == null) { + return fields_.size(); + } else { + return fieldsBuilder_.getCount(); + } + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getFields(int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder setFields( + int index, com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.set(index, value); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder setFields( + int index, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.set(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder addFields(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(value); + onChanged(); + } else { + fieldsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder addFields( + int index, com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (fieldsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFieldsIsMutable(); + fields_.add(index, value); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder addFields( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder addFields( + int index, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.add(index, builderForValue.build()); + onChanged(); + } else { + fieldsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder addAllFields( + java.lang.Iterable + values) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, fields_); + onChanged(); + } else { + fieldsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder clearFields() { + if (fieldsBuilder_ == null) { + fields_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + fieldsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public Builder removeFields(int index) { + if (fieldsBuilder_ == null) { + ensureFieldsIsMutable(); + fields_.remove(index); + onChanged(); + } else { + fieldsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder getFieldsBuilder( + int index) { + return internalGetFieldsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getFieldsOrBuilder( + int index) { + if (fieldsBuilder_ == null) { + return fields_.get(index); + } else { + return fieldsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public java.util.List< + ? extends com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + getFieldsOrBuilderList() { + if (fieldsBuilder_ != null) { + return fieldsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(fields_); + } + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder addFieldsBuilder() { + return internalGetFieldsFieldBuilder() + .addBuilder( + com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()); + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder addFieldsBuilder( + int index) { + return internalGetFieldsFieldBuilder() + .addBuilder( + index, com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()); + } + + /** + * + * + *
+       * The fields to return.
+       *
+       * If empty, all fields are returned. To only return the name
+       * of the document, use `['__name__']`.
+       * 
+ * + * repeated .google.firestore.v1.StructuredQuery.FieldReference fields = 2; + */ + public java.util.List + getFieldsBuilderList() { + return internalGetFieldsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetFieldsFieldBuilder() { + if (fieldsBuilder_ == null) { + fieldsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + fields_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + fields_ = null; + } + return fieldsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.Projection) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.Projection) + private static final com.google.firestore.v1.StructuredQuery.Projection DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.Projection(); + } + + public static com.google.firestore.v1.StructuredQuery.Projection getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Projection parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Projection getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface FindNearestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery.FindNearest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + boolean hasVectorField(); + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + com.google.firestore.v1.StructuredQuery.FieldReference getVectorField(); + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder getVectorFieldOrBuilder(); + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + boolean hasQueryVector(); + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + com.google.firestore.v1.Value getQueryVector(); + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder(); + + /** + * + * + *
+     * Required. The distance measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + int getDistanceMeasureValue(); + + /** + * + * + *
+     * Required. The distance measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure getDistanceMeasure(); + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + boolean hasLimit(); + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + com.google.protobuf.Int32Value getLimit(); + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [document field
+     * name][google.firestore.v1.Document.fields] limitations.
+     * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultField. + */ + java.lang.String getDistanceResultField(); + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [document field
+     * name][google.firestore.v1.Document.fields] limitations.
+     * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultField. + */ + com.google.protobuf.ByteString getDistanceResultFieldBytes(); + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + boolean hasDistanceThreshold(); + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + com.google.protobuf.DoubleValue getDistanceThreshold(); + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder(); + } + + /** + * + * + *
+   * Nearest Neighbors search config. The ordering provided by FindNearest
+   * supersedes the order_by stage. If multiple documents have the same vector
+   * distance, the returned document order is not guaranteed to be stable
+   * between queries.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FindNearest} + */ + public static final class FindNearest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.StructuredQuery.FindNearest) + FindNearestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "FindNearest"); + } + + // Use FindNearest.newBuilder() to construct. + private FindNearest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private FindNearest() { + distanceMeasure_ = 0; + distanceResultField_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FindNearest.class, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder.class); + } + + /** + * + * + *
+     * The distance measure to use when comparing vectors.
+     * 
+ * + * Protobuf enum {@code google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure} + */ + public enum DistanceMeasure implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+       * Should not be set.
+       * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + DISTANCE_MEASURE_UNSPECIFIED(0), + /** + * + * + *
+       * Measures the EUCLIDEAN distance between the vectors. See
+       * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+       * more. The resulting distance decreases the more similar two vectors
+       * are.
+       * 
+ * + * EUCLIDEAN = 1; + */ + EUCLIDEAN(1), + /** + * + * + *
+       * COSINE distance compares vectors based on the angle between them, which
+       * allows you to measure similarity that isn't based on the vectors
+       * magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
+       * instead of COSINE distance, which is mathematically equivalent with
+       * better performance. See [Cosine
+       * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+       * more about COSINE similarity and COSINE distance. The resulting
+       * COSINE distance decreases the more similar two vectors are.
+       * 
+ * + * COSINE = 2; + */ + COSINE(2), + /** + * + * + *
+       * Similar to cosine but is affected by the magnitude of the vectors. See
+       * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+       * The resulting distance increases the more similar two vectors are.
+       * 
+ * + * DOT_PRODUCT = 3; + */ + DOT_PRODUCT(3), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DistanceMeasure"); + } + + /** + * + * + *
+       * Should not be set.
+       * 
+ * + * DISTANCE_MEASURE_UNSPECIFIED = 0; + */ + public static final int DISTANCE_MEASURE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+       * Measures the EUCLIDEAN distance between the vectors. See
+       * [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn
+       * more. The resulting distance decreases the more similar two vectors
+       * are.
+       * 
+ * + * EUCLIDEAN = 1; + */ + public static final int EUCLIDEAN_VALUE = 1; + + /** + * + * + *
+       * COSINE distance compares vectors based on the angle between them, which
+       * allows you to measure similarity that isn't based on the vectors
+       * magnitude. We recommend using DOT_PRODUCT with unit normalized vectors
+       * instead of COSINE distance, which is mathematically equivalent with
+       * better performance. See [Cosine
+       * Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn
+       * more about COSINE similarity and COSINE distance. The resulting
+       * COSINE distance decreases the more similar two vectors are.
+       * 
+ * + * COSINE = 2; + */ + public static final int COSINE_VALUE = 2; + + /** + * + * + *
+       * Similar to cosine but is affected by the magnitude of the vectors. See
+       * [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more.
+       * The resulting distance increases the more similar two vectors are.
+       * 
+ * + * DOT_PRODUCT = 3; + */ + public static final int DOT_PRODUCT_VALUE = 3; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static DistanceMeasure valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static DistanceMeasure forNumber(int value) { + switch (value) { + case 0: + return DISTANCE_MEASURE_UNSPECIFIED; + case 1: + return EUCLIDEAN; + case 2: + return COSINE; + case 3: + return DOT_PRODUCT; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap + internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public DistanceMeasure findValueByNumber(int number) { + return DistanceMeasure.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.StructuredQuery.FindNearest.getDescriptor() + .getEnumTypes() + .get(0); + } + + private static final DistanceMeasure[] VALUES = values(); + + public static DistanceMeasure valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private DistanceMeasure(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure) + } + + private int bitField0_; + public static final int VECTOR_FIELD_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.FieldReference vectorField_; + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + @java.lang.Override + public boolean hasVectorField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReference getVectorField() { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + + /** + * + * + *
+     * Required. An indexed vector field to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder + getVectorFieldOrBuilder() { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + + public static final int QUERY_VECTOR_FIELD_NUMBER = 2; + private com.google.firestore.v1.Value queryVector_; + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + @java.lang.Override + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + @java.lang.Override + public com.google.firestore.v1.Value getQueryVector() { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of
+     * no more than 2048 dimensions.
+     * 
+ * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + + public static final int DISTANCE_MEASURE_FIELD_NUMBER = 3; + private int distanceMeasure_ = 0; + + /** + * + * + *
+     * Required. The distance measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + + /** + * + * + *
+     * Required. The distance measure to use, required.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + getDistanceMeasure() { + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure result = + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.forNumber( + distanceMeasure_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + + public static final int LIMIT_FIELD_NUMBER = 4; + private com.google.protobuf.Int32Value limit_; + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return Whether the limit field is set. + */ + @java.lang.Override + public boolean hasLimit() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The limit. + */ + @java.lang.Override + public com.google.protobuf.Int32Value getLimit() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 1000.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + @java.lang.Override + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + public static final int DISTANCE_RESULT_FIELD_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object distanceResultField_ = ""; + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [document field
+     * name][google.firestore.v1.Document.fields] limitations.
+     * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultField. + */ + @java.lang.Override + public java.lang.String getDistanceResultField() { + java.lang.Object ref = distanceResultField_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + distanceResultField_ = s; + return s; + } + } + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [document field
+     * name][google.firestore.v1.Document.fields] limitations.
+     * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultField. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDistanceResultFieldBytes() { + java.lang.Object ref = distanceResultField_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultField_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DISTANCE_THRESHOLD_FIELD_NUMBER = 6; + private com.google.protobuf.DoubleValue distanceThreshold_; + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + @java.lang.Override + public boolean hasDistanceThreshold() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + @java.lang.Override + public com.google.protobuf.DoubleValue getDistanceThreshold() { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + + /** + * + * + *
+     * Optional. Option to specify a threshold for which no less similar
+     * documents will be returned. The behavior of the specified
+     * `distance_measure` will affect the meaning of the distance threshold.
+     * Since DOT_PRODUCT distances increase when the vectors are more similar,
+     * the comparison is inverted.
+     *
+     * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+     * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+     * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder() { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getVectorField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + .DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + output.writeEnum(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getLimit()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(distanceResultField_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, distanceResultField_); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(6, getDistanceThreshold()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getVectorField()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + .DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getLimit()); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(distanceResultField_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, distanceResultField_); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getDistanceThreshold()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery.FindNearest)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery.FindNearest other = + (com.google.firestore.v1.StructuredQuery.FindNearest) obj; + + if (hasVectorField() != other.hasVectorField()) return false; + if (hasVectorField()) { + if (!getVectorField().equals(other.getVectorField())) return false; + } + if (hasQueryVector() != other.hasQueryVector()) return false; + if (hasQueryVector()) { + if (!getQueryVector().equals(other.getQueryVector())) return false; + } + if (distanceMeasure_ != other.distanceMeasure_) return false; + if (hasLimit() != other.hasLimit()) return false; + if (hasLimit()) { + if (!getLimit().equals(other.getLimit())) return false; + } + if (!getDistanceResultField().equals(other.getDistanceResultField())) return false; + if (hasDistanceThreshold() != other.hasDistanceThreshold()) return false; + if (hasDistanceThreshold()) { + if (!getDistanceThreshold().equals(other.getDistanceThreshold())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasVectorField()) { + hash = (37 * hash) + VECTOR_FIELD_FIELD_NUMBER; + hash = (53 * hash) + getVectorField().hashCode(); + } + if (hasQueryVector()) { + hash = (37 * hash) + QUERY_VECTOR_FIELD_NUMBER; + hash = (53 * hash) + getQueryVector().hashCode(); + } + hash = (37 * hash) + DISTANCE_MEASURE_FIELD_NUMBER; + hash = (53 * hash) + distanceMeasure_; + if (hasLimit()) { + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + getLimit().hashCode(); + } + hash = (37 * hash) + DISTANCE_RESULT_FIELD_FIELD_NUMBER; + hash = (53 * hash) + getDistanceResultField().hashCode(); + if (hasDistanceThreshold()) { + hash = (37 * hash) + DISTANCE_THRESHOLD_FIELD_NUMBER; + hash = (53 * hash) + getDistanceThreshold().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.StructuredQuery.FindNearest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Nearest Neighbors search config. The ordering provided by FindNearest
+     * supersedes the order_by stage. If multiple documents have the same vector
+     * distance, the returned document order is not guaranteed to be stable
+     * between queries.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery.FindNearest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery.FindNearest) + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.FindNearest.class, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.FindNearest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetVectorFieldFieldBuilder(); + internalGetQueryVectorFieldBuilder(); + internalGetLimitFieldBuilder(); + internalGetDistanceThresholdFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + vectorField_ = null; + if (vectorFieldBuilder_ != null) { + vectorFieldBuilder_.dispose(); + vectorFieldBuilder_ = null; + } + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + distanceMeasure_ = 0; + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + distanceResultField_ = ""; + distanceThreshold_ = null; + if (distanceThresholdBuilder_ != null) { + distanceThresholdBuilder_.dispose(); + distanceThresholdBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_FindNearest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest build() { + com.google.firestore.v1.StructuredQuery.FindNearest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest buildPartial() { + com.google.firestore.v1.StructuredQuery.FindNearest result = + new com.google.firestore.v1.StructuredQuery.FindNearest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery.FindNearest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.vectorField_ = + vectorFieldBuilder_ == null ? vectorField_ : vectorFieldBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.queryVector_ = + queryVectorBuilder_ == null ? queryVector_ : queryVectorBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.distanceMeasure_ = distanceMeasure_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.distanceResultField_ = distanceResultField_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.distanceThreshold_ = + distanceThresholdBuilder_ == null + ? distanceThreshold_ + : distanceThresholdBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery.FindNearest) { + return mergeFrom((com.google.firestore.v1.StructuredQuery.FindNearest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery.FindNearest other) { + if (other == com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance()) + return this; + if (other.hasVectorField()) { + mergeVectorField(other.getVectorField()); + } + if (other.hasQueryVector()) { + mergeQueryVector(other.getQueryVector()); + } + if (other.distanceMeasure_ != 0) { + setDistanceMeasureValue(other.getDistanceMeasureValue()); + } + if (other.hasLimit()) { + mergeLimit(other.getLimit()); + } + if (!other.getDistanceResultField().isEmpty()) { + distanceResultField_ = other.distanceResultField_; + bitField0_ |= 0x00000010; + onChanged(); + } + if (other.hasDistanceThreshold()) { + mergeDistanceThreshold(other.getDistanceThreshold()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetVectorFieldFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetQueryVectorFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + distanceMeasure_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage(internalGetLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + distanceResultField_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetDistanceThresholdFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.FieldReference vectorField_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + vectorFieldBuilder_; + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorField field is set. + */ + public boolean hasVectorField() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorField. + */ + public com.google.firestore.v1.StructuredQuery.FieldReference getVectorField() { + if (vectorFieldBuilder_ == null) { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } else { + return vectorFieldBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorField(com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (vectorFieldBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + vectorField_ = value; + } else { + vectorFieldBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorField( + com.google.firestore.v1.StructuredQuery.FieldReference.Builder builderForValue) { + if (vectorFieldBuilder_ == null) { + vectorField_ = builderForValue.build(); + } else { + vectorFieldBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeVectorField( + com.google.firestore.v1.StructuredQuery.FieldReference value) { + if (vectorFieldBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && vectorField_ != null + && vectorField_ + != com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance()) { + getVectorFieldBuilder().mergeFrom(value); + } else { + vectorField_ = value; + } + } else { + vectorFieldBuilder_.mergeFrom(value); + } + if (vectorField_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearVectorField() { + bitField0_ = (bitField0_ & ~0x00000001); + vectorField_ = null; + if (vectorFieldBuilder_ != null) { + vectorFieldBuilder_.dispose(); + vectorFieldBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.StructuredQuery.FieldReference.Builder + getVectorFieldBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetVectorFieldFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder + getVectorFieldOrBuilder() { + if (vectorFieldBuilder_ != null) { + return vectorFieldBuilder_.getMessageOrBuilder(); + } else { + return vectorField_ == null + ? com.google.firestore.v1.StructuredQuery.FieldReference.getDefaultInstance() + : vectorField_; + } + } + + /** + * + * + *
+       * Required. An indexed vector field to search upon. Only documents which
+       * contain vectors whose dimensionality match the query_vector can be
+       * returned.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FieldReference vector_field = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder> + internalGetVectorFieldFieldBuilder() { + if (vectorFieldBuilder_ == null) { + vectorFieldBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FieldReference, + com.google.firestore.v1.StructuredQuery.FieldReference.Builder, + com.google.firestore.v1.StructuredQuery.FieldReferenceOrBuilder>( + getVectorField(), getParentForChildren(), isClean()); + vectorField_ = null; + } + return vectorFieldBuilder_; + } + + private com.google.firestore.v1.Value queryVector_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + queryVectorBuilder_; + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the queryVector field is set. + */ + public boolean hasQueryVector() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + public com.google.firestore.v1.Value getQueryVector() { + if (queryVectorBuilder_ == null) { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } else { + return queryVectorBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.firestore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryVector_ = value; + } else { + queryVectorBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.firestore.v1.Value.Builder builderForValue) { + if (queryVectorBuilder_ == null) { + queryVector_ = builderForValue.build(); + } else { + queryVectorBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeQueryVector(com.google.firestore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && queryVector_ != null + && queryVector_ != com.google.firestore.v1.Value.getDefaultInstance()) { + getQueryVectorBuilder().mergeFrom(value); + } else { + queryVector_ = value; + } + } else { + queryVectorBuilder_.mergeFrom(value); + } + if (queryVector_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearQueryVector() { + bitField0_ = (bitField0_ & ~0x00000002); + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Value.Builder getQueryVectorBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetQueryVectorFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + if (queryVectorBuilder_ != null) { + return queryVectorBuilder_.getMessageOrBuilder(); + } else { + return queryVector_ == null + ? com.google.firestore.v1.Value.getDefaultInstance() + : queryVector_; + } + } + + /** + * + * + *
+       * Required. The query vector that we are searching on. Must be a vector of
+       * no more than 2048 dimensions.
+       * 
+ * + * + * .google.firestore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetQueryVectorFieldBuilder() { + if (queryVectorBuilder_ == null) { + queryVectorBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + getQueryVector(), getParentForChildren(), isClean()); + queryVector_ = null; + } + return queryVectorBuilder_; + } + + private int distanceMeasure_ = 0; + + /** + * + * + *
+       * Required. The distance measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for distanceMeasure. + */ + @java.lang.Override + public int getDistanceMeasureValue() { + return distanceMeasure_; + } + + /** + * + * + *
+       * Required. The distance measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The enum numeric value on the wire for distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasureValue(int value) { + distanceMeasure_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The distance measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure + getDistanceMeasure() { + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure result = + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.forNumber( + distanceMeasure_); + return result == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * Required. The distance measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The distanceMeasure to set. + * @return This builder for chaining. + */ + public Builder setDistanceMeasure( + com.google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + distanceMeasure_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The distance measure to use, required.
+       * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearDistanceMeasure() { + bitField0_ = (bitField0_ & ~0x00000004); + distanceMeasure_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value limit_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + limitBuilder_; + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the limit field is set. + */ + public boolean hasLimit() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The limit. + */ + public com.google.protobuf.Int32Value getLimit() { + if (limitBuilder_ == null) { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } else { + return limitBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + limit_ = value; + } else { + limitBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setLimit(com.google.protobuf.Int32Value.Builder builderForValue) { + if (limitBuilder_ == null) { + limit_ = builderForValue.build(); + } else { + limitBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && limit_ != null + && limit_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getLimitBuilder().mergeFrom(value); + } else { + limit_ = value; + } + } else { + limitBuilder_.mergeFrom(value); + } + if (limit_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearLimit() { + bitField0_ = (bitField0_ & ~0x00000008); + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetLimitFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + if (limitBuilder_ != null) { + return limitBuilder_.getMessageOrBuilder(); + } else { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + } + + /** + * + * + *
+       * Required. The number of nearest neighbors to return. Must be a positive
+       * integer of no more than 1000.
+       * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + internalGetLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + private java.lang.Object distanceResultField_ = ""; + + /** + * + * + *
+       * Optional. Optional name of the field to output the result of the vector
+       * distance calculation. Must conform to [document field
+       * name][google.firestore.v1.Document.fields] limitations.
+       * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultField. + */ + public java.lang.String getDistanceResultField() { + java.lang.Object ref = distanceResultField_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + distanceResultField_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * Optional. Optional name of the field to output the result of the vector
+       * distance calculation. Must conform to [document field
+       * name][google.firestore.v1.Document.fields] limitations.
+       * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultField. + */ + public com.google.protobuf.ByteString getDistanceResultFieldBytes() { + java.lang.Object ref = distanceResultField_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultField_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * Optional. Optional name of the field to output the result of the vector
+       * distance calculation. Must conform to [document field
+       * name][google.firestore.v1.Document.fields] limitations.
+       * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The distanceResultField to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultField(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + distanceResultField_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Optional name of the field to output the result of the vector
+       * distance calculation. Must conform to [document field
+       * name][google.firestore.v1.Document.fields] limitations.
+       * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearDistanceResultField() { + distanceResultField_ = getDefaultInstance().getDistanceResultField(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Optional name of the field to output the result of the vector
+       * distance calculation. Must conform to [document field
+       * name][google.firestore.v1.Document.fields] limitations.
+       * 
+ * + * string distance_result_field = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for distanceResultField to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultFieldBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + distanceResultField_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.protobuf.DoubleValue distanceThreshold_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder> + distanceThresholdBuilder_; + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the distanceThreshold field is set. + */ + public boolean hasDistanceThreshold() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The distanceThreshold. + */ + public com.google.protobuf.DoubleValue getDistanceThreshold() { + if (distanceThresholdBuilder_ == null) { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } else { + return distanceThresholdBuilder_.getMessage(); + } + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setDistanceThreshold(com.google.protobuf.DoubleValue value) { + if (distanceThresholdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + distanceThreshold_ = value; + } else { + distanceThresholdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setDistanceThreshold(com.google.protobuf.DoubleValue.Builder builderForValue) { + if (distanceThresholdBuilder_ == null) { + distanceThreshold_ = builderForValue.build(); + } else { + distanceThresholdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeDistanceThreshold(com.google.protobuf.DoubleValue value) { + if (distanceThresholdBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && distanceThreshold_ != null + && distanceThreshold_ != com.google.protobuf.DoubleValue.getDefaultInstance()) { + getDistanceThresholdBuilder().mergeFrom(value); + } else { + distanceThreshold_ = value; + } + } else { + distanceThresholdBuilder_.mergeFrom(value); + } + if (distanceThreshold_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearDistanceThreshold() { + bitField0_ = (bitField0_ & ~0x00000020); + distanceThreshold_ = null; + if (distanceThresholdBuilder_ != null) { + distanceThresholdBuilder_.dispose(); + distanceThresholdBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.DoubleValue.Builder getDistanceThresholdBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetDistanceThresholdFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.DoubleValueOrBuilder getDistanceThresholdOrBuilder() { + if (distanceThresholdBuilder_ != null) { + return distanceThresholdBuilder_.getMessageOrBuilder(); + } else { + return distanceThreshold_ == null + ? com.google.protobuf.DoubleValue.getDefaultInstance() + : distanceThreshold_; + } + } + + /** + * + * + *
+       * Optional. Option to specify a threshold for which no less similar
+       * documents will be returned. The behavior of the specified
+       * `distance_measure` will affect the meaning of the distance threshold.
+       * Since DOT_PRODUCT distances increase when the vectors are more similar,
+       * the comparison is inverted.
+       *
+       * * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold`
+       * * For DOT_PRODUCT:       `WHERE distance >= distance_threshold`
+       * 
+ * + * + * .google.protobuf.DoubleValue distance_threshold = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder> + internalGetDistanceThresholdFieldBuilder() { + if (distanceThresholdBuilder_ == null) { + distanceThresholdBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder>( + getDistanceThreshold(), getParentForChildren(), isClean()); + distanceThreshold_ = null; + } + return distanceThresholdBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery.FindNearest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery.FindNearest) + private static final com.google.firestore.v1.StructuredQuery.FindNearest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery.FindNearest(); + } + + public static com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FindNearest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int SELECT_FIELD_NUMBER = 1; + private com.google.firestore.v1.StructuredQuery.Projection select_; + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return Whether the select field is set. + */ + @java.lang.Override + public boolean hasSelect() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return The select. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Projection getSelect() { + return select_ == null + ? com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance() + : select_; + } + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder getSelectOrBuilder() { + return select_ == null + ? com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance() + : select_; + } + + public static final int FROM_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List from_; + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + @java.lang.Override + public java.util.List getFromList() { + return from_; + } + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + @java.lang.Override + public java.util.List< + ? extends com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder> + getFromOrBuilderList() { + return from_; + } + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + @java.lang.Override + public int getFromCount() { + return from_.size(); + } + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelector getFrom(int index) { + return from_.get(index); + } + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder getFromOrBuilder( + int index) { + return from_.get(index); + } + + public static final int WHERE_FIELD_NUMBER = 3; + private com.google.firestore.v1.StructuredQuery.Filter where_; + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return Whether the where field is set. + */ + @java.lang.Override + public boolean hasWhere() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return The where. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Filter getWhere() { + return where_ == null + ? com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance() + : where_; + } + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FilterOrBuilder getWhereOrBuilder() { + return where_ == null + ? com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance() + : where_; + } + + public static final int ORDER_BY_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private java.util.List orderBy_; + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + @java.lang.Override + public java.util.List getOrderByList() { + return orderBy_; + } + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + @java.lang.Override + public java.util.List + getOrderByOrBuilderList() { + return orderBy_; + } + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + @java.lang.Override + public int getOrderByCount() { + return orderBy_.size(); + } + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.Order getOrderBy(int index) { + return orderBy_.get(index); + } + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.OrderOrBuilder getOrderByOrBuilder(int index) { + return orderBy_.get(index); + } + + public static final int START_AT_FIELD_NUMBER = 7; + private com.google.firestore.v1.Cursor startAt_; + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return Whether the startAt field is set. + */ + @java.lang.Override + public boolean hasStartAt() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return The startAt. + */ + @java.lang.Override + public com.google.firestore.v1.Cursor getStartAt() { + return startAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : startAt_; + } + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + @java.lang.Override + public com.google.firestore.v1.CursorOrBuilder getStartAtOrBuilder() { + return startAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : startAt_; + } + + public static final int END_AT_FIELD_NUMBER = 8; + private com.google.firestore.v1.Cursor endAt_; + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return Whether the endAt field is set. + */ + @java.lang.Override + public boolean hasEndAt() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return The endAt. + */ + @java.lang.Override + public com.google.firestore.v1.Cursor getEndAt() { + return endAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : endAt_; + } + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + @java.lang.Override + public com.google.firestore.v1.CursorOrBuilder getEndAtOrBuilder() { + return endAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : endAt_; + } + + public static final int OFFSET_FIELD_NUMBER = 6; + private int offset_ = 0; + + /** + * + * + *
+   * The number of documents to skip before returning the first result.
+   *
+   * This applies after the constraints specified by the `WHERE`, `START AT`, &
+   * `END AT` but before the `LIMIT` clause.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * int32 offset = 6; + * + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + + public static final int LIMIT_FIELD_NUMBER = 5; + private com.google.protobuf.Int32Value limit_; + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return Whether the limit field is set. + */ + @java.lang.Override + public boolean hasLimit() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return The limit. + */ + @java.lang.Override + public com.google.protobuf.Int32Value getLimit() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + @java.lang.Override + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + + public static final int FIND_NEAREST_FIELD_NUMBER = 9; + private com.google.firestore.v1.StructuredQuery.FindNearest findNearest_; + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + @java.lang.Override + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest() { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder() { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getSelect()); + } + for (int i = 0; i < from_.size(); i++) { + output.writeMessage(2, from_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getWhere()); + } + for (int i = 0; i < orderBy_.size(); i++) { + output.writeMessage(4, orderBy_.get(i)); + } + if (((bitField0_ & 0x00000010) != 0)) { + output.writeMessage(5, getLimit()); + } + if (offset_ != 0) { + output.writeInt32(6, offset_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(7, getStartAt()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(8, getEndAt()); + } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(9, getFindNearest()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getSelect()); + } + for (int i = 0; i < from_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, from_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getWhere()); + } + for (int i = 0; i < orderBy_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, orderBy_.get(i)); + } + if (((bitField0_ & 0x00000010) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getLimit()); + } + if (offset_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(6, offset_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getStartAt()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, getEndAt()); + } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getFindNearest()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.StructuredQuery)) { + return super.equals(obj); + } + com.google.firestore.v1.StructuredQuery other = (com.google.firestore.v1.StructuredQuery) obj; + + if (hasSelect() != other.hasSelect()) return false; + if (hasSelect()) { + if (!getSelect().equals(other.getSelect())) return false; + } + if (!getFromList().equals(other.getFromList())) return false; + if (hasWhere() != other.hasWhere()) return false; + if (hasWhere()) { + if (!getWhere().equals(other.getWhere())) return false; + } + if (!getOrderByList().equals(other.getOrderByList())) return false; + if (hasStartAt() != other.hasStartAt()) return false; + if (hasStartAt()) { + if (!getStartAt().equals(other.getStartAt())) return false; + } + if (hasEndAt() != other.hasEndAt()) return false; + if (hasEndAt()) { + if (!getEndAt().equals(other.getEndAt())) return false; + } + if (getOffset() != other.getOffset()) return false; + if (hasLimit() != other.hasLimit()) return false; + if (hasLimit()) { + if (!getLimit().equals(other.getLimit())) return false; + } + if (hasFindNearest() != other.hasFindNearest()) return false; + if (hasFindNearest()) { + if (!getFindNearest().equals(other.getFindNearest())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasSelect()) { + hash = (37 * hash) + SELECT_FIELD_NUMBER; + hash = (53 * hash) + getSelect().hashCode(); + } + if (getFromCount() > 0) { + hash = (37 * hash) + FROM_FIELD_NUMBER; + hash = (53 * hash) + getFromList().hashCode(); + } + if (hasWhere()) { + hash = (37 * hash) + WHERE_FIELD_NUMBER; + hash = (53 * hash) + getWhere().hashCode(); + } + if (getOrderByCount() > 0) { + hash = (37 * hash) + ORDER_BY_FIELD_NUMBER; + hash = (53 * hash) + getOrderByList().hashCode(); + } + if (hasStartAt()) { + hash = (37 * hash) + START_AT_FIELD_NUMBER; + hash = (53 * hash) + getStartAt().hashCode(); + } + if (hasEndAt()) { + hash = (37 * hash) + END_AT_FIELD_NUMBER; + hash = (53 * hash) + getEndAt().hashCode(); + } + hash = (37 * hash) + OFFSET_FIELD_NUMBER; + hash = (53 * hash) + getOffset(); + if (hasLimit()) { + hash = (37 * hash) + LIMIT_FIELD_NUMBER; + hash = (53 * hash) + getLimit().hashCode(); + } + if (hasFindNearest()) { + hash = (37 * hash) + FIND_NEAREST_FIELD_NUMBER; + hash = (53 * hash) + getFindNearest().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.StructuredQuery parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.StructuredQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.StructuredQuery prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Firestore query.
+   *
+   * The query stages are executed in the following order:
+   * 1. from
+   * 2. where
+   * 3. select
+   * 4. order_by + start_at + end_at
+   * 5. offset
+   * 6. limit
+   * 7. find_nearest
+   * 
+ * + * Protobuf type {@code google.firestore.v1.StructuredQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.StructuredQuery) + com.google.firestore.v1.StructuredQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.StructuredQuery.class, + com.google.firestore.v1.StructuredQuery.Builder.class); + } + + // Construct using com.google.firestore.v1.StructuredQuery.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetSelectFieldBuilder(); + internalGetFromFieldBuilder(); + internalGetWhereFieldBuilder(); + internalGetOrderByFieldBuilder(); + internalGetStartAtFieldBuilder(); + internalGetEndAtFieldBuilder(); + internalGetLimitFieldBuilder(); + internalGetFindNearestFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + select_ = null; + if (selectBuilder_ != null) { + selectBuilder_.dispose(); + selectBuilder_ = null; + } + if (fromBuilder_ == null) { + from_ = java.util.Collections.emptyList(); + } else { + from_ = null; + fromBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + where_ = null; + if (whereBuilder_ != null) { + whereBuilder_.dispose(); + whereBuilder_ = null; + } + if (orderByBuilder_ == null) { + orderBy_ = java.util.Collections.emptyList(); + } else { + orderBy_ = null; + orderByBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + startAt_ = null; + if (startAtBuilder_ != null) { + startAtBuilder_.dispose(); + startAtBuilder_ = null; + } + endAt_ = null; + if (endAtBuilder_ != null) { + endAtBuilder_.dispose(); + endAtBuilder_ = null; + } + offset_ = 0; + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.QueryProto + .internal_static_google_firestore_v1_StructuredQuery_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getDefaultInstanceForType() { + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery build() { + com.google.firestore.v1.StructuredQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery buildPartial() { + com.google.firestore.v1.StructuredQuery result = + new com.google.firestore.v1.StructuredQuery(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.StructuredQuery result) { + if (fromBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + from_ = java.util.Collections.unmodifiableList(from_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.from_ = from_; + } else { + result.from_ = fromBuilder_.build(); + } + if (orderByBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + orderBy_ = java.util.Collections.unmodifiableList(orderBy_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.orderBy_ = orderBy_; + } else { + result.orderBy_ = orderByBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.StructuredQuery result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.select_ = selectBuilder_ == null ? select_ : selectBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.where_ = whereBuilder_ == null ? where_ : whereBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.startAt_ = startAtBuilder_ == null ? startAt_ : startAtBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.endAt_ = endAtBuilder_ == null ? endAt_ : endAtBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.offset_ = offset_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); + to_bitField0_ |= 0x00000010; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.findNearest_ = + findNearestBuilder_ == null ? findNearest_ : findNearestBuilder_.build(); + to_bitField0_ |= 0x00000020; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.StructuredQuery) { + return mergeFrom((com.google.firestore.v1.StructuredQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.StructuredQuery other) { + if (other == com.google.firestore.v1.StructuredQuery.getDefaultInstance()) return this; + if (other.hasSelect()) { + mergeSelect(other.getSelect()); + } + if (fromBuilder_ == null) { + if (!other.from_.isEmpty()) { + if (from_.isEmpty()) { + from_ = other.from_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureFromIsMutable(); + from_.addAll(other.from_); + } + onChanged(); + } + } else { + if (!other.from_.isEmpty()) { + if (fromBuilder_.isEmpty()) { + fromBuilder_.dispose(); + fromBuilder_ = null; + from_ = other.from_; + bitField0_ = (bitField0_ & ~0x00000002); + fromBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetFromFieldBuilder() + : null; + } else { + fromBuilder_.addAllMessages(other.from_); + } + } + } + if (other.hasWhere()) { + mergeWhere(other.getWhere()); + } + if (orderByBuilder_ == null) { + if (!other.orderBy_.isEmpty()) { + if (orderBy_.isEmpty()) { + orderBy_ = other.orderBy_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureOrderByIsMutable(); + orderBy_.addAll(other.orderBy_); + } + onChanged(); + } + } else { + if (!other.orderBy_.isEmpty()) { + if (orderByBuilder_.isEmpty()) { + orderByBuilder_.dispose(); + orderByBuilder_ = null; + orderBy_ = other.orderBy_; + bitField0_ = (bitField0_ & ~0x00000008); + orderByBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetOrderByFieldBuilder() + : null; + } else { + orderByBuilder_.addAllMessages(other.orderBy_); + } + } + } + if (other.hasStartAt()) { + mergeStartAt(other.getStartAt()); + } + if (other.hasEndAt()) { + mergeEndAt(other.getEndAt()); + } + if (other.getOffset() != 0) { + setOffset(other.getOffset()); + } + if (other.hasLimit()) { + mergeLimit(other.getLimit()); + } + if (other.hasFindNearest()) { + mergeFindNearest(other.getFindNearest()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetSelectFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.StructuredQuery.CollectionSelector m = + input.readMessage( + com.google.firestore.v1.StructuredQuery.CollectionSelector.parser(), + extensionRegistry); + if (fromBuilder_ == null) { + ensureFromIsMutable(); + from_.add(m); + } else { + fromBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + input.readMessage(internalGetWhereFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + com.google.firestore.v1.StructuredQuery.Order m = + input.readMessage( + com.google.firestore.v1.StructuredQuery.Order.parser(), extensionRegistry); + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + orderBy_.add(m); + } else { + orderByBuilder_.addMessage(m); + } + break; + } // case 34 + case 42: + { + input.readMessage(internalGetLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 42 + case 48: + { + offset_ = input.readInt32(); + bitField0_ |= 0x00000040; + break; + } // case 48 + case 58: + { + input.readMessage(internalGetStartAtFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 58 + case 66: + { + input.readMessage(internalGetEndAtFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 66 + case 74: + { + input.readMessage( + internalGetFindNearestFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000100; + break; + } // case 74 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.StructuredQuery.Projection select_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Projection, + com.google.firestore.v1.StructuredQuery.Projection.Builder, + com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder> + selectBuilder_; + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return Whether the select field is set. + */ + public boolean hasSelect() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return The select. + */ + public com.google.firestore.v1.StructuredQuery.Projection getSelect() { + if (selectBuilder_ == null) { + return select_ == null + ? com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance() + : select_; + } else { + return selectBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public Builder setSelect(com.google.firestore.v1.StructuredQuery.Projection value) { + if (selectBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + select_ = value; + } else { + selectBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public Builder setSelect( + com.google.firestore.v1.StructuredQuery.Projection.Builder builderForValue) { + if (selectBuilder_ == null) { + select_ = builderForValue.build(); + } else { + selectBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public Builder mergeSelect(com.google.firestore.v1.StructuredQuery.Projection value) { + if (selectBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && select_ != null + && select_ != com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance()) { + getSelectBuilder().mergeFrom(value); + } else { + select_ = value; + } + } else { + selectBuilder_.mergeFrom(value); + } + if (select_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public Builder clearSelect() { + bitField0_ = (bitField0_ & ~0x00000001); + select_ = null; + if (selectBuilder_ != null) { + selectBuilder_.dispose(); + selectBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public com.google.firestore.v1.StructuredQuery.Projection.Builder getSelectBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetSelectFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + public com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder getSelectOrBuilder() { + if (selectBuilder_ != null) { + return selectBuilder_.getMessageOrBuilder(); + } else { + return select_ == null + ? com.google.firestore.v1.StructuredQuery.Projection.getDefaultInstance() + : select_; + } + } + + /** + * + * + *
+     * Optional sub-set of the fields to return.
+     *
+     * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+     * documents returned from a query. When not set, assumes that the caller
+     * wants all fields returned.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Projection, + com.google.firestore.v1.StructuredQuery.Projection.Builder, + com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder> + internalGetSelectFieldBuilder() { + if (selectBuilder_ == null) { + selectBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Projection, + com.google.firestore.v1.StructuredQuery.Projection.Builder, + com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder>( + getSelect(), getParentForChildren(), isClean()); + select_ = null; + } + return selectBuilder_; + } + + private java.util.List from_ = + java.util.Collections.emptyList(); + + private void ensureFromIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + from_ = + new java.util.ArrayList( + from_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.CollectionSelector, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder, + com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder> + fromBuilder_; + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public java.util.List + getFromList() { + if (fromBuilder_ == null) { + return java.util.Collections.unmodifiableList(from_); + } else { + return fromBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public int getFromCount() { + if (fromBuilder_ == null) { + return from_.size(); + } else { + return fromBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public com.google.firestore.v1.StructuredQuery.CollectionSelector getFrom(int index) { + if (fromBuilder_ == null) { + return from_.get(index); + } else { + return fromBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder setFrom( + int index, com.google.firestore.v1.StructuredQuery.CollectionSelector value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFromIsMutable(); + from_.set(index, value); + onChanged(); + } else { + fromBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder setFrom( + int index, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder builderForValue) { + if (fromBuilder_ == null) { + ensureFromIsMutable(); + from_.set(index, builderForValue.build()); + onChanged(); + } else { + fromBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder addFrom(com.google.firestore.v1.StructuredQuery.CollectionSelector value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFromIsMutable(); + from_.add(value); + onChanged(); + } else { + fromBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder addFrom( + int index, com.google.firestore.v1.StructuredQuery.CollectionSelector value) { + if (fromBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFromIsMutable(); + from_.add(index, value); + onChanged(); + } else { + fromBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder addFrom( + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder builderForValue) { + if (fromBuilder_ == null) { + ensureFromIsMutable(); + from_.add(builderForValue.build()); + onChanged(); + } else { + fromBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder addFrom( + int index, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder builderForValue) { + if (fromBuilder_ == null) { + ensureFromIsMutable(); + from_.add(index, builderForValue.build()); + onChanged(); + } else { + fromBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder addAllFrom( + java.lang.Iterable + values) { + if (fromBuilder_ == null) { + ensureFromIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, from_); + onChanged(); + } else { + fromBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder clearFrom() { + if (fromBuilder_ == null) { + from_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + fromBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public Builder removeFrom(int index) { + if (fromBuilder_ == null) { + ensureFromIsMutable(); + from_.remove(index); + onChanged(); + } else { + fromBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder getFromBuilder( + int index) { + return internalGetFromFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder getFromOrBuilder( + int index) { + if (fromBuilder_ == null) { + return from_.get(index); + } else { + return fromBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public java.util.List< + ? extends com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder> + getFromOrBuilderList() { + if (fromBuilder_ != null) { + return fromBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(from_); + } + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder addFromBuilder() { + return internalGetFromFieldBuilder() + .addBuilder( + com.google.firestore.v1.StructuredQuery.CollectionSelector.getDefaultInstance()); + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder addFromBuilder( + int index) { + return internalGetFromFieldBuilder() + .addBuilder( + index, + com.google.firestore.v1.StructuredQuery.CollectionSelector.getDefaultInstance()); + } + + /** + * + * + *
+     * The collections to query.
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + public java.util.List + getFromBuilderList() { + return internalGetFromFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.CollectionSelector, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder, + com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder> + internalGetFromFieldBuilder() { + if (fromBuilder_ == null) { + fromBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.CollectionSelector, + com.google.firestore.v1.StructuredQuery.CollectionSelector.Builder, + com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder>( + from_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + from_ = null; + } + return fromBuilder_; + } + + private com.google.firestore.v1.StructuredQuery.Filter where_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder> + whereBuilder_; + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return Whether the where field is set. + */ + public boolean hasWhere() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return The where. + */ + public com.google.firestore.v1.StructuredQuery.Filter getWhere() { + if (whereBuilder_ == null) { + return where_ == null + ? com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance() + : where_; + } else { + return whereBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public Builder setWhere(com.google.firestore.v1.StructuredQuery.Filter value) { + if (whereBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + where_ = value; + } else { + whereBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public Builder setWhere( + com.google.firestore.v1.StructuredQuery.Filter.Builder builderForValue) { + if (whereBuilder_ == null) { + where_ = builderForValue.build(); + } else { + whereBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public Builder mergeWhere(com.google.firestore.v1.StructuredQuery.Filter value) { + if (whereBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && where_ != null + && where_ != com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance()) { + getWhereBuilder().mergeFrom(value); + } else { + where_ = value; + } + } else { + whereBuilder_.mergeFrom(value); + } + if (where_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public Builder clearWhere() { + bitField0_ = (bitField0_ & ~0x00000004); + where_ = null; + if (whereBuilder_ != null) { + whereBuilder_.dispose(); + whereBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public com.google.firestore.v1.StructuredQuery.Filter.Builder getWhereBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetWhereFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + public com.google.firestore.v1.StructuredQuery.FilterOrBuilder getWhereOrBuilder() { + if (whereBuilder_ != null) { + return whereBuilder_.getMessageOrBuilder(); + } else { + return where_ == null + ? com.google.firestore.v1.StructuredQuery.Filter.getDefaultInstance() + : where_; + } + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder> + internalGetWhereFieldBuilder() { + if (whereBuilder_ == null) { + whereBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.Filter, + com.google.firestore.v1.StructuredQuery.Filter.Builder, + com.google.firestore.v1.StructuredQuery.FilterOrBuilder>( + getWhere(), getParentForChildren(), isClean()); + where_ = null; + } + return whereBuilder_; + } + + private java.util.List orderBy_ = + java.util.Collections.emptyList(); + + private void ensureOrderByIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + orderBy_ = new java.util.ArrayList(orderBy_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Order, + com.google.firestore.v1.StructuredQuery.Order.Builder, + com.google.firestore.v1.StructuredQuery.OrderOrBuilder> + orderByBuilder_; + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public java.util.List getOrderByList() { + if (orderByBuilder_ == null) { + return java.util.Collections.unmodifiableList(orderBy_); + } else { + return orderByBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public int getOrderByCount() { + if (orderByBuilder_ == null) { + return orderBy_.size(); + } else { + return orderByBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public com.google.firestore.v1.StructuredQuery.Order getOrderBy(int index) { + if (orderByBuilder_ == null) { + return orderBy_.get(index); + } else { + return orderByBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder setOrderBy(int index, com.google.firestore.v1.StructuredQuery.Order value) { + if (orderByBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderByIsMutable(); + orderBy_.set(index, value); + onChanged(); + } else { + orderByBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder setOrderBy( + int index, com.google.firestore.v1.StructuredQuery.Order.Builder builderForValue) { + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + orderBy_.set(index, builderForValue.build()); + onChanged(); + } else { + orderByBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder addOrderBy(com.google.firestore.v1.StructuredQuery.Order value) { + if (orderByBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderByIsMutable(); + orderBy_.add(value); + onChanged(); + } else { + orderByBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder addOrderBy(int index, com.google.firestore.v1.StructuredQuery.Order value) { + if (orderByBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderByIsMutable(); + orderBy_.add(index, value); + onChanged(); + } else { + orderByBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder addOrderBy( + com.google.firestore.v1.StructuredQuery.Order.Builder builderForValue) { + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + orderBy_.add(builderForValue.build()); + onChanged(); + } else { + orderByBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder addOrderBy( + int index, com.google.firestore.v1.StructuredQuery.Order.Builder builderForValue) { + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + orderBy_.add(index, builderForValue.build()); + onChanged(); + } else { + orderByBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder addAllOrderBy( + java.lang.Iterable values) { + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, orderBy_); + onChanged(); + } else { + orderByBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder clearOrderBy() { + if (orderByBuilder_ == null) { + orderBy_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + orderByBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public Builder removeOrderBy(int index) { + if (orderByBuilder_ == null) { + ensureOrderByIsMutable(); + orderBy_.remove(index); + onChanged(); + } else { + orderByBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public com.google.firestore.v1.StructuredQuery.Order.Builder getOrderByBuilder(int index) { + return internalGetOrderByFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public com.google.firestore.v1.StructuredQuery.OrderOrBuilder getOrderByOrBuilder(int index) { + if (orderByBuilder_ == null) { + return orderBy_.get(index); + } else { + return orderByBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public java.util.List + getOrderByOrBuilderList() { + if (orderByBuilder_ != null) { + return orderByBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(orderBy_); + } + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public com.google.firestore.v1.StructuredQuery.Order.Builder addOrderByBuilder() { + return internalGetOrderByFieldBuilder() + .addBuilder(com.google.firestore.v1.StructuredQuery.Order.getDefaultInstance()); + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public com.google.firestore.v1.StructuredQuery.Order.Builder addOrderByBuilder(int index) { + return internalGetOrderByFieldBuilder() + .addBuilder(index, com.google.firestore.v1.StructuredQuery.Order.getDefaultInstance()); + } + + /** + * + * + *
+     * The order to apply to the query results.
+     *
+     * Firestore allows callers to provide a full ordering, a partial ordering, or
+     * no ordering at all. In all cases, Firestore guarantees a stable ordering
+     * through the following rules:
+     *
+     * * The `order_by` is required to reference all fields used with an
+     * inequality filter.
+     * * All fields that are required to be in the `order_by` but are not already
+     * present are appended in lexicographical ordering of the field name.
+     * * If an order on `__name__` is not specified, it is appended by default.
+     *
+     * Fields are appended with the same sort direction as the last order
+     * specified, or 'ASCENDING' if no order was specified. For example:
+     *
+     * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+     * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+     * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+     * * `WHERE __name__ > ... AND a > 1` becomes
+     * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+     * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + public java.util.List + getOrderByBuilderList() { + return internalGetOrderByFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Order, + com.google.firestore.v1.StructuredQuery.Order.Builder, + com.google.firestore.v1.StructuredQuery.OrderOrBuilder> + internalGetOrderByFieldBuilder() { + if (orderByBuilder_ == null) { + orderByBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.StructuredQuery.Order, + com.google.firestore.v1.StructuredQuery.Order.Builder, + com.google.firestore.v1.StructuredQuery.OrderOrBuilder>( + orderBy_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + orderBy_ = null; + } + return orderByBuilder_; + } + + private com.google.firestore.v1.Cursor startAt_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + startAtBuilder_; + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return Whether the startAt field is set. + */ + public boolean hasStartAt() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return The startAt. + */ + public com.google.firestore.v1.Cursor getStartAt() { + if (startAtBuilder_ == null) { + return startAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : startAt_; + } else { + return startAtBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public Builder setStartAt(com.google.firestore.v1.Cursor value) { + if (startAtBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + startAt_ = value; + } else { + startAtBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public Builder setStartAt(com.google.firestore.v1.Cursor.Builder builderForValue) { + if (startAtBuilder_ == null) { + startAt_ = builderForValue.build(); + } else { + startAtBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public Builder mergeStartAt(com.google.firestore.v1.Cursor value) { + if (startAtBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && startAt_ != null + && startAt_ != com.google.firestore.v1.Cursor.getDefaultInstance()) { + getStartAtBuilder().mergeFrom(value); + } else { + startAt_ = value; + } + } else { + startAtBuilder_.mergeFrom(value); + } + if (startAt_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public Builder clearStartAt() { + bitField0_ = (bitField0_ & ~0x00000010); + startAt_ = null; + if (startAtBuilder_ != null) { + startAtBuilder_.dispose(); + startAtBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public com.google.firestore.v1.Cursor.Builder getStartAtBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetStartAtFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + public com.google.firestore.v1.CursorOrBuilder getStartAtOrBuilder() { + if (startAtBuilder_ != null) { + return startAtBuilder_.getMessageOrBuilder(); + } else { + return startAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : startAt_; + } + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to start the query at.
+     *
+     * The ordering of the result set is based on the `ORDER BY` clause of the
+     * original query.
+     *
+     * ```
+     * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+     * ```
+     *
+     * This query's results are ordered by `(b ASC, __name__ ASC)`.
+     *
+     * Cursors can reference either the full ordering or a prefix of the location,
+     * though it cannot reference more fields than what are in the provided
+     * `ORDER BY`.
+     *
+     * Continuing off the example above, attaching the following start cursors
+     * will have varying impact:
+     *
+     * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+     * b > 2 AND __name__ > /k/123`.
+     * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+     *
+     * Unlike `OFFSET` which requires scanning over the first N results to skip,
+     * a start cursor allows the query to begin at a logical position. This
+     * position is not required to match an actual result, it will scan forward
+     * from this position to find the next document.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + internalGetStartAtFieldBuilder() { + if (startAtBuilder_ == null) { + startAtBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder>( + getStartAt(), getParentForChildren(), isClean()); + startAt_ = null; + } + return startAtBuilder_; + } + + private com.google.firestore.v1.Cursor endAt_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + endAtBuilder_; + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return Whether the endAt field is set. + */ + public boolean hasEndAt() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return The endAt. + */ + public com.google.firestore.v1.Cursor getEndAt() { + if (endAtBuilder_ == null) { + return endAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : endAt_; + } else { + return endAtBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public Builder setEndAt(com.google.firestore.v1.Cursor value) { + if (endAtBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + endAt_ = value; + } else { + endAtBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public Builder setEndAt(com.google.firestore.v1.Cursor.Builder builderForValue) { + if (endAtBuilder_ == null) { + endAt_ = builderForValue.build(); + } else { + endAtBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public Builder mergeEndAt(com.google.firestore.v1.Cursor value) { + if (endAtBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && endAt_ != null + && endAt_ != com.google.firestore.v1.Cursor.getDefaultInstance()) { + getEndAtBuilder().mergeFrom(value); + } else { + endAt_ = value; + } + } else { + endAtBuilder_.mergeFrom(value); + } + if (endAt_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public Builder clearEndAt() { + bitField0_ = (bitField0_ & ~0x00000020); + endAt_ = null; + if (endAtBuilder_ != null) { + endAtBuilder_.dispose(); + endAtBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public com.google.firestore.v1.Cursor.Builder getEndAtBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetEndAtFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + public com.google.firestore.v1.CursorOrBuilder getEndAtOrBuilder() { + if (endAtBuilder_ != null) { + return endAtBuilder_.getMessageOrBuilder(); + } else { + return endAt_ == null ? com.google.firestore.v1.Cursor.getDefaultInstance() : endAt_; + } + } + + /** + * + * + *
+     * A potential prefix of a position in the result set to end the query at.
+     *
+     * This is similar to `START_AT` but with it controlling the end position
+     * rather than the start position.
+     *
+     * Requires:
+     *
+     * * The number of values cannot be greater than the number of fields
+     * specified in the `ORDER BY` clause.
+     * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder> + internalGetEndAtFieldBuilder() { + if (endAtBuilder_ == null) { + endAtBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Cursor, + com.google.firestore.v1.Cursor.Builder, + com.google.firestore.v1.CursorOrBuilder>( + getEndAt(), getParentForChildren(), isClean()); + endAt_ = null; + } + return endAtBuilder_; + } + + private int offset_; + + /** + * + * + *
+     * The number of documents to skip before returning the first result.
+     *
+     * This applies after the constraints specified by the `WHERE`, `START AT`, &
+     * `END AT` but before the `LIMIT` clause.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * int32 offset = 6; + * + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + + /** + * + * + *
+     * The number of documents to skip before returning the first result.
+     *
+     * This applies after the constraints specified by the `WHERE`, `START AT`, &
+     * `END AT` but before the `LIMIT` clause.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * int32 offset = 6; + * + * @param value The offset to set. + * @return This builder for chaining. + */ + public Builder setOffset(int value) { + + offset_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of documents to skip before returning the first result.
+     *
+     * This applies after the constraints specified by the `WHERE`, `START AT`, &
+     * `END AT` but before the `LIMIT` clause.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * int32 offset = 6; + * + * @return This builder for chaining. + */ + public Builder clearOffset() { + bitField0_ = (bitField0_ & ~0x00000040); + offset_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value limit_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + limitBuilder_; + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return Whether the limit field is set. + */ + public boolean hasLimit() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return The limit. + */ + public com.google.protobuf.Int32Value getLimit() { + if (limitBuilder_ == null) { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } else { + return limitBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public Builder setLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + limit_ = value; + } else { + limitBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public Builder setLimit(com.google.protobuf.Int32Value.Builder builderForValue) { + if (limitBuilder_ == null) { + limit_ = builderForValue.build(); + } else { + limitBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public Builder mergeLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && limit_ != null + && limit_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getLimitBuilder().mergeFrom(value); + } else { + limit_ = value; + } + } else { + limitBuilder_.mergeFrom(value); + } + if (limit_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public Builder clearLimit() { + bitField0_ = (bitField0_ & ~0x00000080); + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return internalGetLimitFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + public com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder() { + if (limitBuilder_ != null) { + return limitBuilder_.getMessageOrBuilder(); + } else { + return limit_ == null ? com.google.protobuf.Int32Value.getDefaultInstance() : limit_; + } + } + + /** + * + * + *
+     * The maximum number of results to return.
+     *
+     * Applies after all other constraints.
+     *
+     * Requires:
+     *
+     * * The value must be greater than or equal to zero if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + internalGetLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + private com.google.firestore.v1.StructuredQuery.FindNearest findNearest_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder> + findNearestBuilder_; + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000100) != 0); + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + public com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest() { + if (findNearestBuilder_ == null) { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } else { + return findNearestBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.firestore.v1.StructuredQuery.FindNearest value) { + if (findNearestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + findNearest_ = value; + } else { + findNearestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest( + com.google.firestore.v1.StructuredQuery.FindNearest.Builder builderForValue) { + if (findNearestBuilder_ == null) { + findNearest_ = builderForValue.build(); + } else { + findNearestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeFindNearest(com.google.firestore.v1.StructuredQuery.FindNearest value) { + if (findNearestBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0) + && findNearest_ != null + && findNearest_ + != com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance()) { + getFindNearestBuilder().mergeFrom(value); + } else { + findNearest_ = value; + } + } else { + findNearestBuilder_.mergeFrom(value); + } + if (findNearest_ != null) { + bitField0_ |= 0x00000100; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearFindNearest() { + bitField0_ = (bitField0_ & ~0x00000100); + findNearest_ = null; + if (findNearestBuilder_ != null) { + findNearestBuilder_.dispose(); + findNearestBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredQuery.FindNearest.Builder getFindNearestBuilder() { + bitField0_ |= 0x00000100; + onChanged(); + return internalGetFindNearestFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder() { + if (findNearestBuilder_ != null) { + return findNearestBuilder_.getMessageOrBuilder(); + } else { + return findNearest_ == null + ? com.google.firestore.v1.StructuredQuery.FindNearest.getDefaultInstance() + : findNearest_; + } + } + + /** + * + * + *
+     * Optional. A potential nearest neighbors search.
+     *
+     * Applies after all other filters and ordering.
+     *
+     * Finds the closest vector embeddings to the given query vector.
+     * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder> + internalGetFindNearestFieldBuilder() { + if (findNearestBuilder_ == null) { + findNearestBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery.FindNearest, + com.google.firestore.v1.StructuredQuery.FindNearest.Builder, + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder>( + getFindNearest(), getParentForChildren(), isClean()); + findNearest_ = null; + } + return findNearestBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.StructuredQuery) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.StructuredQuery) + private static final com.google.firestore.v1.StructuredQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.StructuredQuery(); + } + + public static com.google.firestore.v1.StructuredQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public StructuredQuery parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java new file mode 100644 index 000000000000..5a407bba5a42 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/StructuredQueryOrBuilder.java @@ -0,0 +1,639 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/query.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface StructuredQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.StructuredQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return Whether the select field is set. + */ + boolean hasSelect(); + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + * + * @return The select. + */ + com.google.firestore.v1.StructuredQuery.Projection getSelect(); + + /** + * + * + *
+   * Optional sub-set of the fields to return.
+   *
+   * This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the
+   * documents returned from a query. When not set, assumes that the caller
+   * wants all fields returned.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Projection select = 1; + */ + com.google.firestore.v1.StructuredQuery.ProjectionOrBuilder getSelectOrBuilder(); + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + java.util.List getFromList(); + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + com.google.firestore.v1.StructuredQuery.CollectionSelector getFrom(int index); + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + int getFromCount(); + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + java.util.List + getFromOrBuilderList(); + + /** + * + * + *
+   * The collections to query.
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.CollectionSelector from = 2; + */ + com.google.firestore.v1.StructuredQuery.CollectionSelectorOrBuilder getFromOrBuilder(int index); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return Whether the where field is set. + */ + boolean hasWhere(); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + * + * @return The where. + */ + com.google.firestore.v1.StructuredQuery.Filter getWhere(); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.firestore.v1.StructuredQuery.Filter where = 3; + */ + com.google.firestore.v1.StructuredQuery.FilterOrBuilder getWhereOrBuilder(); + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + java.util.List getOrderByList(); + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + com.google.firestore.v1.StructuredQuery.Order getOrderBy(int index); + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + int getOrderByCount(); + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + java.util.List + getOrderByOrBuilderList(); + + /** + * + * + *
+   * The order to apply to the query results.
+   *
+   * Firestore allows callers to provide a full ordering, a partial ordering, or
+   * no ordering at all. In all cases, Firestore guarantees a stable ordering
+   * through the following rules:
+   *
+   * * The `order_by` is required to reference all fields used with an
+   * inequality filter.
+   * * All fields that are required to be in the `order_by` but are not already
+   * present are appended in lexicographical ordering of the field name.
+   * * If an order on `__name__` is not specified, it is appended by default.
+   *
+   * Fields are appended with the same sort direction as the last order
+   * specified, or 'ASCENDING' if no order was specified. For example:
+   *
+   * * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC`
+   * * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC`
+   * * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC`
+   * * `WHERE __name__ > ... AND a > 1` becomes
+   * `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC`
+   * 
+ * + * repeated .google.firestore.v1.StructuredQuery.Order order_by = 4; + */ + com.google.firestore.v1.StructuredQuery.OrderOrBuilder getOrderByOrBuilder(int index); + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return Whether the startAt field is set. + */ + boolean hasStartAt(); + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + * + * @return The startAt. + */ + com.google.firestore.v1.Cursor getStartAt(); + + /** + * + * + *
+   * A potential prefix of a position in the result set to start the query at.
+   *
+   * The ordering of the result set is based on the `ORDER BY` clause of the
+   * original query.
+   *
+   * ```
+   * SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC;
+   * ```
+   *
+   * This query's results are ordered by `(b ASC, __name__ ASC)`.
+   *
+   * Cursors can reference either the full ordering or a prefix of the location,
+   * though it cannot reference more fields than what are in the provided
+   * `ORDER BY`.
+   *
+   * Continuing off the example above, attaching the following start cursors
+   * will have varying impact:
+   *
+   * - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND
+   * b > 2 AND __name__ > /k/123`.
+   * - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`.
+   *
+   * Unlike `OFFSET` which requires scanning over the first N results to skip,
+   * a start cursor allows the query to begin at a logical position. This
+   * position is not required to match an actual result, it will scan forward
+   * from this position to find the next document.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor start_at = 7; + */ + com.google.firestore.v1.CursorOrBuilder getStartAtOrBuilder(); + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return Whether the endAt field is set. + */ + boolean hasEndAt(); + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + * + * @return The endAt. + */ + com.google.firestore.v1.Cursor getEndAt(); + + /** + * + * + *
+   * A potential prefix of a position in the result set to end the query at.
+   *
+   * This is similar to `START_AT` but with it controlling the end position
+   * rather than the start position.
+   *
+   * Requires:
+   *
+   * * The number of values cannot be greater than the number of fields
+   * specified in the `ORDER BY` clause.
+   * 
+ * + * .google.firestore.v1.Cursor end_at = 8; + */ + com.google.firestore.v1.CursorOrBuilder getEndAtOrBuilder(); + + /** + * + * + *
+   * The number of documents to skip before returning the first result.
+   *
+   * This applies after the constraints specified by the `WHERE`, `START AT`, &
+   * `END AT` but before the `LIMIT` clause.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * int32 offset = 6; + * + * @return The offset. + */ + int getOffset(); + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return Whether the limit field is set. + */ + boolean hasLimit(); + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + * + * @return The limit. + */ + com.google.protobuf.Int32Value getLimit(); + + /** + * + * + *
+   * The maximum number of results to return.
+   *
+   * Applies after all other constraints.
+   *
+   * Requires:
+   *
+   * * The value must be greater than or equal to zero if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 5; + */ + com.google.protobuf.Int32ValueOrBuilder getLimitOrBuilder(); + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + boolean hasFindNearest(); + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + com.google.firestore.v1.StructuredQuery.FindNearest getFindNearest(); + + /** + * + * + *
+   * Optional. A potential nearest neighbors search.
+   *
+   * Applies after all other filters and ordering.
+   *
+   * Finds the closest vector embeddings to the given query vector.
+   * 
+ * + * + * .google.firestore.v1.StructuredQuery.FindNearest find_nearest = 9 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.firestore.v1.StructuredQuery.FindNearestOrBuilder getFindNearestOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java new file mode 100644 index 000000000000..38aec7fdc3a7 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Target.java @@ -0,0 +1,4136 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A specification of a set of documents to listen to.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Target} + */ +@com.google.protobuf.Generated +public final class Target extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Target) + TargetOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Target"); + } + + // Use Target.newBuilder() to construct. + private Target(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Target() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.class, com.google.firestore.v1.Target.Builder.class); + } + + public interface DocumentsTargetOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Target.DocumentsTarget) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + java.util.List getDocumentsList(); + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + int getDocumentsCount(); + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + java.lang.String getDocuments(int index); + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + com.google.protobuf.ByteString getDocumentsBytes(int index); + } + + /** + * + * + *
+   * A target specified by a set of documents names.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Target.DocumentsTarget} + */ + public static final class DocumentsTarget extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Target.DocumentsTarget) + DocumentsTargetOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "DocumentsTarget"); + } + + // Use DocumentsTarget.newBuilder() to construct. + private DocumentsTarget(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private DocumentsTarget() { + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_DocumentsTarget_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_DocumentsTarget_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.DocumentsTarget.class, + com.google.firestore.v1.Target.DocumentsTarget.Builder.class); + } + + public static final int DOCUMENTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList documents_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + public com.google.protobuf.ProtocolStringList getDocumentsList() { + return documents_; + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + public int getDocumentsCount() { + return documents_.size(); + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + public java.lang.String getDocuments(int index) { + return documents_.get(index); + } + + /** + * + * + *
+     * The names of the documents to retrieve. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * The request will fail if any of the document is not a child resource of
+     * the given `database`. Duplicate names will be elided.
+     * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + public com.google.protobuf.ByteString getDocumentsBytes(int index) { + return documents_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + for (int i = 0; i < documents_.size(); i++) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, documents_.getRaw(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < documents_.size(); i++) { + dataSize += computeStringSizeNoTag(documents_.getRaw(i)); + } + size += dataSize; + size += 1 * getDocumentsList().size(); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Target.DocumentsTarget)) { + return super.equals(obj); + } + com.google.firestore.v1.Target.DocumentsTarget other = + (com.google.firestore.v1.Target.DocumentsTarget) obj; + + if (!getDocumentsList().equals(other.getDocumentsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getDocumentsCount() > 0) { + hash = (37 * hash) + DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getDocumentsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.DocumentsTarget parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Target.DocumentsTarget prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A target specified by a set of documents names.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.Target.DocumentsTarget} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Target.DocumentsTarget) + com.google.firestore.v1.Target.DocumentsTargetOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_DocumentsTarget_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_DocumentsTarget_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.DocumentsTarget.class, + com.google.firestore.v1.Target.DocumentsTarget.Builder.class); + } + + // Construct using com.google.firestore.v1.Target.DocumentsTarget.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_DocumentsTarget_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget getDefaultInstanceForType() { + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget build() { + com.google.firestore.v1.Target.DocumentsTarget result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget buildPartial() { + com.google.firestore.v1.Target.DocumentsTarget result = + new com.google.firestore.v1.Target.DocumentsTarget(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Target.DocumentsTarget result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + documents_.makeImmutable(); + result.documents_ = documents_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Target.DocumentsTarget) { + return mergeFrom((com.google.firestore.v1.Target.DocumentsTarget) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Target.DocumentsTarget other) { + if (other == com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance()) + return this; + if (!other.documents_.isEmpty()) { + if (documents_.isEmpty()) { + documents_ = other.documents_; + bitField0_ |= 0x00000001; + } else { + ensureDocumentsIsMutable(); + documents_.addAll(other.documents_); + } + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureDocumentsIsMutable(); + documents_.add(s); + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.LazyStringArrayList documents_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureDocumentsIsMutable() { + if (!documents_.isModifiable()) { + documents_ = new com.google.protobuf.LazyStringArrayList(documents_); + } + bitField0_ |= 0x00000001; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @return A list containing the documents. + */ + public com.google.protobuf.ProtocolStringList getDocumentsList() { + documents_.makeImmutable(); + return documents_; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @return The count of documents. + */ + public int getDocumentsCount() { + return documents_.size(); + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param index The index of the element to return. + * @return The documents at the given index. + */ + public java.lang.String getDocuments(int index) { + return documents_.get(index); + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param index The index of the value to return. + * @return The bytes of the documents at the given index. + */ + public com.google.protobuf.ByteString getDocumentsBytes(int index) { + return documents_.getByteString(index); + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param index The index to set the value at. + * @param value The documents to set. + * @return This builder for chaining. + */ + public Builder setDocuments(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param value The documents to add. + * @return This builder for chaining. + */ + public Builder addDocuments(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureDocumentsIsMutable(); + documents_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param values The documents to add. + * @return This builder for chaining. + */ + public Builder addAllDocuments(java.lang.Iterable values) { + ensureDocumentsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, documents_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @return This builder for chaining. + */ + public Builder clearDocuments() { + documents_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + + /** + * + * + *
+       * The names of the documents to retrieve. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * The request will fail if any of the document is not a child resource of
+       * the given `database`. Duplicate names will be elided.
+       * 
+ * + * repeated string documents = 2; + * + * @param value The bytes of the documents to add. + * @return This builder for chaining. + */ + public Builder addDocumentsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureDocumentsIsMutable(); + documents_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Target.DocumentsTarget) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Target.DocumentsTarget) + private static final com.google.firestore.v1.Target.DocumentsTarget DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Target.DocumentsTarget(); + } + + public static com.google.firestore.v1.Target.DocumentsTarget getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DocumentsTarget parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface QueryTargetOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Target.QueryTarget) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1; + * + * @return The parent. + */ + java.lang.String getParent(); + + /** + * + * + *
+     * The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + boolean hasStructuredQuery(); + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + com.google.firestore.v1.StructuredQuery getStructuredQuery(); + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder(); + + com.google.firestore.v1.Target.QueryTarget.QueryTypeCase getQueryTypeCase(); + } + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Target.QueryTarget} + */ + public static final class QueryTarget extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Target.QueryTarget) + QueryTargetOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "QueryTarget"); + } + + // Use QueryTarget.newBuilder() to construct. + private QueryTarget(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private QueryTarget() { + parent_ = ""; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_QueryTarget_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_QueryTarget_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.QueryTarget.class, + com.google.firestore.v1.Target.QueryTarget.Builder.class); + } + + private int queryTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object queryType_; + + public enum QueryTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + STRUCTURED_QUERY(2), + QUERYTYPE_NOT_SET(0); + private final int value; + + private QueryTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static QueryTypeCase valueOf(int value) { + return forNumber(value); + } + + public static QueryTypeCase forNumber(int value) { + switch (value) { + case 2: + return STRUCTURED_QUERY; + case 0: + return QUERYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + + /** + * + * + *
+     * The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1; + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + + /** + * + * + *
+     * The parent resource name. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents` or
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * For example:
+     * `projects/my-project/databases/my-database/documents` or
+     * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+     * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STRUCTURED_QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + /** + * + * + *
+     * A structured query.
+     * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, parent_); + } + if (queryTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, parent_); + } + if (queryTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.StructuredQuery) queryType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Target.QueryTarget)) { + return super.equals(obj); + } + com.google.firestore.v1.Target.QueryTarget other = + (com.google.firestore.v1.Target.QueryTarget) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 2: + if (!getStructuredQuery().equals(other.getStructuredQuery())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + switch (queryTypeCase_) { + case 2: + hash = (37 * hash) + STRUCTURED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getStructuredQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target.QueryTarget parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.QueryTarget parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target.QueryTarget parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Target.QueryTarget prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.Target.QueryTarget} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Target.QueryTarget) + com.google.firestore.v1.Target.QueryTargetOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_QueryTarget_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_QueryTarget_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.QueryTarget.class, + com.google.firestore.v1.Target.QueryTarget.Builder.class); + } + + // Construct using com.google.firestore.v1.Target.QueryTarget.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + if (structuredQueryBuilder_ != null) { + structuredQueryBuilder_.clear(); + } + queryTypeCase_ = 0; + queryType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_QueryTarget_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget getDefaultInstanceForType() { + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget build() { + com.google.firestore.v1.Target.QueryTarget result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget buildPartial() { + com.google.firestore.v1.Target.QueryTarget result = + new com.google.firestore.v1.Target.QueryTarget(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Target.QueryTarget result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + } + + private void buildPartialOneofs(com.google.firestore.v1.Target.QueryTarget result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 2 && structuredQueryBuilder_ != null) { + result.queryType_ = structuredQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Target.QueryTarget) { + return mergeFrom((com.google.firestore.v1.Target.QueryTarget) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Target.QueryTarget other) { + if (other == com.google.firestore.v1.Target.QueryTarget.getDefaultInstance()) return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getQueryTypeCase()) { + case STRUCTURED_QUERY: + { + mergeStructuredQuery(other.getStructuredQuery()); + break; + } + case QUERYTYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetStructuredQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int queryTypeCase_ = 0; + private java.lang.Object queryType_; + + public QueryTypeCase getQueryTypeCase() { + return QueryTypeCase.forNumber(queryTypeCase_); + } + + public Builder clearQueryType() { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + + /** + * + * + *
+       * The parent resource name. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents` or
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * For example:
+       * `projects/my-project/databases/my-database/documents` or
+       * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+       * 
+ * + * string parent = 1; + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The parent resource name. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents` or
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * For example:
+       * `projects/my-project/databases/my-database/documents` or
+       * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+       * 
+ * + * string parent = 1; + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The parent resource name. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents` or
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * For example:
+       * `projects/my-project/databases/my-database/documents` or
+       * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+       * 
+ * + * string parent = 1; + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The parent resource name. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents` or
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * For example:
+       * `projects/my-project/databases/my-database/documents` or
+       * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+       * 
+ * + * string parent = 1; + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * The parent resource name. In the format:
+       * `projects/{project_id}/databases/{database_id}/documents` or
+       * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+       * For example:
+       * `projects/my-project/databases/my-database/documents` or
+       * `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom`
+       * 
+ * + * string parent = 1; + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + structuredQueryBuilder_; + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return Whether the structuredQuery field is set. + */ + @java.lang.Override + public boolean hasStructuredQuery() { + return queryTypeCase_ == 2; + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + * + * @return The structuredQuery. + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQuery getStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 2) { + return structuredQueryBuilder_.getMessage(); + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + structuredQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder setStructuredQuery( + com.google.firestore.v1.StructuredQuery.Builder builderForValue) { + if (structuredQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + structuredQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder mergeStructuredQuery(com.google.firestore.v1.StructuredQuery value) { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2 + && queryType_ != com.google.firestore.v1.StructuredQuery.getDefaultInstance()) { + queryType_ = + com.google.firestore.v1.StructuredQuery.newBuilder( + (com.google.firestore.v1.StructuredQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 2) { + structuredQueryBuilder_.mergeFrom(value); + } else { + structuredQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 2; + return this; + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public Builder clearStructuredQuery() { + if (structuredQueryBuilder_ == null) { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 2) { + queryTypeCase_ = 0; + queryType_ = null; + } + structuredQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + public com.google.firestore.v1.StructuredQuery.Builder getStructuredQueryBuilder() { + return internalGetStructuredQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.StructuredQueryOrBuilder getStructuredQueryOrBuilder() { + if ((queryTypeCase_ == 2) && (structuredQueryBuilder_ != null)) { + return structuredQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 2) { + return (com.google.firestore.v1.StructuredQuery) queryType_; + } + return com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+       * A structured query.
+       * 
+ * + * .google.firestore.v1.StructuredQuery structured_query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder> + internalGetStructuredQueryFieldBuilder() { + if (structuredQueryBuilder_ == null) { + if (!(queryTypeCase_ == 2)) { + queryType_ = com.google.firestore.v1.StructuredQuery.getDefaultInstance(); + } + structuredQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.StructuredQuery, + com.google.firestore.v1.StructuredQuery.Builder, + com.google.firestore.v1.StructuredQueryOrBuilder>( + (com.google.firestore.v1.StructuredQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 2; + onChanged(); + return structuredQueryBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Target.QueryTarget) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Target.QueryTarget) + private static final com.google.firestore.v1.Target.QueryTarget DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Target.QueryTarget(); + } + + public static com.google.firestore.v1.Target.QueryTarget getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public QueryTarget parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + private int targetTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object targetType_; + + public enum TargetTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + QUERY(2), + DOCUMENTS(3), + TARGETTYPE_NOT_SET(0); + private final int value; + + private TargetTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TargetTypeCase valueOf(int value) { + return forNumber(value); + } + + public static TargetTypeCase forNumber(int value) { + switch (value) { + case 2: + return QUERY; + case 3: + return DOCUMENTS; + case 0: + return TARGETTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TargetTypeCase getTargetTypeCase() { + return TargetTypeCase.forNumber(targetTypeCase_); + } + + private int resumeTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object resumeType_; + + public enum ResumeTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + RESUME_TOKEN(4), + READ_TIME(11), + RESUMETYPE_NOT_SET(0); + private final int value; + + private ResumeTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ResumeTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ResumeTypeCase forNumber(int value) { + switch (value) { + case 4: + return RESUME_TOKEN; + case 11: + return READ_TIME; + case 0: + return RESUMETYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ResumeTypeCase getResumeTypeCase() { + return ResumeTypeCase.forNumber(resumeTypeCase_); + } + + public static final int QUERY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return targetTypeCase_ == 2; + } + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return The query. + */ + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget getQuery() { + if (targetTypeCase_ == 2) { + return (com.google.firestore.v1.Target.QueryTarget) targetType_; + } + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Target.QueryTargetOrBuilder getQueryOrBuilder() { + if (targetTypeCase_ == 2) { + return (com.google.firestore.v1.Target.QueryTarget) targetType_; + } + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + + public static final int DOCUMENTS_FIELD_NUMBER = 3; + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return Whether the documents field is set. + */ + @java.lang.Override + public boolean hasDocuments() { + return targetTypeCase_ == 3; + } + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return The documents. + */ + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget getDocuments() { + if (targetTypeCase_ == 3) { + return (com.google.firestore.v1.Target.DocumentsTarget) targetType_; + } + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTargetOrBuilder getDocumentsOrBuilder() { + if (targetTypeCase_ == 3) { + return (com.google.firestore.v1.Target.DocumentsTarget) targetType_; + } + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + + 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; + } + + /** + * + * + *
+   * 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 The resumeToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getResumeToken() { + if (resumeTypeCase_ == 4) { + return (com.google.protobuf.ByteString) resumeType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int READ_TIME_FIELD_NUMBER = 11; + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return resumeTypeCase_ == 11; + } + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (resumeTypeCase_ == 11) { + return (com.google.protobuf.Timestamp) resumeType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (resumeTypeCase_ == 11) { + return (com.google.protobuf.Timestamp) resumeType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + public static final int TARGET_ID_FIELD_NUMBER = 5; + private int targetId_ = 0; + + /** + * + * + *
+   * The target ID that identifies the target on the stream. Must be a positive
+   * number and non-zero.
+   *
+   * If `target_id` is 0 (or unspecified), the server will assign an ID for this
+   * target and return that in a `TargetChange::ADD` event. Once a target with
+   * `target_id=0` is added, all subsequent targets must also have
+   * `target_id=0`. If an `AddTarget` request with `target_id != 0` is
+   * sent to the server after a target with `target_id=0` is added, the server
+   * will immediately send a response with a `TargetChange::Remove` event.
+   *
+   * Note that if the client sends multiple `AddTarget` requests
+   * without an ID, the order of IDs returned in `TargetChange.target_ids` are
+   * undefined. Therefore, clients should provide a target ID instead of relying
+   * on the server to assign one.
+   *
+   * If `target_id` is non-zero, there must not be an existing active target on
+   * this stream with the same ID.
+   * 
+ * + * int32 target_id = 5; + * + * @return The targetId. + */ + @java.lang.Override + public int getTargetId() { + return targetId_; + } + + public static final int ONCE_FIELD_NUMBER = 6; + private boolean once_ = false; + + /** + * + * + *
+   * If the target should be removed once it is current and consistent.
+   * 
+ * + * bool once = 6; + * + * @return The once. + */ + @java.lang.Override + public boolean getOnce() { + return once_; + } + + public static final int EXPECTED_COUNT_FIELD_NUMBER = 12; + private com.google.protobuf.Int32Value expectedCount_; + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return Whether the expectedCount field is set. + */ + @java.lang.Override + public boolean hasExpectedCount() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return The expectedCount. + */ + @java.lang.Override + public com.google.protobuf.Int32Value getExpectedCount() { + return expectedCount_ == null + ? com.google.protobuf.Int32Value.getDefaultInstance() + : expectedCount_; + } + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + @java.lang.Override + public com.google.protobuf.Int32ValueOrBuilder getExpectedCountOrBuilder() { + return expectedCount_ == null + ? com.google.protobuf.Int32Value.getDefaultInstance() + : expectedCount_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (targetTypeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.Target.QueryTarget) targetType_); + } + if (targetTypeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.v1.Target.DocumentsTarget) targetType_); + } + if (resumeTypeCase_ == 4) { + output.writeBytes(4, (com.google.protobuf.ByteString) resumeType_); + } + if (targetId_ != 0) { + output.writeInt32(5, targetId_); + } + if (once_ != false) { + output.writeBool(6, once_); + } + if (resumeTypeCase_ == 11) { + output.writeMessage(11, (com.google.protobuf.Timestamp) resumeType_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(12, getExpectedCount()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (targetTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.Target.QueryTarget) targetType_); + } + if (targetTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.Target.DocumentsTarget) targetType_); + } + if (resumeTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 4, (com.google.protobuf.ByteString) resumeType_); + } + if (targetId_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(5, targetId_); + } + if (once_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(6, once_); + } + if (resumeTypeCase_ == 11) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 11, (com.google.protobuf.Timestamp) resumeType_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, getExpectedCount()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Target)) { + return super.equals(obj); + } + com.google.firestore.v1.Target other = (com.google.firestore.v1.Target) obj; + + if (getTargetId() != other.getTargetId()) return false; + if (getOnce() != other.getOnce()) return false; + if (hasExpectedCount() != other.hasExpectedCount()) return false; + if (hasExpectedCount()) { + if (!getExpectedCount().equals(other.getExpectedCount())) return false; + } + if (!getTargetTypeCase().equals(other.getTargetTypeCase())) return false; + switch (targetTypeCase_) { + case 2: + if (!getQuery().equals(other.getQuery())) return false; + break; + case 3: + if (!getDocuments().equals(other.getDocuments())) return false; + break; + case 0: + default: + } + if (!getResumeTypeCase().equals(other.getResumeTypeCase())) return false; + switch (resumeTypeCase_) { + case 4: + if (!getResumeToken().equals(other.getResumeToken())) return false; + break; + case 11: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TARGET_ID_FIELD_NUMBER; + hash = (53 * hash) + getTargetId(); + hash = (37 * hash) + ONCE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getOnce()); + if (hasExpectedCount()) { + hash = (37 * hash) + EXPECTED_COUNT_FIELD_NUMBER; + hash = (53 * hash) + getExpectedCount().hashCode(); + } + switch (targetTypeCase_) { + case 2: + hash = (37 * hash) + QUERY_FIELD_NUMBER; + hash = (53 * hash) + getQuery().hashCode(); + break; + case 3: + hash = (37 * hash) + DOCUMENTS_FIELD_NUMBER; + hash = (53 * hash) + getDocuments().hashCode(); + break; + case 0: + default: + } + switch (resumeTypeCase_) { + case 4: + hash = (37 * hash) + RESUME_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getResumeToken().hashCode(); + break; + case 11: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Target parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Target parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Target parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Target parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Target parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Target prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A specification of a set of documents to listen to.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Target} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Target) + com.google.firestore.v1.TargetOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Target.class, com.google.firestore.v1.Target.Builder.class); + } + + // Construct using com.google.firestore.v1.Target.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetExpectedCountFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (queryBuilder_ != null) { + queryBuilder_.clear(); + } + if (documentsBuilder_ != null) { + documentsBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + targetId_ = 0; + once_ = false; + expectedCount_ = null; + if (expectedCountBuilder_ != null) { + expectedCountBuilder_.dispose(); + expectedCountBuilder_ = null; + } + targetTypeCase_ = 0; + targetType_ = null; + resumeTypeCase_ = 0; + resumeType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_Target_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Target getDefaultInstanceForType() { + return com.google.firestore.v1.Target.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Target build() { + com.google.firestore.v1.Target result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Target buildPartial() { + com.google.firestore.v1.Target result = new com.google.firestore.v1.Target(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Target result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000010) != 0)) { + result.targetId_ = targetId_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.once_ = once_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000040) != 0)) { + result.expectedCount_ = + expectedCountBuilder_ == null ? expectedCount_ : expectedCountBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.Target result) { + result.targetTypeCase_ = targetTypeCase_; + result.targetType_ = this.targetType_; + if (targetTypeCase_ == 2 && queryBuilder_ != null) { + result.targetType_ = queryBuilder_.build(); + } + if (targetTypeCase_ == 3 && documentsBuilder_ != null) { + result.targetType_ = documentsBuilder_.build(); + } + result.resumeTypeCase_ = resumeTypeCase_; + result.resumeType_ = this.resumeType_; + if (resumeTypeCase_ == 11 && readTimeBuilder_ != null) { + result.resumeType_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Target) { + return mergeFrom((com.google.firestore.v1.Target) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Target other) { + if (other == com.google.firestore.v1.Target.getDefaultInstance()) return this; + if (other.getTargetId() != 0) { + setTargetId(other.getTargetId()); + } + if (other.getOnce() != false) { + setOnce(other.getOnce()); + } + if (other.hasExpectedCount()) { + mergeExpectedCount(other.getExpectedCount()); + } + switch (other.getTargetTypeCase()) { + case QUERY: + { + mergeQuery(other.getQuery()); + break; + } + case DOCUMENTS: + { + mergeDocuments(other.getDocuments()); + break; + } + case TARGETTYPE_NOT_SET: + { + break; + } + } + switch (other.getResumeTypeCase()) { + case RESUME_TOKEN: + { + setResumeToken(other.getResumeToken()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case RESUMETYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + input.readMessage(internalGetQueryFieldBuilder().getBuilder(), extensionRegistry); + targetTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetDocumentsFieldBuilder().getBuilder(), extensionRegistry); + targetTypeCase_ = 3; + break; + } // case 26 + case 34: + { + resumeType_ = input.readBytes(); + resumeTypeCase_ = 4; + break; + } // case 34 + case 40: + { + targetId_ = input.readInt32(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 48: + { + once_ = input.readBool(); + bitField0_ |= 0x00000020; + break; + } // case 48 + case 90: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + resumeTypeCase_ = 11; + break; + } // case 90 + case 98: + { + input.readMessage( + internalGetExpectedCountFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 98 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int targetTypeCase_ = 0; + private java.lang.Object targetType_; + + public TargetTypeCase getTargetTypeCase() { + return TargetTypeCase.forNumber(targetTypeCase_); + } + + public Builder clearTargetType() { + targetTypeCase_ = 0; + targetType_ = null; + onChanged(); + return this; + } + + private int resumeTypeCase_ = 0; + private java.lang.Object resumeType_; + + public ResumeTypeCase getResumeTypeCase() { + return ResumeTypeCase.forNumber(resumeTypeCase_); + } + + public Builder clearResumeType() { + resumeTypeCase_ = 0; + resumeType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.QueryTarget, + com.google.firestore.v1.Target.QueryTarget.Builder, + com.google.firestore.v1.Target.QueryTargetOrBuilder> + queryBuilder_; + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return targetTypeCase_ == 2; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return The query. + */ + @java.lang.Override + public com.google.firestore.v1.Target.QueryTarget getQuery() { + if (queryBuilder_ == null) { + if (targetTypeCase_ == 2) { + return (com.google.firestore.v1.Target.QueryTarget) targetType_; + } + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } else { + if (targetTypeCase_ == 2) { + return queryBuilder_.getMessage(); + } + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + public Builder setQuery(com.google.firestore.v1.Target.QueryTarget value) { + if (queryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + targetType_ = value; + onChanged(); + } else { + queryBuilder_.setMessage(value); + } + targetTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + public Builder setQuery(com.google.firestore.v1.Target.QueryTarget.Builder builderForValue) { + if (queryBuilder_ == null) { + targetType_ = builderForValue.build(); + onChanged(); + } else { + queryBuilder_.setMessage(builderForValue.build()); + } + targetTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + public Builder mergeQuery(com.google.firestore.v1.Target.QueryTarget value) { + if (queryBuilder_ == null) { + if (targetTypeCase_ == 2 + && targetType_ != com.google.firestore.v1.Target.QueryTarget.getDefaultInstance()) { + targetType_ = + com.google.firestore.v1.Target.QueryTarget.newBuilder( + (com.google.firestore.v1.Target.QueryTarget) targetType_) + .mergeFrom(value) + .buildPartial(); + } else { + targetType_ = value; + } + onChanged(); + } else { + if (targetTypeCase_ == 2) { + queryBuilder_.mergeFrom(value); + } else { + queryBuilder_.setMessage(value); + } + } + targetTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + public Builder clearQuery() { + if (queryBuilder_ == null) { + if (targetTypeCase_ == 2) { + targetTypeCase_ = 0; + targetType_ = null; + onChanged(); + } + } else { + if (targetTypeCase_ == 2) { + targetTypeCase_ = 0; + targetType_ = null; + } + queryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + public com.google.firestore.v1.Target.QueryTarget.Builder getQueryBuilder() { + return internalGetQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Target.QueryTargetOrBuilder getQueryOrBuilder() { + if ((targetTypeCase_ == 2) && (queryBuilder_ != null)) { + return queryBuilder_.getMessageOrBuilder(); + } else { + if (targetTypeCase_ == 2) { + return (com.google.firestore.v1.Target.QueryTarget) targetType_; + } + return com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target specified by a query.
+     * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.QueryTarget, + com.google.firestore.v1.Target.QueryTarget.Builder, + com.google.firestore.v1.Target.QueryTargetOrBuilder> + internalGetQueryFieldBuilder() { + if (queryBuilder_ == null) { + if (!(targetTypeCase_ == 2)) { + targetType_ = com.google.firestore.v1.Target.QueryTarget.getDefaultInstance(); + } + queryBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.QueryTarget, + com.google.firestore.v1.Target.QueryTarget.Builder, + com.google.firestore.v1.Target.QueryTargetOrBuilder>( + (com.google.firestore.v1.Target.QueryTarget) targetType_, + getParentForChildren(), + isClean()); + targetType_ = null; + } + targetTypeCase_ = 2; + onChanged(); + return queryBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.DocumentsTarget, + com.google.firestore.v1.Target.DocumentsTarget.Builder, + com.google.firestore.v1.Target.DocumentsTargetOrBuilder> + documentsBuilder_; + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return Whether the documents field is set. + */ + @java.lang.Override + public boolean hasDocuments() { + return targetTypeCase_ == 3; + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return The documents. + */ + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTarget getDocuments() { + if (documentsBuilder_ == null) { + if (targetTypeCase_ == 3) { + return (com.google.firestore.v1.Target.DocumentsTarget) targetType_; + } + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } else { + if (targetTypeCase_ == 3) { + return documentsBuilder_.getMessage(); + } + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + public Builder setDocuments(com.google.firestore.v1.Target.DocumentsTarget value) { + if (documentsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + targetType_ = value; + onChanged(); + } else { + documentsBuilder_.setMessage(value); + } + targetTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + public Builder setDocuments( + com.google.firestore.v1.Target.DocumentsTarget.Builder builderForValue) { + if (documentsBuilder_ == null) { + targetType_ = builderForValue.build(); + onChanged(); + } else { + documentsBuilder_.setMessage(builderForValue.build()); + } + targetTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + public Builder mergeDocuments(com.google.firestore.v1.Target.DocumentsTarget value) { + if (documentsBuilder_ == null) { + if (targetTypeCase_ == 3 + && targetType_ != com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance()) { + targetType_ = + com.google.firestore.v1.Target.DocumentsTarget.newBuilder( + (com.google.firestore.v1.Target.DocumentsTarget) targetType_) + .mergeFrom(value) + .buildPartial(); + } else { + targetType_ = value; + } + onChanged(); + } else { + if (targetTypeCase_ == 3) { + documentsBuilder_.mergeFrom(value); + } else { + documentsBuilder_.setMessage(value); + } + } + targetTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + public Builder clearDocuments() { + if (documentsBuilder_ == null) { + if (targetTypeCase_ == 3) { + targetTypeCase_ = 0; + targetType_ = null; + onChanged(); + } + } else { + if (targetTypeCase_ == 3) { + targetTypeCase_ = 0; + targetType_ = null; + } + documentsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + public com.google.firestore.v1.Target.DocumentsTarget.Builder getDocumentsBuilder() { + return internalGetDocumentsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Target.DocumentsTargetOrBuilder getDocumentsOrBuilder() { + if ((targetTypeCase_ == 3) && (documentsBuilder_ != null)) { + return documentsBuilder_.getMessageOrBuilder(); + } else { + if (targetTypeCase_ == 3) { + return (com.google.firestore.v1.Target.DocumentsTarget) targetType_; + } + return com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A target specified by a set of document names.
+     * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.DocumentsTarget, + com.google.firestore.v1.Target.DocumentsTarget.Builder, + com.google.firestore.v1.Target.DocumentsTargetOrBuilder> + internalGetDocumentsFieldBuilder() { + if (documentsBuilder_ == null) { + if (!(targetTypeCase_ == 3)) { + targetType_ = com.google.firestore.v1.Target.DocumentsTarget.getDefaultInstance(); + } + documentsBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Target.DocumentsTarget, + com.google.firestore.v1.Target.DocumentsTarget.Builder, + com.google.firestore.v1.Target.DocumentsTargetOrBuilder>( + (com.google.firestore.v1.Target.DocumentsTarget) targetType_, + getParentForChildren(), + isClean()); + targetType_ = null; + } + targetTypeCase_ = 3; + onChanged(); + 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; + } + + /** + * + * + *
+     * 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 The resumeToken. + */ + public com.google.protobuf.ByteString getResumeToken() { + if (resumeTypeCase_ == 4) { + return (com.google.protobuf.ByteString) resumeType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * 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; + * + * @param value The resumeToken to set. + * @return This builder for chaining. + */ + public Builder setResumeToken(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + resumeTypeCase_ = 4; + resumeType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * 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 This builder for chaining. + */ + public Builder clearResumeToken() { + if (resumeTypeCase_ == 4) { + resumeTypeCase_ = 0; + resumeType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return resumeTypeCase_ == 11; + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (resumeTypeCase_ == 11) { + return (com.google.protobuf.Timestamp) resumeType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (resumeTypeCase_ == 11) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + resumeType_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + resumeTypeCase_ = 11; + return this; + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + resumeType_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + resumeTypeCase_ = 11; + return this; + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (resumeTypeCase_ == 11 + && resumeType_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + resumeType_ = + com.google.protobuf.Timestamp.newBuilder((com.google.protobuf.Timestamp) resumeType_) + .mergeFrom(value) + .buildPartial(); + } else { + resumeType_ = value; + } + onChanged(); + } else { + if (resumeTypeCase_ == 11) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + resumeTypeCase_ = 11; + return this; + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (resumeTypeCase_ == 11) { + resumeTypeCase_ = 0; + resumeType_ = null; + onChanged(); + } + } else { + if (resumeTypeCase_ == 11) { + resumeTypeCase_ = 0; + resumeType_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((resumeTypeCase_ == 11) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (resumeTypeCase_ == 11) { + return (com.google.protobuf.Timestamp) resumeType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Start listening after a specific `read_time`.
+     *
+     * The client must know the state of matching documents at this time.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(resumeTypeCase_ == 11)) { + resumeType_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) resumeType_, getParentForChildren(), isClean()); + resumeType_ = null; + } + resumeTypeCase_ = 11; + onChanged(); + return readTimeBuilder_; + } + + private int targetId_; + + /** + * + * + *
+     * The target ID that identifies the target on the stream. Must be a positive
+     * number and non-zero.
+     *
+     * If `target_id` is 0 (or unspecified), the server will assign an ID for this
+     * target and return that in a `TargetChange::ADD` event. Once a target with
+     * `target_id=0` is added, all subsequent targets must also have
+     * `target_id=0`. If an `AddTarget` request with `target_id != 0` is
+     * sent to the server after a target with `target_id=0` is added, the server
+     * will immediately send a response with a `TargetChange::Remove` event.
+     *
+     * Note that if the client sends multiple `AddTarget` requests
+     * without an ID, the order of IDs returned in `TargetChange.target_ids` are
+     * undefined. Therefore, clients should provide a target ID instead of relying
+     * on the server to assign one.
+     *
+     * If `target_id` is non-zero, there must not be an existing active target on
+     * this stream with the same ID.
+     * 
+ * + * int32 target_id = 5; + * + * @return The targetId. + */ + @java.lang.Override + public int getTargetId() { + return targetId_; + } + + /** + * + * + *
+     * The target ID that identifies the target on the stream. Must be a positive
+     * number and non-zero.
+     *
+     * If `target_id` is 0 (or unspecified), the server will assign an ID for this
+     * target and return that in a `TargetChange::ADD` event. Once a target with
+     * `target_id=0` is added, all subsequent targets must also have
+     * `target_id=0`. If an `AddTarget` request with `target_id != 0` is
+     * sent to the server after a target with `target_id=0` is added, the server
+     * will immediately send a response with a `TargetChange::Remove` event.
+     *
+     * Note that if the client sends multiple `AddTarget` requests
+     * without an ID, the order of IDs returned in `TargetChange.target_ids` are
+     * undefined. Therefore, clients should provide a target ID instead of relying
+     * on the server to assign one.
+     *
+     * If `target_id` is non-zero, there must not be an existing active target on
+     * this stream with the same ID.
+     * 
+ * + * int32 target_id = 5; + * + * @param value The targetId to set. + * @return This builder for chaining. + */ + public Builder setTargetId(int value) { + + targetId_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The target ID that identifies the target on the stream. Must be a positive
+     * number and non-zero.
+     *
+     * If `target_id` is 0 (or unspecified), the server will assign an ID for this
+     * target and return that in a `TargetChange::ADD` event. Once a target with
+     * `target_id=0` is added, all subsequent targets must also have
+     * `target_id=0`. If an `AddTarget` request with `target_id != 0` is
+     * sent to the server after a target with `target_id=0` is added, the server
+     * will immediately send a response with a `TargetChange::Remove` event.
+     *
+     * Note that if the client sends multiple `AddTarget` requests
+     * without an ID, the order of IDs returned in `TargetChange.target_ids` are
+     * undefined. Therefore, clients should provide a target ID instead of relying
+     * on the server to assign one.
+     *
+     * If `target_id` is non-zero, there must not be an existing active target on
+     * this stream with the same ID.
+     * 
+ * + * int32 target_id = 5; + * + * @return This builder for chaining. + */ + public Builder clearTargetId() { + bitField0_ = (bitField0_ & ~0x00000010); + targetId_ = 0; + onChanged(); + return this; + } + + private boolean once_; + + /** + * + * + *
+     * If the target should be removed once it is current and consistent.
+     * 
+ * + * bool once = 6; + * + * @return The once. + */ + @java.lang.Override + public boolean getOnce() { + return once_; + } + + /** + * + * + *
+     * If the target should be removed once it is current and consistent.
+     * 
+ * + * bool once = 6; + * + * @param value The once to set. + * @return This builder for chaining. + */ + public Builder setOnce(boolean value) { + + once_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * If the target should be removed once it is current and consistent.
+     * 
+ * + * bool once = 6; + * + * @return This builder for chaining. + */ + public Builder clearOnce() { + bitField0_ = (bitField0_ & ~0x00000020); + once_ = false; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value expectedCount_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + expectedCountBuilder_; + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return Whether the expectedCount field is set. + */ + public boolean hasExpectedCount() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return The expectedCount. + */ + public com.google.protobuf.Int32Value getExpectedCount() { + if (expectedCountBuilder_ == null) { + return expectedCount_ == null + ? com.google.protobuf.Int32Value.getDefaultInstance() + : expectedCount_; + } else { + return expectedCountBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public Builder setExpectedCount(com.google.protobuf.Int32Value value) { + if (expectedCountBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + expectedCount_ = value; + } else { + expectedCountBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public Builder setExpectedCount(com.google.protobuf.Int32Value.Builder builderForValue) { + if (expectedCountBuilder_ == null) { + expectedCount_ = builderForValue.build(); + } else { + expectedCountBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public Builder mergeExpectedCount(com.google.protobuf.Int32Value value) { + if (expectedCountBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && expectedCount_ != null + && expectedCount_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getExpectedCountBuilder().mergeFrom(value); + } else { + expectedCount_ = value; + } + } else { + expectedCountBuilder_.mergeFrom(value); + } + if (expectedCount_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public Builder clearExpectedCount() { + bitField0_ = (bitField0_ & ~0x00000040); + expectedCount_ = null; + if (expectedCountBuilder_ != null) { + expectedCountBuilder_.dispose(); + expectedCountBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public com.google.protobuf.Int32Value.Builder getExpectedCountBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return internalGetExpectedCountFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + public com.google.protobuf.Int32ValueOrBuilder getExpectedCountOrBuilder() { + if (expectedCountBuilder_ != null) { + return expectedCountBuilder_.getMessageOrBuilder(); + } else { + return expectedCount_ == null + ? com.google.protobuf.Int32Value.getDefaultInstance() + : expectedCount_; + } + } + + /** + * + * + *
+     * The number of documents that last matched the query at the resume token or
+     * read time.
+     *
+     * This value is only relevant when a `resume_type` is provided. This value
+     * being present and greater than zero signals that the client wants
+     * `ExistenceFilter.unchanged_names` to be included in the response.
+     * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + internalGetExpectedCountFieldBuilder() { + if (expectedCountBuilder_ == null) { + expectedCountBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getExpectedCount(), getParentForChildren(), isClean()); + expectedCount_ = null; + } + return expectedCountBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Target) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Target) + private static final com.google.firestore.v1.Target DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Target(); + } + + public static com.google.firestore.v1.Target getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Target parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Target getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChange.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChange.java new file mode 100644 index 000000000000..3ca65afa07d5 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChange.java @@ -0,0 +1,1867 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Targets being watched have changed.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.TargetChange} + */ +@com.google.protobuf.Generated +public final class TargetChange extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.TargetChange) + TargetChangeOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "TargetChange"); + } + + // Use TargetChange.newBuilder() to construct. + private TargetChange(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private TargetChange() { + targetChangeType_ = 0; + targetIds_ = emptyIntList(); + resumeToken_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_TargetChange_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_TargetChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TargetChange.class, + com.google.firestore.v1.TargetChange.Builder.class); + } + + /** + * + * + *
+   * The type of change.
+   * 
+ * + * Protobuf enum {@code google.firestore.v1.TargetChange.TargetChangeType} + */ + public enum TargetChangeType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * No change has occurred. Used only to send an updated `resume_token`.
+     * 
+ * + * NO_CHANGE = 0; + */ + NO_CHANGE(0), + /** + * + * + *
+     * The targets have been added.
+     * 
+ * + * ADD = 1; + */ + ADD(1), + /** + * + * + *
+     * The targets have been removed.
+     * 
+ * + * REMOVE = 2; + */ + REMOVE(2), + /** + * + * + *
+     * The targets reflect all changes committed before the targets were added
+     * to the stream.
+     *
+     * This will be sent after or with a `read_time` that is greater than or
+     * equal to the time at which the targets were added.
+     *
+     * Listeners can wait for this change if read-after-write semantics
+     * are desired.
+     * 
+ * + * CURRENT = 3; + */ + CURRENT(3), + /** + * + * + *
+     * The targets have been reset, and a new initial state for the targets
+     * will be returned in subsequent changes.
+     *
+     * After the initial state is complete, `CURRENT` will be returned even
+     * if the target was previously indicated to be `CURRENT`.
+     * 
+ * + * RESET = 4; + */ + RESET(4), + UNRECOGNIZED(-1), + ; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "TargetChangeType"); + } + + /** + * + * + *
+     * No change has occurred. Used only to send an updated `resume_token`.
+     * 
+ * + * NO_CHANGE = 0; + */ + public static final int NO_CHANGE_VALUE = 0; + + /** + * + * + *
+     * The targets have been added.
+     * 
+ * + * ADD = 1; + */ + public static final int ADD_VALUE = 1; + + /** + * + * + *
+     * The targets have been removed.
+     * 
+ * + * REMOVE = 2; + */ + public static final int REMOVE_VALUE = 2; + + /** + * + * + *
+     * The targets reflect all changes committed before the targets were added
+     * to the stream.
+     *
+     * This will be sent after or with a `read_time` that is greater than or
+     * equal to the time at which the targets were added.
+     *
+     * Listeners can wait for this change if read-after-write semantics
+     * are desired.
+     * 
+ * + * CURRENT = 3; + */ + public static final int CURRENT_VALUE = 3; + + /** + * + * + *
+     * The targets have been reset, and a new initial state for the targets
+     * will be returned in subsequent changes.
+     *
+     * After the initial state is complete, `CURRENT` will be returned even
+     * if the target was previously indicated to be `CURRENT`.
+     * 
+ * + * RESET = 4; + */ + public static final int RESET_VALUE = 4; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException( + "Can't get the number of an unknown enum value."); + } + return value; + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static TargetChangeType valueOf(int value) { + return forNumber(value); + } + + /** + * @param value The numeric wire value of the corresponding enum entry. + * @return The enum associated with the given numeric wire value. + */ + public static TargetChangeType forNumber(int value) { + switch (value) { + case 0: + return NO_CHANGE; + case 1: + return ADD; + case 2: + return REMOVE; + case 3: + return CURRENT; + case 4: + return RESET; + default: + return null; + } + } + + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } + + private static final com.google.protobuf.Internal.EnumLiteMap + internalValueMap = + new com.google.protobuf.Internal.EnumLiteMap() { + public TargetChangeType findValueByNumber(int number) { + return TargetChangeType.forNumber(number); + } + }; + + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalStateException( + "Can't get the descriptor of an unrecognized enum value."); + } + return getDescriptor().getValues().get(ordinal()); + } + + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } + + public static com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.firestore.v1.TargetChange.getDescriptor().getEnumTypes().get(0); + } + + private static final TargetChangeType[] VALUES = values(); + + public static TargetChangeType valueOf( + com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } + + private final int value; + + private TargetChangeType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.firestore.v1.TargetChange.TargetChangeType) + } + + private int bitField0_; + public static final int TARGET_CHANGE_TYPE_FIELD_NUMBER = 1; + private int targetChangeType_ = 0; + + /** + * + * + *
+   * The type of change that occurred.
+   * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The enum numeric value on the wire for targetChangeType. + */ + @java.lang.Override + public int getTargetChangeTypeValue() { + return targetChangeType_; + } + + /** + * + * + *
+   * The type of change that occurred.
+   * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The targetChangeType. + */ + @java.lang.Override + public com.google.firestore.v1.TargetChange.TargetChangeType getTargetChangeType() { + com.google.firestore.v1.TargetChange.TargetChangeType result = + com.google.firestore.v1.TargetChange.TargetChangeType.forNumber(targetChangeType_); + return result == null + ? com.google.firestore.v1.TargetChange.TargetChangeType.UNRECOGNIZED + : result; + } + + public static final int TARGET_IDS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private com.google.protobuf.Internal.IntList targetIds_ = emptyIntList(); + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @return A list containing the targetIds. + */ + @java.lang.Override + public java.util.List getTargetIdsList() { + return targetIds_; + } + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @return The count of targetIds. + */ + public int getTargetIdsCount() { + return targetIds_.size(); + } + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + public int getTargetIds(int index) { + return targetIds_.getInt(index); + } + + private int targetIdsMemoizedSerializedSize = -1; + + public static final int CAUSE_FIELD_NUMBER = 3; + private com.google.rpc.Status cause_; + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + * + * @return Whether the cause field is set. + */ + @java.lang.Override + public boolean hasCause() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + * + * @return The cause. + */ + @java.lang.Override + public com.google.rpc.Status getCause() { + return cause_ == null ? com.google.rpc.Status.getDefaultInstance() : cause_; + } + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + */ + @java.lang.Override + public com.google.rpc.StatusOrBuilder getCauseOrBuilder() { + return cause_ == null ? com.google.rpc.Status.getDefaultInstance() : cause_; + } + + public static final int RESUME_TOKEN_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString resumeToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A token that can be used to resume the stream for the given `target_ids`,
+   * or all targets if `target_ids` is empty.
+   *
+   * Not set on every target change.
+   * 
+ * + * bytes resume_token = 4; + * + * @return The resumeToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getResumeToken() { + return resumeToken_; + } + + public static final int READ_TIME_FIELD_NUMBER = 6; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + getSerializedSize(); + if (targetChangeType_ + != com.google.firestore.v1.TargetChange.TargetChangeType.NO_CHANGE.getNumber()) { + output.writeEnum(1, targetChangeType_); + } + if (getTargetIdsList().size() > 0) { + output.writeUInt32NoTag(18); + output.writeUInt32NoTag(targetIdsMemoizedSerializedSize); + } + for (int i = 0; i < targetIds_.size(); i++) { + output.writeInt32NoTag(targetIds_.getInt(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getCause()); + } + if (!resumeToken_.isEmpty()) { + output.writeBytes(4, resumeToken_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(6, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (targetChangeType_ + != com.google.firestore.v1.TargetChange.TargetChangeType.NO_CHANGE.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, targetChangeType_); + } + { + int dataSize = 0; + for (int i = 0; i < targetIds_.size(); i++) { + dataSize += + com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(targetIds_.getInt(i)); + } + size += dataSize; + if (!getTargetIdsList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream.computeInt32SizeNoTag(dataSize); + } + targetIdsMemoizedSerializedSize = dataSize; + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCause()); + } + if (!resumeToken_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, resumeToken_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getReadTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.TargetChange)) { + return super.equals(obj); + } + com.google.firestore.v1.TargetChange other = (com.google.firestore.v1.TargetChange) obj; + + if (targetChangeType_ != other.targetChangeType_) return false; + if (!getTargetIdsList().equals(other.getTargetIdsList())) return false; + if (hasCause() != other.hasCause()) return false; + if (hasCause()) { + if (!getCause().equals(other.getCause())) return false; + } + if (!getResumeToken().equals(other.getResumeToken())) return false; + if (hasReadTime() != other.hasReadTime()) return false; + if (hasReadTime()) { + if (!getReadTime().equals(other.getReadTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + TARGET_CHANGE_TYPE_FIELD_NUMBER; + hash = (53 * hash) + targetChangeType_; + if (getTargetIdsCount() > 0) { + hash = (37 * hash) + TARGET_IDS_FIELD_NUMBER; + hash = (53 * hash) + getTargetIdsList().hashCode(); + } + if (hasCause()) { + hash = (37 * hash) + CAUSE_FIELD_NUMBER; + hash = (53 * hash) + getCause().hashCode(); + } + hash = (37 * hash) + RESUME_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getResumeToken().hashCode(); + if (hasReadTime()) { + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.TargetChange parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TargetChange parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TargetChange parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TargetChange parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TargetChange parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TargetChange parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TargetChange parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.TargetChange prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Targets being watched have changed.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.TargetChange} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.TargetChange) + com.google.firestore.v1.TargetChangeOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_TargetChange_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_TargetChange_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TargetChange.class, + com.google.firestore.v1.TargetChange.Builder.class); + } + + // Construct using com.google.firestore.v1.TargetChange.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetCauseFieldBuilder(); + internalGetReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + targetChangeType_ = 0; + targetIds_ = emptyIntList(); + cause_ = null; + if (causeBuilder_ != null) { + causeBuilder_.dispose(); + causeBuilder_ = null; + } + resumeToken_ = com.google.protobuf.ByteString.EMPTY; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_TargetChange_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.TargetChange getDefaultInstanceForType() { + return com.google.firestore.v1.TargetChange.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.TargetChange build() { + com.google.firestore.v1.TargetChange result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.TargetChange buildPartial() { + com.google.firestore.v1.TargetChange result = new com.google.firestore.v1.TargetChange(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.TargetChange result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.targetChangeType_ = targetChangeType_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + targetIds_.makeImmutable(); + result.targetIds_ = targetIds_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.cause_ = causeBuilder_ == null ? cause_ : causeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.resumeToken_ = resumeToken_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.TargetChange) { + return mergeFrom((com.google.firestore.v1.TargetChange) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.TargetChange other) { + if (other == com.google.firestore.v1.TargetChange.getDefaultInstance()) return this; + if (other.targetChangeType_ != 0) { + setTargetChangeTypeValue(other.getTargetChangeTypeValue()); + } + if (!other.targetIds_.isEmpty()) { + if (targetIds_.isEmpty()) { + targetIds_ = other.targetIds_; + targetIds_.makeImmutable(); + bitField0_ |= 0x00000002; + } else { + ensureTargetIdsIsMutable(); + targetIds_.addAll(other.targetIds_); + } + onChanged(); + } + if (other.hasCause()) { + mergeCause(other.getCause()); + } + if (!other.getResumeToken().isEmpty()) { + setResumeToken(other.getResumeToken()); + } + if (other.hasReadTime()) { + mergeReadTime(other.getReadTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + targetChangeType_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + int v = input.readInt32(); + ensureTargetIdsIsMutable(); + targetIds_.addInt(v); + break; + } // case 16 + case 18: + { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + ensureTargetIdsIsMutable(); + while (input.getBytesUntilLimit() > 0) { + targetIds_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } // case 18 + case 26: + { + input.readMessage(internalGetCauseFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + resumeToken_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 50: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 50 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private int targetChangeType_ = 0; + + /** + * + * + *
+     * The type of change that occurred.
+     * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The enum numeric value on the wire for targetChangeType. + */ + @java.lang.Override + public int getTargetChangeTypeValue() { + return targetChangeType_; + } + + /** + * + * + *
+     * The type of change that occurred.
+     * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @param value The enum numeric value on the wire for targetChangeType to set. + * @return This builder for chaining. + */ + public Builder setTargetChangeTypeValue(int value) { + targetChangeType_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of change that occurred.
+     * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The targetChangeType. + */ + @java.lang.Override + public com.google.firestore.v1.TargetChange.TargetChangeType getTargetChangeType() { + com.google.firestore.v1.TargetChange.TargetChangeType result = + com.google.firestore.v1.TargetChange.TargetChangeType.forNumber(targetChangeType_); + return result == null + ? com.google.firestore.v1.TargetChange.TargetChangeType.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The type of change that occurred.
+     * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @param value The targetChangeType to set. + * @return This builder for chaining. + */ + public Builder setTargetChangeType( + com.google.firestore.v1.TargetChange.TargetChangeType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + targetChangeType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of change that occurred.
+     * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return This builder for chaining. + */ + public Builder clearTargetChangeType() { + bitField0_ = (bitField0_ & ~0x00000001); + targetChangeType_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Internal.IntList targetIds_ = emptyIntList(); + + private void ensureTargetIdsIsMutable() { + if (!targetIds_.isModifiable()) { + targetIds_ = makeMutableCopy(targetIds_); + } + bitField0_ |= 0x00000002; + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @return A list containing the targetIds. + */ + public java.util.List getTargetIdsList() { + targetIds_.makeImmutable(); + return targetIds_; + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @return The count of targetIds. + */ + public int getTargetIdsCount() { + return targetIds_.size(); + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + public int getTargetIds(int index) { + return targetIds_.getInt(index); + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @param index The index to set the value at. + * @param value The targetIds to set. + * @return This builder for chaining. + */ + public Builder setTargetIds(int index, int value) { + + ensureTargetIdsIsMutable(); + targetIds_.setInt(index, value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @param value The targetIds to add. + * @return This builder for chaining. + */ + public Builder addTargetIds(int value) { + + ensureTargetIdsIsMutable(); + targetIds_.addInt(value); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @param values The targetIds to add. + * @return This builder for chaining. + */ + public Builder addAllTargetIds(java.lang.Iterable values) { + ensureTargetIdsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, targetIds_); + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The target IDs of targets that have changed.
+     *
+     * If empty, the change applies to all targets.
+     *
+     * The order of the target IDs is not defined.
+     * 
+ * + * repeated int32 target_ids = 2; + * + * @return This builder for chaining. + */ + public Builder clearTargetIds() { + targetIds_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + private com.google.rpc.Status cause_; + private com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + causeBuilder_; + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + * + * @return Whether the cause field is set. + */ + public boolean hasCause() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + * + * @return The cause. + */ + public com.google.rpc.Status getCause() { + if (causeBuilder_ == null) { + return cause_ == null ? com.google.rpc.Status.getDefaultInstance() : cause_; + } else { + return causeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public Builder setCause(com.google.rpc.Status value) { + if (causeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + cause_ = value; + } else { + causeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public Builder setCause(com.google.rpc.Status.Builder builderForValue) { + if (causeBuilder_ == null) { + cause_ = builderForValue.build(); + } else { + causeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public Builder mergeCause(com.google.rpc.Status value) { + if (causeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && cause_ != null + && cause_ != com.google.rpc.Status.getDefaultInstance()) { + getCauseBuilder().mergeFrom(value); + } else { + cause_ = value; + } + } else { + causeBuilder_.mergeFrom(value); + } + if (cause_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public Builder clearCause() { + bitField0_ = (bitField0_ & ~0x00000004); + cause_ = null; + if (causeBuilder_ != null) { + causeBuilder_.dispose(); + causeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public com.google.rpc.Status.Builder getCauseBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetCauseFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + public com.google.rpc.StatusOrBuilder getCauseOrBuilder() { + if (causeBuilder_ != null) { + return causeBuilder_.getMessageOrBuilder(); + } else { + return cause_ == null ? com.google.rpc.Status.getDefaultInstance() : cause_; + } + } + + /** + * + * + *
+     * The error that resulted in this change, if applicable.
+     * 
+ * + * .google.rpc.Status cause = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, com.google.rpc.Status.Builder, com.google.rpc.StatusOrBuilder> + internalGetCauseFieldBuilder() { + if (causeBuilder_ == null) { + causeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.rpc.Status, + com.google.rpc.Status.Builder, + com.google.rpc.StatusOrBuilder>(getCause(), getParentForChildren(), isClean()); + cause_ = null; + } + return causeBuilder_; + } + + private com.google.protobuf.ByteString resumeToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A token that can be used to resume the stream for the given `target_ids`,
+     * or all targets if `target_ids` is empty.
+     *
+     * Not set on every target change.
+     * 
+ * + * bytes resume_token = 4; + * + * @return The resumeToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getResumeToken() { + return resumeToken_; + } + + /** + * + * + *
+     * A token that can be used to resume the stream for the given `target_ids`,
+     * or all targets if `target_ids` is empty.
+     *
+     * Not set on every target change.
+     * 
+ * + * bytes resume_token = 4; + * + * @param value The resumeToken to set. + * @return This builder for chaining. + */ + public Builder setResumeToken(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + resumeToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * A token that can be used to resume the stream for the given `target_ids`,
+     * or all targets if `target_ids` is empty.
+     *
+     * Not set on every target change.
+     * 
+ * + * bytes resume_token = 4; + * + * @return This builder for chaining. + */ + public Builder clearResumeToken() { + bitField0_ = (bitField0_ & ~0x00000008); + resumeToken_ = getDefaultInstance().getResumeToken(); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } else { + return readTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000010); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * The consistent `read_time` for the given `target_ids` (omitted when the
+     * target_ids are not at a consistent snapshot).
+     *
+     * The stream is guaranteed to send a `read_time` with `target_ids` empty
+     * whenever the entire stream reaches a new consistent snapshot. ADD,
+     * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+     * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+     *
+     * For a given stream, `read_time` is guaranteed to be monotonically
+     * increasing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.TargetChange) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.TargetChange) + private static final com.google.firestore.v1.TargetChange DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.TargetChange(); + } + + public static com.google.firestore.v1.TargetChange getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TargetChange parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.TargetChange getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChangeOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChangeOrBuilder.java new file mode 100644 index 000000000000..8ac111a44660 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetChangeOrBuilder.java @@ -0,0 +1,223 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface TargetChangeOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.TargetChange) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The type of change that occurred.
+   * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The enum numeric value on the wire for targetChangeType. + */ + int getTargetChangeTypeValue(); + + /** + * + * + *
+   * The type of change that occurred.
+   * 
+ * + * .google.firestore.v1.TargetChange.TargetChangeType target_change_type = 1; + * + * @return The targetChangeType. + */ + com.google.firestore.v1.TargetChange.TargetChangeType getTargetChangeType(); + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @return A list containing the targetIds. + */ + java.util.List getTargetIdsList(); + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @return The count of targetIds. + */ + int getTargetIdsCount(); + + /** + * + * + *
+   * The target IDs of targets that have changed.
+   *
+   * If empty, the change applies to all targets.
+   *
+   * The order of the target IDs is not defined.
+   * 
+ * + * repeated int32 target_ids = 2; + * + * @param index The index of the element to return. + * @return The targetIds at the given index. + */ + int getTargetIds(int index); + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + * + * @return Whether the cause field is set. + */ + boolean hasCause(); + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + * + * @return The cause. + */ + com.google.rpc.Status getCause(); + + /** + * + * + *
+   * The error that resulted in this change, if applicable.
+   * 
+ * + * .google.rpc.Status cause = 3; + */ + com.google.rpc.StatusOrBuilder getCauseOrBuilder(); + + /** + * + * + *
+   * A token that can be used to resume the stream for the given `target_ids`,
+   * or all targets if `target_ids` is empty.
+   *
+   * Not set on every target change.
+   * 
+ * + * bytes resume_token = 4; + * + * @return The resumeToken. + */ + com.google.protobuf.ByteString getResumeToken(); + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The consistent `read_time` for the given `target_ids` (omitted when the
+   * target_ids are not at a consistent snapshot).
+   *
+   * The stream is guaranteed to send a `read_time` with `target_ids` empty
+   * whenever the entire stream reaches a new consistent snapshot. ADD,
+   * CURRENT, and RESET messages are guaranteed to (eventually) result in a
+   * new consistent snapshot (while NO_CHANGE and REMOVE messages are not).
+   *
+   * For a given stream, `read_time` is guaranteed to be monotonically
+   * increasing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java new file mode 100644 index 000000000000..70e34d295e3f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TargetOrBuilder.java @@ -0,0 +1,275 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface TargetOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Target) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return Whether the query field is set. + */ + boolean hasQuery(); + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + * + * @return The query. + */ + com.google.firestore.v1.Target.QueryTarget getQuery(); + + /** + * + * + *
+   * A target specified by a query.
+   * 
+ * + * .google.firestore.v1.Target.QueryTarget query = 2; + */ + com.google.firestore.v1.Target.QueryTargetOrBuilder getQueryOrBuilder(); + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return Whether the documents field is set. + */ + boolean hasDocuments(); + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + * + * @return The documents. + */ + com.google.firestore.v1.Target.DocumentsTarget getDocuments(); + + /** + * + * + *
+   * A target specified by a set of document names.
+   * 
+ * + * .google.firestore.v1.Target.DocumentsTarget documents = 3; + */ + 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(); + + /** + * + * + *
+   * 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 The resumeToken. + */ + com.google.protobuf.ByteString getResumeToken(); + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Start listening after a specific `read_time`.
+   *
+   * The client must know the state of matching documents at this time.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 11; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + /** + * + * + *
+   * The target ID that identifies the target on the stream. Must be a positive
+   * number and non-zero.
+   *
+   * If `target_id` is 0 (or unspecified), the server will assign an ID for this
+   * target and return that in a `TargetChange::ADD` event. Once a target with
+   * `target_id=0` is added, all subsequent targets must also have
+   * `target_id=0`. If an `AddTarget` request with `target_id != 0` is
+   * sent to the server after a target with `target_id=0` is added, the server
+   * will immediately send a response with a `TargetChange::Remove` event.
+   *
+   * Note that if the client sends multiple `AddTarget` requests
+   * without an ID, the order of IDs returned in `TargetChange.target_ids` are
+   * undefined. Therefore, clients should provide a target ID instead of relying
+   * on the server to assign one.
+   *
+   * If `target_id` is non-zero, there must not be an existing active target on
+   * this stream with the same ID.
+   * 
+ * + * int32 target_id = 5; + * + * @return The targetId. + */ + int getTargetId(); + + /** + * + * + *
+   * If the target should be removed once it is current and consistent.
+   * 
+ * + * bool once = 6; + * + * @return The once. + */ + boolean getOnce(); + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return Whether the expectedCount field is set. + */ + boolean hasExpectedCount(); + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + * + * @return The expectedCount. + */ + com.google.protobuf.Int32Value getExpectedCount(); + + /** + * + * + *
+   * The number of documents that last matched the query at the resume token or
+   * read time.
+   *
+   * This value is only relevant when a `resume_type` is provided. This value
+   * being present and greater than zero signals that the client wants
+   * `ExistenceFilter.unchanged_names` to be included in the response.
+   * 
+ * + * .google.protobuf.Int32Value expected_count = 12; + */ + com.google.protobuf.Int32ValueOrBuilder getExpectedCountOrBuilder(); + + com.google.firestore.v1.Target.TargetTypeCase getTargetTypeCase(); + + com.google.firestore.v1.Target.ResumeTypeCase getResumeTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptions.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptions.java new file mode 100644 index 000000000000..18ecb61c4f18 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptions.java @@ -0,0 +1,2495 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * Options for creating a new transaction.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions} + */ +@com.google.protobuf.Generated +public final class TransactionOptions extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.TransactionOptions) + TransactionOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "TransactionOptions"); + } + + // Use TransactionOptions.newBuilder() to construct. + private TransactionOptions(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private TransactionOptions() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.class, + com.google.firestore.v1.TransactionOptions.Builder.class); + } + + public interface ReadWriteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.TransactionOptions.ReadWrite) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * An optional transaction to retry.
+     * 
+ * + * bytes retry_transaction = 1; + * + * @return The retryTransaction. + */ + com.google.protobuf.ByteString getRetryTransaction(); + } + + /** + * + * + *
+   * Options for a transaction that can be used to read and write documents.
+   *
+   * Firestore does not allow 3rd party auth requests to create read-write.
+   * transactions.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions.ReadWrite} + */ + public static final class ReadWrite extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.TransactionOptions.ReadWrite) + ReadWriteOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ReadWrite"); + } + + // Use ReadWrite.newBuilder() to construct. + private ReadWrite(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ReadWrite() { + retryTransaction_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadWrite_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.ReadWrite.class, + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder.class); + } + + public static final int RETRY_TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString retryTransaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * An optional transaction to retry.
+     * 
+ * + * bytes retry_transaction = 1; + * + * @return The retryTransaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRetryTransaction() { + return retryTransaction_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!retryTransaction_.isEmpty()) { + output.writeBytes(1, retryTransaction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!retryTransaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, retryTransaction_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.TransactionOptions.ReadWrite)) { + return super.equals(obj); + } + com.google.firestore.v1.TransactionOptions.ReadWrite other = + (com.google.firestore.v1.TransactionOptions.ReadWrite) obj; + + if (!getRetryTransaction().equals(other.getRetryTransaction())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + RETRY_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getRetryTransaction().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.TransactionOptions.ReadWrite prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Options for a transaction that can be used to read and write documents.
+     *
+     * Firestore does not allow 3rd party auth requests to create read-write.
+     * transactions.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions.ReadWrite} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.TransactionOptions.ReadWrite) + com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadWrite_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.ReadWrite.class, + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder.class); + } + + // Construct using com.google.firestore.v1.TransactionOptions.ReadWrite.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + retryTransaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite getDefaultInstanceForType() { + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite build() { + com.google.firestore.v1.TransactionOptions.ReadWrite result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite buildPartial() { + com.google.firestore.v1.TransactionOptions.ReadWrite result = + new com.google.firestore.v1.TransactionOptions.ReadWrite(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.TransactionOptions.ReadWrite result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.retryTransaction_ = retryTransaction_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.TransactionOptions.ReadWrite) { + return mergeFrom((com.google.firestore.v1.TransactionOptions.ReadWrite) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.TransactionOptions.ReadWrite other) { + if (other == com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance()) + return this; + if (!other.getRetryTransaction().isEmpty()) { + setRetryTransaction(other.getRetryTransaction()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + retryTransaction_ = input.readBytes(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.ByteString retryTransaction_ = + com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+       * An optional transaction to retry.
+       * 
+ * + * bytes retry_transaction = 1; + * + * @return The retryTransaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getRetryTransaction() { + return retryTransaction_; + } + + /** + * + * + *
+       * An optional transaction to retry.
+       * 
+ * + * bytes retry_transaction = 1; + * + * @param value The retryTransaction to set. + * @return This builder for chaining. + */ + public Builder setRetryTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + retryTransaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * An optional transaction to retry.
+       * 
+ * + * bytes retry_transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearRetryTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + retryTransaction_ = getDefaultInstance().getRetryTransaction(); + onChanged(); + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.TransactionOptions.ReadWrite) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.TransactionOptions.ReadWrite) + private static final com.google.firestore.v1.TransactionOptions.ReadWrite DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.TransactionOptions.ReadWrite(); + } + + public static com.google.firestore.v1.TransactionOptions.ReadWrite getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ReadWrite parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface ReadOnlyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.TransactionOptions.ReadOnly) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + + com.google.firestore.v1.TransactionOptions.ReadOnly.ConsistencySelectorCase + getConsistencySelectorCase(); + } + + /** + * + * + *
+   * Options for a transaction that can only be used to read documents.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions.ReadOnly} + */ + public static final class ReadOnly extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.TransactionOptions.ReadOnly) + ReadOnlyOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "ReadOnly"); + } + + // Use ReadOnly.newBuilder() to construct. + private ReadOnly(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private ReadOnly() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadOnly_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.ReadOnly.class, + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder.class); + } + + private int consistencySelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencySelector_; + + public enum ConsistencySelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_TIME(2), + CONSISTENCYSELECTOR_NOT_SET(0); + private final int value; + + private ConsistencySelectorCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ConsistencySelectorCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencySelectorCase forNumber(int value) { + switch (value) { + case 2: + return READ_TIME; + case 0: + return CONSISTENCYSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public static final int READ_TIME_FIELD_NUMBER = 2; + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 2; + } + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (consistencySelectorCase_ == 2) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+     * Reads documents at the given time.
+     *
+     * This must be a microsecond precision timestamp within the past one
+     * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+     * whole minute timestamp within the past 7 days.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (consistencySelectorCase_ == 2) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (consistencySelectorCase_ == 2) { + output.writeMessage(2, (com.google.protobuf.Timestamp) consistencySelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (consistencySelectorCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.protobuf.Timestamp) consistencySelector_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.TransactionOptions.ReadOnly)) { + return super.equals(obj); + } + com.google.firestore.v1.TransactionOptions.ReadOnly other = + (com.google.firestore.v1.TransactionOptions.ReadOnly) obj; + + if (!getConsistencySelectorCase().equals(other.getConsistencySelectorCase())) return false; + switch (consistencySelectorCase_) { + case 2: + if (!getReadTime().equals(other.getReadTime())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (consistencySelectorCase_) { + case 2: + hash = (37 * hash) + READ_TIME_FIELD_NUMBER; + hash = (53 * hash) + getReadTime().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder( + com.google.firestore.v1.TransactionOptions.ReadOnly prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Options for a transaction that can only be used to read documents.
+     * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions.ReadOnly} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.TransactionOptions.ReadOnly) + com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadOnly_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.ReadOnly.class, + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder.class); + } + + // Construct using com.google.firestore.v1.TransactionOptions.ReadOnly.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + consistencySelectorCase_ = 0; + consistencySelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly getDefaultInstanceForType() { + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly build() { + com.google.firestore.v1.TransactionOptions.ReadOnly result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly buildPartial() { + com.google.firestore.v1.TransactionOptions.ReadOnly result = + new com.google.firestore.v1.TransactionOptions.ReadOnly(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.TransactionOptions.ReadOnly result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.TransactionOptions.ReadOnly result) { + result.consistencySelectorCase_ = consistencySelectorCase_; + result.consistencySelector_ = this.consistencySelector_; + if (consistencySelectorCase_ == 2 && readTimeBuilder_ != null) { + result.consistencySelector_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.TransactionOptions.ReadOnly) { + return mergeFrom((com.google.firestore.v1.TransactionOptions.ReadOnly) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.TransactionOptions.ReadOnly other) { + if (other == com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance()) + return this; + switch (other.getConsistencySelectorCase()) { + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYSELECTOR_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + input.readMessage( + internalGetReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencySelectorCase_ = 2; + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int consistencySelectorCase_ = 0; + private java.lang.Object consistencySelector_; + + public ConsistencySelectorCase getConsistencySelectorCase() { + return ConsistencySelectorCase.forNumber(consistencySelectorCase_); + } + + public Builder clearConsistencySelector() { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return consistencySelectorCase_ == 2; + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 2) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencySelectorCase_ == 2) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencySelector_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencySelectorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + consistencySelector_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencySelectorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 2 + && consistencySelector_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencySelector_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencySelector_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencySelector_ = value; + } + onChanged(); + } else { + if (consistencySelectorCase_ == 2) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencySelectorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public Builder clearReadTime() { + if (readTimeBuilder_ == null) { + if (consistencySelectorCase_ == 2) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + onChanged(); + } + } else { + if (consistencySelectorCase_ == 2) { + consistencySelectorCase_ = 0; + consistencySelector_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + return internalGetReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if ((consistencySelectorCase_ == 2) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencySelectorCase_ == 2) { + return (com.google.protobuf.Timestamp) consistencySelector_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Reads documents at the given time.
+       *
+       * This must be a microsecond precision timestamp within the past one
+       * hour, or if Point-in-Time Recovery is enabled, can additionally be a
+       * whole minute timestamp within the past 7 days.
+       * 
+ * + * .google.protobuf.Timestamp read_time = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencySelectorCase_ == 2)) { + consistencySelector_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencySelector_, + getParentForChildren(), + isClean()); + consistencySelector_ = null; + } + consistencySelectorCase_ = 2; + onChanged(); + return readTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.TransactionOptions.ReadOnly) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.TransactionOptions.ReadOnly) + private static final com.google.firestore.v1.TransactionOptions.ReadOnly DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.TransactionOptions.ReadOnly(); + } + + public static com.google.firestore.v1.TransactionOptions.ReadOnly getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ReadOnly parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException() + .setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int modeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object mode_; + + public enum ModeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_ONLY(2), + READ_WRITE(3), + MODE_NOT_SET(0); + private final int value; + + private ModeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ModeCase valueOf(int value) { + return forNumber(value); + } + + public static ModeCase forNumber(int value) { + switch (value) { + case 2: + return READ_ONLY; + case 3: + return READ_WRITE; + case 0: + return MODE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ModeCase getModeCase() { + return ModeCase.forNumber(modeCase_); + } + + public static final int READ_ONLY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + @java.lang.Override + public boolean hasReadOnly() { + return modeCase_ == 2; + } + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly getReadOnly() { + if (modeCase_ == 2) { + return (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder() { + if (modeCase_ == 2) { + return (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + + public static final int READ_WRITE_FIELD_NUMBER = 3; + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return Whether the readWrite field is set. + */ + @java.lang.Override + public boolean hasReadWrite() { + return modeCase_ == 3; + } + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return The readWrite. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite getReadWrite() { + if (modeCase_ == 3) { + return (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder() { + if (modeCase_ == 3) { + return (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (modeCase_ == 2) { + output.writeMessage(2, (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_); + } + if (modeCase_ == 3) { + output.writeMessage(3, (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (modeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_); + } + if (modeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.TransactionOptions)) { + return super.equals(obj); + } + com.google.firestore.v1.TransactionOptions other = + (com.google.firestore.v1.TransactionOptions) obj; + + if (!getModeCase().equals(other.getModeCase())) return false; + switch (modeCase_) { + case 2: + if (!getReadOnly().equals(other.getReadOnly())) return false; + break; + case 3: + if (!getReadWrite().equals(other.getReadWrite())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (modeCase_) { + case 2: + hash = (37 * hash) + READ_ONLY_FIELD_NUMBER; + hash = (53 * hash) + getReadOnly().hashCode(); + break; + case 3: + hash = (37 * hash) + READ_WRITE_FIELD_NUMBER; + hash = (53 * hash) + getReadWrite().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.TransactionOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.TransactionOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.TransactionOptions prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Options for creating a new transaction.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.TransactionOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.TransactionOptions) + com.google.firestore.v1.TransactionOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.TransactionOptions.class, + com.google.firestore.v1.TransactionOptions.Builder.class); + } + + // Construct using com.google.firestore.v1.TransactionOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (readOnlyBuilder_ != null) { + readOnlyBuilder_.clear(); + } + if (readWriteBuilder_ != null) { + readWriteBuilder_.clear(); + } + modeCase_ = 0; + mode_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.CommonProto + .internal_static_google_firestore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getDefaultInstanceForType() { + return com.google.firestore.v1.TransactionOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions build() { + com.google.firestore.v1.TransactionOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions buildPartial() { + com.google.firestore.v1.TransactionOptions result = + new com.google.firestore.v1.TransactionOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.TransactionOptions result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.TransactionOptions result) { + result.modeCase_ = modeCase_; + result.mode_ = this.mode_; + if (modeCase_ == 2 && readOnlyBuilder_ != null) { + result.mode_ = readOnlyBuilder_.build(); + } + if (modeCase_ == 3 && readWriteBuilder_ != null) { + result.mode_ = readWriteBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.TransactionOptions) { + return mergeFrom((com.google.firestore.v1.TransactionOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.TransactionOptions other) { + if (other == com.google.firestore.v1.TransactionOptions.getDefaultInstance()) return this; + switch (other.getModeCase()) { + case READ_ONLY: + { + mergeReadOnly(other.getReadOnly()); + break; + } + case READ_WRITE: + { + mergeReadWrite(other.getReadWrite()); + break; + } + case MODE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 18: + { + input.readMessage( + internalGetReadOnlyFieldBuilder().getBuilder(), extensionRegistry); + modeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetReadWriteFieldBuilder().getBuilder(), extensionRegistry); + modeCase_ = 3; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int modeCase_ = 0; + private java.lang.Object mode_; + + public ModeCase getModeCase() { + return ModeCase.forNumber(modeCase_); + } + + public Builder clearMode() { + modeCase_ = 0; + mode_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadOnly, + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder, + com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder> + readOnlyBuilder_; + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + @java.lang.Override + public boolean hasReadOnly() { + return modeCase_ == 2; + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnly getReadOnly() { + if (readOnlyBuilder_ == null) { + if (modeCase_ == 2) { + return (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } else { + if (modeCase_ == 2) { + return readOnlyBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder setReadOnly(com.google.firestore.v1.TransactionOptions.ReadOnly value) { + if (readOnlyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mode_ = value; + onChanged(); + } else { + readOnlyBuilder_.setMessage(value); + } + modeCase_ = 2; + return this; + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder setReadOnly( + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder builderForValue) { + if (readOnlyBuilder_ == null) { + mode_ = builderForValue.build(); + onChanged(); + } else { + readOnlyBuilder_.setMessage(builderForValue.build()); + } + modeCase_ = 2; + return this; + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder mergeReadOnly(com.google.firestore.v1.TransactionOptions.ReadOnly value) { + if (readOnlyBuilder_ == null) { + if (modeCase_ == 2 + && mode_ != com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance()) { + mode_ = + com.google.firestore.v1.TransactionOptions.ReadOnly.newBuilder( + (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_) + .mergeFrom(value) + .buildPartial(); + } else { + mode_ = value; + } + onChanged(); + } else { + if (modeCase_ == 2) { + readOnlyBuilder_.mergeFrom(value); + } else { + readOnlyBuilder_.setMessage(value); + } + } + modeCase_ = 2; + return this; + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder clearReadOnly() { + if (readOnlyBuilder_ == null) { + if (modeCase_ == 2) { + modeCase_ = 0; + mode_ = null; + onChanged(); + } + } else { + if (modeCase_ == 2) { + modeCase_ = 0; + mode_ = null; + } + readOnlyBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public com.google.firestore.v1.TransactionOptions.ReadOnly.Builder getReadOnlyBuilder() { + return internalGetReadOnlyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder() { + if ((modeCase_ == 2) && (readOnlyBuilder_ != null)) { + return readOnlyBuilder_.getMessageOrBuilder(); + } else { + if (modeCase_ == 2) { + return (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction can only be used for read operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadOnly, + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder, + com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder> + internalGetReadOnlyFieldBuilder() { + if (readOnlyBuilder_ == null) { + if (!(modeCase_ == 2)) { + mode_ = com.google.firestore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + readOnlyBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadOnly, + com.google.firestore.v1.TransactionOptions.ReadOnly.Builder, + com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder>( + (com.google.firestore.v1.TransactionOptions.ReadOnly) mode_, + getParentForChildren(), + isClean()); + mode_ = null; + } + modeCase_ = 2; + onChanged(); + return readOnlyBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadWrite, + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder, + com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder> + readWriteBuilder_; + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return Whether the readWrite field is set. + */ + @java.lang.Override + public boolean hasReadWrite() { + return modeCase_ == 3; + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return The readWrite. + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWrite getReadWrite() { + if (readWriteBuilder_ == null) { + if (modeCase_ == 3) { + return (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } else { + if (modeCase_ == 3) { + return readWriteBuilder_.getMessage(); + } + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + public Builder setReadWrite(com.google.firestore.v1.TransactionOptions.ReadWrite value) { + if (readWriteBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mode_ = value; + onChanged(); + } else { + readWriteBuilder_.setMessage(value); + } + modeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + public Builder setReadWrite( + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder builderForValue) { + if (readWriteBuilder_ == null) { + mode_ = builderForValue.build(); + onChanged(); + } else { + readWriteBuilder_.setMessage(builderForValue.build()); + } + modeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + public Builder mergeReadWrite(com.google.firestore.v1.TransactionOptions.ReadWrite value) { + if (readWriteBuilder_ == null) { + if (modeCase_ == 3 + && mode_ != com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance()) { + mode_ = + com.google.firestore.v1.TransactionOptions.ReadWrite.newBuilder( + (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_) + .mergeFrom(value) + .buildPartial(); + } else { + mode_ = value; + } + onChanged(); + } else { + if (modeCase_ == 3) { + readWriteBuilder_.mergeFrom(value); + } else { + readWriteBuilder_.setMessage(value); + } + } + modeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + public Builder clearReadWrite() { + if (readWriteBuilder_ == null) { + if (modeCase_ == 3) { + modeCase_ = 0; + mode_ = null; + onChanged(); + } + } else { + if (modeCase_ == 3) { + modeCase_ = 0; + mode_ = null; + } + readWriteBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + public com.google.firestore.v1.TransactionOptions.ReadWrite.Builder getReadWriteBuilder() { + return internalGetReadWriteFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + @java.lang.Override + public com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder() { + if ((modeCase_ == 3) && (readWriteBuilder_ != null)) { + return readWriteBuilder_.getMessageOrBuilder(); + } else { + if (modeCase_ == 3) { + return (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction can be used for both read and write operations.
+     * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadWrite, + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder, + com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder> + internalGetReadWriteFieldBuilder() { + if (readWriteBuilder_ == null) { + if (!(modeCase_ == 3)) { + mode_ = com.google.firestore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + readWriteBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.TransactionOptions.ReadWrite, + com.google.firestore.v1.TransactionOptions.ReadWrite.Builder, + com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder>( + (com.google.firestore.v1.TransactionOptions.ReadWrite) mode_, + getParentForChildren(), + isClean()); + mode_ = null; + } + modeCase_ = 3; + onChanged(); + return readWriteBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.TransactionOptions) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.TransactionOptions) + private static final com.google.firestore.v1.TransactionOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.TransactionOptions(); + } + + public static com.google.firestore.v1.TransactionOptions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public TransactionOptions parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.TransactionOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptionsOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptionsOrBuilder.java new file mode 100644 index 000000000000..cafcfad43bd9 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/TransactionOptionsOrBuilder.java @@ -0,0 +1,104 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/common.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface TransactionOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.TransactionOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + boolean hasReadOnly(); + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + com.google.firestore.v1.TransactionOptions.ReadOnly getReadOnly(); + + /** + * + * + *
+   * The transaction can only be used for read operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + com.google.firestore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder(); + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return Whether the readWrite field is set. + */ + boolean hasReadWrite(); + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + * + * @return The readWrite. + */ + com.google.firestore.v1.TransactionOptions.ReadWrite getReadWrite(); + + /** + * + * + *
+   * The transaction can be used for both read and write operations.
+   * 
+ * + * .google.firestore.v1.TransactionOptions.ReadWrite read_write = 3; + */ + com.google.firestore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder(); + + com.google.firestore.v1.TransactionOptions.ModeCase getModeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequest.java new file mode 100644 index 000000000000..d8635cac01e4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequest.java @@ -0,0 +1,1675 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for
+ * [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.UpdateDocumentRequest} + */ +@com.google.protobuf.Generated +public final class UpdateDocumentRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.UpdateDocumentRequest) + UpdateDocumentRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "UpdateDocumentRequest"); + } + + // Use UpdateDocumentRequest.newBuilder() to construct. + private UpdateDocumentRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private UpdateDocumentRequest() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_UpdateDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_UpdateDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.UpdateDocumentRequest.class, + com.google.firestore.v1.UpdateDocumentRequest.Builder.class); + } + + private int bitField0_; + public static final int DOCUMENT_FIELD_NUMBER = 1; + private com.google.firestore.v1.Document document_; + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + @java.lang.Override + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + @java.lang.Override + public com.google.firestore.v1.Document getDocument() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + return document_ == null ? com.google.firestore.v1.Document.getDefaultInstance() : document_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.firestore.v1.DocumentMask updateMask_; + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getUpdateMask() { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + + public static final int MASK_FIELD_NUMBER = 3; + private com.google.firestore.v1.DocumentMask mask_; + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + @java.lang.Override + public boolean hasMask() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getMask() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + + public static final int CURRENT_DOCUMENT_FIELD_NUMBER = 4; + private com.google.firestore.v1.Precondition currentDocument_; + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + @java.lang.Override + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + @java.lang.Override + public com.google.firestore.v1.Precondition getCurrentDocument() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + @java.lang.Override + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getDocument()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(3, getMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(4, getCurrentDocument()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getDocument()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getCurrentDocument()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.UpdateDocumentRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.UpdateDocumentRequest other = + (com.google.firestore.v1.UpdateDocumentRequest) obj; + + if (hasDocument() != other.hasDocument()) return false; + if (hasDocument()) { + if (!getDocument().equals(other.getDocument())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (hasMask() != other.hasMask()) return false; + if (hasMask()) { + if (!getMask().equals(other.getMask())) return false; + } + if (hasCurrentDocument() != other.hasCurrentDocument()) return false; + if (hasCurrentDocument()) { + if (!getCurrentDocument().equals(other.getCurrentDocument())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasDocument()) { + hash = (37 * hash) + DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getDocument().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + if (hasMask()) { + hash = (37 * hash) + MASK_FIELD_NUMBER; + hash = (53 * hash) + getMask().hashCode(); + } + if (hasCurrentDocument()) { + hash = (37 * hash) + CURRENT_DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getCurrentDocument().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.UpdateDocumentRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.UpdateDocumentRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.UpdateDocumentRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.UpdateDocumentRequest) + com.google.firestore.v1.UpdateDocumentRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_UpdateDocumentRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_UpdateDocumentRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.UpdateDocumentRequest.class, + com.google.firestore.v1.UpdateDocumentRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.UpdateDocumentRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetDocumentFieldBuilder(); + internalGetUpdateMaskFieldBuilder(); + internalGetMaskFieldBuilder(); + internalGetCurrentDocumentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_UpdateDocumentRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.UpdateDocumentRequest getDefaultInstanceForType() { + return com.google.firestore.v1.UpdateDocumentRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.UpdateDocumentRequest build() { + com.google.firestore.v1.UpdateDocumentRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.UpdateDocumentRequest buildPartial() { + com.google.firestore.v1.UpdateDocumentRequest result = + new com.google.firestore.v1.UpdateDocumentRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.UpdateDocumentRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.document_ = documentBuilder_ == null ? document_ : documentBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.mask_ = maskBuilder_ == null ? mask_ : maskBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.currentDocument_ = + currentDocumentBuilder_ == null ? currentDocument_ : currentDocumentBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.UpdateDocumentRequest) { + return mergeFrom((com.google.firestore.v1.UpdateDocumentRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.UpdateDocumentRequest other) { + if (other == com.google.firestore.v1.UpdateDocumentRequest.getDefaultInstance()) return this; + if (other.hasDocument()) { + mergeDocument(other.getDocument()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + if (other.hasMask()) { + mergeMask(other.getMask()); + } + if (other.hasCurrentDocument()) { + mergeCurrentDocument(other.getCurrentDocument()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + internalGetUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(internalGetMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetCurrentDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.firestore.v1.Document document_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + documentBuilder_; + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + public boolean hasDocument() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + public com.google.firestore.v1.Document getDocument() { + if (documentBuilder_ == null) { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } else { + return documentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + document_ = value; + } else { + documentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setDocument(com.google.firestore.v1.Document.Builder builderForValue) { + if (documentBuilder_ == null) { + document_ = builderForValue.build(); + } else { + documentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeDocument(com.google.firestore.v1.Document value) { + if (documentBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && document_ != null + && document_ != com.google.firestore.v1.Document.getDefaultInstance()) { + getDocumentBuilder().mergeFrom(value); + } else { + document_ = value; + } + } else { + documentBuilder_.mergeFrom(value); + } + if (document_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearDocument() { + bitField0_ = (bitField0_ & ~0x00000001); + document_ = null; + if (documentBuilder_ != null) { + documentBuilder_.dispose(); + documentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.Document.Builder getDocumentBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder() { + if (documentBuilder_ != null) { + return documentBuilder_.getMessageOrBuilder(); + } else { + return document_ == null + ? com.google.firestore.v1.Document.getDefaultInstance() + : document_; + } + } + + /** + * + * + *
+     * Required. The updated document.
+     * Creates the document if it does not already exist.
+     * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetDocumentFieldBuilder() { + if (documentBuilder_ == null) { + documentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + getDocument(), getParentForChildren(), isClean()); + document_ = null; + } + return documentBuilder_; + } + + private com.google.firestore.v1.DocumentMask updateMask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + updateMaskBuilder_; + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return The updateMask. + */ + public com.google.firestore.v1.DocumentMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.firestore.v1.DocumentMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public Builder setUpdateMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public Builder mergeUpdateMask(com.google.firestore.v1.DocumentMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public com.google.firestore.v1.DocumentMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return internalGetUpdateMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + } + + /** + * + * + *
+     * The fields to update.
+     * None of the field paths in the mask may contain a reserved name.
+     *
+     * If the document exists on the server and has fields not referenced in the
+     * mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + private com.google.firestore.v1.DocumentMask mask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + maskBuilder_; + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + public boolean hasMask() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + public com.google.firestore.v1.DocumentMask getMask() { + if (maskBuilder_ == null) { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } else { + return maskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mask_ = value; + } else { + maskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder setMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (maskBuilder_ == null) { + mask_ = builderForValue.build(); + } else { + maskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder mergeMask(com.google.firestore.v1.DocumentMask value) { + if (maskBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && mask_ != null + && mask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getMaskBuilder().mergeFrom(value); + } else { + mask_ = value; + } + } else { + maskBuilder_.mergeFrom(value); + } + if (mask_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public Builder clearMask() { + bitField0_ = (bitField0_ & ~0x00000004); + mask_ = null; + if (maskBuilder_ != null) { + maskBuilder_.dispose(); + maskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public com.google.firestore.v1.DocumentMask.Builder getMaskBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return internalGetMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder() { + if (maskBuilder_ != null) { + return maskBuilder_.getMessageOrBuilder(); + } else { + return mask_ == null ? com.google.firestore.v1.DocumentMask.getDefaultInstance() : mask_; + } + } + + /** + * + * + *
+     * The fields to return. If not set, returns all fields.
+     *
+     * If the document has a field that is not present in this mask, that field
+     * will not be returned in the response.
+     * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetMaskFieldBuilder() { + if (maskBuilder_ == null) { + maskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getMask(), getParentForChildren(), isClean()); + mask_ = null; + } + return maskBuilder_; + } + + private com.google.firestore.v1.Precondition currentDocument_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + currentDocumentBuilder_; + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + public com.google.firestore.v1.Precondition getCurrentDocument() { + if (currentDocumentBuilder_ == null) { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } else { + return currentDocumentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder setCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + currentDocument_ = value; + } else { + currentDocumentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder setCurrentDocument( + com.google.firestore.v1.Precondition.Builder builderForValue) { + if (currentDocumentBuilder_ == null) { + currentDocument_ = builderForValue.build(); + } else { + currentDocumentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder mergeCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && currentDocument_ != null + && currentDocument_ != com.google.firestore.v1.Precondition.getDefaultInstance()) { + getCurrentDocumentBuilder().mergeFrom(value); + } else { + currentDocument_ = value; + } + } else { + currentDocumentBuilder_.mergeFrom(value); + } + if (currentDocument_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder clearCurrentDocument() { + bitField0_ = (bitField0_ & ~0x00000008); + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public com.google.firestore.v1.Precondition.Builder getCurrentDocumentBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetCurrentDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + if (currentDocumentBuilder_ != null) { + return currentDocumentBuilder_.getMessageOrBuilder(); + } else { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     * The request will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + internalGetCurrentDocumentFieldBuilder() { + if (currentDocumentBuilder_ == null) { + currentDocumentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder>( + getCurrentDocument(), getParentForChildren(), isClean()); + currentDocument_ = null; + } + return currentDocumentBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.UpdateDocumentRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.UpdateDocumentRequest) + private static final com.google.firestore.v1.UpdateDocumentRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.UpdateDocumentRequest(); + } + + public static com.google.firestore.v1.UpdateDocumentRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateDocumentRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.UpdateDocumentRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequestOrBuilder.java new file mode 100644 index 000000000000..c1a11c249b0a --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/UpdateDocumentRequestOrBuilder.java @@ -0,0 +1,212 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface UpdateDocumentRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.UpdateDocumentRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the document field is set. + */ + boolean hasDocument(); + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The document. + */ + com.google.firestore.v1.Document getDocument(); + + /** + * + * + *
+   * Required. The updated document.
+   * Creates the document if it does not already exist.
+   * 
+ * + * .google.firestore.v1.Document document = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.firestore.v1.DocumentOrBuilder getDocumentOrBuilder(); + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + * + * @return The updateMask. + */ + com.google.firestore.v1.DocumentMask getUpdateMask(); + + /** + * + * + *
+   * The fields to update.
+   * None of the field paths in the mask may contain a reserved name.
+   *
+   * If the document exists on the server and has fields not referenced in the
+   * mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 2; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return Whether the mask field is set. + */ + boolean hasMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + * + * @return The mask. + */ + com.google.firestore.v1.DocumentMask getMask(); + + /** + * + * + *
+   * The fields to return. If not set, returns all fields.
+   *
+   * If the document has a field that is not present in this mask, that field
+   * will not be returned in the response.
+   * 
+ * + * .google.firestore.v1.DocumentMask mask = 3; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getMaskOrBuilder(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + boolean hasCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + com.google.firestore.v1.Precondition getCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   * The request will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java new file mode 100644 index 000000000000..08b6125a6311 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Value.java @@ -0,0 +1,4384 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A message that can hold any of the supported value types.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Value} + */ +@com.google.protobuf.Generated +public final class Value extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Value) + ValueOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Value"); + } + + // Use Value.newBuilder() to construct. + private Value(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Value() {} + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Value_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Value_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Value.class, com.google.firestore.v1.Value.Builder.class); + } + + private int valueTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object valueType_; + + public enum ValueTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + NULL_VALUE(11), + BOOLEAN_VALUE(1), + INTEGER_VALUE(2), + DOUBLE_VALUE(3), + TIMESTAMP_VALUE(10), + STRING_VALUE(17), + BYTES_VALUE(18), + REFERENCE_VALUE(5), + GEO_POINT_VALUE(8), + ARRAY_VALUE(9), + MAP_VALUE(6), + FIELD_REFERENCE_VALUE(19), + VARIABLE_REFERENCE_VALUE(22), + FUNCTION_VALUE(20), + PIPELINE_VALUE(21), + VALUETYPE_NOT_SET(0); + private final int value; + + private ValueTypeCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static ValueTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ValueTypeCase forNumber(int value) { + switch (value) { + case 11: + return NULL_VALUE; + case 1: + return BOOLEAN_VALUE; + case 2: + return INTEGER_VALUE; + case 3: + return DOUBLE_VALUE; + case 10: + return TIMESTAMP_VALUE; + case 17: + return STRING_VALUE; + case 18: + return BYTES_VALUE; + case 5: + return REFERENCE_VALUE; + case 8: + return GEO_POINT_VALUE; + case 9: + return ARRAY_VALUE; + case 6: + return MAP_VALUE; + case 19: + return FIELD_REFERENCE_VALUE; + case 22: + return VARIABLE_REFERENCE_VALUE; + case 20: + return FUNCTION_VALUE; + case 21: + return PIPELINE_VALUE; + case 0: + return VALUETYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ValueTypeCase getValueTypeCase() { + return ValueTypeCase.forNumber(valueTypeCase_); + } + + 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; + } + + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The enum numeric value on the wire for nullValue. + */ + public int getNullValueValue() { + if (valueTypeCase_ == 11) { + return (java.lang.Integer) valueType_; + } + return 0; + } + + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The nullValue. + */ + public com.google.protobuf.NullValue getNullValue() { + if (valueTypeCase_ == 11) { + com.google.protobuf.NullValue result = + com.google.protobuf.NullValue.forNumber((java.lang.Integer) valueType_); + return result == null ? com.google.protobuf.NullValue.UNRECOGNIZED : result; + } + return com.google.protobuf.NullValue.NULL_VALUE; + } + + 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; + } + + /** + * + * + *
+   * A boolean value.
+   * 
+ * + * bool boolean_value = 1; + * + * @return The booleanValue. + */ + @java.lang.Override + public boolean getBooleanValue() { + if (valueTypeCase_ == 1) { + return (java.lang.Boolean) valueType_; + } + return false; + } + + 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; + } + + /** + * + * + *
+   * An integer value.
+   * 
+ * + * int64 integer_value = 2; + * + * @return The integerValue. + */ + @java.lang.Override + public long getIntegerValue() { + if (valueTypeCase_ == 2) { + return (java.lang.Long) valueType_; + } + return 0L; + } + + 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; + } + + /** + * + * + *
+   * A double value.
+   * 
+ * + * double double_value = 3; + * + * @return The doubleValue. + */ + @java.lang.Override + public double getDoubleValue() { + if (valueTypeCase_ == 3) { + return (java.lang.Double) valueType_; + } + return 0D; + } + + public static final int TIMESTAMP_VALUE_FIELD_NUMBER = 10; + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return Whether the timestampValue field is set. + */ + @java.lang.Override + public boolean hasTimestampValue() { + return valueTypeCase_ == 10; + } + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return The timestampValue. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getTimestampValue() { + if (valueTypeCase_ == 10) { + return (com.google.protobuf.Timestamp) valueType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() { + if (valueTypeCase_ == 10) { + return (com.google.protobuf.Timestamp) valueType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + 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; + } + + /** + * + * + *
+   * 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 The stringValue. + */ + public java.lang.String getStringValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 17) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 17) { + valueType_ = s; + } + return s; + } + } + + /** + * + * + *
+   * 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 The bytes for stringValue. + */ + public com.google.protobuf.ByteString getStringValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 17) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 17) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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; + } + + /** + * + * + *
+   * 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 The bytesValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBytesValue() { + if (valueTypeCase_ == 18) { + return (com.google.protobuf.ByteString) valueType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + 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; + } + + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return The referenceValue. + */ + public java.lang.String getReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 5) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 5) { + valueType_ = s; + } + return s; + } + } + + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return The bytes for referenceValue. + */ + public com.google.protobuf.ByteString getReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 5) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 5) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int GEO_POINT_VALUE_FIELD_NUMBER = 8; + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return Whether the geoPointValue field is set. + */ + @java.lang.Override + public boolean hasGeoPointValue() { + return valueTypeCase_ == 8; + } + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return The geoPointValue. + */ + @java.lang.Override + public com.google.type.LatLng getGeoPointValue() { + if (valueTypeCase_ == 8) { + return (com.google.type.LatLng) valueType_; + } + return com.google.type.LatLng.getDefaultInstance(); + } + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + @java.lang.Override + public com.google.type.LatLngOrBuilder getGeoPointValueOrBuilder() { + if (valueTypeCase_ == 8) { + return (com.google.type.LatLng) valueType_; + } + return com.google.type.LatLng.getDefaultInstance(); + } + + public static final int ARRAY_VALUE_FIELD_NUMBER = 9; + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return Whether the arrayValue field is set. + */ + @java.lang.Override + public boolean hasArrayValue() { + return valueTypeCase_ == 9; + } + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getArrayValue() { + if (valueTypeCase_ == 9) { + return (com.google.firestore.v1.ArrayValue) valueType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getArrayValueOrBuilder() { + if (valueTypeCase_ == 9) { + return (com.google.firestore.v1.ArrayValue) valueType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + + public static final int MAP_VALUE_FIELD_NUMBER = 6; + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return Whether the mapValue field is set. + */ + @java.lang.Override + public boolean hasMapValue() { + return valueTypeCase_ == 6; + } + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return The mapValue. + */ + @java.lang.Override + public com.google.firestore.v1.MapValue getMapValue() { + if (valueTypeCase_ == 6) { + return (com.google.firestore.v1.MapValue) valueType_; + } + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + @java.lang.Override + public com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder() { + if (valueTypeCase_ == 6) { + return (com.google.firestore.v1.MapValue) valueType_; + } + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } + + public static final int FIELD_REFERENCE_VALUE_FIELD_NUMBER = 19; + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + public boolean hasFieldReferenceValue() { + return valueTypeCase_ == 19; + } + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + public java.lang.String getFieldReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 19) { + valueType_ = s; + } + return s; + } + } + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + public com.google.protobuf.ByteString getFieldReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 19) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int VARIABLE_REFERENCE_VALUE_FIELD_NUMBER = 22; + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return Whether the variableReferenceValue field is set. + */ + public boolean hasVariableReferenceValue() { + return valueTypeCase_ == 22; + } + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return The variableReferenceValue. + */ + public java.lang.String getVariableReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 22) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 22) { + valueType_ = s; + } + return s; + } + } + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return The bytes for variableReferenceValue. + */ + public com.google.protobuf.ByteString getVariableReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 22) { + ref = valueType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 22) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FUNCTION_VALUE_FIELD_NUMBER = 20; + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + @java.lang.Override + public boolean hasFunctionValue() { + return valueTypeCase_ == 20; + } + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + @java.lang.Override + public com.google.firestore.v1.Function getFunctionValue() { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + @java.lang.Override + public com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder() { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + + public static final int PIPELINE_VALUE_FIELD_NUMBER = 21; + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + @java.lang.Override + public boolean hasPipelineValue() { + return valueTypeCase_ == 21; + } + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipelineValue() { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder() { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (valueTypeCase_ == 1) { + output.writeBool(1, (boolean) ((java.lang.Boolean) valueType_)); + } + if (valueTypeCase_ == 2) { + output.writeInt64(2, (long) ((java.lang.Long) valueType_)); + } + if (valueTypeCase_ == 3) { + output.writeDouble(3, (double) ((java.lang.Double) valueType_)); + } + if (valueTypeCase_ == 5) { + com.google.protobuf.GeneratedMessage.writeString(output, 5, valueType_); + } + if (valueTypeCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.MapValue) valueType_); + } + if (valueTypeCase_ == 8) { + output.writeMessage(8, (com.google.type.LatLng) valueType_); + } + if (valueTypeCase_ == 9) { + output.writeMessage(9, (com.google.firestore.v1.ArrayValue) valueType_); + } + if (valueTypeCase_ == 10) { + output.writeMessage(10, (com.google.protobuf.Timestamp) valueType_); + } + if (valueTypeCase_ == 11) { + output.writeEnum(11, ((java.lang.Integer) valueType_)); + } + if (valueTypeCase_ == 17) { + com.google.protobuf.GeneratedMessage.writeString(output, 17, valueType_); + } + if (valueTypeCase_ == 18) { + output.writeBytes(18, (com.google.protobuf.ByteString) valueType_); + } + if (valueTypeCase_ == 19) { + com.google.protobuf.GeneratedMessage.writeString(output, 19, valueType_); + } + if (valueTypeCase_ == 20) { + output.writeMessage(20, (com.google.firestore.v1.Function) valueType_); + } + if (valueTypeCase_ == 21) { + output.writeMessage(21, (com.google.firestore.v1.Pipeline) valueType_); + } + if (valueTypeCase_ == 22) { + com.google.protobuf.GeneratedMessage.writeString(output, 22, valueType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (valueTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeBoolSize( + 1, (boolean) ((java.lang.Boolean) valueType_)); + } + if (valueTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeInt64Size( + 2, (long) ((java.lang.Long) valueType_)); + } + if (valueTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeDoubleSize( + 3, (double) ((java.lang.Double) valueType_)); + } + if (valueTypeCase_ == 5) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(5, valueType_); + } + if (valueTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.MapValue) valueType_); + } + if (valueTypeCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 8, (com.google.type.LatLng) valueType_); + } + if (valueTypeCase_ == 9) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 9, (com.google.firestore.v1.ArrayValue) valueType_); + } + if (valueTypeCase_ == 10) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 10, (com.google.protobuf.Timestamp) valueType_); + } + if (valueTypeCase_ == 11) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 11, ((java.lang.Integer) valueType_)); + } + if (valueTypeCase_ == 17) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(17, valueType_); + } + if (valueTypeCase_ == 18) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 18, (com.google.protobuf.ByteString) valueType_); + } + if (valueTypeCase_ == 19) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(19, valueType_); + } + if (valueTypeCase_ == 20) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 20, (com.google.firestore.v1.Function) valueType_); + } + if (valueTypeCase_ == 21) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 21, (com.google.firestore.v1.Pipeline) valueType_); + } + if (valueTypeCase_ == 22) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(22, valueType_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Value)) { + return super.equals(obj); + } + com.google.firestore.v1.Value other = (com.google.firestore.v1.Value) obj; + + if (!getValueTypeCase().equals(other.getValueTypeCase())) return false; + switch (valueTypeCase_) { + case 11: + if (getNullValueValue() != other.getNullValueValue()) return false; + break; + case 1: + if (getBooleanValue() != other.getBooleanValue()) return false; + break; + case 2: + if (getIntegerValue() != other.getIntegerValue()) return false; + break; + case 3: + if (java.lang.Double.doubleToLongBits(getDoubleValue()) + != java.lang.Double.doubleToLongBits(other.getDoubleValue())) return false; + break; + case 10: + if (!getTimestampValue().equals(other.getTimestampValue())) return false; + break; + case 17: + if (!getStringValue().equals(other.getStringValue())) return false; + break; + case 18: + if (!getBytesValue().equals(other.getBytesValue())) return false; + break; + case 5: + if (!getReferenceValue().equals(other.getReferenceValue())) return false; + break; + case 8: + if (!getGeoPointValue().equals(other.getGeoPointValue())) return false; + break; + case 9: + if (!getArrayValue().equals(other.getArrayValue())) return false; + break; + case 6: + if (!getMapValue().equals(other.getMapValue())) return false; + break; + case 19: + if (!getFieldReferenceValue().equals(other.getFieldReferenceValue())) return false; + break; + case 22: + if (!getVariableReferenceValue().equals(other.getVariableReferenceValue())) return false; + break; + case 20: + if (!getFunctionValue().equals(other.getFunctionValue())) return false; + break; + case 21: + if (!getPipelineValue().equals(other.getPipelineValue())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + switch (valueTypeCase_) { + case 11: + hash = (37 * hash) + NULL_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getNullValueValue(); + break; + case 1: + hash = (37 * hash) + BOOLEAN_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getBooleanValue()); + break; + case 2: + hash = (37 * hash) + INTEGER_VALUE_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getIntegerValue()); + break; + case 3: + hash = (37 * hash) + DOUBLE_VALUE_FIELD_NUMBER; + hash = + (53 * hash) + + com.google.protobuf.Internal.hashLong( + java.lang.Double.doubleToLongBits(getDoubleValue())); + break; + case 10: + hash = (37 * hash) + TIMESTAMP_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getTimestampValue().hashCode(); + break; + case 17: + hash = (37 * hash) + STRING_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getStringValue().hashCode(); + break; + case 18: + hash = (37 * hash) + BYTES_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getBytesValue().hashCode(); + break; + case 5: + hash = (37 * hash) + REFERENCE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getReferenceValue().hashCode(); + break; + case 8: + hash = (37 * hash) + GEO_POINT_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getGeoPointValue().hashCode(); + break; + case 9: + hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getArrayValue().hashCode(); + break; + case 6: + hash = (37 * hash) + MAP_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getMapValue().hashCode(); + break; + case 19: + hash = (37 * hash) + FIELD_REFERENCE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getFieldReferenceValue().hashCode(); + break; + case 22: + hash = (37 * hash) + VARIABLE_REFERENCE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getVariableReferenceValue().hashCode(); + break; + case 20: + hash = (37 * hash) + FUNCTION_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getFunctionValue().hashCode(); + break; + case 21: + hash = (37 * hash) + PIPELINE_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getPipelineValue().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Value parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Value parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Value parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Value parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Value parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Value parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Value parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Value parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Value parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Value parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Value parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Value parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Value prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A message that can hold any of the supported value types.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Value} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Value) + com.google.firestore.v1.ValueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Value_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Value_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Value.class, com.google.firestore.v1.Value.Builder.class); + } + + // Construct using com.google.firestore.v1.Value.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (timestampValueBuilder_ != null) { + timestampValueBuilder_.clear(); + } + if (geoPointValueBuilder_ != null) { + geoPointValueBuilder_.clear(); + } + if (arrayValueBuilder_ != null) { + arrayValueBuilder_.clear(); + } + if (mapValueBuilder_ != null) { + mapValueBuilder_.clear(); + } + if (functionValueBuilder_ != null) { + functionValueBuilder_.clear(); + } + if (pipelineValueBuilder_ != null) { + pipelineValueBuilder_.clear(); + } + valueTypeCase_ = 0; + valueType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.DocumentProto + .internal_static_google_firestore_v1_Value_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Value getDefaultInstanceForType() { + return com.google.firestore.v1.Value.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Value build() { + com.google.firestore.v1.Value result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Value buildPartial() { + com.google.firestore.v1.Value result = new com.google.firestore.v1.Value(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.firestore.v1.Value result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.Value result) { + result.valueTypeCase_ = valueTypeCase_; + result.valueType_ = this.valueType_; + if (valueTypeCase_ == 10 && timestampValueBuilder_ != null) { + result.valueType_ = timestampValueBuilder_.build(); + } + if (valueTypeCase_ == 8 && geoPointValueBuilder_ != null) { + result.valueType_ = geoPointValueBuilder_.build(); + } + if (valueTypeCase_ == 9 && arrayValueBuilder_ != null) { + result.valueType_ = arrayValueBuilder_.build(); + } + if (valueTypeCase_ == 6 && mapValueBuilder_ != null) { + result.valueType_ = mapValueBuilder_.build(); + } + if (valueTypeCase_ == 20 && functionValueBuilder_ != null) { + result.valueType_ = functionValueBuilder_.build(); + } + if (valueTypeCase_ == 21 && pipelineValueBuilder_ != null) { + result.valueType_ = pipelineValueBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Value) { + return mergeFrom((com.google.firestore.v1.Value) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Value other) { + if (other == com.google.firestore.v1.Value.getDefaultInstance()) return this; + switch (other.getValueTypeCase()) { + case NULL_VALUE: + { + setNullValueValue(other.getNullValueValue()); + break; + } + case BOOLEAN_VALUE: + { + setBooleanValue(other.getBooleanValue()); + break; + } + case INTEGER_VALUE: + { + setIntegerValue(other.getIntegerValue()); + break; + } + case DOUBLE_VALUE: + { + setDoubleValue(other.getDoubleValue()); + break; + } + case TIMESTAMP_VALUE: + { + mergeTimestampValue(other.getTimestampValue()); + break; + } + case STRING_VALUE: + { + valueTypeCase_ = 17; + valueType_ = other.valueType_; + onChanged(); + break; + } + case BYTES_VALUE: + { + setBytesValue(other.getBytesValue()); + break; + } + case REFERENCE_VALUE: + { + valueTypeCase_ = 5; + valueType_ = other.valueType_; + onChanged(); + break; + } + case GEO_POINT_VALUE: + { + mergeGeoPointValue(other.getGeoPointValue()); + break; + } + case ARRAY_VALUE: + { + mergeArrayValue(other.getArrayValue()); + break; + } + case MAP_VALUE: + { + mergeMapValue(other.getMapValue()); + break; + } + case FIELD_REFERENCE_VALUE: + { + valueTypeCase_ = 19; + valueType_ = other.valueType_; + onChanged(); + break; + } + case VARIABLE_REFERENCE_VALUE: + { + valueTypeCase_ = 22; + valueType_ = other.valueType_; + onChanged(); + break; + } + case FUNCTION_VALUE: + { + mergeFunctionValue(other.getFunctionValue()); + break; + } + case PIPELINE_VALUE: + { + mergePipelineValue(other.getPipelineValue()); + break; + } + case VALUETYPE_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: + { + valueType_ = input.readBool(); + valueTypeCase_ = 1; + break; + } // case 8 + case 16: + { + valueType_ = input.readInt64(); + valueTypeCase_ = 2; + break; + } // case 16 + case 25: + { + valueType_ = input.readDouble(); + valueTypeCase_ = 3; + break; + } // case 25 + case 42: + { + java.lang.String s = input.readStringRequireUtf8(); + valueTypeCase_ = 5; + valueType_ = s; + break; + } // case 42 + case 50: + { + input.readMessage( + internalGetMapValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 6; + break; + } // case 50 + case 66: + { + input.readMessage( + internalGetGeoPointValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 8; + break; + } // case 66 + case 74: + { + input.readMessage( + internalGetArrayValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 9; + break; + } // case 74 + case 82: + { + input.readMessage( + internalGetTimestampValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 10; + break; + } // case 82 + case 88: + { + int rawValue = input.readEnum(); + valueTypeCase_ = 11; + valueType_ = rawValue; + break; + } // case 88 + case 138: + { + java.lang.String s = input.readStringRequireUtf8(); + valueTypeCase_ = 17; + valueType_ = s; + break; + } // case 138 + case 146: + { + valueType_ = input.readBytes(); + valueTypeCase_ = 18; + break; + } // case 146 + case 154: + { + java.lang.String s = input.readStringRequireUtf8(); + valueTypeCase_ = 19; + valueType_ = s; + break; + } // case 154 + case 162: + { + input.readMessage( + internalGetFunctionValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 20; + break; + } // case 162 + case 170: + { + input.readMessage( + internalGetPipelineValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 21; + break; + } // case 170 + case 178: + { + java.lang.String s = input.readStringRequireUtf8(); + valueTypeCase_ = 22; + valueType_ = s; + break; + } // case 178 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int valueTypeCase_ = 0; + private java.lang.Object valueType_; + + public ValueTypeCase getValueTypeCase() { + return ValueTypeCase.forNumber(valueTypeCase_); + } + + public Builder clearValueType() { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + /** + * + * + *
+     * 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; + } + + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The enum numeric value on the wire for nullValue. + */ + @java.lang.Override + public int getNullValueValue() { + if (valueTypeCase_ == 11) { + return ((java.lang.Integer) valueType_).intValue(); + } + return 0; + } + + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @param value The enum numeric value on the wire for nullValue to set. + * @return This builder for chaining. + */ + public Builder setNullValueValue(int value) { + valueTypeCase_ = 11; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The nullValue. + */ + @java.lang.Override + public com.google.protobuf.NullValue getNullValue() { + if (valueTypeCase_ == 11) { + com.google.protobuf.NullValue result = + com.google.protobuf.NullValue.forNumber((java.lang.Integer) valueType_); + return result == null ? com.google.protobuf.NullValue.UNRECOGNIZED : result; + } + return com.google.protobuf.NullValue.NULL_VALUE; + } + + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @param value The nullValue to set. + * @return This builder for chaining. + */ + public Builder setNullValue(com.google.protobuf.NullValue value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 11; + valueType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * A null value.
+     * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return This builder for chaining. + */ + public Builder clearNullValue() { + if (valueTypeCase_ == 11) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A boolean value.
+     * 
+ * + * bool boolean_value = 1; + * + * @return Whether the booleanValue field is set. + */ + public boolean hasBooleanValue() { + return valueTypeCase_ == 1; + } + + /** + * + * + *
+     * A boolean value.
+     * 
+ * + * bool boolean_value = 1; + * + * @return The booleanValue. + */ + public boolean getBooleanValue() { + if (valueTypeCase_ == 1) { + return (java.lang.Boolean) valueType_; + } + return false; + } + + /** + * + * + *
+     * A boolean value.
+     * 
+ * + * bool boolean_value = 1; + * + * @param value The booleanValue to set. + * @return This builder for chaining. + */ + public Builder setBooleanValue(boolean value) { + + valueTypeCase_ = 1; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A boolean value.
+     * 
+ * + * bool boolean_value = 1; + * + * @return This builder for chaining. + */ + public Builder clearBooleanValue() { + if (valueTypeCase_ == 1) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An integer value.
+     * 
+ * + * int64 integer_value = 2; + * + * @return Whether the integerValue field is set. + */ + public boolean hasIntegerValue() { + return valueTypeCase_ == 2; + } + + /** + * + * + *
+     * An integer value.
+     * 
+ * + * int64 integer_value = 2; + * + * @return The integerValue. + */ + public long getIntegerValue() { + if (valueTypeCase_ == 2) { + return (java.lang.Long) valueType_; + } + return 0L; + } + + /** + * + * + *
+     * An integer value.
+     * 
+ * + * int64 integer_value = 2; + * + * @param value The integerValue to set. + * @return This builder for chaining. + */ + public Builder setIntegerValue(long value) { + + valueTypeCase_ = 2; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * An integer value.
+     * 
+ * + * int64 integer_value = 2; + * + * @return This builder for chaining. + */ + public Builder clearIntegerValue() { + if (valueTypeCase_ == 2) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A double value.
+     * 
+ * + * double double_value = 3; + * + * @return Whether the doubleValue field is set. + */ + public boolean hasDoubleValue() { + return valueTypeCase_ == 3; + } + + /** + * + * + *
+     * A double value.
+     * 
+ * + * double double_value = 3; + * + * @return The doubleValue. + */ + public double getDoubleValue() { + if (valueTypeCase_ == 3) { + return (java.lang.Double) valueType_; + } + return 0D; + } + + /** + * + * + *
+     * A double value.
+     * 
+ * + * double double_value = 3; + * + * @param value The doubleValue to set. + * @return This builder for chaining. + */ + public Builder setDoubleValue(double value) { + + valueTypeCase_ = 3; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A double value.
+     * 
+ * + * double double_value = 3; + * + * @return This builder for chaining. + */ + public Builder clearDoubleValue() { + if (valueTypeCase_ == 3) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + timestampValueBuilder_; + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return Whether the timestampValue field is set. + */ + @java.lang.Override + public boolean hasTimestampValue() { + return valueTypeCase_ == 10; + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return The timestampValue. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getTimestampValue() { + if (timestampValueBuilder_ == null) { + if (valueTypeCase_ == 10) { + return (com.google.protobuf.Timestamp) valueType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (valueTypeCase_ == 10) { + return timestampValueBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public Builder setTimestampValue(com.google.protobuf.Timestamp value) { + if (timestampValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + timestampValueBuilder_.setMessage(value); + } + valueTypeCase_ = 10; + return this; + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public Builder setTimestampValue(com.google.protobuf.Timestamp.Builder builderForValue) { + if (timestampValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + timestampValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 10; + return this; + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public Builder mergeTimestampValue(com.google.protobuf.Timestamp value) { + if (timestampValueBuilder_ == null) { + if (valueTypeCase_ == 10 + && valueType_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + valueType_ = + com.google.protobuf.Timestamp.newBuilder((com.google.protobuf.Timestamp) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 10) { + timestampValueBuilder_.mergeFrom(value); + } else { + timestampValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 10; + return this; + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public Builder clearTimestampValue() { + if (timestampValueBuilder_ == null) { + if (valueTypeCase_ == 10) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 10) { + valueTypeCase_ = 0; + valueType_ = null; + } + timestampValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public com.google.protobuf.Timestamp.Builder getTimestampValueBuilder() { + return internalGetTimestampValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder() { + if ((valueTypeCase_ == 10) && (timestampValueBuilder_ != null)) { + return timestampValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 10) { + return (com.google.protobuf.Timestamp) valueType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A timestamp value.
+     *
+     * Precise only to microseconds. When stored, any additional precision is
+     * rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetTimestampValueFieldBuilder() { + if (timestampValueBuilder_ == null) { + if (!(valueTypeCase_ == 10)) { + valueType_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + timestampValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 10; + onChanged(); + 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; + } + + /** + * + * + *
+     * 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 The stringValue. + */ + @java.lang.Override + public java.lang.String getStringValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 17) { + ref = valueType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 17) { + valueType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * 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 The bytes for stringValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStringValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 17) { + ref = valueType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 17) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * 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; + * + * @param value The stringValue to set. + * @return This builder for chaining. + */ + public Builder setStringValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 17; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * 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 This builder for chaining. + */ + public Builder clearStringValue() { + if (valueTypeCase_ == 17) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * 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; + * + * @param value The bytes for stringValue to set. + * @return This builder for chaining. + */ + public Builder setStringValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueTypeCase_ = 17; + valueType_ = value; + onChanged(); + 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; + } + + /** + * + * + *
+     * 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 The bytesValue. + */ + public com.google.protobuf.ByteString getBytesValue() { + if (valueTypeCase_ == 18) { + return (com.google.protobuf.ByteString) valueType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * A bytes value.
+     *
+     * Must not exceed 1 MiB - 89 bytes.
+     * Only the first 1,500 bytes are considered by queries.
+     * 
+ * + * bytes bytes_value = 18; + * + * @param value The bytesValue to set. + * @return This builder for chaining. + */ + public Builder setBytesValue(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 18; + valueType_ = value; + onChanged(); + 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 This builder for chaining. + */ + public Builder clearBytesValue() { + if (valueTypeCase_ == 18) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + 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; + } + + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @return The referenceValue. + */ + @java.lang.Override + public java.lang.String getReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 5) { + ref = valueType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 5) { + valueType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @return The bytes for referenceValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 5) { + ref = valueType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 5) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @param value The referenceValue to set. + * @return This builder for chaining. + */ + public Builder setReferenceValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 5; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @return This builder for chaining. + */ + public Builder clearReferenceValue() { + if (valueTypeCase_ == 5) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A reference to a document. For example:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string reference_value = 5; + * + * @param value The bytes for referenceValue to set. + * @return This builder for chaining. + */ + public Builder setReferenceValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueTypeCase_ = 5; + valueType_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder> + geoPointValueBuilder_; + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return Whether the geoPointValue field is set. + */ + @java.lang.Override + public boolean hasGeoPointValue() { + return valueTypeCase_ == 8; + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return The geoPointValue. + */ + @java.lang.Override + public com.google.type.LatLng getGeoPointValue() { + if (geoPointValueBuilder_ == null) { + if (valueTypeCase_ == 8) { + return (com.google.type.LatLng) valueType_; + } + return com.google.type.LatLng.getDefaultInstance(); + } else { + if (valueTypeCase_ == 8) { + return geoPointValueBuilder_.getMessage(); + } + return com.google.type.LatLng.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + public Builder setGeoPointValue(com.google.type.LatLng value) { + if (geoPointValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + geoPointValueBuilder_.setMessage(value); + } + valueTypeCase_ = 8; + return this; + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + public Builder setGeoPointValue(com.google.type.LatLng.Builder builderForValue) { + if (geoPointValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + geoPointValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 8; + return this; + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + public Builder mergeGeoPointValue(com.google.type.LatLng value) { + if (geoPointValueBuilder_ == null) { + if (valueTypeCase_ == 8 && valueType_ != com.google.type.LatLng.getDefaultInstance()) { + valueType_ = + com.google.type.LatLng.newBuilder((com.google.type.LatLng) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 8) { + geoPointValueBuilder_.mergeFrom(value); + } else { + geoPointValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 8; + return this; + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + public Builder clearGeoPointValue() { + if (geoPointValueBuilder_ == null) { + if (valueTypeCase_ == 8) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 8) { + valueTypeCase_ = 0; + valueType_ = null; + } + geoPointValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + public com.google.type.LatLng.Builder getGeoPointValueBuilder() { + return internalGetGeoPointValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + @java.lang.Override + public com.google.type.LatLngOrBuilder getGeoPointValueOrBuilder() { + if ((valueTypeCase_ == 8) && (geoPointValueBuilder_ != null)) { + return geoPointValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 8) { + return (com.google.type.LatLng) valueType_; + } + return com.google.type.LatLng.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A geo point value representing a point on the surface of Earth.
+     * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder> + internalGetGeoPointValueFieldBuilder() { + if (geoPointValueBuilder_ == null) { + if (!(valueTypeCase_ == 8)) { + valueType_ = com.google.type.LatLng.getDefaultInstance(); + } + geoPointValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.type.LatLng, + com.google.type.LatLng.Builder, + com.google.type.LatLngOrBuilder>( + (com.google.type.LatLng) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 8; + onChanged(); + return geoPointValueBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + arrayValueBuilder_; + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return Whether the arrayValue field is set. + */ + @java.lang.Override + public boolean hasArrayValue() { + return valueTypeCase_ == 9; + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValue getArrayValue() { + if (arrayValueBuilder_ == null) { + if (valueTypeCase_ == 9) { + return (com.google.firestore.v1.ArrayValue) valueType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } else { + if (valueTypeCase_ == 9) { + return arrayValueBuilder_.getMessage(); + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + public Builder setArrayValue(com.google.firestore.v1.ArrayValue value) { + if (arrayValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + arrayValueBuilder_.setMessage(value); + } + valueTypeCase_ = 9; + return this; + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + public Builder setArrayValue(com.google.firestore.v1.ArrayValue.Builder builderForValue) { + if (arrayValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + arrayValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 9; + return this; + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + public Builder mergeArrayValue(com.google.firestore.v1.ArrayValue value) { + if (arrayValueBuilder_ == null) { + if (valueTypeCase_ == 9 + && valueType_ != com.google.firestore.v1.ArrayValue.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.ArrayValue.newBuilder( + (com.google.firestore.v1.ArrayValue) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 9) { + arrayValueBuilder_.mergeFrom(value); + } else { + arrayValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 9; + return this; + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + public Builder clearArrayValue() { + if (arrayValueBuilder_ == null) { + if (valueTypeCase_ == 9) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 9) { + valueTypeCase_ = 0; + valueType_ = null; + } + arrayValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + public com.google.firestore.v1.ArrayValue.Builder getArrayValueBuilder() { + return internalGetArrayValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + @java.lang.Override + public com.google.firestore.v1.ArrayValueOrBuilder getArrayValueOrBuilder() { + if ((valueTypeCase_ == 9) && (arrayValueBuilder_ != null)) { + return arrayValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 9) { + return (com.google.firestore.v1.ArrayValue) valueType_; + } + return com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An array value.
+     *
+     * Cannot directly contain another array value, though can contain a
+     * map which contains another array.
+     * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder> + internalGetArrayValueFieldBuilder() { + if (arrayValueBuilder_ == null) { + if (!(valueTypeCase_ == 9)) { + valueType_ = com.google.firestore.v1.ArrayValue.getDefaultInstance(); + } + arrayValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.ArrayValue, + com.google.firestore.v1.ArrayValue.Builder, + com.google.firestore.v1.ArrayValueOrBuilder>( + (com.google.firestore.v1.ArrayValue) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 9; + onChanged(); + return arrayValueBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.MapValue, + com.google.firestore.v1.MapValue.Builder, + com.google.firestore.v1.MapValueOrBuilder> + mapValueBuilder_; + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return Whether the mapValue field is set. + */ + @java.lang.Override + public boolean hasMapValue() { + return valueTypeCase_ == 6; + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return The mapValue. + */ + @java.lang.Override + public com.google.firestore.v1.MapValue getMapValue() { + if (mapValueBuilder_ == null) { + if (valueTypeCase_ == 6) { + return (com.google.firestore.v1.MapValue) valueType_; + } + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } else { + if (valueTypeCase_ == 6) { + return mapValueBuilder_.getMessage(); + } + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + public Builder setMapValue(com.google.firestore.v1.MapValue value) { + if (mapValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + mapValueBuilder_.setMessage(value); + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + public Builder setMapValue(com.google.firestore.v1.MapValue.Builder builderForValue) { + if (mapValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + mapValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + public Builder mergeMapValue(com.google.firestore.v1.MapValue value) { + if (mapValueBuilder_ == null) { + if (valueTypeCase_ == 6 + && valueType_ != com.google.firestore.v1.MapValue.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.MapValue.newBuilder( + (com.google.firestore.v1.MapValue) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 6) { + mapValueBuilder_.mergeFrom(value); + } else { + mapValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + public Builder clearMapValue() { + if (mapValueBuilder_ == null) { + if (valueTypeCase_ == 6) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 6) { + valueTypeCase_ = 0; + valueType_ = null; + } + mapValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + public com.google.firestore.v1.MapValue.Builder getMapValueBuilder() { + return internalGetMapValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + @java.lang.Override + public com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder() { + if ((valueTypeCase_ == 6) && (mapValueBuilder_ != null)) { + return mapValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 6) { + return (com.google.firestore.v1.MapValue) valueType_; + } + return com.google.firestore.v1.MapValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A map value.
+     * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.MapValue, + com.google.firestore.v1.MapValue.Builder, + com.google.firestore.v1.MapValueOrBuilder> + internalGetMapValueFieldBuilder() { + if (mapValueBuilder_ == null) { + if (!(valueTypeCase_ == 6)) { + valueType_ = com.google.firestore.v1.MapValue.getDefaultInstance(); + } + mapValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.MapValue, + com.google.firestore.v1.MapValue.Builder, + com.google.firestore.v1.MapValueOrBuilder>( + (com.google.firestore.v1.MapValue) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 6; + onChanged(); + return mapValueBuilder_; + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + @java.lang.Override + public boolean hasFieldReferenceValue() { + return valueTypeCase_ == 19; + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + @java.lang.Override + public java.lang.String getFieldReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 19) { + valueType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getFieldReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 19) { + ref = valueType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 19) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @param value The fieldReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setFieldReferenceValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 19; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @return This builder for chaining. + */ + public Builder clearFieldReferenceValue() { + if (valueTypeCase_ == 19) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Value which references a field.
+     *
+     * This is considered relative (vs absolute) since it only refers to a field
+     * and not a field within a particular document.
+     *
+     * **Requires:**
+     *
+     * * Must follow [field reference][FieldReference.field_path] limitations.
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * string field_reference_value = 19; + * + * @param value The bytes for fieldReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setFieldReferenceValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueTypeCase_ = 19; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @return Whether the variableReferenceValue field is set. + */ + @java.lang.Override + public boolean hasVariableReferenceValue() { + return valueTypeCase_ == 22; + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @return The variableReferenceValue. + */ + @java.lang.Override + public java.lang.String getVariableReferenceValue() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 22) { + ref = valueType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (valueTypeCase_ == 22) { + valueType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @return The bytes for variableReferenceValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getVariableReferenceValueBytes() { + java.lang.Object ref = ""; + if (valueTypeCase_ == 22) { + ref = valueType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (valueTypeCase_ == 22) { + valueType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @param value The variableReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setVariableReferenceValue(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 22; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @return This builder for chaining. + */ + public Builder clearVariableReferenceValue() { + if (valueTypeCase_ == 22) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Pointer to a variable defined elsewhere in a pipeline.
+     *
+     * Unlike `field_reference_value` which references a field within a
+     * document, this refers to a variable, defined in a separate namespace than
+     * the fields of a document.
+     * 
+ * + * string variable_reference_value = 22; + * + * @param value The bytes for variableReferenceValue to set. + * @return This builder for chaining. + */ + public Builder setVariableReferenceValueBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + valueTypeCase_ = 22; + valueType_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder> + functionValueBuilder_; + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + @java.lang.Override + public boolean hasFunctionValue() { + return valueTypeCase_ == 20; + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + @java.lang.Override + public com.google.firestore.v1.Function getFunctionValue() { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } else { + if (valueTypeCase_ == 20) { + return functionValueBuilder_.getMessage(); + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder setFunctionValue(com.google.firestore.v1.Function value) { + if (functionValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + functionValueBuilder_.setMessage(value); + } + valueTypeCase_ = 20; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder setFunctionValue(com.google.firestore.v1.Function.Builder builderForValue) { + if (functionValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + functionValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 20; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder mergeFunctionValue(com.google.firestore.v1.Function value) { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20 + && valueType_ != com.google.firestore.v1.Function.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.Function.newBuilder( + (com.google.firestore.v1.Function) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 20) { + functionValueBuilder_.mergeFrom(value); + } else { + functionValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 20; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public Builder clearFunctionValue() { + if (functionValueBuilder_ == null) { + if (valueTypeCase_ == 20) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 20) { + valueTypeCase_ = 0; + valueType_ = null; + } + functionValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + public com.google.firestore.v1.Function.Builder getFunctionValueBuilder() { + return internalGetFunctionValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + @java.lang.Override + public com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder() { + if ((valueTypeCase_ == 20) && (functionValueBuilder_ != null)) { + return functionValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 20) { + return (com.google.firestore.v1.Function) valueType_; + } + return com.google.firestore.v1.Function.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value that represents an unevaluated expression.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder> + internalGetFunctionValueFieldBuilder() { + if (functionValueBuilder_ == null) { + if (!(valueTypeCase_ == 20)) { + valueType_ = com.google.firestore.v1.Function.getDefaultInstance(); + } + functionValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Function, + com.google.firestore.v1.Function.Builder, + com.google.firestore.v1.FunctionOrBuilder>( + (com.google.firestore.v1.Function) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 20; + onChanged(); + return functionValueBuilder_; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + pipelineValueBuilder_; + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + @java.lang.Override + public boolean hasPipelineValue() { + return valueTypeCase_ == 21; + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + @java.lang.Override + public com.google.firestore.v1.Pipeline getPipelineValue() { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } else { + if (valueTypeCase_ == 21) { + return pipelineValueBuilder_.getMessage(); + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder setPipelineValue(com.google.firestore.v1.Pipeline value) { + if (pipelineValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + pipelineValueBuilder_.setMessage(value); + } + valueTypeCase_ = 21; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder setPipelineValue(com.google.firestore.v1.Pipeline.Builder builderForValue) { + if (pipelineValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + pipelineValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 21; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder mergePipelineValue(com.google.firestore.v1.Pipeline value) { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21 + && valueType_ != com.google.firestore.v1.Pipeline.getDefaultInstance()) { + valueType_ = + com.google.firestore.v1.Pipeline.newBuilder( + (com.google.firestore.v1.Pipeline) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 21) { + pipelineValueBuilder_.mergeFrom(value); + } else { + pipelineValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 21; + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public Builder clearPipelineValue() { + if (pipelineValueBuilder_ == null) { + if (valueTypeCase_ == 21) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 21) { + valueTypeCase_ = 0; + valueType_ = null; + } + pipelineValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + public com.google.firestore.v1.Pipeline.Builder getPipelineValueBuilder() { + return internalGetPipelineValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + @java.lang.Override + public com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder() { + if ((valueTypeCase_ == 21) && (pipelineValueBuilder_ != null)) { + return pipelineValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 21) { + return (com.google.firestore.v1.Pipeline) valueType_; + } + return com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value that represents an unevaluated pipeline.
+     *
+     * **Requires:**
+     *
+     * * Not allowed to be used when writing documents.
+     * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder> + internalGetPipelineValueFieldBuilder() { + if (pipelineValueBuilder_ == null) { + if (!(valueTypeCase_ == 21)) { + valueType_ = com.google.firestore.v1.Pipeline.getDefaultInstance(); + } + pipelineValueBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Pipeline, + com.google.firestore.v1.Pipeline.Builder, + com.google.firestore.v1.PipelineOrBuilder>( + (com.google.firestore.v1.Pipeline) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 21; + onChanged(); + return pipelineValueBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Value) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Value) + private static final com.google.firestore.v1.Value DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Value(); + } + + public static com.google.firestore.v1.Value getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Value parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Value getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java new file mode 100644 index 000000000000..e2f5d15eca26 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/ValueOrBuilder.java @@ -0,0 +1,653 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/document.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface ValueOrBuilder + extends + // @@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(); + + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The enum numeric value on the wire for nullValue. + */ + int getNullValueValue(); + + /** + * + * + *
+   * A null value.
+   * 
+ * + * .google.protobuf.NullValue null_value = 11; + * + * @return The nullValue. + */ + com.google.protobuf.NullValue getNullValue(); + + /** + * + * + *
+   * A boolean value.
+   * 
+ * + * bool boolean_value = 1; + * + * @return Whether the booleanValue field is set. + */ + boolean hasBooleanValue(); + + /** + * + * + *
+   * A boolean value.
+   * 
+ * + * bool boolean_value = 1; + * + * @return The booleanValue. + */ + boolean getBooleanValue(); + + /** + * + * + *
+   * An integer value.
+   * 
+ * + * int64 integer_value = 2; + * + * @return Whether the integerValue field is set. + */ + boolean hasIntegerValue(); + + /** + * + * + *
+   * An integer value.
+   * 
+ * + * int64 integer_value = 2; + * + * @return The integerValue. + */ + long getIntegerValue(); + + /** + * + * + *
+   * A double value.
+   * 
+ * + * double double_value = 3; + * + * @return Whether the doubleValue field is set. + */ + boolean hasDoubleValue(); + + /** + * + * + *
+   * A double value.
+   * 
+ * + * double double_value = 3; + * + * @return The doubleValue. + */ + double getDoubleValue(); + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return Whether the timestampValue field is set. + */ + boolean hasTimestampValue(); + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return The timestampValue. + */ + com.google.protobuf.Timestamp getTimestampValue(); + + /** + * + * + *
+   * A timestamp value.
+   *
+   * Precise only to microseconds. When stored, any additional precision is
+   * rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + 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(); + + /** + * + * + *
+   * 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 The stringValue. + */ + java.lang.String getStringValue(); + + /** + * + * + *
+   * 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 The bytes for stringValue. + */ + 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(); + + /** + * + * + *
+   * 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 The bytesValue. + */ + 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(); + + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return The referenceValue. + */ + java.lang.String getReferenceValue(); + + /** + * + * + *
+   * A reference to a document. For example:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string reference_value = 5; + * + * @return The bytes for referenceValue. + */ + com.google.protobuf.ByteString getReferenceValueBytes(); + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return Whether the geoPointValue field is set. + */ + boolean hasGeoPointValue(); + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + * + * @return The geoPointValue. + */ + com.google.type.LatLng getGeoPointValue(); + + /** + * + * + *
+   * A geo point value representing a point on the surface of Earth.
+   * 
+ * + * .google.type.LatLng geo_point_value = 8; + */ + com.google.type.LatLngOrBuilder getGeoPointValueOrBuilder(); + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return Whether the arrayValue field is set. + */ + boolean hasArrayValue(); + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + com.google.firestore.v1.ArrayValue getArrayValue(); + + /** + * + * + *
+   * An array value.
+   *
+   * Cannot directly contain another array value, though can contain a
+   * map which contains another array.
+   * 
+ * + * .google.firestore.v1.ArrayValue array_value = 9; + */ + com.google.firestore.v1.ArrayValueOrBuilder getArrayValueOrBuilder(); + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return Whether the mapValue field is set. + */ + boolean hasMapValue(); + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + * + * @return The mapValue. + */ + com.google.firestore.v1.MapValue getMapValue(); + + /** + * + * + *
+   * A map value.
+   * 
+ * + * .google.firestore.v1.MapValue map_value = 6; + */ + com.google.firestore.v1.MapValueOrBuilder getMapValueOrBuilder(); + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return Whether the fieldReferenceValue field is set. + */ + boolean hasFieldReferenceValue(); + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return The fieldReferenceValue. + */ + java.lang.String getFieldReferenceValue(); + + /** + * + * + *
+   * Value which references a field.
+   *
+   * This is considered relative (vs absolute) since it only refers to a field
+   * and not a field within a particular document.
+   *
+   * **Requires:**
+   *
+   * * Must follow [field reference][FieldReference.field_path] limitations.
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * string field_reference_value = 19; + * + * @return The bytes for fieldReferenceValue. + */ + com.google.protobuf.ByteString getFieldReferenceValueBytes(); + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return Whether the variableReferenceValue field is set. + */ + boolean hasVariableReferenceValue(); + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return The variableReferenceValue. + */ + java.lang.String getVariableReferenceValue(); + + /** + * + * + *
+   * Pointer to a variable defined elsewhere in a pipeline.
+   *
+   * Unlike `field_reference_value` which references a field within a
+   * document, this refers to a variable, defined in a separate namespace than
+   * the fields of a document.
+   * 
+ * + * string variable_reference_value = 22; + * + * @return The bytes for variableReferenceValue. + */ + com.google.protobuf.ByteString getVariableReferenceValueBytes(); + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return Whether the functionValue field is set. + */ + boolean hasFunctionValue(); + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + * + * @return The functionValue. + */ + com.google.firestore.v1.Function getFunctionValue(); + + /** + * + * + *
+   * A value that represents an unevaluated expression.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Function function_value = 20; + */ + com.google.firestore.v1.FunctionOrBuilder getFunctionValueOrBuilder(); + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return Whether the pipelineValue field is set. + */ + boolean hasPipelineValue(); + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + * + * @return The pipelineValue. + */ + com.google.firestore.v1.Pipeline getPipelineValue(); + + /** + * + * + *
+   * A value that represents an unevaluated pipeline.
+   *
+   * **Requires:**
+   *
+   * * Not allowed to be used when writing documents.
+   * 
+ * + * .google.firestore.v1.Pipeline pipeline_value = 21; + */ + com.google.firestore.v1.PipelineOrBuilder getPipelineValueOrBuilder(); + + com.google.firestore.v1.Value.ValueTypeCase getValueTypeCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java new file mode 100644 index 000000000000..be73a7a76047 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/Write.java @@ -0,0 +1,2704 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * A write on a document.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.Write} + */ +@com.google.protobuf.Generated +public final class Write extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.Write) + WriteOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "Write"); + } + + // Use Write.newBuilder() to construct. + private Write(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private Write() { + updateTransforms_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto.internal_static_google_firestore_v1_Write_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_Write_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Write.class, com.google.firestore.v1.Write.Builder.class); + } + + private int bitField0_; + private int operationCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object operation_; + + public enum OperationCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + UPDATE(1), + DELETE(2), + TRANSFORM(6), + OPERATION_NOT_SET(0); + private final int value; + + private OperationCase(int value) { + this.value = value; + } + + /** + * @param value The number of the enum to look for. + * @return The enum associated with the given number. + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static OperationCase valueOf(int value) { + return forNumber(value); + } + + public static OperationCase forNumber(int value) { + switch (value) { + case 1: + return UPDATE; + case 2: + return DELETE; + case 6: + return TRANSFORM; + case 0: + return OPERATION_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public OperationCase getOperationCase() { + return OperationCase.forNumber(operationCase_); + } + + public static final int UPDATE_FIELD_NUMBER = 1; + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return Whether the update field is set. + */ + @java.lang.Override + public boolean hasUpdate() { + return operationCase_ == 1; + } + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return The update. + */ + @java.lang.Override + public com.google.firestore.v1.Document getUpdate() { + if (operationCase_ == 1) { + return (com.google.firestore.v1.Document) operation_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getUpdateOrBuilder() { + if (operationCase_ == 1) { + return (com.google.firestore.v1.Document) operation_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + + 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; + } + + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return The delete. + */ + public java.lang.String getDelete() { + java.lang.Object ref = ""; + if (operationCase_ == 2) { + ref = operation_; + } + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (operationCase_ == 2) { + operation_ = s; + } + return s; + } + } + + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return The bytes for delete. + */ + public com.google.protobuf.ByteString getDeleteBytes() { + java.lang.Object ref = ""; + if (operationCase_ == 2) { + ref = operation_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (operationCase_ == 2) { + operation_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TRANSFORM_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return Whether the transform field is set. + */ + @java.lang.Override + public boolean hasTransform() { + return operationCase_ == 6; + } + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return The transform. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform getTransform() { + if (operationCase_ == 6) { + return (com.google.firestore.v1.DocumentTransform) operation_; + } + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransformOrBuilder getTransformOrBuilder() { + if (operationCase_ == 6) { + return (com.google.firestore.v1.DocumentTransform) operation_; + } + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 3; + private com.google.firestore.v1.DocumentMask updateMask_; + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMask getUpdateMask() { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + + public static final int UPDATE_TRANSFORMS_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private java.util.List + updateTransforms_; + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + @java.lang.Override + public java.util.List + getUpdateTransformsList() { + return updateTransforms_; + } + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + @java.lang.Override + public java.util.List + getUpdateTransformsOrBuilderList() { + return updateTransforms_; + } + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + @java.lang.Override + public int getUpdateTransformsCount() { + return updateTransforms_.size(); + } + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransform getUpdateTransforms(int index) { + return updateTransforms_.get(index); + } + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder + getUpdateTransformsOrBuilder(int index) { + return updateTransforms_.get(index); + } + + public static final int CURRENT_DOCUMENT_FIELD_NUMBER = 4; + private com.google.firestore.v1.Precondition currentDocument_; + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + @java.lang.Override + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + @java.lang.Override + public com.google.firestore.v1.Precondition getCurrentDocument() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + @java.lang.Override + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (operationCase_ == 1) { + output.writeMessage(1, (com.google.firestore.v1.Document) operation_); + } + if (operationCase_ == 2) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, operation_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getUpdateMask()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(4, getCurrentDocument()); + } + if (operationCase_ == 6) { + output.writeMessage(6, (com.google.firestore.v1.DocumentTransform) operation_); + } + for (int i = 0; i < updateTransforms_.size(); i++) { + output.writeMessage(7, updateTransforms_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (operationCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.firestore.v1.Document) operation_); + } + if (operationCase_ == 2) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, operation_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getUpdateMask()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getCurrentDocument()); + } + if (operationCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.firestore.v1.DocumentTransform) operation_); + } + for (int i = 0; i < updateTransforms_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, updateTransforms_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.Write)) { + return super.equals(obj); + } + com.google.firestore.v1.Write other = (com.google.firestore.v1.Write) obj; + + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUpdateTransformsList().equals(other.getUpdateTransformsList())) return false; + if (hasCurrentDocument() != other.hasCurrentDocument()) return false; + if (hasCurrentDocument()) { + if (!getCurrentDocument().equals(other.getCurrentDocument())) return false; + } + if (!getOperationCase().equals(other.getOperationCase())) return false; + switch (operationCase_) { + case 1: + if (!getUpdate().equals(other.getUpdate())) return false; + break; + case 2: + if (!getDelete().equals(other.getDelete())) return false; + break; + case 6: + if (!getTransform().equals(other.getTransform())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + if (getUpdateTransformsCount() > 0) { + hash = (37 * hash) + UPDATE_TRANSFORMS_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTransformsList().hashCode(); + } + if (hasCurrentDocument()) { + hash = (37 * hash) + CURRENT_DOCUMENT_FIELD_NUMBER; + hash = (53 * hash) + getCurrentDocument().hashCode(); + } + switch (operationCase_) { + case 1: + hash = (37 * hash) + UPDATE_FIELD_NUMBER; + hash = (53 * hash) + getUpdate().hashCode(); + break; + case 2: + hash = (37 * hash) + DELETE_FIELD_NUMBER; + hash = (53 * hash) + getDelete().hashCode(); + break; + case 6: + hash = (37 * hash) + TRANSFORM_FIELD_NUMBER; + hash = (53 * hash) + getTransform().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.Write parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Write parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Write parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Write parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Write parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.Write parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.Write parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Write parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Write parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Write parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.Write parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.Write parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.Write prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A write on a document.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.Write} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.Write) + com.google.firestore.v1.WriteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_Write_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_Write_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.Write.class, com.google.firestore.v1.Write.Builder.class); + } + + // Construct using com.google.firestore.v1.Write.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetUpdateMaskFieldBuilder(); + internalGetUpdateTransformsFieldBuilder(); + internalGetCurrentDocumentFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (updateBuilder_ != null) { + updateBuilder_.clear(); + } + if (transformBuilder_ != null) { + transformBuilder_.clear(); + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + if (updateTransformsBuilder_ == null) { + updateTransforms_ = java.util.Collections.emptyList(); + } else { + updateTransforms_ = null; + updateTransformsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + operationCase_ = 0; + operation_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_Write_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.Write getDefaultInstanceForType() { + return com.google.firestore.v1.Write.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.Write build() { + com.google.firestore.v1.Write result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.Write buildPartial() { + com.google.firestore.v1.Write result = new com.google.firestore.v1.Write(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.Write result) { + if (updateTransformsBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0)) { + updateTransforms_ = java.util.Collections.unmodifiableList(updateTransforms_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.updateTransforms_ = updateTransforms_; + } else { + result.updateTransforms_ = updateTransformsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.Write result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.currentDocument_ = + currentDocumentBuilder_ == null ? currentDocument_ : currentDocumentBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.firestore.v1.Write result) { + result.operationCase_ = operationCase_; + result.operation_ = this.operation_; + if (operationCase_ == 1 && updateBuilder_ != null) { + result.operation_ = updateBuilder_.build(); + } + if (operationCase_ == 6 && transformBuilder_ != null) { + result.operation_ = transformBuilder_.build(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.Write) { + return mergeFrom((com.google.firestore.v1.Write) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.Write other) { + if (other == com.google.firestore.v1.Write.getDefaultInstance()) return this; + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + if (updateTransformsBuilder_ == null) { + if (!other.updateTransforms_.isEmpty()) { + if (updateTransforms_.isEmpty()) { + updateTransforms_ = other.updateTransforms_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureUpdateTransformsIsMutable(); + updateTransforms_.addAll(other.updateTransforms_); + } + onChanged(); + } + } else { + if (!other.updateTransforms_.isEmpty()) { + if (updateTransformsBuilder_.isEmpty()) { + updateTransformsBuilder_.dispose(); + updateTransformsBuilder_ = null; + updateTransforms_ = other.updateTransforms_; + bitField0_ = (bitField0_ & ~0x00000010); + updateTransformsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetUpdateTransformsFieldBuilder() + : null; + } else { + updateTransformsBuilder_.addAllMessages(other.updateTransforms_); + } + } + } + if (other.hasCurrentDocument()) { + mergeCurrentDocument(other.getCurrentDocument()); + } + switch (other.getOperationCase()) { + case UPDATE: + { + mergeUpdate(other.getUpdate()); + break; + } + case DELETE: + { + operationCase_ = 2; + operation_ = other.operation_; + onChanged(); + break; + } + case TRANSFORM: + { + mergeTransform(other.getTransform()); + break; + } + case OPERATION_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(internalGetUpdateFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 1; + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + operationCase_ = 2; + operation_ = s; + break; + } // case 18 + case 26: + { + input.readMessage( + internalGetUpdateMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetCurrentDocumentFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000020; + break; + } // case 34 + case 50: + { + input.readMessage( + internalGetTransformFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 6; + break; + } // case 50 + case 58: + { + com.google.firestore.v1.DocumentTransform.FieldTransform m = + input.readMessage( + com.google.firestore.v1.DocumentTransform.FieldTransform.parser(), + extensionRegistry); + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + updateTransforms_.add(m); + } else { + updateTransformsBuilder_.addMessage(m); + } + break; + } // case 58 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int operationCase_ = 0; + private java.lang.Object operation_; + + public OperationCase getOperationCase() { + return OperationCase.forNumber(operationCase_); + } + + public Builder clearOperation() { + operationCase_ = 0; + operation_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + updateBuilder_; + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return Whether the update field is set. + */ + @java.lang.Override + public boolean hasUpdate() { + return operationCase_ == 1; + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return The update. + */ + @java.lang.Override + public com.google.firestore.v1.Document getUpdate() { + if (updateBuilder_ == null) { + if (operationCase_ == 1) { + return (com.google.firestore.v1.Document) operation_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } else { + if (operationCase_ == 1) { + return updateBuilder_.getMessage(); + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + public Builder setUpdate(com.google.firestore.v1.Document value) { + if (updateBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + updateBuilder_.setMessage(value); + } + operationCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + public Builder setUpdate(com.google.firestore.v1.Document.Builder builderForValue) { + if (updateBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + updateBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + public Builder mergeUpdate(com.google.firestore.v1.Document value) { + if (updateBuilder_ == null) { + if (operationCase_ == 1 + && operation_ != com.google.firestore.v1.Document.getDefaultInstance()) { + operation_ = + com.google.firestore.v1.Document.newBuilder( + (com.google.firestore.v1.Document) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 1) { + updateBuilder_.mergeFrom(value); + } else { + updateBuilder_.setMessage(value); + } + } + operationCase_ = 1; + return this; + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + public Builder clearUpdate() { + if (updateBuilder_ == null) { + if (operationCase_ == 1) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 1) { + operationCase_ = 0; + operation_ = null; + } + updateBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + public com.google.firestore.v1.Document.Builder getUpdateBuilder() { + return internalGetUpdateFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentOrBuilder getUpdateOrBuilder() { + if ((operationCase_ == 1) && (updateBuilder_ != null)) { + return updateBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 1) { + return (com.google.firestore.v1.Document) operation_; + } + return com.google.firestore.v1.Document.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A document to write.
+     * 
+ * + * .google.firestore.v1.Document update = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder> + internalGetUpdateFieldBuilder() { + if (updateBuilder_ == null) { + if (!(operationCase_ == 1)) { + operation_ = com.google.firestore.v1.Document.getDefaultInstance(); + } + updateBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Document, + com.google.firestore.v1.Document.Builder, + com.google.firestore.v1.DocumentOrBuilder>( + (com.google.firestore.v1.Document) operation_, getParentForChildren(), isClean()); + operation_ = null; + } + operationCase_ = 1; + onChanged(); + 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; + } + + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @return The delete. + */ + @java.lang.Override + public java.lang.String getDelete() { + java.lang.Object ref = ""; + if (operationCase_ == 2) { + ref = operation_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (operationCase_ == 2) { + operation_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @return The bytes for delete. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDeleteBytes() { + java.lang.Object ref = ""; + if (operationCase_ == 2) { + ref = operation_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (operationCase_ == 2) { + operation_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @param value The delete to set. + * @return This builder for chaining. + */ + public Builder setDelete(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + operationCase_ = 2; + operation_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @return This builder for chaining. + */ + public Builder clearDelete() { + if (operationCase_ == 2) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A document name to delete. In the format:
+     * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+     * 
+ * + * string delete = 2; + * + * @param value The bytes for delete to set. + * @return This builder for chaining. + */ + public Builder setDeleteBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + operationCase_ = 2; + operation_ = value; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentTransform, + com.google.firestore.v1.DocumentTransform.Builder, + com.google.firestore.v1.DocumentTransformOrBuilder> + transformBuilder_; + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return Whether the transform field is set. + */ + @java.lang.Override + public boolean hasTransform() { + return operationCase_ == 6; + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return The transform. + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransform getTransform() { + if (transformBuilder_ == null) { + if (operationCase_ == 6) { + return (com.google.firestore.v1.DocumentTransform) operation_; + } + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } else { + if (operationCase_ == 6) { + return transformBuilder_.getMessage(); + } + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + public Builder setTransform(com.google.firestore.v1.DocumentTransform value) { + if (transformBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + transformBuilder_.setMessage(value); + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + public Builder setTransform(com.google.firestore.v1.DocumentTransform.Builder builderForValue) { + if (transformBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + transformBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + public Builder mergeTransform(com.google.firestore.v1.DocumentTransform value) { + if (transformBuilder_ == null) { + if (operationCase_ == 6 + && operation_ != com.google.firestore.v1.DocumentTransform.getDefaultInstance()) { + operation_ = + com.google.firestore.v1.DocumentTransform.newBuilder( + (com.google.firestore.v1.DocumentTransform) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 6) { + transformBuilder_.mergeFrom(value); + } else { + transformBuilder_.setMessage(value); + } + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + public Builder clearTransform() { + if (transformBuilder_ == null) { + if (operationCase_ == 6) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 6) { + operationCase_ = 0; + operation_ = null; + } + transformBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + public com.google.firestore.v1.DocumentTransform.Builder getTransformBuilder() { + return internalGetTransformFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + @java.lang.Override + public com.google.firestore.v1.DocumentTransformOrBuilder getTransformOrBuilder() { + if ((operationCase_ == 6) && (transformBuilder_ != null)) { + return transformBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 6) { + return (com.google.firestore.v1.DocumentTransform) operation_; + } + return com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Applies a transformation to a document.
+     * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentTransform, + com.google.firestore.v1.DocumentTransform.Builder, + com.google.firestore.v1.DocumentTransformOrBuilder> + internalGetTransformFieldBuilder() { + if (transformBuilder_ == null) { + if (!(operationCase_ == 6)) { + operation_ = com.google.firestore.v1.DocumentTransform.getDefaultInstance(); + } + transformBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentTransform, + com.google.firestore.v1.DocumentTransform.Builder, + com.google.firestore.v1.DocumentTransformOrBuilder>( + (com.google.firestore.v1.DocumentTransform) operation_, + getParentForChildren(), + isClean()); + operation_ = null; + } + operationCase_ = 6; + onChanged(); + return transformBuilder_; + } + + private com.google.firestore.v1.DocumentMask updateMask_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + updateMaskBuilder_; + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return The updateMask. + */ + public com.google.firestore.v1.DocumentMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public Builder setUpdateMask(com.google.firestore.v1.DocumentMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public Builder setUpdateMask(com.google.firestore.v1.DocumentMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public Builder mergeUpdateMask(com.google.firestore.v1.DocumentMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && updateMask_ != null + && updateMask_ != com.google.firestore.v1.DocumentMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000008); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public com.google.firestore.v1.DocumentMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetUpdateMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + public com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.firestore.v1.DocumentMask.getDefaultInstance() + : updateMask_; + } + } + + /** + * + * + *
+     * The fields to update in this write.
+     *
+     * This field can be set only when the operation is `update`.
+     * If the mask is not set for an `update` and the document exists, any
+     * existing data will be overwritten.
+     * If the mask is set and the document on the server has fields not covered by
+     * the mask, they are left unchanged.
+     * Fields referenced in the mask, but not present in the input document, are
+     * deleted from the document on the server.
+     * The field paths in this mask must not contain a reserved field name.
+     * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder> + internalGetUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.DocumentMask, + com.google.firestore.v1.DocumentMask.Builder, + com.google.firestore.v1.DocumentMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + private java.util.List + updateTransforms_ = java.util.Collections.emptyList(); + + private void ensureUpdateTransformsIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + updateTransforms_ = + new java.util.ArrayList( + updateTransforms_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + updateTransformsBuilder_; + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public java.util.List + getUpdateTransformsList() { + if (updateTransformsBuilder_ == null) { + return java.util.Collections.unmodifiableList(updateTransforms_); + } else { + return updateTransformsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public int getUpdateTransformsCount() { + if (updateTransformsBuilder_ == null) { + return updateTransforms_.size(); + } else { + return updateTransformsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform getUpdateTransforms(int index) { + if (updateTransformsBuilder_ == null) { + return updateTransforms_.get(index); + } else { + return updateTransformsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder setUpdateTransforms( + int index, com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (updateTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUpdateTransformsIsMutable(); + updateTransforms_.set(index, value); + onChanged(); + } else { + updateTransformsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder setUpdateTransforms( + int index, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + updateTransforms_.set(index, builderForValue.build()); + onChanged(); + } else { + updateTransformsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder addUpdateTransforms( + com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (updateTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUpdateTransformsIsMutable(); + updateTransforms_.add(value); + onChanged(); + } else { + updateTransformsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder addUpdateTransforms( + int index, com.google.firestore.v1.DocumentTransform.FieldTransform value) { + if (updateTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureUpdateTransformsIsMutable(); + updateTransforms_.add(index, value); + onChanged(); + } else { + updateTransformsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder addUpdateTransforms( + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + updateTransforms_.add(builderForValue.build()); + onChanged(); + } else { + updateTransformsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder addUpdateTransforms( + int index, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder builderForValue) { + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + updateTransforms_.add(index, builderForValue.build()); + onChanged(); + } else { + updateTransformsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder addAllUpdateTransforms( + java.lang.Iterable + values) { + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, updateTransforms_); + onChanged(); + } else { + updateTransformsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder clearUpdateTransforms() { + if (updateTransformsBuilder_ == null) { + updateTransforms_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + updateTransformsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public Builder removeUpdateTransforms(int index) { + if (updateTransformsBuilder_ == null) { + ensureUpdateTransformsIsMutable(); + updateTransforms_.remove(index); + onChanged(); + } else { + updateTransformsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + getUpdateTransformsBuilder(int index) { + return internalGetUpdateTransformsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder + getUpdateTransformsOrBuilder(int index) { + if (updateTransformsBuilder_ == null) { + return updateTransforms_.get(index); + } else { + return updateTransformsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public java.util.List< + ? extends com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + getUpdateTransformsOrBuilderList() { + if (updateTransformsBuilder_ != null) { + return updateTransformsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(updateTransforms_); + } + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + addUpdateTransformsBuilder() { + return internalGetUpdateTransformsFieldBuilder() + .addBuilder( + com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public com.google.firestore.v1.DocumentTransform.FieldTransform.Builder + addUpdateTransformsBuilder(int index) { + return internalGetUpdateTransformsFieldBuilder() + .addBuilder( + index, com.google.firestore.v1.DocumentTransform.FieldTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * The transforms to perform after update.
+     *
+     * This field can be set only when the operation is `update`. If present, this
+     * write is equivalent to performing `update` and `transform` to the same
+     * document atomically and in order.
+     * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + public java.util.List + getUpdateTransformsBuilderList() { + return internalGetUpdateTransformsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder> + internalGetUpdateTransformsFieldBuilder() { + if (updateTransformsBuilder_ == null) { + updateTransformsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.DocumentTransform.FieldTransform, + com.google.firestore.v1.DocumentTransform.FieldTransform.Builder, + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder>( + updateTransforms_, + ((bitField0_ & 0x00000010) != 0), + getParentForChildren(), + isClean()); + updateTransforms_ = null; + } + return updateTransformsBuilder_; + } + + private com.google.firestore.v1.Precondition currentDocument_; + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + currentDocumentBuilder_; + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + public boolean hasCurrentDocument() { + return ((bitField0_ & 0x00000020) != 0); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + public com.google.firestore.v1.Precondition getCurrentDocument() { + if (currentDocumentBuilder_ == null) { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } else { + return currentDocumentBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder setCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + currentDocument_ = value; + } else { + currentDocumentBuilder_.setMessage(value); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder setCurrentDocument( + com.google.firestore.v1.Precondition.Builder builderForValue) { + if (currentDocumentBuilder_ == null) { + currentDocument_ = builderForValue.build(); + } else { + currentDocumentBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder mergeCurrentDocument(com.google.firestore.v1.Precondition value) { + if (currentDocumentBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0) + && currentDocument_ != null + && currentDocument_ != com.google.firestore.v1.Precondition.getDefaultInstance()) { + getCurrentDocumentBuilder().mergeFrom(value); + } else { + currentDocument_ = value; + } + } else { + currentDocumentBuilder_.mergeFrom(value); + } + if (currentDocument_ != null) { + bitField0_ |= 0x00000020; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public Builder clearCurrentDocument() { + bitField0_ = (bitField0_ & ~0x00000020); + currentDocument_ = null; + if (currentDocumentBuilder_ != null) { + currentDocumentBuilder_.dispose(); + currentDocumentBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public com.google.firestore.v1.Precondition.Builder getCurrentDocumentBuilder() { + bitField0_ |= 0x00000020; + onChanged(); + return internalGetCurrentDocumentFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + public com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder() { + if (currentDocumentBuilder_ != null) { + return currentDocumentBuilder_.getMessageOrBuilder(); + } else { + return currentDocument_ == null + ? com.google.firestore.v1.Precondition.getDefaultInstance() + : currentDocument_; + } + } + + /** + * + * + *
+     * An optional precondition on the document.
+     *
+     * The write will fail if this is set and not met by the target document.
+     * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder> + internalGetCurrentDocumentFieldBuilder() { + if (currentDocumentBuilder_ == null) { + currentDocumentBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.firestore.v1.Precondition, + com.google.firestore.v1.Precondition.Builder, + com.google.firestore.v1.PreconditionOrBuilder>( + getCurrentDocument(), getParentForChildren(), isClean()); + currentDocument_ = null; + } + return currentDocumentBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.Write) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.Write) + private static final com.google.firestore.v1.Write DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.Write(); + } + + public static com.google.firestore.v1.Write getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Write parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.Write getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java new file mode 100644 index 000000000000..0def186f7176 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteOrBuilder.java @@ -0,0 +1,336 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface WriteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.Write) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return Whether the update field is set. + */ + boolean hasUpdate(); + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + * + * @return The update. + */ + com.google.firestore.v1.Document getUpdate(); + + /** + * + * + *
+   * A document to write.
+   * 
+ * + * .google.firestore.v1.Document update = 1; + */ + 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(); + + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return The delete. + */ + java.lang.String getDelete(); + + /** + * + * + *
+   * A document name to delete. In the format:
+   * `projects/{project_id}/databases/{database_id}/documents/{document_path}`.
+   * 
+ * + * string delete = 2; + * + * @return The bytes for delete. + */ + com.google.protobuf.ByteString getDeleteBytes(); + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return Whether the transform field is set. + */ + boolean hasTransform(); + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + * + * @return The transform. + */ + com.google.firestore.v1.DocumentTransform getTransform(); + + /** + * + * + *
+   * Applies a transformation to a document.
+   * 
+ * + * .google.firestore.v1.DocumentTransform transform = 6; + */ + com.google.firestore.v1.DocumentTransformOrBuilder getTransformOrBuilder(); + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + * + * @return The updateMask. + */ + com.google.firestore.v1.DocumentMask getUpdateMask(); + + /** + * + * + *
+   * The fields to update in this write.
+   *
+   * This field can be set only when the operation is `update`.
+   * If the mask is not set for an `update` and the document exists, any
+   * existing data will be overwritten.
+   * If the mask is set and the document on the server has fields not covered by
+   * the mask, they are left unchanged.
+   * Fields referenced in the mask, but not present in the input document, are
+   * deleted from the document on the server.
+   * The field paths in this mask must not contain a reserved field name.
+   * 
+ * + * .google.firestore.v1.DocumentMask update_mask = 3; + */ + com.google.firestore.v1.DocumentMaskOrBuilder getUpdateMaskOrBuilder(); + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + java.util.List + getUpdateTransformsList(); + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + com.google.firestore.v1.DocumentTransform.FieldTransform getUpdateTransforms(int index); + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + int getUpdateTransformsCount(); + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + java.util.List + getUpdateTransformsOrBuilderList(); + + /** + * + * + *
+   * The transforms to perform after update.
+   *
+   * This field can be set only when the operation is `update`. If present, this
+   * write is equivalent to performing `update` and `transform` to the same
+   * document atomically and in order.
+   * 
+ * + * repeated .google.firestore.v1.DocumentTransform.FieldTransform update_transforms = 7; + * + */ + com.google.firestore.v1.DocumentTransform.FieldTransformOrBuilder getUpdateTransformsOrBuilder( + int index); + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return Whether the currentDocument field is set. + */ + boolean hasCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + * + * @return The currentDocument. + */ + com.google.firestore.v1.Precondition getCurrentDocument(); + + /** + * + * + *
+   * An optional precondition on the document.
+   *
+   * The write will fail if this is set and not met by the target document.
+   * 
+ * + * .google.firestore.v1.Precondition current_document = 4; + */ + com.google.firestore.v1.PreconditionOrBuilder getCurrentDocumentOrBuilder(); + + com.google.firestore.v1.Write.OperationCase getOperationCase(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteProto.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteProto.java new file mode 100644 index 000000000000..3084b525b47b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteProto.java @@ -0,0 +1,226 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public final class WriteProto extends com.google.protobuf.GeneratedFile { + private WriteProto() {} + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "WriteProto"); + } + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) {} + + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); + } + + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_Write_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_Write_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentTransform_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentTransform_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentTransform_FieldTransform_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_WriteResult_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_WriteResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentChange_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentChange_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentDelete_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentDelete_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_DocumentRemove_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_DocumentRemove_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_firestore_v1_ExistenceFilter_descriptor; + static final com.google.protobuf.GeneratedMessage.FieldAccessorTable + internal_static_google_firestore_v1_ExistenceFilter_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n\037google/firestore/v1/write.proto\022\023googl" + + "e.firestore.v1\032&google/firestore/v1/bloo" + + "m_filter.proto\032 google/firestore/v1/comm" + + "on.proto\032\"google/firestore/v1/document.p" + + "roto\032\037google/protobuf/timestamp.proto\"\333\002" + + "\n\005Write\022/\n\006update\030\001 \001(\0132\035.google.firesto" + + "re.v1.DocumentH\000\022\020\n\006delete\030\002 \001(\tH\000\022;\n\ttr" + + "ansform\030\006 \001(\0132&.google.firestore.v1.Docu" + + "mentTransformH\000\0226\n\013update_mask\030\003 \001(\0132!.g" + + "oogle.firestore.v1.DocumentMask\022P\n\021updat" + + "e_transforms\030\007 \003(\01325.google.firestore.v1" + + ".DocumentTransform.FieldTransform\022;\n\020cur" + + "rent_document\030\004 \001(\0132!.google.firestore.v" + + "1.PreconditionB\013\n\toperation\"\345\004\n\021Document" + + "Transform\022\020\n\010document\030\001 \001(\t\022O\n\020field_tra" + + "nsforms\030\002 \003(\01325.google.firestore.v1.Docu" + + "mentTransform.FieldTransform\032\354\003\n\016FieldTr" + + "ansform\022\022\n\nfield_path\030\001 \001(\t\022`\n\023set_to_se" + + "rver_value\030\002 \001(\0162A.google.firestore.v1.D" + + "ocumentTransform.FieldTransform.ServerVa" + + "lueH\000\022/\n\tincrement\030\003 \001(\0132\032.google.firest" + + "ore.v1.ValueH\000\022-\n\007maximum\030\004 \001(\0132\032.google" + + ".firestore.v1.ValueH\000\022-\n\007minimum\030\005 \001(\0132\032" + + ".google.firestore.v1.ValueH\000\022B\n\027append_m" + + "issing_elements\030\006 \001(\0132\037.google.firestore" + + ".v1.ArrayValueH\000\022@\n\025remove_all_from_arra" + + "y\030\007 \001(\0132\037.google.firestore.v1.ArrayValue" + + "H\000\"=\n\013ServerValue\022\034\n\030SERVER_VALUE_UNSPEC" + + "IFIED\020\000\022\020\n\014REQUEST_TIME\020\001B\020\n\016transform_t" + + "ype\"u\n\013WriteResult\022/\n\013update_time\030\001 \001(\0132" + + "\032.google.protobuf.Timestamp\0225\n\021transform" + + "_results\030\002 \003(\0132\032.google.firestore.v1.Val" + + "ue\"q\n\016DocumentChange\022/\n\010document\030\001 \001(\0132\035" + + ".google.firestore.v1.Document\022\022\n\ntarget_" + + "ids\030\005 \003(\005\022\032\n\022removed_target_ids\030\006 \003(\005\"m\n" + + "\016DocumentDelete\022\020\n\010document\030\001 \001(\t\022\032\n\022rem" + + "oved_target_ids\030\006 \003(\005\022-\n\tread_time\030\004 \001(\013" + + "2\032.google.protobuf.Timestamp\"m\n\016Document" + + "Remove\022\020\n\010document\030\001 \001(\t\022\032\n\022removed_targ" + + "et_ids\030\002 \003(\005\022-\n\tread_time\030\004 \001(\0132\032.google" + + ".protobuf.Timestamp\"n\n\017ExistenceFilter\022\021" + + "\n\ttarget_id\030\001 \001(\005\022\r\n\005count\030\002 \001(\005\0229\n\017unch" + + "anged_names\030\003 \001(\0132 .google.firestore.v1." + + "BloomFilterB\302\001\n\027com.google.firestore.v1B" + + "\nWriteProtoP\001Z;cloud.google.com/go/fires" + + "tore/apiv1/firestorepb;firestorepb\242\002\004GCF" + + "S\252\002\031Google.Cloud.Firestore.V1\312\002\031Google\\C" + + "loud\\Firestore\\V1\352\002\034Google::Cloud::Fires" + + "tore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.firestore.v1.BloomFilterProto.getDescriptor(), + com.google.firestore.v1.CommonProto.getDescriptor(), + com.google.firestore.v1.DocumentProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_firestore_v1_Write_descriptor = getDescriptor().getMessageType(0); + internal_static_google_firestore_v1_Write_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_Write_descriptor, + new java.lang.String[] { + "Update", + "Delete", + "Transform", + "UpdateMask", + "UpdateTransforms", + "CurrentDocument", + "Operation", + }); + internal_static_google_firestore_v1_DocumentTransform_descriptor = + getDescriptor().getMessageType(1); + internal_static_google_firestore_v1_DocumentTransform_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentTransform_descriptor, + new java.lang.String[] { + "Document", "FieldTransforms", + }); + internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor = + internal_static_google_firestore_v1_DocumentTransform_descriptor.getNestedType(0); + internal_static_google_firestore_v1_DocumentTransform_FieldTransform_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentTransform_FieldTransform_descriptor, + new java.lang.String[] { + "FieldPath", + "SetToServerValue", + "Increment", + "Maximum", + "Minimum", + "AppendMissingElements", + "RemoveAllFromArray", + "TransformType", + }); + internal_static_google_firestore_v1_WriteResult_descriptor = getDescriptor().getMessageType(2); + internal_static_google_firestore_v1_WriteResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_WriteResult_descriptor, + new java.lang.String[] { + "UpdateTime", "TransformResults", + }); + internal_static_google_firestore_v1_DocumentChange_descriptor = + getDescriptor().getMessageType(3); + internal_static_google_firestore_v1_DocumentChange_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentChange_descriptor, + new java.lang.String[] { + "Document", "TargetIds", "RemovedTargetIds", + }); + internal_static_google_firestore_v1_DocumentDelete_descriptor = + getDescriptor().getMessageType(4); + internal_static_google_firestore_v1_DocumentDelete_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentDelete_descriptor, + new java.lang.String[] { + "Document", "RemovedTargetIds", "ReadTime", + }); + internal_static_google_firestore_v1_DocumentRemove_descriptor = + getDescriptor().getMessageType(5); + internal_static_google_firestore_v1_DocumentRemove_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_DocumentRemove_descriptor, + new java.lang.String[] { + "Document", "RemovedTargetIds", "ReadTime", + }); + internal_static_google_firestore_v1_ExistenceFilter_descriptor = + getDescriptor().getMessageType(6); + internal_static_google_firestore_v1_ExistenceFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessage.FieldAccessorTable( + internal_static_google_firestore_v1_ExistenceFilter_descriptor, + new java.lang.String[] { + "TargetId", "Count", "UnchangedNames", + }); + descriptor.resolveAllFeaturesImmutable(); + com.google.firestore.v1.BloomFilterProto.getDescriptor(); + com.google.firestore.v1.CommonProto.getDescriptor(); + com.google.firestore.v1.DocumentProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequest.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequest.java new file mode 100644 index 000000000000..53a2ef9fce92 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequest.java @@ -0,0 +1,1952 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The request for [Firestore.Write][google.firestore.v1.Firestore.Write].
+ *
+ * The first request creates a stream, or resumes an existing one from a token.
+ *
+ * When creating a new stream, the server replies with a response containing
+ * only an ID and a token, to use in the next request.
+ *
+ * When resuming a stream, the server first streams any responses later than the
+ * given token, then a response containing only an up-to-date token, to use in
+ * the next request.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.WriteRequest} + */ +@com.google.protobuf.Generated +public final class WriteRequest extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.WriteRequest) + WriteRequestOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "WriteRequest"); + } + + // Use WriteRequest.newBuilder() to construct. + private WriteRequest(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private WriteRequest() { + database_ = ""; + streamId_ = ""; + writes_ = java.util.Collections.emptyList(); + streamToken_ = com.google.protobuf.ByteString.EMPTY; + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteRequest.class, + com.google.firestore.v1.WriteRequest.Builder.class); + } + + public static final int DATABASE_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object database_ = ""; + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * This is only required in the first message.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + @java.lang.Override + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * This is only required in the first message.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STREAM_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object streamId_ = ""; + + /** + * + * + *
+   * The ID of the write stream to resume.
+   * This may only be set in the first message. When left empty, a new write
+   * stream will be created.
+   * 
+ * + * string stream_id = 2; + * + * @return The streamId. + */ + @java.lang.Override + public java.lang.String getStreamId() { + java.lang.Object ref = streamId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + streamId_ = s; + return s; + } + } + + /** + * + * + *
+   * The ID of the write stream to resume.
+   * This may only be set in the first message. When left empty, a new write
+   * stream will be created.
+   * 
+ * + * string stream_id = 2; + * + * @return The bytes for streamId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamIdBytes() { + java.lang.Object ref = streamId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + streamId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int WRITES_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List writes_; + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + @java.lang.Override + public java.util.List getWritesList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + @java.lang.Override + public java.util.List getWritesOrBuilderList() { + return writes_; + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + @java.lang.Override + public int getWritesCount() { + return writes_.size(); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + @java.lang.Override + public com.google.firestore.v1.Write getWrites(int index) { + return writes_.get(index); + } + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + @java.lang.Override + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + return writes_.get(index); + } + + public static final int STREAM_TOKEN_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString streamToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A stream token that was previously sent by the server.
+   *
+   * The client should set this field to the token from the most recent
+   * [WriteResponse][google.firestore.v1.WriteResponse] it has received. This
+   * acknowledges that the client has received responses up to this token. After
+   * sending this token, earlier tokens may not be used anymore.
+   *
+   * The server may close the stream if there are too many unacknowledged
+   * responses.
+   *
+   * Leave this field unset when creating a new stream. To resume a stream at
+   * a specific point, set this field and the `stream_id` field.
+   *
+   * Leave this field unset when creating a new stream.
+   * 
+ * + * bytes stream_token = 4; + * + * @return The streamToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamToken() { + return streamToken_; + } + + public static final int LABELS_FIELD_NUMBER = 5; + + private static final class LabelsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_LabelsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, database_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(streamId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, streamId_); + } + for (int i = 0; i < writes_.size(); i++) { + output.writeMessage(3, writes_.get(i)); + } + if (!streamToken_.isEmpty()) { + output.writeBytes(4, streamToken_); + } + com.google.protobuf.GeneratedMessage.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 5); + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(database_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, database_); + } + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(streamId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, streamId_); + } + for (int i = 0; i < writes_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, writes_.get(i)); + } + if (!streamToken_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, streamToken_); + } + for (java.util.Map.Entry entry : + internalGetLabels().getMap().entrySet()) { + com.google.protobuf.MapEntry labels__ = + LabelsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, labels__); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.WriteRequest)) { + return super.equals(obj); + } + com.google.firestore.v1.WriteRequest other = (com.google.firestore.v1.WriteRequest) obj; + + if (!getDatabase().equals(other.getDatabase())) return false; + if (!getStreamId().equals(other.getStreamId())) return false; + if (!getWritesList().equals(other.getWritesList())) return false; + if (!getStreamToken().equals(other.getStreamToken())) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + DATABASE_FIELD_NUMBER; + hash = (53 * hash) + getDatabase().hashCode(); + hash = (37 * hash) + STREAM_ID_FIELD_NUMBER; + hash = (53 * hash) + getStreamId().hashCode(); + if (getWritesCount() > 0) { + hash = (37 * hash) + WRITES_FIELD_NUMBER; + hash = (53 * hash) + getWritesList().hashCode(); + } + hash = (37 * hash) + STREAM_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getStreamToken().hashCode(); + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.WriteRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteRequest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.WriteRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Firestore.Write][google.firestore.v1.Firestore.Write].
+   *
+   * The first request creates a stream, or resumes an existing one from a token.
+   *
+   * When creating a new stream, the server replies with a response containing
+   * only an ID and a token, to use in the next request.
+   *
+   * When resuming a stream, the server first streams any responses later than the
+   * given token, then a response containing only an up-to-date token, to use in
+   * the next request.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.WriteRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.WriteRequest) + com.google.firestore.v1.WriteRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetMutableLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteRequest.class, + com.google.firestore.v1.WriteRequest.Builder.class); + } + + // Construct using com.google.firestore.v1.WriteRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + database_ = ""; + streamId_ = ""; + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + } else { + writes_ = null; + writesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + streamToken_ = com.google.protobuf.ByteString.EMPTY; + internalGetMutableLabels().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteRequest_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.WriteRequest getDefaultInstanceForType() { + return com.google.firestore.v1.WriteRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.WriteRequest build() { + com.google.firestore.v1.WriteRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.WriteRequest buildPartial() { + com.google.firestore.v1.WriteRequest result = new com.google.firestore.v1.WriteRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.WriteRequest result) { + if (writesBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + writes_ = java.util.Collections.unmodifiableList(writes_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.writes_ = writes_; + } else { + result.writes_ = writesBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.WriteRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.database_ = database_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.streamId_ = streamId_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.streamToken_ = streamToken_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.WriteRequest) { + return mergeFrom((com.google.firestore.v1.WriteRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.WriteRequest other) { + if (other == com.google.firestore.v1.WriteRequest.getDefaultInstance()) return this; + if (!other.getDatabase().isEmpty()) { + database_ = other.database_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getStreamId().isEmpty()) { + streamId_ = other.streamId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (writesBuilder_ == null) { + if (!other.writes_.isEmpty()) { + if (writes_.isEmpty()) { + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureWritesIsMutable(); + writes_.addAll(other.writes_); + } + onChanged(); + } + } else { + if (!other.writes_.isEmpty()) { + if (writesBuilder_.isEmpty()) { + writesBuilder_.dispose(); + writesBuilder_ = null; + writes_ = other.writes_; + bitField0_ = (bitField0_ & ~0x00000004); + writesBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWritesFieldBuilder() + : null; + } else { + writesBuilder_.addAllMessages(other.writes_); + } + } + } + if (!other.getStreamToken().isEmpty()) { + setStreamToken(other.getStreamToken()); + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000010; + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + database_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + streamId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + com.google.firestore.v1.Write m = + input.readMessage(com.google.firestore.v1.Write.parser(), extensionRegistry); + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(m); + } else { + writesBuilder_.addMessage(m); + } + break; + } // case 26 + case 34: + { + streamToken_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + com.google.protobuf.MapEntry labels__ = + input.readMessage( + LabelsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableLabels() + .getMutableMap() + .put(labels__.getKey(), labels__.getValue()); + bitField0_ |= 0x00000010; + break; + } // case 42 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object database_ = ""; + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * This is only required in the first message.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + public java.lang.String getDatabase() { + java.lang.Object ref = database_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + database_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * This is only required in the first message.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + public com.google.protobuf.ByteString getDatabaseBytes() { + java.lang.Object ref = database_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + database_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * This is only required in the first message.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The database to set. + * @return This builder for chaining. + */ + public Builder setDatabase(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * This is only required in the first message.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearDatabase() { + database_ = getDefaultInstance().getDatabase(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The database name. In the format:
+     * `projects/{project_id}/databases/{database_id}`.
+     * This is only required in the first message.
+     * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for database to set. + * @return This builder for chaining. + */ + public Builder setDatabaseBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + database_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object streamId_ = ""; + + /** + * + * + *
+     * The ID of the write stream to resume.
+     * This may only be set in the first message. When left empty, a new write
+     * stream will be created.
+     * 
+ * + * string stream_id = 2; + * + * @return The streamId. + */ + public java.lang.String getStreamId() { + java.lang.Object ref = streamId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + streamId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The ID of the write stream to resume.
+     * This may only be set in the first message. When left empty, a new write
+     * stream will be created.
+     * 
+ * + * string stream_id = 2; + * + * @return The bytes for streamId. + */ + public com.google.protobuf.ByteString getStreamIdBytes() { + java.lang.Object ref = streamId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + streamId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The ID of the write stream to resume.
+     * This may only be set in the first message. When left empty, a new write
+     * stream will be created.
+     * 
+ * + * string stream_id = 2; + * + * @param value The streamId to set. + * @return This builder for chaining. + */ + public Builder setStreamId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + streamId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the write stream to resume.
+     * This may only be set in the first message. When left empty, a new write
+     * stream will be created.
+     * 
+ * + * string stream_id = 2; + * + * @return This builder for chaining. + */ + public Builder clearStreamId() { + streamId_ = getDefaultInstance().getStreamId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the write stream to resume.
+     * This may only be set in the first message. When left empty, a new write
+     * stream will be created.
+     * 
+ * + * string stream_id = 2; + * + * @param value The bytes for streamId to set. + * @return This builder for chaining. + */ + public Builder setStreamIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + streamId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.util.List writes_ = + java.util.Collections.emptyList(); + + private void ensureWritesIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + writes_ = new java.util.ArrayList(writes_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + writesBuilder_; + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public java.util.List getWritesList() { + if (writesBuilder_ == null) { + return java.util.Collections.unmodifiableList(writes_); + } else { + return writesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public int getWritesCount() { + if (writesBuilder_ == null) { + return writes_.size(); + } else { + return writesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public com.google.firestore.v1.Write getWrites(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.set(index, value); + onChanged(); + } else { + writesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder setWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.set(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder addWrites(com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(value); + onChanged(); + } else { + writesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write value) { + if (writesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWritesIsMutable(); + writes_.add(index, value); + onChanged(); + } else { + writesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder addWrites(com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder addWrites(int index, com.google.firestore.v1.Write.Builder builderForValue) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.add(index, builderForValue.build()); + onChanged(); + } else { + writesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder addAllWrites( + java.lang.Iterable values) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writes_); + onChanged(); + } else { + writesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder clearWrites() { + if (writesBuilder_ == null) { + writes_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + writesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public Builder removeWrites(int index) { + if (writesBuilder_ == null) { + ensureWritesIsMutable(); + writes_.remove(index); + onChanged(); + } else { + writesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public com.google.firestore.v1.Write.Builder getWritesBuilder(int index) { + return internalGetWritesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index) { + if (writesBuilder_ == null) { + return writes_.get(index); + } else { + return writesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public java.util.List + getWritesOrBuilderList() { + if (writesBuilder_ != null) { + return writesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writes_); + } + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder() { + return internalGetWritesFieldBuilder() + .addBuilder(com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public com.google.firestore.v1.Write.Builder addWritesBuilder(int index) { + return internalGetWritesFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Write.getDefaultInstance()); + } + + /** + * + * + *
+     * The writes to apply.
+     *
+     * Always executed atomically and in order.
+     * This must be empty on the first request.
+     * This may be empty on the last request.
+     * This must not be empty on all other requests.
+     * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + public java.util.List getWritesBuilderList() { + return internalGetWritesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder> + internalGetWritesFieldBuilder() { + if (writesBuilder_ == null) { + writesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Write, + com.google.firestore.v1.Write.Builder, + com.google.firestore.v1.WriteOrBuilder>( + writes_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + writes_ = null; + } + return writesBuilder_; + } + + private com.google.protobuf.ByteString streamToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A stream token that was previously sent by the server.
+     *
+     * The client should set this field to the token from the most recent
+     * [WriteResponse][google.firestore.v1.WriteResponse] it has received. This
+     * acknowledges that the client has received responses up to this token. After
+     * sending this token, earlier tokens may not be used anymore.
+     *
+     * The server may close the stream if there are too many unacknowledged
+     * responses.
+     *
+     * Leave this field unset when creating a new stream. To resume a stream at
+     * a specific point, set this field and the `stream_id` field.
+     *
+     * Leave this field unset when creating a new stream.
+     * 
+ * + * bytes stream_token = 4; + * + * @return The streamToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamToken() { + return streamToken_; + } + + /** + * + * + *
+     * A stream token that was previously sent by the server.
+     *
+     * The client should set this field to the token from the most recent
+     * [WriteResponse][google.firestore.v1.WriteResponse] it has received. This
+     * acknowledges that the client has received responses up to this token. After
+     * sending this token, earlier tokens may not be used anymore.
+     *
+     * The server may close the stream if there are too many unacknowledged
+     * responses.
+     *
+     * Leave this field unset when creating a new stream. To resume a stream at
+     * a specific point, set this field and the `stream_id` field.
+     *
+     * Leave this field unset when creating a new stream.
+     * 
+ * + * bytes stream_token = 4; + * + * @param value The streamToken to set. + * @return This builder for chaining. + */ + public Builder setStreamToken(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + streamToken_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * A stream token that was previously sent by the server.
+     *
+     * The client should set this field to the token from the most recent
+     * [WriteResponse][google.firestore.v1.WriteResponse] it has received. This
+     * acknowledges that the client has received responses up to this token. After
+     * sending this token, earlier tokens may not be used anymore.
+     *
+     * The server may close the stream if there are too many unacknowledged
+     * responses.
+     *
+     * Leave this field unset when creating a new stream. To resume a stream at
+     * a specific point, set this field and the `stream_id` field.
+     *
+     * Leave this field unset when creating a new stream.
+     * 
+ * + * bytes stream_token = 4; + * + * @return This builder for chaining. + */ + public Builder clearStreamToken() { + bitField0_ = (bitField0_ & ~0x00000008); + streamToken_ = getDefaultInstance().getStreamToken(); + onChanged(); + return this; + } + + private com.google.protobuf.MapField labels_; + + private com.google.protobuf.MapField internalGetLabels() { + if (labels_ == null) { + return com.google.protobuf.MapField.emptyMapField(LabelsDefaultEntryHolder.defaultEntry); + } + return labels_; + } + + private com.google.protobuf.MapField + internalGetMutableLabels() { + if (labels_ == null) { + labels_ = com.google.protobuf.MapField.newMapField(LabelsDefaultEntryHolder.defaultEntry); + } + if (!labels_.isMutable()) { + labels_ = labels_.copy(); + } + bitField0_ |= 0x00000010; + onChanged(); + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public boolean containsLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetLabels().getMap().containsKey(key); + } + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getLabels() { + return getLabelsMap(); + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public /* nullable */ java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + @java.lang.Override + public java.lang.String getLabelsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = internalGetLabels().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearLabels() { + bitField0_ = (bitField0_ & ~0x00000010); + internalGetMutableLabels().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + public Builder removeLabels(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableLabels().getMutableMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableLabels() { + bitField0_ |= 0x00000010; + return internalGetMutableLabels().getMutableMap(); + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + public Builder putLabels(java.lang.String key, java.lang.String value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableLabels().getMutableMap().put(key, value); + bitField0_ |= 0x00000010; + return this; + } + + /** + * + * + *
+     * Labels associated with this write request.
+     * 
+ * + * map<string, string> labels = 5; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000010; + return this; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.WriteRequest) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.WriteRequest) + private static final com.google.firestore.v1.WriteRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.WriteRequest(); + } + + public static com.google.firestore.v1.WriteRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public WriteRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.WriteRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequestOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequestOrBuilder.java new file mode 100644 index 000000000000..82cb90c244b6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteRequestOrBuilder.java @@ -0,0 +1,257 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface WriteRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.WriteRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * This is only required in the first message.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The database. + */ + java.lang.String getDatabase(); + + /** + * + * + *
+   * Required. The database name. In the format:
+   * `projects/{project_id}/databases/{database_id}`.
+   * This is only required in the first message.
+   * 
+ * + * string database = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for database. + */ + com.google.protobuf.ByteString getDatabaseBytes(); + + /** + * + * + *
+   * The ID of the write stream to resume.
+   * This may only be set in the first message. When left empty, a new write
+   * stream will be created.
+   * 
+ * + * string stream_id = 2; + * + * @return The streamId. + */ + java.lang.String getStreamId(); + + /** + * + * + *
+   * The ID of the write stream to resume.
+   * This may only be set in the first message. When left empty, a new write
+   * stream will be created.
+   * 
+ * + * string stream_id = 2; + * + * @return The bytes for streamId. + */ + com.google.protobuf.ByteString getStreamIdBytes(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + java.util.List getWritesList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + com.google.firestore.v1.Write getWrites(int index); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + int getWritesCount(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + java.util.List getWritesOrBuilderList(); + + /** + * + * + *
+   * The writes to apply.
+   *
+   * Always executed atomically and in order.
+   * This must be empty on the first request.
+   * This may be empty on the last request.
+   * This must not be empty on all other requests.
+   * 
+ * + * repeated .google.firestore.v1.Write writes = 3; + */ + com.google.firestore.v1.WriteOrBuilder getWritesOrBuilder(int index); + + /** + * + * + *
+   * A stream token that was previously sent by the server.
+   *
+   * The client should set this field to the token from the most recent
+   * [WriteResponse][google.firestore.v1.WriteResponse] it has received. This
+   * acknowledges that the client has received responses up to this token. After
+   * sending this token, earlier tokens may not be used anymore.
+   *
+   * The server may close the stream if there are too many unacknowledged
+   * responses.
+   *
+   * Leave this field unset when creating a new stream. To resume a stream at
+   * a specific point, set this field and the `stream_id` field.
+   *
+   * Leave this field unset when creating a new stream.
+   * 
+ * + * bytes stream_token = 4; + * + * @return The streamToken. + */ + com.google.protobuf.ByteString getStreamToken(); + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + int getLabelsCount(); + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Labels associated with this write request.
+   * 
+ * + * map<string, string> labels = 5; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponse.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponse.java new file mode 100644 index 000000000000..9f57786dde95 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponse.java @@ -0,0 +1,1596 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The response for [Firestore.Write][google.firestore.v1.Firestore.Write].
+ * 
+ * + * Protobuf type {@code google.firestore.v1.WriteResponse} + */ +@com.google.protobuf.Generated +public final class WriteResponse extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.WriteResponse) + WriteResponseOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "WriteResponse"); + } + + // Use WriteResponse.newBuilder() to construct. + private WriteResponse(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private WriteResponse() { + streamId_ = ""; + streamToken_ = com.google.protobuf.ByteString.EMPTY; + writeResults_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteResponse.class, + com.google.firestore.v1.WriteResponse.Builder.class); + } + + private int bitField0_; + public static final int STREAM_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object streamId_ = ""; + + /** + * + * + *
+   * The ID of the stream.
+   * Only set on the first message, when a new stream was created.
+   * 
+ * + * string stream_id = 1; + * + * @return The streamId. + */ + @java.lang.Override + public java.lang.String getStreamId() { + java.lang.Object ref = streamId_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + streamId_ = s; + return s; + } + } + + /** + * + * + *
+   * The ID of the stream.
+   * Only set on the first message, when a new stream was created.
+   * 
+ * + * string stream_id = 1; + * + * @return The bytes for streamId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamIdBytes() { + java.lang.Object ref = streamId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + streamId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int STREAM_TOKEN_FIELD_NUMBER = 2; + private com.google.protobuf.ByteString streamToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A token that represents the position of this response in the stream.
+   * This can be used by a client to resume the stream at this point.
+   *
+   * This field is always set.
+   * 
+ * + * bytes stream_token = 2; + * + * @return The streamToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamToken() { + return streamToken_; + } + + public static final int WRITE_RESULTS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List writeResults_; + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + @java.lang.Override + public java.util.List getWriteResultsList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + @java.lang.Override + public java.util.List + getWriteResultsOrBuilderList() { + return writeResults_; + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + @java.lang.Override + public int getWriteResultsCount() { + return writeResults_.size(); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + return writeResults_.get(index); + } + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + @java.lang.Override + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + return writeResults_.get(index); + } + + public static final int COMMIT_TIME_FIELD_NUMBER = 4; + private com.google.protobuf.Timestamp commitTime_; + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return Whether the commitTime field is set. + */ + @java.lang.Override + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return The commitTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCommitTime() { + return commitTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : commitTime_; + } + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder() { + return commitTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : commitTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(streamId_)) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, streamId_); + } + if (!streamToken_.isEmpty()) { + output.writeBytes(2, streamToken_); + } + for (int i = 0; i < writeResults_.size(); i++) { + output.writeMessage(3, writeResults_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getCommitTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessage.isStringEmpty(streamId_)) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, streamId_); + } + if (!streamToken_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(2, streamToken_); + } + for (int i = 0; i < writeResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, writeResults_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getCommitTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.WriteResponse)) { + return super.equals(obj); + } + com.google.firestore.v1.WriteResponse other = (com.google.firestore.v1.WriteResponse) obj; + + if (!getStreamId().equals(other.getStreamId())) return false; + if (!getStreamToken().equals(other.getStreamToken())) return false; + if (!getWriteResultsList().equals(other.getWriteResultsList())) return false; + if (hasCommitTime() != other.hasCommitTime()) return false; + if (hasCommitTime()) { + if (!getCommitTime().equals(other.getCommitTime())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + STREAM_ID_FIELD_NUMBER; + hash = (53 * hash) + getStreamId().hashCode(); + hash = (37 * hash) + STREAM_TOKEN_FIELD_NUMBER; + hash = (53 * hash) + getStreamToken().hashCode(); + if (getWriteResultsCount() > 0) { + hash = (37 * hash) + WRITE_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getWriteResultsList().hashCode(); + } + if (hasCommitTime()) { + hash = (37 * hash) + COMMIT_TIME_FIELD_NUMBER; + hash = (53 * hash) + getCommitTime().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.WriteResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResponse parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.WriteResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Firestore.Write][google.firestore.v1.Firestore.Write].
+   * 
+ * + * Protobuf type {@code google.firestore.v1.WriteResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.WriteResponse) + com.google.firestore.v1.WriteResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteResponse.class, + com.google.firestore.v1.WriteResponse.Builder.class); + } + + // Construct using com.google.firestore.v1.WriteResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetWriteResultsFieldBuilder(); + internalGetCommitTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + streamId_ = ""; + streamToken_ = com.google.protobuf.ByteString.EMPTY; + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + } else { + writeResults_ = null; + writeResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.FirestoreProto + .internal_static_google_firestore_v1_WriteResponse_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResponse getDefaultInstanceForType() { + return com.google.firestore.v1.WriteResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.WriteResponse build() { + com.google.firestore.v1.WriteResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResponse buildPartial() { + com.google.firestore.v1.WriteResponse result = + new com.google.firestore.v1.WriteResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.WriteResponse result) { + if (writeResultsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + writeResults_ = java.util.Collections.unmodifiableList(writeResults_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.writeResults_ = writeResults_; + } else { + result.writeResults_ = writeResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.WriteResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.streamId_ = streamId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.streamToken_ = streamToken_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.commitTime_ = commitTimeBuilder_ == null ? commitTime_ : commitTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.WriteResponse) { + return mergeFrom((com.google.firestore.v1.WriteResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.WriteResponse other) { + if (other == com.google.firestore.v1.WriteResponse.getDefaultInstance()) return this; + if (!other.getStreamId().isEmpty()) { + streamId_ = other.streamId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getStreamToken().isEmpty()) { + setStreamToken(other.getStreamToken()); + } + if (writeResultsBuilder_ == null) { + if (!other.writeResults_.isEmpty()) { + if (writeResults_.isEmpty()) { + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureWriteResultsIsMutable(); + writeResults_.addAll(other.writeResults_); + } + onChanged(); + } + } else { + if (!other.writeResults_.isEmpty()) { + if (writeResultsBuilder_.isEmpty()) { + writeResultsBuilder_.dispose(); + writeResultsBuilder_ = null; + writeResults_ = other.writeResults_; + bitField0_ = (bitField0_ & ~0x00000004); + writeResultsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetWriteResultsFieldBuilder() + : null; + } else { + writeResultsBuilder_.addAllMessages(other.writeResults_); + } + } + } + if (other.hasCommitTime()) { + mergeCommitTime(other.getCommitTime()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + streamId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + streamToken_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + com.google.firestore.v1.WriteResult m = + input.readMessage( + com.google.firestore.v1.WriteResult.parser(), extensionRegistry); + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(m); + } else { + writeResultsBuilder_.addMessage(m); + } + break; + } // case 26 + case 34: + { + input.readMessage( + internalGetCommitTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object streamId_ = ""; + + /** + * + * + *
+     * The ID of the stream.
+     * Only set on the first message, when a new stream was created.
+     * 
+ * + * string stream_id = 1; + * + * @return The streamId. + */ + public java.lang.String getStreamId() { + java.lang.Object ref = streamId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + streamId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The ID of the stream.
+     * Only set on the first message, when a new stream was created.
+     * 
+ * + * string stream_id = 1; + * + * @return The bytes for streamId. + */ + public com.google.protobuf.ByteString getStreamIdBytes() { + java.lang.Object ref = streamId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + streamId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The ID of the stream.
+     * Only set on the first message, when a new stream was created.
+     * 
+ * + * string stream_id = 1; + * + * @param value The streamId to set. + * @return This builder for chaining. + */ + public Builder setStreamId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + streamId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the stream.
+     * Only set on the first message, when a new stream was created.
+     * 
+ * + * string stream_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearStreamId() { + streamId_ = getDefaultInstance().getStreamId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the stream.
+     * Only set on the first message, when a new stream was created.
+     * 
+ * + * string stream_id = 1; + * + * @param value The bytes for streamId to set. + * @return This builder for chaining. + */ + public Builder setStreamIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + streamId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString streamToken_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A token that represents the position of this response in the stream.
+     * This can be used by a client to resume the stream at this point.
+     *
+     * This field is always set.
+     * 
+ * + * bytes stream_token = 2; + * + * @return The streamToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStreamToken() { + return streamToken_; + } + + /** + * + * + *
+     * A token that represents the position of this response in the stream.
+     * This can be used by a client to resume the stream at this point.
+     *
+     * This field is always set.
+     * 
+ * + * bytes stream_token = 2; + * + * @param value The streamToken to set. + * @return This builder for chaining. + */ + public Builder setStreamToken(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + streamToken_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A token that represents the position of this response in the stream.
+     * This can be used by a client to resume the stream at this point.
+     *
+     * This field is always set.
+     * 
+ * + * bytes stream_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearStreamToken() { + bitField0_ = (bitField0_ & ~0x00000002); + streamToken_ = getDefaultInstance().getStreamToken(); + onChanged(); + return this; + } + + private java.util.List writeResults_ = + java.util.Collections.emptyList(); + + private void ensureWriteResultsIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + writeResults_ = new java.util.ArrayList(writeResults_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + writeResultsBuilder_; + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public java.util.List getWriteResultsList() { + if (writeResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(writeResults_); + } else { + return writeResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public int getWriteResultsCount() { + if (writeResultsBuilder_ == null) { + return writeResults_.size(); + } else { + return writeResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public com.google.firestore.v1.WriteResult getWriteResults(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder setWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.set(index, value); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder setWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.set(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder addWriteResults(int index, com.google.firestore.v1.WriteResult value) { + if (writeResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureWriteResultsIsMutable(); + writeResults_.add(index, value); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder addWriteResults(com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder addWriteResults( + int index, com.google.firestore.v1.WriteResult.Builder builderForValue) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.add(index, builderForValue.build()); + onChanged(); + } else { + writeResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder addAllWriteResults( + java.lang.Iterable values) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, writeResults_); + onChanged(); + } else { + writeResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder clearWriteResults() { + if (writeResultsBuilder_ == null) { + writeResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + writeResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public Builder removeWriteResults(int index) { + if (writeResultsBuilder_ == null) { + ensureWriteResultsIsMutable(); + writeResults_.remove(index); + onChanged(); + } else { + writeResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public com.google.firestore.v1.WriteResult.Builder getWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index) { + if (writeResultsBuilder_ == null) { + return writeResults_.get(index); + } else { + return writeResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public java.util.List + getWriteResultsOrBuilderList() { + if (writeResultsBuilder_ != null) { + return writeResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(writeResults_); + } + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder() { + return internalGetWriteResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public com.google.firestore.v1.WriteResult.Builder addWriteResultsBuilder(int index) { + return internalGetWriteResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.WriteResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of applying the writes.
+     *
+     * This i-th write result corresponds to the i-th write in the
+     * request.
+     * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + public java.util.List + getWriteResultsBuilderList() { + return internalGetWriteResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder> + internalGetWriteResultsFieldBuilder() { + if (writeResultsBuilder_ == null) { + writeResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.WriteResult, + com.google.firestore.v1.WriteResult.Builder, + com.google.firestore.v1.WriteResultOrBuilder>( + writeResults_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + writeResults_ = null; + } + return writeResultsBuilder_; + } + + private com.google.protobuf.Timestamp commitTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + commitTimeBuilder_; + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return Whether the commitTime field is set. + */ + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return The commitTime. + */ + public com.google.protobuf.Timestamp getCommitTime() { + if (commitTimeBuilder_ == null) { + return commitTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : commitTime_; + } else { + return commitTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + commitTime_ = value; + } else { + commitTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (commitTimeBuilder_ == null) { + commitTime_ = builderForValue.build(); + } else { + commitTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public Builder mergeCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && commitTime_ != null + && commitTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCommitTimeBuilder().mergeFrom(value); + } else { + commitTime_ = value; + } + } else { + commitTimeBuilder_.mergeFrom(value); + } + if (commitTime_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public Builder clearCommitTime() { + bitField0_ = (bitField0_ & ~0x00000008); + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public com.google.protobuf.Timestamp.Builder getCommitTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return internalGetCommitTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + public com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder() { + if (commitTimeBuilder_ != null) { + return commitTimeBuilder_.getMessageOrBuilder(); + } else { + return commitTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : commitTime_; + } + } + + /** + * + * + *
+     * The time at which the commit occurred. Any read with an equal or greater
+     * `read_time` is guaranteed to see the effects of the write.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetCommitTimeFieldBuilder() { + if (commitTimeBuilder_ == null) { + commitTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCommitTime(), getParentForChildren(), isClean()); + commitTime_ = null; + } + return commitTimeBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.WriteResponse) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.WriteResponse) + private static final com.google.firestore.v1.WriteResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.WriteResponse(); + } + + public static com.google.firestore.v1.WriteResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public WriteResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponseOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponseOrBuilder.java new file mode 100644 index 000000000000..79641fc89d22 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResponseOrBuilder.java @@ -0,0 +1,183 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/firestore.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface WriteResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.WriteResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The ID of the stream.
+   * Only set on the first message, when a new stream was created.
+   * 
+ * + * string stream_id = 1; + * + * @return The streamId. + */ + java.lang.String getStreamId(); + + /** + * + * + *
+   * The ID of the stream.
+   * Only set on the first message, when a new stream was created.
+   * 
+ * + * string stream_id = 1; + * + * @return The bytes for streamId. + */ + com.google.protobuf.ByteString getStreamIdBytes(); + + /** + * + * + *
+   * A token that represents the position of this response in the stream.
+   * This can be used by a client to resume the stream at this point.
+   *
+   * This field is always set.
+   * 
+ * + * bytes stream_token = 2; + * + * @return The streamToken. + */ + com.google.protobuf.ByteString getStreamToken(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + java.util.List getWriteResultsList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + com.google.firestore.v1.WriteResult getWriteResults(int index); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + int getWriteResultsCount(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + java.util.List + getWriteResultsOrBuilderList(); + + /** + * + * + *
+   * The result of applying the writes.
+   *
+   * This i-th write result corresponds to the i-th write in the
+   * request.
+   * 
+ * + * repeated .google.firestore.v1.WriteResult write_results = 3; + */ + com.google.firestore.v1.WriteResultOrBuilder getWriteResultsOrBuilder(int index); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return Whether the commitTime field is set. + */ + boolean hasCommitTime(); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + * + * @return The commitTime. + */ + com.google.protobuf.Timestamp getCommitTime(); + + /** + * + * + *
+   * The time at which the commit occurred. Any read with an equal or greater
+   * `read_time` is guaranteed to see the effects of the write.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 4; + */ + com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder(); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResult.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResult.java new file mode 100644 index 000000000000..b2b0447e2d84 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResult.java @@ -0,0 +1,1302 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +/** + * + * + *
+ * The result of applying a write.
+ * 
+ * + * Protobuf type {@code google.firestore.v1.WriteResult} + */ +@com.google.protobuf.Generated +public final class WriteResult extends com.google.protobuf.GeneratedMessage + implements + // @@protoc_insertion_point(message_implements:google.firestore.v1.WriteResult) + WriteResultOrBuilder { + private static final long serialVersionUID = 0L; + + static { + com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( + com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, + /* major= */ 4, + /* minor= */ 33, + /* patch= */ 2, + /* suffix= */ "", + "WriteResult"); + } + + // Use WriteResult.newBuilder() to construct. + private WriteResult(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } + + private WriteResult() { + transformResults_ = java.util.Collections.emptyList(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_WriteResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_WriteResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteResult.class, + com.google.firestore.v1.WriteResult.Builder.class); + } + + private int bitField0_; + public static final int UPDATE_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int TRANSFORM_RESULTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List transformResults_; + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + @java.lang.Override + public java.util.List getTransformResultsList() { + return transformResults_; + } + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + @java.lang.Override + public java.util.List + getTransformResultsOrBuilderList() { + return transformResults_; + } + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + @java.lang.Override + public int getTransformResultsCount() { + return transformResults_.size(); + } + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.Value getTransformResults(int index) { + return transformResults_.get(index); + } + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + @java.lang.Override + public com.google.firestore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index) { + return transformResults_.get(index); + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getUpdateTime()); + } + for (int i = 0; i < transformResults_.size(); i++) { + output.writeMessage(2, transformResults_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getUpdateTime()); + } + for (int i = 0; i < transformResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, transformResults_.get(i)); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.firestore.v1.WriteResult)) { + return super.equals(obj); + } + com.google.firestore.v1.WriteResult other = (com.google.firestore.v1.WriteResult) obj; + + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (!getTransformResultsList().equals(other.getTransformResultsList())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + if (getTransformResultsCount() > 0) { + hash = (37 * hash) + TRANSFORM_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getTransformResultsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.firestore.v1.WriteResult parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResult parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResult parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.google.firestore.v1.WriteResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException( + PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.google.firestore.v1.WriteResult prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The result of applying a write.
+   * 
+ * + * Protobuf type {@code google.firestore.v1.WriteResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder + implements + // @@protoc_insertion_point(builder_implements:google.firestore.v1.WriteResult) + com.google.firestore.v1.WriteResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_WriteResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_WriteResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.firestore.v1.WriteResult.class, + com.google.firestore.v1.WriteResult.Builder.class); + } + + // Construct using com.google.firestore.v1.WriteResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + internalGetUpdateTimeFieldBuilder(); + internalGetTransformResultsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + } else { + transformResults_ = null; + transformResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.firestore.v1.WriteProto + .internal_static_google_firestore_v1_WriteResult_descriptor; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResult getDefaultInstanceForType() { + return com.google.firestore.v1.WriteResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.firestore.v1.WriteResult build() { + com.google.firestore.v1.WriteResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResult buildPartial() { + com.google.firestore.v1.WriteResult result = new com.google.firestore.v1.WriteResult(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.firestore.v1.WriteResult result) { + if (transformResultsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + transformResults_ = java.util.Collections.unmodifiableList(transformResults_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.transformResults_ = transformResults_; + } else { + result.transformResults_ = transformResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.firestore.v1.WriteResult result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.firestore.v1.WriteResult) { + return mergeFrom((com.google.firestore.v1.WriteResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.firestore.v1.WriteResult other) { + if (other == com.google.firestore.v1.WriteResult.getDefaultInstance()) return this; + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (transformResultsBuilder_ == null) { + if (!other.transformResults_.isEmpty()) { + if (transformResults_.isEmpty()) { + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureTransformResultsIsMutable(); + transformResults_.addAll(other.transformResults_); + } + onChanged(); + } + } else { + if (!other.transformResults_.isEmpty()) { + if (transformResultsBuilder_.isEmpty()) { + transformResultsBuilder_.dispose(); + transformResultsBuilder_ = null; + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000002); + transformResultsBuilder_ = + com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders + ? internalGetTransformResultsFieldBuilder() + : null; + } else { + transformResultsBuilder_.addAllMessages(other.transformResults_); + } + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage( + internalGetUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.firestore.v1.Value m = + input.readMessage(com.google.firestore.v1.Value.parser(), extensionRegistry); + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(m); + } else { + transformResultsBuilder_.addMessage(m); + } + break; + } // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private com.google.protobuf.Timestamp updateTime_; + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000001); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return internalGetUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * The last update time of the document after applying the write. Not set
+     * after a `delete`.
+     *
+     * If the write did not actually change the document, this will be the
+     * previous update_time.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + private com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + internalGetUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilder< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private java.util.List transformResults_ = + java.util.Collections.emptyList(); + + private void ensureTransformResultsIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + transformResults_ = + new java.util.ArrayList(transformResults_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + transformResultsBuilder_; + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public java.util.List getTransformResultsList() { + if (transformResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transformResults_); + } else { + return transformResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public int getTransformResultsCount() { + if (transformResultsBuilder_ == null) { + return transformResults_.size(); + } else { + return transformResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public com.google.firestore.v1.Value getTransformResults(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder setTransformResults(int index, com.google.firestore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.set(index, value); + onChanged(); + } else { + transformResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder setTransformResults( + int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.set(index, builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder addTransformResults(com.google.firestore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.add(value); + onChanged(); + } else { + transformResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder addTransformResults(int index, com.google.firestore.v1.Value value) { + if (transformResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureTransformResultsIsMutable(); + transformResults_.add(index, value); + onChanged(); + } else { + transformResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder addTransformResults(com.google.firestore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder addTransformResults( + int index, com.google.firestore.v1.Value.Builder builderForValue) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(index, builderForValue.build()); + onChanged(); + } else { + transformResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder addAllTransformResults( + java.lang.Iterable values) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, transformResults_); + onChanged(); + } else { + transformResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder clearTransformResults() { + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + transformResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public Builder removeTransformResults(int index) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.remove(index); + onChanged(); + } else { + transformResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public com.google.firestore.v1.Value.Builder getTransformResultsBuilder(int index) { + return internalGetTransformResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public com.google.firestore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public java.util.List + getTransformResultsOrBuilderList() { + if (transformResultsBuilder_ != null) { + return transformResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transformResults_); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public com.google.firestore.v1.Value.Builder addTransformResultsBuilder() { + return internalGetTransformResultsFieldBuilder() + .addBuilder(com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public com.google.firestore.v1.Value.Builder addTransformResultsBuilder(int index) { + return internalGetTransformResultsFieldBuilder() + .addBuilder(index, com.google.firestore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The results of applying each
+     * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+     * in the same order.
+     * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + public java.util.List getTransformResultsBuilderList() { + return internalGetTransformResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder> + internalGetTransformResultsFieldBuilder() { + if (transformResultsBuilder_ == null) { + transformResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilder< + com.google.firestore.v1.Value, + com.google.firestore.v1.Value.Builder, + com.google.firestore.v1.ValueOrBuilder>( + transformResults_, + ((bitField0_ & 0x00000002) != 0), + getParentForChildren(), + isClean()); + transformResults_ = null; + } + return transformResultsBuilder_; + } + + // @@protoc_insertion_point(builder_scope:google.firestore.v1.WriteResult) + } + + // @@protoc_insertion_point(class_scope:google.firestore.v1.WriteResult) + private static final com.google.firestore.v1.WriteResult DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.firestore.v1.WriteResult(); + } + + public static com.google.firestore.v1.WriteResult getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public WriteResult parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.firestore.v1.WriteResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResultOrBuilder.java b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResultOrBuilder.java new file mode 100644 index 000000000000..a8cae16f7f02 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/java/com/google/firestore/v1/WriteResultOrBuilder.java @@ -0,0 +1,143 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// NO CHECKED-IN PROTOBUF GENCODE +// source: google/firestore/v1/write.proto +// Protobuf Java Version: 4.33.2 + +package com.google.firestore.v1; + +@com.google.protobuf.Generated +public interface WriteResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.firestore.v1.WriteResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * The last update time of the document after applying the write. Not set
+   * after a `delete`.
+   *
+   * If the write did not actually change the document, this will be the
+   * previous update_time.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + java.util.List getTransformResultsList(); + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + com.google.firestore.v1.Value getTransformResults(int index); + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + int getTransformResultsCount(); + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + java.util.List + getTransformResultsOrBuilderList(); + + /** + * + * + *
+   * The results of applying each
+   * [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform],
+   * in the same order.
+   * 
+ * + * repeated .google.firestore.v1.Value transform_results = 2; + */ + com.google.firestore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index); +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/BUILD.bazel b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/BUILD.bazel new file mode 100644 index 000000000000..2630288f80ce --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/BUILD.bazel @@ -0,0 +1,88 @@ +# This is an API workspace, having public visibility by default makes perfect sense. +package(default_visibility = ["//visibility:public"]) + +############################################################################## +# Common +############################################################################## +load("@rules_proto//proto:defs.bzl", "proto_library") +load("@com_google_googleapis_imports//:imports.bzl", "proto_library_with_info") + +proto_library( + name = "firestore_bundle_proto", + srcs = [ + "bundle.proto", + ], + deps = [ + "//google/firestore/v1:firestore_proto", + "@com_google_protobuf//:timestamp_proto", + ], +) + +proto_library_with_info( + name = "firestore_bundle_proto_with_info", + deps = [ + ":firestore_bundle_proto", + "//google/cloud:common_resources_proto", + ], +) + +############################################################################## +# Java +############################################################################## +load( + "@com_google_googleapis_imports//:imports.bzl", + "java_gapic_assembly_gradle_pkg", + "java_gapic_library", + "java_gapic_test", + "java_grpc_library", + "java_proto_library", +) + +java_proto_library( + name = "firestore_bundle_java_proto", + deps = [":firestore_bundle_proto"], +) + +# Open Source Packages +java_gapic_assembly_gradle_pkg( + name = "google-cloud-firestore-bundle-v1-java", + deps = [ + ":firestore_bundle_java_proto", + ":firestore_bundle_proto", + ], +) + +############################################################################## +# Go +############################################################################## +# Put your Go rules here + +############################################################################## +# Python +############################################################################## +# Put your Python rules here + +############################################################################## +# PHP +############################################################################## +# Put your PHP rules here + +############################################################################## +# Node.js +############################################################################## +# Put your Node.js rules here + +############################################################################## +# Ruby +############################################################################## +# Put your Ruby rules here + +############################################################################## +# C# +############################################################################## +# Put your C# rules here + +############################################################################## +# C++ +############################################################################## +# Put your C++ rules here diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/bundle.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/bundle.proto new file mode 100644 index 000000000000..22bbd8a09153 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/firestore/bundle.proto @@ -0,0 +1,120 @@ +// Copyright 2020 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// This file defines the format of Firestore bundle file/stream. It is not a part of the +// Firestore API, only a specification used by Server and Client SDK to write and read +// bundles. + +syntax = "proto3"; + +package firestore; + +import "google/firestore/v1/document.proto"; +import "google/firestore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Firestore.Proto"; +option go_package = "google.golang.org/genproto/firestore/proto;firestore"; +option java_multiple_files = true; +option java_outer_classname = "BundleProto"; +option java_package = "com.google.firestore.proto"; +option objc_class_prefix = "FSTPB"; +option php_namespace = "Firestore\\Proto"; + +// Encodes a query saved in the bundle. +message BundledQuery { + // The parent resource name. + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + google.firestore.v1.StructuredQuery structured_query = 2; + } + + // If the query is a limit query, should the limit be applied to the beginning or + // the end of results. + enum LimitType { + FIRST = 0; + LAST = 1; + } + LimitType limit_type = 3; +} + +// A Query associated with a name, created as part of the bundle file, and can be read +// by client SDKs once the bundle containing them is loaded. +message NamedQuery { + // Name of the query, such that client can use the name to load this query + // from bundle, and resume from when the query results are materialized + // into this bundle. + string name = 1; + + // The query saved in the bundle. + BundledQuery bundled_query = 2; + + // The read time of the query, when it is used to build the bundle. This is useful to + // resume the query from the bundle, once it is loaded by client SDKs. + google.protobuf.Timestamp read_time = 3; +} + +// Metadata describing a Firestore document saved in the bundle. +message BundledDocumentMetadata { + // The document key of a bundled document. + string name = 1; + + // The snapshot version of the document data bundled. + google.protobuf.Timestamp read_time = 2; + + // Whether the document exists. + bool exists = 3; + + // The names of the queries in this bundle that this document matches to. + repeated string queries = 4; +} + +// Metadata describing the bundle file/stream. +message BundleMetadata { + // The ID of the bundle. + string id = 1; + + // Time at which the documents snapshot is taken for this bundle. + google.protobuf.Timestamp create_time = 2; + + // The schema version of the bundle. + uint32 version = 3; + + // The number of documents in the bundle. + uint32 total_documents = 4; + + // The size of the bundle in bytes, excluding this `BundleMetadata`. + uint64 total_bytes = 5; +} + +// A Firestore bundle is a length-prefixed stream of JSON representations of +// `BundleElement`. +// Only one `BundleMetadata` is expected, and it should be the first element. +// The named queries follow after `metadata`. Every `document_metadata` is +// immediately followed by a `document`. +message BundleElement { + oneof element_type { + BundleMetadata metadata = 1; + + NamedQuery named_query = 2; + + BundledDocumentMetadata document_metadata = 3; + + google.firestore.v1.Document document = 4; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/aggregation_result.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/aggregation_result.proto new file mode 100644 index 000000000000..4eee2ddc8aa4 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/aggregation_result.proto @@ -0,0 +1,43 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/firestore/v1/document.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "AggregationResultProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// The result of a single bucket from a Firestore aggregation query. +// +// The keys of `aggregate_fields` are the same for all results in an aggregation +// query, unlike document queries which can have different fields present for +// each result. +message AggregationResult { + // The result of the aggregation functions, ex: `COUNT(*) AS total_docs`. + // + // The key is the + // [alias][google.firestore.v1.StructuredAggregationQuery.Aggregation.alias] + // assigned to the aggregation function on input and the size of this map + // equals the number of aggregation functions in the query. + map aggregate_fields = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/bloom_filter.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/bloom_filter.proto new file mode 100644 index 000000000000..f9bbdbf08d52 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/bloom_filter.proto @@ -0,0 +1,73 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "BloomFilterProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A sequence of bits, encoded in a byte array. +// +// Each byte in the `bitmap` byte array stores 8 bits of the sequence. The only +// exception is the last byte, which may store 8 _or fewer_ bits. The `padding` +// defines the number of bits of the last byte to be ignored as "padding". The +// values of these "padding" bits are unspecified and must be ignored. +// +// To retrieve the first bit, bit 0, calculate: `(bitmap[0] & 0x01) != 0`. +// To retrieve the second bit, bit 1, calculate: `(bitmap[0] & 0x02) != 0`. +// To retrieve the third bit, bit 2, calculate: `(bitmap[0] & 0x04) != 0`. +// To retrieve the fourth bit, bit 3, calculate: `(bitmap[0] & 0x08) != 0`. +// To retrieve bit n, calculate: `(bitmap[n / 8] & (0x01 << (n % 8))) != 0`. +// +// The "size" of a `BitSequence` (the number of bits it contains) is calculated +// by this formula: `(bitmap.length * 8) - padding`. +message BitSequence { + // The bytes that encode the bit sequence. + // May have a length of zero. + bytes bitmap = 1; + + // The number of bits of the last byte in `bitmap` to ignore as "padding". + // If the length of `bitmap` is zero, then this value must be `0`. + // Otherwise, this value must be between 0 and 7, inclusive. + int32 padding = 2; +} + +// A bloom filter (https://en.wikipedia.org/wiki/Bloom_filter). +// +// The bloom filter hashes the entries with MD5 and treats the resulting 128-bit +// hash as 2 distinct 64-bit hash values, interpreted as unsigned integers +// using 2's complement encoding. +// +// These two hash values, named `h1` and `h2`, are then used to compute the +// `hash_count` hash values using the formula, starting at `i=0`: +// +// h(i) = h1 + (i * h2) +// +// These resulting values are then taken modulo the number of bits in the bloom +// filter to get the bits of the bloom filter to test for the given entry. +message BloomFilter { + // The bloom filter data. + BitSequence bits = 1; + + // The number of hashes used by the algorithm. + int32 hash_count = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto new file mode 100644 index 000000000000..799fd011c26b --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/common.proto @@ -0,0 +1,90 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "CommonProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A set of field paths on a document. +// Used to restrict a get or update operation on a document to a subset of its +// fields. +// This is different from standard field masks, as this is always scoped to a +// [Document][google.firestore.v1.Document], and takes in account the dynamic +// nature of [Value][google.firestore.v1.Value]. +message DocumentMask { + // The list of field paths in the mask. See + // [Document.fields][google.firestore.v1.Document.fields] for a field path + // syntax reference. + repeated string field_paths = 1; +} + +// A precondition on a document, used for conditional operations. +message Precondition { + // The type of precondition. + oneof condition_type { + // When set to `true`, the target document must exist. + // When set to `false`, the target document must not exist. + bool exists = 1; + + // When set, the target document must exist and have been last updated at + // that time. Timestamp must be microsecond aligned. + google.protobuf.Timestamp update_time = 2; + } +} + +// Options for creating a new transaction. +message TransactionOptions { + // Options for a transaction that can be used to read and write documents. + // + // Firestore does not allow 3rd party auth requests to create read-write. + // transactions. + message ReadWrite { + // An optional transaction to retry. + bytes retry_transaction = 1; + } + + // Options for a transaction that can only be used to read documents. + message ReadOnly { + // The consistency mode for this transaction. If not set, defaults to strong + // consistency. + oneof consistency_selector { + // Reads documents at the given time. + // + // This must be a microsecond precision timestamp within the past one + // hour, or if Point-in-Time Recovery is enabled, can additionally be a + // whole minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 2; + } + } + + // The mode of the transaction. + oneof mode { + // The transaction can only be used for read operations. + ReadOnly read_only = 2; + + // The transaction can be used for both read and write operations. + ReadWrite read_write = 3; + } +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto new file mode 100644 index 000000000000..a77dbd997189 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/document.proto @@ -0,0 +1,247 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "DocumentProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A Firestore document. +// +// Must not exceed 1 MiB - 4 bytes. +message Document { + // The resource name of the document, for example + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1; + + // The document's fields. + // + // The map keys represent field names. + // + // Field names matching the regular expression `__.*__` are reserved. Reserved + // field names are forbidden except in certain documented contexts. The field + // names, represented as UTF-8, must not exceed 1,500 bytes and cannot be + // empty. + // + // Field paths may be used in other contexts to refer to structured fields + // defined here. For `map_value`, the field path is represented by a + // dot-delimited (`.`) string of segments. Each segment is either a simple + // field name (defined below) or a quoted field name. For example, the + // structured field `"foo" : { map_value: { "x&y" : { string_value: "hello" + // }}}` would be represented by the field path `` foo.`x&y` ``. + // + // A simple field name contains only characters `a` to `z`, `A` to `Z`, + // `0` to `9`, or `_`, and must not start with `0` to `9`. For example, + // `foo_bar_17`. + // + // A quoted field name starts and ends with `` ` `` and + // may contain any character. Some characters, including `` ` ``, must be + // escaped using a `\`. For example, `` `x&y` `` represents `x&y` and + // `` `bak\`tik` `` represents `` bak`tik ``. + map fields = 2; + + // Output only. The time at which the document was created. + // + // This value increases monotonically when a document is deleted then + // recreated. It can also be compared to values from other documents and + // the `read_time` of a query. + google.protobuf.Timestamp create_time = 3; + + // Output only. The time at which the document was last changed. + // + // This value is initially set to the `create_time` then increases + // monotonically with each change to the document. It can also be + // compared to values from other documents and the `read_time` of a query. + google.protobuf.Timestamp update_time = 4; +} + +// A message that can hold any of the supported value types. +message Value { + // Must have a value set. + oneof value_type { + // A null value. + google.protobuf.NullValue null_value = 11; + + // A boolean value. + bool boolean_value = 1; + + // An integer value. + int64 integer_value = 2; + + // A double value. + double double_value = 3; + + // A timestamp value. + // + // Precise only to microseconds. When stored, any additional precision is + // rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // 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; + + // A bytes value. + // + // Must not exceed 1 MiB - 89 bytes. + // Only the first 1,500 bytes are considered by queries. + bytes bytes_value = 18; + + // A reference to a document. For example: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string reference_value = 5; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An array value. + // + // Cannot directly contain another array value, though can contain a + // map which contains another array. + ArrayValue array_value = 9; + + // A map value. + MapValue map_value = 6; + + // Value which references a field. + // + // This is considered relative (vs absolute) since it only refers to a field + // and not a field within a particular document. + // + // **Requires:** + // + // * Must follow [field reference][FieldReference.field_path] limitations. + // + // * Not allowed to be used when writing documents. + string field_reference_value = 19; + + // Pointer to a variable defined elsewhere in a pipeline. + // + // Unlike `field_reference_value` which references a field within a + // document, this refers to a variable, defined in a separate namespace than + // the fields of a document. + string variable_reference_value = 22; + + // A value that represents an unevaluated expression. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + Function function_value = 20; + + // A value that represents an unevaluated pipeline. + // + // **Requires:** + // + // * Not allowed to be used when writing documents. + Pipeline pipeline_value = 21; + } +} + +// An array value. +message ArrayValue { + // Values in the array. + repeated Value values = 1; +} + +// A map value. +message MapValue { + // The map's fields. + // + // The map keys represent field names. Field names matching the regular + // expression `__.*__` are reserved. Reserved field names are forbidden except + // in certain documented contexts. The map keys, represented as UTF-8, must + // not exceed 1,500 bytes and cannot be empty. + map fields = 1; +} + +// Represents an unevaluated scalar expression. +// +// For example, the expression `like(user_name, "%alice%")` is represented as: +// +// ``` +// name: "like" +// args { field_reference: "user_name" } +// args { string_value: "%alice%" } +// ``` +message Function { + // Required. The name of the function to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Ordered list of arguments the given function expects. + repeated Value args = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional named arguments that certain functions may support. + map options = 3 [(google.api.field_behavior) = OPTIONAL]; +} + +// A Firestore query represented as an ordered list of operations / stages. +message Pipeline { + // A single operation within a pipeline. + // + // A stage is made up of a unique name, and a list of arguments. The exact + // number of arguments & types is dependent on the stage type. + // + // To give an example, the stage `filter(state = "MD")` would be encoded as: + // + // ``` + // name: "filter" + // args { + // function_value { + // name: "eq" + // args { field_reference_value: "state" } + // args { string_value: "MD" } + // } + // } + // ``` + // + // See public documentation for the full list. + message Stage { + // Required. The name of the stage to evaluate. + // + // **Requires:** + // + // * must be in snake case (lower case with underscore separator). + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Ordered list of arguments the given stage expects. + repeated Value args = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Optional named arguments that certain functions may support. + map options = 3 [(google.api.field_behavior) = OPTIONAL]; + } + + // Required. Ordered list of stages to evaluate. + repeated Stage stages = 1 [(google.api.field_behavior) = REQUIRED]; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/explain_stats.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/explain_stats.proto new file mode 100644 index 000000000000..a05d530133b3 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/explain_stats.proto @@ -0,0 +1,41 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/protobuf/any.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "ExplainStatsProto"; +option java_package = "com.google.firestore.v1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of Firestore Explain Stats fields. + +// Pipeline explain stats. +// +// Depending on the explain options in the original request, this can contain +// the optimized plan and / or execution stats. +message ExplainStats { + // The format depends on the `output_format` options in the request. + // + // Currently there are two supported options: `TEXT` and `JSON`. + // Both supply a `google.protobuf.StringValue`. + google.protobuf.Any data = 1; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto new file mode 100644 index 000000000000..f65646a4afdf --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/firestore.proto @@ -0,0 +1,1229 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/routing.proto"; +import "google/firestore/v1/aggregation_result.proto"; +import "google/firestore/v1/common.proto"; +import "google/firestore/v1/document.proto"; +import "google/firestore/v1/explain_stats.proto"; +import "google/firestore/v1/pipeline.proto"; +import "google/firestore/v1/query.proto"; +import "google/firestore/v1/query_profile.proto"; +import "google/firestore/v1/write.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; +import "google/rpc/status.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "FirestoreProto"; +option java_package = "com.google.firestore.v1"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore API. + +// The Cloud Firestore service. +// +// Cloud Firestore is a fast, fully managed, serverless, cloud-native NoSQL +// document database that simplifies storing, syncing, and querying data for +// your mobile, web, and IoT apps at global scale. Its client libraries provide +// live synchronization and offline support, while its security features and +// integrations with Firebase and Google Cloud Platform accelerate building +// truly serverless apps. +service Firestore { + option (google.api.default_host) = "firestore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Gets a single document. + rpc GetDocument(GetDocumentRequest) returns (Document) { + option (google.api.http) = { + get: "/v1/{name=projects/*/databases/*/documents/*/**}" + }; + } + + // Lists documents. + rpc ListDocuments(ListDocumentsRequest) returns (ListDocumentsResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/databases/*/documents/*/**}/{collection_id}" + additional_bindings { + get: "/v1/{parent=projects/*/databases/*/documents}/{collection_id}" + } + }; + } + + // Updates or inserts a document. + rpc UpdateDocument(UpdateDocumentRequest) returns (Document) { + option (google.api.http) = { + patch: "/v1/{document.name=projects/*/databases/*/documents/*/**}" + body: "document" + }; + option (google.api.method_signature) = "document,update_mask"; + } + + // Deletes a document. + rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/databases/*/documents/*/**}" + }; + option (google.api.method_signature) = "name"; + } + + // Gets multiple documents. + // + // Documents returned by this method are not guaranteed to be returned in the + // same order that they were requested. + rpc BatchGetDocuments(BatchGetDocumentsRequest) + returns (stream BatchGetDocumentsResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:batchGet" + body: "*" + }; + } + + // Starts a new transaction. + rpc BeginTransaction(BeginTransactionRequest) + returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:beginTransaction" + body: "*" + }; + option (google.api.method_signature) = "database"; + } + + // Commits a transaction, while optionally updating documents. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:commit" + body: "*" + }; + option (google.api.method_signature) = "database,writes"; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:rollback" + body: "*" + }; + option (google.api.method_signature) = "database,transaction"; + } + + // Runs a query. + rpc RunQuery(RunQueryRequest) returns (stream RunQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:runQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runQuery" + body: "*" + } + }; + } + + // Executes a pipeline query. + rpc ExecutePipeline(ExecutePipelineRequest) + returns (stream ExecutePipelineResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:executePipeline" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { + field: "database" + path_template: "projects/{project_id=*}/**" + } + routing_parameters { + field: "database" + path_template: "projects/*/databases/{database_id=*}/**" + } + }; + } + + // Runs an aggregation query. + // + // Rather than producing [Document][google.firestore.v1.Document] results like + // [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery], this API + // allows running an aggregation to produce a series of + // [AggregationResult][google.firestore.v1.AggregationResult] server-side. + // + // High-Level Example: + // + // ``` + // -- Return the number of documents in table given a filter. + // SELECT COUNT(*) FROM ( SELECT * FROM k where a = true ); + // ``` + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (stream RunAggregationQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:runAggregationQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:runAggregationQuery" + body: "*" + } + }; + } + + // 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. + rpc PartitionQuery(PartitionQueryRequest) returns (PartitionQueryResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:partitionQuery" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:partitionQuery" + body: "*" + } + }; + } + + // Streams batches of document updates and deletes, in order. This method is + // only available via gRPC or WebChannel (not REST). + rpc Write(stream WriteRequest) returns (stream WriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:write" + body: "*" + }; + } + + // Listens to changes. This method is only available via gRPC or WebChannel + // (not REST). + rpc Listen(stream ListenRequest) returns (stream ListenResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:listen" + body: "*" + }; + } + + // Lists all the collection IDs underneath a document. + rpc ListCollectionIds(ListCollectionIdsRequest) + returns (ListCollectionIdsResponse) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents}:listCollectionIds" + body: "*" + additional_bindings { + post: "/v1/{parent=projects/*/databases/*/documents/*/**}:listCollectionIds" + body: "*" + } + }; + option (google.api.method_signature) = "parent"; + } + + // 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. + rpc BatchWrite(BatchWriteRequest) returns (BatchWriteResponse) { + option (google.api.http) = { + post: "/v1/{database=projects/*/databases/*}/documents:batchWrite" + body: "*" + }; + } + + // Creates a new document. + rpc CreateDocument(CreateDocumentRequest) returns (Document) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/databases/*/documents/**}/{collection_id}" + body: "document" + }; + } +} + +// The request for +// [Firestore.GetDocument][google.firestore.v1.Firestore.GetDocument]. +message GetDocumentRequest { + // Required. The resource name of the Document to get. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 2; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads the document in a transaction. + bytes transaction = 3; + + // Reads the version of the document at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 5; + } +} + +// The request for +// [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. +message ListDocumentsRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. The collection ID, relative to `parent`, to list. + // + // For example: `chatrooms` or `messages`. + // + // This is optional, and when not provided, Firestore will list documents + // from all collections under the provided `parent`. + string collection_id = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The maximum number of documents to return in a single response. + // + // Firestore may return fewer than this value. + int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. A page token, received from a previous `ListDocuments` response. + // + // Provide this to retrieve the subsequent page. When paginating, all other + // parameters (with the exception of `page_size`) must match the values set + // in the request that generated the page token. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The optional ordering of the documents to return. + // + // For example: `priority desc, __name__ desc`. + // + // This mirrors the [`ORDER BY`][google.firestore.v1.StructuredQuery.order_by] + // used in Firestore queries but in a string representation. When absent, + // documents are ordered based on `__name__ ASC`. + string order_by = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 7 [(google.api.field_behavior) = OPTIONAL]; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Perform the read as part of an already active transaction. + bytes transaction = 8; + + // Perform the read at the provided time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 10; + } + + // If the list should show missing documents. + // + // A document is missing if it does not exist, but there are sub-documents + // nested underneath it. When true, such missing documents will be returned + // with a key but will not have fields, + // [`create_time`][google.firestore.v1.Document.create_time], or + // [`update_time`][google.firestore.v1.Document.update_time] set. + // + // Requests with `show_missing` may not specify `where` or `order_by`. + bool show_missing = 12; +} + +// The response for +// [Firestore.ListDocuments][google.firestore.v1.Firestore.ListDocuments]. +message ListDocumentsResponse { + // The Documents found. + repeated Document documents = 1; + + // A token to retrieve the next page of documents. + // + // If this field is omitted, there are no subsequent pages. + string next_page_token = 2; +} + +// The request for +// [Firestore.CreateDocument][google.firestore.v1.Firestore.CreateDocument]. +message CreateDocumentRequest { + // Required. The parent resource. For example: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/chatrooms/{chatroom_id}` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The collection ID, relative to `parent`, to list. For example: + // `chatrooms`. + string collection_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // The client-assigned document ID to use for this document. + // + // Optional. If not specified, an ID will be assigned by the service. + string document_id = 3; + + // Required. The document to create. `name` must not be set. + Document document = 4 [(google.api.field_behavior) = REQUIRED]; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 5; +} + +// The request for +// [Firestore.UpdateDocument][google.firestore.v1.Firestore.UpdateDocument]. +message UpdateDocumentRequest { + // Required. The updated document. + // Creates the document if it does not already exist. + Document document = 1 [(google.api.field_behavior) = REQUIRED]; + + // The fields to update. + // None of the field paths in the mask may contain a reserved name. + // + // If the document exists on the server and has fields not referenced in the + // mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + DocumentMask update_mask = 2; + + // The fields to return. If not set, returns all fields. + // + // If the document has a field that is not present in this mask, that field + // will not be returned in the response. + DocumentMask mask = 3; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// The request for +// [Firestore.DeleteDocument][google.firestore.v1.Firestore.DeleteDocument]. +message DeleteDocumentRequest { + // Required. The resource name of the Document to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // An optional precondition on the document. + // The request will fail if this is set and not met by the target document. + Precondition current_document = 2; +} + +// The request for +// [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of the + // given `database`. Duplicate names will be elided. + repeated string documents = 2; + + // The fields to return. If not set, returns all fields. + // + // If a document has a field that is not present in this mask, that field will + // not be returned in the response. + DocumentMask mask = 3; + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents in a transaction. + bytes transaction = 4; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } +} + +// The streamed response for +// [Firestore.BatchGetDocuments][google.firestore.v1.Firestore.BatchGetDocuments]. +message BatchGetDocumentsResponse { + // A single result. + // This can be empty if the server is just returning a transaction. + oneof result { + // A document that was requested. + Document found = 1; + + // 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; + } + + // The transaction that was started as part of this request. + // Will only be set in the first response, and only if + // [BatchGetDocumentsRequest.new_transaction][google.firestore.v1.BatchGetDocumentsRequest.new_transaction] + // was set in the request. + bytes transaction = 3; + + // The time at which the document was read. + // This may be monotically increasing, in this case the previous documents in + // the result stream are guaranteed not to have changed between their + // read_time and this one. + google.protobuf.Timestamp read_time = 4; +} + +// The request for +// [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. +message BeginTransactionRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The options for the transaction. + // Defaults to a read-write transaction. + TransactionOptions options = 2; +} + +// The response for +// [Firestore.BeginTransaction][google.firestore.v1.Firestore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction that was started. + bytes transaction = 1; +} + +// The request for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. +message CommitRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Always executed atomically and in order. + repeated Write writes = 2; + + // If set, applies all writes in this transaction, and commits it. + bytes transaction = 3; +} + +// The response for [Firestore.Commit][google.firestore.v1.Firestore.Commit]. +message CommitResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the commit. + google.protobuf.Timestamp commit_time = 2; +} + +// The request for [Firestore.Rollback][google.firestore.v1.Firestore.Rollback]. +message RollbackRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The transaction to roll back. + bytes transaction = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. +message RunQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + + // The consistency mode for this transaction. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Starts a new transaction and reads the documents. + // Defaults to a read-only transaction. + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 6; + + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } + + // Optional. Explain options for the query. If set, additional query + // statistics will be returned. If not, only query results will be returned. + ExplainOptions explain_options = 10 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Firestore.RunQuery][google.firestore.v1.Firestore.RunQuery]. +message RunQueryResponse { + // The transaction that was started as part of this request. + // Can only be set in the first response, and only if + // [RunQueryRequest.new_transaction][google.firestore.v1.RunQueryRequest.new_transaction] + // was set in the request. If set, no other fields will be set in this + // response. + bytes transaction = 2; + + // A query result, not set when reporting partial progress. + Document document = 1; + + // The time at which the document was read. This may be monotonically + // increasing; in this case, the previous documents in the result stream are + // guaranteed not to have changed between their `read_time` and this one. + // + // If the query returns no results, a response with `read_time` and no + // `document` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; + + // The number of results that have been skipped due to an offset between + // the last response and the current response. + int32 skipped_results = 4; + + // The continuation mode for the query. If present, it indicates the current + // query response stream has finished. This can be set with or without a + // `document` present, but when set, no more results are returned. + oneof continuation_selector { + // If present, Firestore has completely finished the request and no more + // documents will be returned. + bool done = 6; + } + + // Query explain metrics. This is only present when the + // [RunQueryRequest.explain_options][google.firestore.v1.RunQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 11; +} + +// The request for +// [Firestore.ExecutePipeline][google.firestore.v1.Firestore.ExecutePipeline]. +message ExecutePipelineRequest { + // Required. Database identifier, in the form + // `projects/{project}/databases/{database}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + oneof pipeline_type { + // A pipelined operation. + StructuredPipeline structured_pipeline = 2; + } + + // Optional consistency arguments, defaults to strong consistency. + oneof consistency_selector { + // Run the query within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 5; + + // Execute the pipeline in a new transaction. + // + // The identifier of the newly created transaction will be returned in the + // first response on the stream. This defaults to a read-only transaction. + TransactionOptions new_transaction = 6; + + // Execute the pipeline in a snapshot transaction at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 7; + } +} + +// The response for [Firestore.Execute][]. +message ExecutePipelineResponse { + // Newly created transaction identifier. + // + // This field is only specified as part of the first response from the server, + // alongside the `results` field when the original request specified + // [ExecuteRequest.new_transaction][]. + bytes transaction = 1; + + // An ordered batch of results returned executing a pipeline. + // + // The batch size is variable, and can even be zero for when only a partial + // progress message is returned. + // + // The fields present in the returned documents are only those that were + // explicitly requested in the pipeline, this includes those like + // [`__name__`][google.firestore.v1.Document.name] and + // [`__update_time__`][google.firestore.v1.Document.update_time]. This is + // explicitly a divergence from `Firestore.RunQuery` / `Firestore.GetDocument` + // RPCs which always return such fields even when they are not specified in + // the [`mask`][google.firestore.v1.DocumentMask]. + repeated Document results = 2; + + // The time at which the results are valid. + // + // This is a (not strictly) monotonically increasing value across multiple + // responses in the same stream. The API guarantees that all previously + // returned results are still valid at the latest `execution_time`. This + // allows the API consumer to treat the query if it ran at the latest + // `execution_time` returned. + // + // If the query returns no results, a response with `execution_time` and no + // `results` will be sent, and this represents the time at which the operation + // was run. + google.protobuf.Timestamp execution_time = 3; + + // Query explain stats. + // + // This is present on the **last** response if the request configured explain + // to run in 'analyze' or 'explain' mode in the pipeline options. If the query + // does not return any results, a response with `explain_stats` and no + // `results` will still be sent. + ExplainStats explain_stats = 4; +} + +// The request for +// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to run. + oneof query_type { + // An aggregation query. + StructuredAggregationQuery structured_aggregation_query = 2; + } + + // The consistency mode for the query, defaults to strong consistency. + oneof consistency_selector { + // Run the aggregation within an already active transaction. + // + // The value here is the opaque transaction ID to execute the query in. + bytes transaction = 4; + + // Starts a new transaction as part of the query, defaulting to read-only. + // + // The new transaction ID will be returned as the first response in the + // stream. + TransactionOptions new_transaction = 5; + + // Executes the query at the given timestamp. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } + + // Optional. Explain options for the query. If set, additional query + // statistics will be returned. If not, only query results will be returned. + ExplainOptions explain_options = 8 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Firestore.RunAggregationQuery][google.firestore.v1.Firestore.RunAggregationQuery]. +message RunAggregationQueryResponse { + // A single aggregation result. + // + // Not present when reporting partial progress. + AggregationResult result = 1; + + // The transaction that was started as part of this request. + // + // Only present on the first response when the request requested to start + // a new transaction. + bytes transaction = 2; + + // The time at which the aggregate result was computed. This is always + // monotonically increasing; in this case, the previous AggregationResult in + // the result stream are guaranteed not to have changed between their + // `read_time` and this one. + // + // If the query returns no results, a response with `read_time` and no + // `result` will be sent, and this represents the time at which the query + // was run. + google.protobuf.Timestamp read_time = 3; + + // Query explain metrics. This is only present when the + // [RunAggregationQueryRequest.explain_options][google.firestore.v1.RunAggregationQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 10; +} + +// The request for +// [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryRequest { + // Required. The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents`. + // Document resource names are not supported; only database resource names + // can be specified. + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The query to partition. + oneof query_type { + // A structured query. + // Query must specify collection with all descendants and be ordered by name + // ascending. Other filters, order bys, limits, offsets, and start/end + // cursors are not supported. + StructuredQuery structured_query = 2; + } + + // The desired maximum number of partition points. + // The partitions may be returned across multiple pages of results. + // The number must be positive. The actual number of partitions + // returned may be fewer. + // + // For example, this may be set to one fewer than the number of parallel + // queries to be run, or in running a data pipeline job, one fewer than the + // number of workers or compute instances available. + int64 partition_count = 3; + + // The `next_page_token` value returned from a previous call to + // PartitionQuery that may be used to get an additional set of results. + // There are no ordering guarantees between sets of results. Thus, using + // multiple sets of results will require merging the different result sets. + // + // For example, two subsequent calls using a page_token may return: + // + // * cursor B, cursor M, cursor Q + // * cursor A, cursor U, cursor W + // + // To obtain a complete result set ordered with respect to the results of the + // query supplied to PartitionQuery, the results sets should be merged: + // cursor A, cursor B, cursor M, cursor Q, cursor U, cursor W + string page_token = 4; + + // The maximum number of partitions to return in this call, subject to + // `partition_count`. + // + // For example, if `partition_count` = 10 and `page_size` = 8, the first call + // to PartitionQuery will return up to 8 partitions and a `next_page_token` + // if more results exist. A second call to PartitionQuery will return up to + // 2 partitions, to complete the total of 10 specified in `partition_count`. + int32 page_size = 5; + + // The consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 6; + } +} + +// The response for +// [Firestore.PartitionQuery][google.firestore.v1.Firestore.PartitionQuery]. +message PartitionQueryResponse { + // Partition results. + // Each partition is a split point that can be used by RunQuery as a starting + // or end point for the query results. The RunQuery requests must be made with + // the same query supplied to this PartitionQuery request. The partition + // cursors will be ordered according to same ordering as the results of the + // query supplied to PartitionQuery. + // + // For example, if a PartitionQuery request returns partition cursors A and B, + // running the following three queries will return the entire result set of + // the original query: + // + // * query, end_at A + // * query, start_at A, end_at B + // * query, start_at B + // + // An empty result may indicate that the query has too few results to be + // partitioned, or that the query is not yet supported for partitioning. + repeated Cursor partitions = 1; + + // A page token that may be used to request an additional set of results, up + // to the number specified by `partition_count` in the PartitionQuery request. + // If blank, there are no more results. + string next_page_token = 2; +} + +// The request for [Firestore.Write][google.firestore.v1.Firestore.Write]. +// +// The first request creates a stream, or resumes an existing one from a token. +// +// When creating a new stream, the server replies with a response containing +// only an ID and a token, to use in the next request. +// +// When resuming a stream, the server first streams any responses later than the +// given token, then a response containing only an up-to-date token, to use in +// the next request. +message WriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + // This is only required in the first message. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the write stream to resume. + // This may only be set in the first message. When left empty, a new write + // stream will be created. + string stream_id = 2; + + // The writes to apply. + // + // Always executed atomically and in order. + // This must be empty on the first request. + // This may be empty on the last request. + // This must not be empty on all other requests. + repeated Write writes = 3; + + // A stream token that was previously sent by the server. + // + // The client should set this field to the token from the most recent + // [WriteResponse][google.firestore.v1.WriteResponse] it has received. This + // acknowledges that the client has received responses up to this token. After + // sending this token, earlier tokens may not be used anymore. + // + // The server may close the stream if there are too many unacknowledged + // responses. + // + // Leave this field unset when creating a new stream. To resume a stream at + // a specific point, set this field and the `stream_id` field. + // + // Leave this field unset when creating a new stream. + bytes stream_token = 4; + + // Labels associated with this write request. + map labels = 5; +} + +// The response for [Firestore.Write][google.firestore.v1.Firestore.Write]. +message WriteResponse { + // The ID of the stream. + // Only set on the first message, when a new stream was created. + string stream_id = 1; + + // A token that represents the position of this response in the stream. + // This can be used by a client to resume the stream at this point. + // + // This field is always set. + bytes stream_token = 2; + + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 3; + + // The time at which the commit occurred. Any read with an equal or greater + // `read_time` is guaranteed to see the effects of the write. + google.protobuf.Timestamp commit_time = 4; +} + +// A request for [Firestore.Listen][google.firestore.v1.Firestore.Listen] +message ListenRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The supported target changes. + oneof target_change { + // A target to add to this stream. + Target add_target = 2; + + // The ID of a target to remove from this stream. + int32 remove_target = 3; + } + + // Labels associated with this target change. + map labels = 4; +} + +// The response for [Firestore.Listen][google.firestore.v1.Firestore.Listen]. +message ListenResponse { + // The supported responses. + oneof response_type { + // Targets have changed. + TargetChange target_change = 2; + + // A [Document][google.firestore.v1.Document] has changed. + DocumentChange document_change = 3; + + // A [Document][google.firestore.v1.Document] has been deleted. + DocumentDelete document_delete = 4; + + // A [Document][google.firestore.v1.Document] has been removed from a target + // (because it is no longer relevant to that target). + DocumentRemove document_remove = 6; + + // A filter to apply to the set of documents previously returned for the + // given target. + // + // Returned when documents may have been removed from the given target, but + // the exact documents are unknown. + ExistenceFilter filter = 5; + } +} + +// A specification of a set of documents to listen to. +message Target { + // A target specified by a set of documents names. + message DocumentsTarget { + // The names of the documents to retrieve. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // The request will fail if any of the document is not a child resource of + // the given `database`. Duplicate names will be elided. + repeated string documents = 2; + } + + // A target specified by a query. + message QueryTarget { + // The parent resource name. In the format: + // `projects/{project_id}/databases/{database_id}/documents` or + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents` or + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1; + + // The query to run. + oneof query_type { + // A structured query. + StructuredQuery structured_query = 2; + } + } + + // The type of target to listen to. + oneof target_type { + // A target specified by a query. + QueryTarget query = 2; + + // A target specified by a set of document names. + DocumentsTarget documents = 3; + } + + // When to start listening. + // + // If specified, only the matching Documents that have been updated AFTER the + // `resume_token` or `read_time` will be returned. Otherwise, all matching + // Documents are returned before any subsequent changes. + oneof resume_type { + // 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; + + // Start listening after a specific `read_time`. + // + // The client must know the state of matching documents at this time. + google.protobuf.Timestamp read_time = 11; + } + + // The target ID that identifies the target on the stream. Must be a positive + // number and non-zero. + // + // If `target_id` is 0 (or unspecified), the server will assign an ID for this + // target and return that in a `TargetChange::ADD` event. Once a target with + // `target_id=0` is added, all subsequent targets must also have + // `target_id=0`. If an `AddTarget` request with `target_id != 0` is + // sent to the server after a target with `target_id=0` is added, the server + // will immediately send a response with a `TargetChange::Remove` event. + // + // Note that if the client sends multiple `AddTarget` requests + // without an ID, the order of IDs returned in `TargetChange.target_ids` are + // undefined. Therefore, clients should provide a target ID instead of relying + // on the server to assign one. + // + // If `target_id` is non-zero, there must not be an existing active target on + // this stream with the same ID. + int32 target_id = 5; + + // If the target should be removed once it is current and consistent. + bool once = 6; + + // The number of documents that last matched the query at the resume token or + // read time. + // + // This value is only relevant when a `resume_type` is provided. This value + // being present and greater than zero signals that the client wants + // `ExistenceFilter.unchanged_names` to be included in the response. + google.protobuf.Int32Value expected_count = 12; +} + +// Targets being watched have changed. +message TargetChange { + // The type of change. + enum TargetChangeType { + // No change has occurred. Used only to send an updated `resume_token`. + NO_CHANGE = 0; + + // The targets have been added. + ADD = 1; + + // The targets have been removed. + REMOVE = 2; + + // The targets reflect all changes committed before the targets were added + // to the stream. + // + // This will be sent after or with a `read_time` that is greater than or + // equal to the time at which the targets were added. + // + // Listeners can wait for this change if read-after-write semantics + // are desired. + CURRENT = 3; + + // The targets have been reset, and a new initial state for the targets + // will be returned in subsequent changes. + // + // After the initial state is complete, `CURRENT` will be returned even + // if the target was previously indicated to be `CURRENT`. + RESET = 4; + } + + // The type of change that occurred. + TargetChangeType target_change_type = 1; + + // The target IDs of targets that have changed. + // + // If empty, the change applies to all targets. + // + // The order of the target IDs is not defined. + repeated int32 target_ids = 2; + + // The error that resulted in this change, if applicable. + google.rpc.Status cause = 3; + + // A token that can be used to resume the stream for the given `target_ids`, + // or all targets if `target_ids` is empty. + // + // Not set on every target change. + bytes resume_token = 4; + + // The consistent `read_time` for the given `target_ids` (omitted when the + // target_ids are not at a consistent snapshot). + // + // The stream is guaranteed to send a `read_time` with `target_ids` empty + // whenever the entire stream reaches a new consistent snapshot. ADD, + // CURRENT, and RESET messages are guaranteed to (eventually) result in a + // new consistent snapshot (while NO_CHANGE and REMOVE messages are not). + // + // For a given stream, `read_time` is guaranteed to be monotonically + // increasing. + google.protobuf.Timestamp read_time = 6; +} + +// The request for +// [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. +message ListCollectionIdsRequest { + // Required. The parent document. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // For example: + // `projects/my-project/databases/my-database/documents/chatrooms/my-chatroom` + string parent = 1 [(google.api.field_behavior) = REQUIRED]; + + // The maximum number of results to return. + int32 page_size = 2; + + // A page token. Must be a value from + // [ListCollectionIdsResponse][google.firestore.v1.ListCollectionIdsResponse]. + string page_token = 3; + + // The consistency mode for this request. + // If not set, defaults to strong consistency. + oneof consistency_selector { + // Reads documents as they were at the given time. + // + // This must be a microsecond precision timestamp within the past one hour, + // or if Point-in-Time Recovery is enabled, can additionally be a whole + // minute timestamp within the past 7 days. + google.protobuf.Timestamp read_time = 4; + } +} + +// The response from +// [Firestore.ListCollectionIds][google.firestore.v1.Firestore.ListCollectionIds]. +message ListCollectionIdsResponse { + // The collection ids. + repeated string collection_ids = 1; + + // A page token that may be used to continue the list. + string next_page_token = 2; +} + +// The request for +// [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. +message BatchWriteRequest { + // Required. The database name. In the format: + // `projects/{project_id}/databases/{database_id}`. + string database = 1 [(google.api.field_behavior) = REQUIRED]; + + // The writes to apply. + // + // Method does not apply writes atomically and does not guarantee ordering. + // Each write succeeds or fails independently. You cannot write to the same + // document more than once per request. + repeated Write writes = 2; + + // Labels associated with this batch write. + map labels = 3; +} + +// The response from +// [Firestore.BatchWrite][google.firestore.v1.Firestore.BatchWrite]. +message BatchWriteResponse { + // The result of applying the writes. + // + // This i-th write result corresponds to the i-th write in the + // request. + repeated WriteResult write_results = 1; + + // The status of applying the writes. + // + // This i-th write status corresponds to the i-th write in the + // request. + repeated google.rpc.Status status = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto new file mode 100644 index 000000000000..509ecd2730e6 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/pipeline.proto @@ -0,0 +1,43 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/firestore/v1/document.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "PipelineProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A Firestore query represented as an ordered list of operations / stages. +// +// This is considered the top-level function which plans and executes a query. +// It is logically equivalent to `query(stages, options)`, but prevents the +// client from having to build a function wrapper. +message StructuredPipeline { + // Required. The pipeline query to execute. + Pipeline pipeline = 1 [(google.api.field_behavior) = REQUIRED]; + + // Optional. Optional query-level arguments. + // + map options = 2 [(google.api.field_behavior) = OPTIONAL]; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto new file mode 100644 index 000000000000..0144ffe5cd9f --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query.proto @@ -0,0 +1,590 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/firestore/v1/document.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A Firestore query. +// +// The query stages are executed in the following order: +// 1. from +// 2. where +// 3. select +// 4. order_by + start_at + end_at +// 5. offset +// 6. limit +// 7. find_nearest +message StructuredQuery { + // A selection of a collection, such as `messages as m1`. + message CollectionSelector { + // The collection ID. + // When set, selects only collections with this ID. + string collection_id = 2; + + // When false, selects only collections that are immediate children of + // the `parent` specified in the containing `RunQueryRequest`. + // When true, selects all descendant collections. + bool all_descendants = 3; + } + + // A filter. + message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a document field. + FieldFilter field_filter = 2; + + // A filter that takes exactly one argument. + UnaryFilter unary_filter = 3; + } + } + + // A filter that merges multiple other filters using the given operator. + message CompositeFilter { + // A composite filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // Documents are required to satisfy all of the combined filters. + AND = 1; + + // Documents are required to satisfy at least one of the combined filters. + OR = 2; + } + + // The operator for combining multiple filters. + Operator op = 1; + + // The list of filters to combine. + // + // Requires: + // + // * At least one filter is present. + repeated Filter filters = 2; + } + + // A filter on a specific field. + message FieldFilter { + // A field filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is less than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN = 1; + + // The given `field` is less than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `field` is greater than the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN = 3; + + // The given `field` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `field` come first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `field` is equal to the given `value`. + EQUAL = 5; + + // The given `field` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_EQUAL = 6; + + // The given `field` is an array that contains the given `value`. + ARRAY_CONTAINS = 7; + + // The given `field` is equal to at least one value in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue`, subject to disjunction + // limits. + // * No `NOT_IN` filters in the same query. + IN = 8; + + // The given `field` is an array that contains any of the values in the + // given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue`, subject to disjunction + // limits. + // * No other `ARRAY_CONTAINS_ANY` filters within the same disjunction. + // * No `NOT_IN` filters in the same query. + ARRAY_CONTAINS_ANY = 9; + + // The value of the `field` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `OR`, `IN`, `ARRAY_CONTAINS_ANY`, `NOT_IN`, `NOT_EQUAL`, + // `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + NOT_IN = 10; + } + + // The field to filter by. + FieldReference field = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare to. + Value value = 3; + } + + // A filter with a single operand. + message UnaryFilter { + // A unary operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `field` is equal to `NaN`. + IS_NAN = 2; + + // The given `field` is equal to `NULL`. + IS_NULL = 3; + + // The given `field` is not equal to `NaN`. + // + // Requires: + // + // * No other `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NAN = 4; + + // The given `field` is not equal to `NULL`. + // + // Requires: + // + // * A single `NOT_EQUAL`, `NOT_IN`, `IS_NOT_NULL`, or `IS_NOT_NAN`. + // * That `field` comes first in the `order_by`. + IS_NOT_NULL = 5; + } + + // The unary operator to apply. + Operator op = 1; + + // The argument to the filter. + oneof operand_type { + // The field to which to apply the operator. + FieldReference field = 2; + } + } + + // An order on a field. + message Order { + // The field to order by. + FieldReference field = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; + } + + // A sort direction. + enum Direction { + // Unspecified. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // A reference to a field in a document, ex: `stats.operations`. + message FieldReference { + // A reference to a field in a document. + // + // Requires: + // + // * MUST be a dot-delimited (`.`) string of segments, where each segment + // conforms to [document field name][google.firestore.v1.Document.fields] + // limitations. + string field_path = 2; + } + + // The projection of document's fields to return. + message Projection { + // The fields to return. + // + // If empty, all fields are returned. To only return the name + // of the document, use `['__name__']`. + repeated FieldReference fields = 2; + } + + // Nearest Neighbors search config. The ordering provided by FindNearest + // supersedes the order_by stage. If multiple documents have the same vector + // distance, the returned document order is not guaranteed to be stable + // between queries. + message FindNearest { + // The distance measure to use when comparing vectors. + enum DistanceMeasure { + // Should not be set. + DISTANCE_MEASURE_UNSPECIFIED = 0; + + // Measures the EUCLIDEAN distance between the vectors. See + // [Euclidean](https://en.wikipedia.org/wiki/Euclidean_distance) to learn + // more. The resulting distance decreases the more similar two vectors + // are. + EUCLIDEAN = 1; + + // COSINE distance compares vectors based on the angle between them, which + // allows you to measure similarity that isn't based on the vectors + // magnitude. We recommend using DOT_PRODUCT with unit normalized vectors + // instead of COSINE distance, which is mathematically equivalent with + // better performance. See [Cosine + // Similarity](https://en.wikipedia.org/wiki/Cosine_similarity) to learn + // more about COSINE similarity and COSINE distance. The resulting + // COSINE distance decreases the more similar two vectors are. + COSINE = 2; + + // Similar to cosine but is affected by the magnitude of the vectors. See + // [Dot Product](https://en.wikipedia.org/wiki/Dot_product) to learn more. + // The resulting distance increases the more similar two vectors are. + DOT_PRODUCT = 3; + } + + // Required. An indexed vector field to search upon. Only documents which + // contain vectors whose dimensionality match the query_vector can be + // returned. + FieldReference vector_field = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The query vector that we are searching on. Must be a vector of + // no more than 2048 dimensions. + Value query_vector = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The distance measure to use, required. + DistanceMeasure distance_measure = 3 + [(google.api.field_behavior) = REQUIRED]; + + // Required. The number of nearest neighbors to return. Must be a positive + // integer of no more than 1000. + google.protobuf.Int32Value limit = 4 + [(google.api.field_behavior) = REQUIRED]; + + // Optional. Optional name of the field to output the result of the vector + // distance calculation. Must conform to [document field + // name][google.firestore.v1.Document.fields] limitations. + string distance_result_field = 5 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. Option to specify a threshold for which no less similar + // documents will be returned. The behavior of the specified + // `distance_measure` will affect the meaning of the distance threshold. + // Since DOT_PRODUCT distances increase when the vectors are more similar, + // the comparison is inverted. + // + // * For EUCLIDEAN, COSINE: `WHERE distance <= distance_threshold` + // * For DOT_PRODUCT: `WHERE distance >= distance_threshold` + google.protobuf.DoubleValue distance_threshold = 6 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Optional sub-set of the fields to return. + // + // This acts as a [DocumentMask][google.firestore.v1.DocumentMask] over the + // documents returned from a query. When not set, assumes that the caller + // wants all fields returned. + Projection select = 1; + + // The collections to query. + repeated CollectionSelector from = 2; + + // The filter to apply. + Filter where = 3; + + // The order to apply to the query results. + // + // Firestore allows callers to provide a full ordering, a partial ordering, or + // no ordering at all. In all cases, Firestore guarantees a stable ordering + // through the following rules: + // + // * The `order_by` is required to reference all fields used with an + // inequality filter. + // * All fields that are required to be in the `order_by` but are not already + // present are appended in lexicographical ordering of the field name. + // * If an order on `__name__` is not specified, it is appended by default. + // + // Fields are appended with the same sort direction as the last order + // specified, or 'ASCENDING' if no order was specified. For example: + // + // * `ORDER BY a` becomes `ORDER BY a ASC, __name__ ASC` + // * `ORDER BY a DESC` becomes `ORDER BY a DESC, __name__ DESC` + // * `WHERE a > 1` becomes `WHERE a > 1 ORDER BY a ASC, __name__ ASC` + // * `WHERE __name__ > ... AND a > 1` becomes + // `WHERE __name__ > ... AND a > 1 ORDER BY a ASC, __name__ ASC` + repeated Order order_by = 4; + + // A potential prefix of a position in the result set to start the query at. + // + // The ordering of the result set is based on the `ORDER BY` clause of the + // original query. + // + // ``` + // SELECT * FROM k WHERE a = 1 AND b > 2 ORDER BY b ASC, __name__ ASC; + // ``` + // + // This query's results are ordered by `(b ASC, __name__ ASC)`. + // + // Cursors can reference either the full ordering or a prefix of the location, + // though it cannot reference more fields than what are in the provided + // `ORDER BY`. + // + // Continuing off the example above, attaching the following start cursors + // will have varying impact: + // + // - `START BEFORE (2, /k/123)`: start the query right before `a = 1 AND + // b > 2 AND __name__ > /k/123`. + // - `START AFTER (10)`: start the query right after `a = 1 AND b > 10`. + // + // Unlike `OFFSET` which requires scanning over the first N results to skip, + // a start cursor allows the query to begin at a logical position. This + // position is not required to match an actual result, it will scan forward + // from this position to find the next document. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor start_at = 7; + + // A potential prefix of a position in the result set to end the query at. + // + // This is similar to `START_AT` but with it controlling the end position + // rather than the start position. + // + // Requires: + // + // * The number of values cannot be greater than the number of fields + // specified in the `ORDER BY` clause. + Cursor end_at = 8; + + // The number of documents to skip before returning the first result. + // + // This applies after the constraints specified by the `WHERE`, `START AT`, & + // `END AT` but before the `LIMIT` clause. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + int32 offset = 6; + + // The maximum number of results to return. + // + // Applies after all other constraints. + // + // Requires: + // + // * The value must be greater than or equal to zero if specified. + google.protobuf.Int32Value limit = 5; + + // Optional. A potential nearest neighbors search. + // + // Applies after all other filters and ordering. + // + // Finds the closest vector embeddings to the given query vector. + FindNearest find_nearest = 9 [(google.api.field_behavior) = OPTIONAL]; +} + +// Firestore query for running an aggregation over a +// [StructuredQuery][google.firestore.v1.StructuredQuery]. +message StructuredAggregationQuery { + // Defines an aggregation that produces a single result. + message Aggregation { + // Count of documents that match the query. + // + // The `COUNT(*)` aggregation function operates on the entire document + // so it does not require a field reference. + message Count { + // Optional. Optional constraint on the maximum number of documents to + // count. + // + // This provides a way to set an upper bound on the number of documents + // to scan, limiting latency, and cost. + // + // Unspecified is interpreted as no bound. + // + // High-Level Example: + // + // ``` + // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); + // ``` + // + // Requires: + // + // * Must be greater than zero when present. + google.protobuf.Int64Value up_to = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Sum of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns 0. + // + // * Returns a 64-bit integer if all aggregated numbers are integers and the + // sum result does not overflow. Otherwise, the result is returned as a + // double. Note that even if all the aggregated values are integers, the + // result is returned as a double if it cannot fit within a 64-bit signed + // integer. When this occurs, the returned value will lose precision. + // + // * When underflow occurs, floating-point aggregation is non-deterministic. + // This means that running the same query repeatedly without any changes to + // the underlying values could produce slightly different results each + // time. In those cases, values should be stored as integers over + // floating-point numbers. + message Sum { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // Average of the values of the requested field. + // + // * Only numeric values will be aggregated. All non-numeric values + // including `NULL` are skipped. + // + // * If the aggregated values contain `NaN`, returns `NaN`. Infinity math + // follows IEEE-754 standards. + // + // * If the aggregated value set is empty, returns `NULL`. + // + // * Always returns the result as a double. + message Avg { + // The field to aggregate on. + StructuredQuery.FieldReference field = 1; + } + + // The type of aggregation to perform, required. + oneof operator { + // Count aggregator. + Count count = 1; + + // Sum aggregator. + Sum sum = 2; + + // Average aggregator. + Avg avg = 3; + } + + // Optional. Optional name of the field to store the result of the + // aggregation into. + // + // If not provided, Firestore will pick a default name following the format + // `field_`. For example: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2), + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) + // OVER ( + // ... + // ); + // ``` + // + // becomes: + // + // ``` + // AGGREGATE + // COUNT_UP_TO(1) AS count_up_to_1, + // COUNT_UP_TO(2) AS field_1, + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) AS field_2 + // OVER ( + // ... + // ); + // ``` + // + // Requires: + // + // * Must be unique across all aggregation aliases. + // * Conform to [document field name][google.firestore.v1.Document.fields] + // limitations. + string alias = 7 [(google.api.field_behavior) = OPTIONAL]; + } + + // The base query to aggregate over. + oneof query_type { + // Nested structured query. + StructuredQuery structured_query = 1; + } + + // Optional. Series of aggregations to apply over the results of the + // `structured_query`. + // + // Requires: + // + // * A minimum of one and maximum of five aggregations per query. + repeated Aggregation aggregations = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A position in a query result set. +message Cursor { + // The values that represent a position, in the order they appear in + // the order by clause of a query. + // + // Can contain fewer values than specified in the order by clause. + repeated Value values = 1; + + // If the position is just before or just after the given values, relative + // to the sort order defined by the query. + bool before = 2; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto new file mode 100644 index 000000000000..a5f9e95c51fe --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/query_profile.proto @@ -0,0 +1,92 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// Specification of the Firestore Query Profile fields. + +// Explain options for the query. +message ExplainOptions { + // Optional. Whether to execute this query. + // + // When false (the default), the query will be planned, returning only + // metrics from the planning stages. + // + // When true, the query will be planned and executed, returning the full + // query results along with both planning and execution stage metrics. + bool analyze = 1 [(google.api.field_behavior) = OPTIONAL]; +} + +// Explain metrics for the query. +message ExplainMetrics { + // Planning phase information for the query. + PlanSummary plan_summary = 1; + + // Aggregated stats from the execution of the query. Only present when + // [ExplainOptions.analyze][google.firestore.v1.ExplainOptions.analyze] is set + // to true. + ExecutionStats execution_stats = 2; +} + +// Planning phase information for the query. +message PlanSummary { + // The indexes selected for the query. For example: + // [ + // {"query_scope": "Collection", "properties": "(foo ASC, __name__ ASC)"}, + // {"query_scope": "Collection", "properties": "(bar ASC, __name__ ASC)"} + // ] + repeated google.protobuf.Struct indexes_used = 1; +} + +// Execution statistics for the query. +message ExecutionStats { + // Total number of results returned, including documents, projections, + // aggregation results, keys. + int64 results_returned = 1; + + // Total time to execute the query in the backend. + google.protobuf.Duration execution_duration = 3; + + // Total billable read operations. + int64 read_operations = 4; + + // Debugging statistics from the execution of the query. Note that the + // debugging stats are subject to change as Firestore evolves. It could + // include: + // { + // "indexes_entries_scanned": "1000", + // "documents_scanned": "20", + // "billing_details" : { + // "documents_billable": "20", + // "index_entries_billable": "1000", + // "min_query_cost": "0" + // } + // } + google.protobuf.Struct debug_stats = 5; +} diff --git a/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto new file mode 100644 index 000000000000..49f9a4870f92 --- /dev/null +++ b/java-firestore/proto-google-cloud-firestore-v1/src/main/proto/google/firestore/v1/write.proto @@ -0,0 +1,286 @@ +// Copyright 2026 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 +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.firestore.v1; + +import "google/firestore/v1/bloom_filter.proto"; +import "google/firestore/v1/common.proto"; +import "google/firestore/v1/document.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Firestore.V1"; +option go_package = "cloud.google.com/go/firestore/apiv1/firestorepb;firestorepb"; +option java_multiple_files = true; +option java_outer_classname = "WriteProto"; +option java_package = "com.google.firestore.v1"; +option objc_class_prefix = "GCFS"; +option php_namespace = "Google\\Cloud\\Firestore\\V1"; +option ruby_package = "Google::Cloud::Firestore::V1"; + +// A write on a document. +message Write { + // The operation to execute. + oneof operation { + // A document to write. + Document update = 1; + + // A document name to delete. In the format: + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + string delete = 2; + + // Applies a transformation to a document. + DocumentTransform transform = 6; + } + + // The fields to update in this write. + // + // This field can be set only when the operation is `update`. + // If the mask is not set for an `update` and the document exists, any + // existing data will be overwritten. + // If the mask is set and the document on the server has fields not covered by + // the mask, they are left unchanged. + // Fields referenced in the mask, but not present in the input document, are + // deleted from the document on the server. + // The field paths in this mask must not contain a reserved field name. + DocumentMask update_mask = 3; + + // The transforms to perform after update. + // + // This field can be set only when the operation is `update`. If present, this + // write is equivalent to performing `update` and `transform` to the same + // document atomically and in order. + repeated DocumentTransform.FieldTransform update_transforms = 7; + + // An optional precondition on the document. + // + // The write will fail if this is set and not met by the target document. + Precondition current_document = 4; +} + +// A transformation of a document. +message DocumentTransform { + // A transformation of a field of the document. + message FieldTransform { + // A value that is calculated by the server. + enum ServerValue { + // Unspecified. This value must not be used. + SERVER_VALUE_UNSPECIFIED = 0; + + // The time at which the server processed the request, with millisecond + // 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; + } + + // The path of the field. See + // [Document.fields][google.firestore.v1.Document.fields] for the field path + // syntax reference. + string field_path = 1; + + // The transformation to apply on the field. + oneof transform_type { + // Sets the field to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the field's current value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If either of the given value or the current field value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follow IEEE 754 semantics. + // If there is positive/negative integer overflow, the field is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the field to the maximum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the given value. + // If a maximum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and + // zero input value is always the stored value. + // The maximum of any numeric value x and NaN is NaN. + Value maximum = 4; + + // Sets the field to the minimum of its current value and the given value. + // + // This must be an integer or a double value. + // If the field is not an integer or double, or if the field does not yet + // exist, the transformation will set the field to the input value. + // If a minimum operation is applied where the field and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the field takes on the type of the smaller operand. If the operands are + // equivalent (e.g. 3 and 3.0), the field does not change. + // 0, 0.0, and -0.0 are all zero. The minimum of a zero stored value and + // zero input value is always the stored value. + // The minimum of any numeric value x and NaN is NaN. + Value minimum = 5; + + // Append the given elements in order if they are not already present in + // the current field value. + // If the field is not an array, or if the field does not yet exist, it is + // first set to the empty array. + // + // Equivalent numbers of different types (e.g. 3L and 3.0) are + // considered equal when checking if a value is missing. + // NaN is equal to NaN, and Null is equal to Null. + // If the input contains multiple equivalent values, only the first will + // be considered. + // + // The corresponding transform_result will be the null value. + ArrayValue append_missing_elements = 6; + + // Remove all of the given elements from the array in the field. + // If the field is not an array, or if the field does not yet exist, it is + // set to the empty array. + // + // Equivalent numbers of the different types (e.g. 3L and 3.0) are + // considered equal when deciding whether an element should be removed. + // NaN is equal to NaN, and Null is equal to Null. + // This will remove all equivalent values if there are duplicates. + // + // The corresponding transform_result will be the null value. + ArrayValue remove_all_from_array = 7; + } + } + + // The name of the document to transform. + string document = 1; + + // The list of transformations to apply to the fields of the document, in + // order. + // This must not be empty. + repeated FieldTransform field_transforms = 2; +} + +// The result of applying a write. +message WriteResult { + // The last update time of the document after applying the write. Not set + // after a `delete`. + // + // If the write did not actually change the document, this will be the + // previous update_time. + google.protobuf.Timestamp update_time = 1; + + // The results of applying each + // [DocumentTransform.FieldTransform][google.firestore.v1.DocumentTransform.FieldTransform], + // in the same order. + repeated Value transform_results = 2; +} + +// A [Document][google.firestore.v1.Document] has changed. +// +// May be the result of multiple [writes][google.firestore.v1.Write], including +// deletes, that ultimately resulted in a new value for the +// [Document][google.firestore.v1.Document]. +// +// Multiple [DocumentChange][google.firestore.v1.DocumentChange] messages may be +// returned for the same logical change, if multiple targets are affected. +message DocumentChange { + // The new state of the [Document][google.firestore.v1.Document]. + // + // If `mask` is set, contains only fields that were updated or added. + Document document = 1; + + // A set of target IDs of targets that match this document. + repeated int32 target_ids = 5; + + // A set of target IDs for targets that no longer match this document. + repeated int32 removed_target_ids = 6; +} + +// A [Document][google.firestore.v1.Document] has been deleted. +// +// May be the result of multiple [writes][google.firestore.v1.Write], including +// updates, the last of which deleted the +// [Document][google.firestore.v1.Document]. +// +// Multiple [DocumentDelete][google.firestore.v1.DocumentDelete] messages may be +// returned for the same logical delete, if multiple targets are affected. +message DocumentDelete { + // The resource name of the [Document][google.firestore.v1.Document] that was + // deleted. + string document = 1; + + // A set of target IDs for targets that previously matched this entity. + repeated int32 removed_target_ids = 6; + + // The read timestamp at which the delete was observed. + // + // Greater or equal to the `commit_time` of the delete. + google.protobuf.Timestamp read_time = 4; +} + +// A [Document][google.firestore.v1.Document] has been removed from the view of +// the targets. +// +// Sent if the document is no longer relevant to a target and is out of view. +// Can be sent instead of a DocumentDelete or a DocumentChange if the server +// can not send the new value of the document. +// +// Multiple [DocumentRemove][google.firestore.v1.DocumentRemove] messages may be +// returned for the same logical write or delete, if multiple targets are +// affected. +message DocumentRemove { + // The resource name of the [Document][google.firestore.v1.Document] that has + // gone out of view. + string document = 1; + + // A set of target IDs for targets that previously matched this document. + repeated int32 removed_target_ids = 2; + + // The read timestamp at which the remove was observed. + // + // Greater or equal to the `commit_time` of the change/delete/remove. + google.protobuf.Timestamp read_time = 4; +} + +// A digest of all the documents that match a given target. +message ExistenceFilter { + // The target ID to which this filter applies. + int32 target_id = 1; + + // The total count of documents that match + // [target_id][google.firestore.v1.ExistenceFilter.target_id]. + // + // If different from the count of documents in the client that match, the + // client must manually determine which documents no longer match the target. + // + // The client can use the `unchanged_names` bloom filter to assist with + // this determination by testing ALL the document names against the filter; + // if the document name is NOT in the filter, it means the document no + // longer matches the target. + int32 count = 2; + + // A bloom filter that, despite its name, contains the UTF-8 byte encodings of + // the resource names of ALL the documents that match + // [target_id][google.firestore.v1.ExistenceFilter.target_id], in the form + // `projects/{project_id}/databases/{database_id}/documents/{document_path}`. + // + // This bloom filter may be omitted at the server's discretion, such as if it + // is deemed that the client will not make use of it or if it is too + // computationally expensive to calculate or transmit. Clients must gracefully + // handle this field being absent by falling back to the logic used before + // this field existed; that is, re-add the target without a resume token to + // figure out which documents in the client's cache are out of sync. + BloomFilter unchanged_names = 3; +} diff --git a/java-firestore/samples/install-without-bom/pom.xml b/java-firestore/samples/install-without-bom/pom.xml new file mode 100644 index 000000000000..335a38132874 --- /dev/null +++ b/java-firestore/samples/install-without-bom/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + com.google.cloud + firestore-install-without-bom + jar + Google Cloud Firestore Install Without Bom + https://github.com/googleapis/java-firestore + + + + com.google.cloud.samples + shared-configuration + 1.2.2 + + + + 1.8 + 1.8 + 2.66.0 + UTF-8 + + + + + + + com.google.cloud + google-cloud-firestore + 3.31.9 + + + + + + org.apache.beam + beam-runners-direct-java + ${beam.version} + + + org.apache.beam + beam-runners-google-cloud-dataflow-java + ${beam.version} + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.4.4 + test + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.6.1 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + diff --git a/java-firestore/samples/pom.xml b/java-firestore/samples/pom.xml new file mode 100644 index 000000000000..7ff40616b8ca --- /dev/null +++ b/java-firestore/samples/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.cloud + google-cloud-firestore-samples + 0.0.1-SNAPSHOT + pom + Google Cloud Firestore Samples Parent + https://github.com/googleapis/java-firestore + + Java idiomatic client for Google Cloud Platform services. + + + + + com.google.cloud.samples + shared-configuration + 1.2.2 + + + + 1.8 + 1.8 + UTF-8 + + + + install-without-bom + snapshot + snippets + + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.4 + + true + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.7.0 + + true + + + + + diff --git a/java-firestore/samples/preview-snippets/pom.xml b/java-firestore/samples/preview-snippets/pom.xml new file mode 100644 index 000000000000..fa7e330ab3da --- /dev/null +++ b/java-firestore/samples/preview-snippets/pom.xml @@ -0,0 +1,86 @@ + + + 4.0.0 + com.google.cloud + firestore-snippets + jar + Google Cloud Firestore Snippets + https://github.com/googleapis/java-firestore + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + 2.57.0 + + + + + + + + + com.google.cloud + google-cloud-firestore-bom + 3.33.4 + pom + import + + + + + + + + com.google.firebase + firebase-admin + 9.7.0 + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.3.0 + + + + quickstart + + exec + + + java + + -classpath + + com.example.firestore.Quickstart + ${firestore.project.id} + + + + + beam-sample + + exec + + + + + + + diff --git a/java-firestore/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java b/java-firestore/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java new file mode 100644 index 000000000000..cf6efe72d1ac --- /dev/null +++ b/java-firestore/samples/preview-snippets/src/main/java/com/example/firestore/PipelineSnippets.java @@ -0,0 +1,2988 @@ +/* + * Copyright 2025 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore; + +import static com.google.cloud.firestore.pipeline.expressions.AggregateFunction.*; +import static com.google.cloud.firestore.pipeline.expressions.Expression.*; +import static com.google.cloud.firestore.pipeline.expressions.Ordering.*; + +import com.google.api.core.ApiFuture; +import com.google.api.gax.rpc.ApiStreamObserver; +import com.google.cloud.firestore.ExplainMetrics; +import com.google.cloud.firestore.ExplainOptions; +import com.google.cloud.firestore.ExplainResults; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.Pipeline; +import com.google.cloud.firestore.PlanSummary; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.pipeline.stages.Aggregate; +import com.google.cloud.firestore.pipeline.stages.FindNearest; +import com.google.cloud.firestore.pipeline.stages.FindNearestOptions; +import com.google.cloud.firestore.pipeline.stages.Sample; +import com.google.cloud.firestore.pipeline.stages.UnnestOptions; +import java.util.Arrays; +import java.util.HashMap; +import java.util.concurrent.ExecutionException; + +class PipelineSnippets { + private final Firestore firestore; + + PipelineSnippets(Firestore firestore) { + this.firestore = firestore; + } + + void queryExplain() throws ExecutionException, InterruptedException { + // [START query_explain] + Query q = firestore.collection("cities").whereGreaterThan("population", 1); + ExplainOptions options = ExplainOptions.builder().build(); + + ExplainResults explainResults = q.explain(options).get(); + ExplainMetrics metrics = explainResults.getMetrics(); + PlanSummary planSummary = metrics.getPlanSummary(); + // [END query_explain] + } + + void pipelineConcepts() throws ExecutionException, InterruptedException { + // [START pipeline_concepts] + Pipeline pipeline = + firestore + .pipeline() + .collection("cities") + .where(field("population").greaterThan(100_000)) + .sort(ascending(field("name"))) + .limit(10); + // [END pipeline_concepts] + System.out.println(pipeline); + } + + void basicRead() throws ExecutionException, InterruptedException { + // [START basic_read] + Pipeline pipeline = firestore.pipeline().collection("users"); + ApiFuture future = pipeline.execute(); + for (com.google.cloud.firestore.PipelineResult result : future.get().getResults()) { + System.out.println(result.getId() + " => " + result.getData()); + } + // or, asynchronously + pipeline.execute( + new ApiStreamObserver() { + @Override + public void onNext(com.google.cloud.firestore.PipelineResult result) { + System.out.println(result.getId() + " => " + result.getData()); + } + + @Override + public void onError(Throwable t) { + System.err.println(t); + } + + @Override + public void onCompleted() { + System.out.println("done"); + } + }); + // [END basic_read] + } + + void pipelineInitialization() { + // [START pipeline_initialization] + FirestoreOptions firestoreOptions = firestore.getOptions(); + Firestore firestoreClient = firestoreOptions.getService(); + Pipeline pipeline = firestoreClient.pipeline().collection("books"); + // [END pipeline_initialization] + System.out.println(pipeline); + } + + void fieldVsConstants() { + // [START field_or_constant] + Pipeline pipeline = + firestore.pipeline().collection("cities").where(field("name").equal(constant("Toronto"))); + // [END field_or_constant] + System.out.println(pipeline); + } + + void inputStages() throws ExecutionException, InterruptedException { + // [START input_stages] + // Return all restaurants in San Francisco + Pipeline.Snapshot results1 = + firestore.pipeline().collection("cities/sf/restaurants").execute().get(); + + // Return all restaurants + Pipeline.Snapshot results2 = + firestore.pipeline().collectionGroup("restaurants").execute().get(); + + // Return all documents across all collections in the database (the entire database) + Pipeline.Snapshot results3 = firestore.pipeline().database().execute().get(); + + // Batch read of 3 documents + Pipeline.Snapshot results4 = + firestore + .pipeline() + .documents( + firestore.collection("cities").document("SF"), + firestore.collection("cities").document("DC"), + firestore.collection("cities").document("NY")) + .execute() + .get(); + // [END input_stages] + System.out.println(results1.getResults()); + System.out.println(results2.getResults()); + System.out.println(results3.getResults()); + System.out.println(results4.getResults()); + } + + void wherePipeline() throws ExecutionException, InterruptedException { + // [START pipeline_where] + Pipeline.Snapshot results1 = + firestore + .pipeline() + .collection("books") + .where(field("rating").equal(5)) + .where(field("published").lessThan(1900)) + .execute() + .get(); + + Pipeline.Snapshot results2 = + firestore + .pipeline() + .collection("books") + .where(and(field("rating").equal(5), field("published").lessThan(1900))) + .execute() + .get(); + // [END pipeline_where] + System.out.println(results1.getResults()); + System.out.println(results2.getResults()); + } + + void aggregateGroups() throws ExecutionException, InterruptedException { + // [START aggregate_groups] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .aggregate( + Aggregate.withAccumulators(average("rating").as("avg_rating")).withGroups("genre")) + .execute() + .get(); + // [END aggregate_groups] + System.out.println(results.getResults()); + } + + void aggregateDistinct() throws ExecutionException, InterruptedException { + // [START aggregate_distinct] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .distinct(toUpper(field("author")).as("author"), field("genre")) + .execute() + .get(); + // [END aggregate_distinct] + System.out.println(results.getResults()); + } + + void sort() throws ExecutionException, InterruptedException { + // [START sort] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .sort(descending(field("release_date")), ascending(field("author"))) + .execute() + .get(); + // [END sort] + System.out.println(results.getResults()); + } + + void sortComparison() { + // [START sort_comparison] + Query query = + firestore + .collection("cities") + .orderBy("state") + .orderBy("population", Query.Direction.DESCENDING); + + Pipeline pipeline = + firestore + .pipeline() + .collection("books") + .sort(descending(field("release_date")), ascending(field("author"))); + // [END sort_comparison] + System.out.println(query); + System.out.println(pipeline); + } + + void functionsExample() throws ExecutionException, InterruptedException { + // [START functions_example] + // Type 1: Scalar (for use in non-aggregation stages) + // Example: Return the min store price for each book. + Pipeline.Snapshot results1 = + firestore + .pipeline() + .collection("books") + .select(logicalMinimum(field("current"), field("updated")).as("price_min")) + .execute() + .get(); + + // Type 2: Aggregation (for use in aggregate stages) + // Example: Return the min price of all books. + Pipeline.Snapshot results2 = + firestore + .pipeline() + .collection("books") + .aggregate(minimum("price").as("min_price")) + .execute() + .get(); + // [END functions_example] + System.out.println(results1.getResults()); + System.out.println(results2.getResults()); + } + + void creatingIndexes() throws ExecutionException, InterruptedException { + // [START query_example] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .where(field("published").lessThan(1900)) + .where(field("genre").equal("Science Fiction")) + .where(field("rating").greaterThan(4.3)) + .sort(descending(field("published"))) + .execute() + .get(); + // [END query_example] + System.out.println(results.getResults()); + } + + void sparseIndexes() throws ExecutionException, InterruptedException { + // [START sparse_index_example] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .where(field("category").like("%fantasy%")) + .execute() + .get(); + // [END sparse_index_example] + System.out.println(results.getResults()); + } + + void sparseIndexes2() throws ExecutionException, InterruptedException { + // [START sparse_index_example_2] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .sort(ascending(field("release_date"))) + .execute() + .get(); + // [END sparse_index_example_2] + System.out.println(results.getResults()); + } + + void coveredQuery() throws ExecutionException, InterruptedException { + // [START covered_query] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("books") + .where(field("category").like("%fantasy%")) + .where(field("title").exists()) + .where(field("author").exists()) + .select("title", "author") + .execute() + .get(); + // [END covered_query] + System.out.println(results.getResults()); + } + + void pagination() { + // [START pagination_not_supported_preview] + // Existing pagination via `start_at()` + Query query = firestore.collection("cities").orderBy("population").startAt(1_000_000); + + // Private preview workaround using pipelines + Pipeline pipeline = + firestore + .pipeline() + .collection("cities") + .where(field("population").greaterThanOrEqual(1_000_000)) + .sort(descending(field("population"))); + // [END pagination_not_supported_preview] + System.out.println(query); + System.out.println(pipeline); + } + + void collectionStage() throws ExecutionException, InterruptedException { + // [START collection_example] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("users/bob/games") + .sort(ascending(field("name"))) + .execute() + .get(); + // [END collection_example] + System.out.println(results.getResults()); + } + + void collectionGroupStage() throws ExecutionException, InterruptedException { + // [START collection_group_example] + Pipeline.Snapshot results = + firestore + .pipeline() + .collectionGroup("games") + .sort(ascending(field("name"))) + .execute() + .get(); + // [END collection_group_example] + System.out.println(results.getResults()); + } + + void databaseStage() throws ExecutionException, InterruptedException { + // [START database_example] + // Count all documents in the database + Pipeline.Snapshot results = + firestore.pipeline().database().aggregate(countAll().as("total")).execute().get(); + // [END database_example] + System.out.println(results.getResults()); + } + + void documentsStage() throws ExecutionException, InterruptedException { + // [START documents_example] + Pipeline.Snapshot results = + firestore + .pipeline() + .documents( + firestore.collection("cities").document("SF"), + firestore.collection("cities").document("DC"), + firestore.collection("cities").document("NY")) + .execute() + .get(); + // [END documents_example] + System.out.println(results.getResults()); + } + + void replaceWithStage() throws ExecutionException, InterruptedException { + // [START initial_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("population", 800_000); + put( + "location", + new HashMap() { + { + put("country", "USA"); + put("state", "California"); + } + }); + } + }); + firestore + .collection("cities") + .document("TO") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("population", 3_000_000); + put("province", "ON"); + put( + "location", + new HashMap() { + { + put("country", "Canada"); + put("province", "Ontario"); + } + }); + } + }); + firestore + .collection("cities") + .document("NY") + .set( + new HashMap() { + { + put("name", "New York"); + put("population", 8_500_000); + put( + "location", + new HashMap() { + { + put("country", "USA"); + put("state", "New York"); + } + }); + } + }); + firestore + .collection("cities") + .document("AT") + .set( + new HashMap() { + { + put("name", "Atlantis"); + } + }); + // [END initial_data] + + // [START full_replace] + Pipeline.Snapshot names = + firestore.pipeline().collection("cities").replaceWith(field("location")).execute().get(); + // [END full_replace] + + // [START map_merge_overwrite] + // unsupported in client SDKs for now + // [END map_merge_overwrite] + System.out.println(names.getResults()); + } + + void sampleStage() throws ExecutionException, InterruptedException { + // [START sample_example] + // Get a sample of 100 documents in a database + Pipeline.Snapshot results1 = firestore.pipeline().database().sample(100).execute().get(); + + // Randomly shuffle a list of 3 documents + Pipeline.Snapshot results2 = + firestore + .pipeline() + .documents( + firestore.collection("cities").document("SF"), + firestore.collection("cities").document("NY"), + firestore.collection("cities").document("DC")) + .sample(3) + .execute() + .get(); + // [END sample_example] + System.out.println(results1.getResults()); + System.out.println(results2.getResults()); + } + + void samplePercent() throws ExecutionException, InterruptedException { + // [START sample_percent] + // Get a sample of on average 50% of the documents in the database + Pipeline.Snapshot results = + firestore.pipeline().database().sample(Sample.withPercentage(0.5)).execute().get(); + // [END sample_percent] + System.out.println(results.getResults()); + } + + void unionStage() throws ExecutionException, InterruptedException { + // [START union_stage] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities/SF/restaurants") + .where(field("type").equal("Chinese")) + .union( + firestore + .pipeline() + .collection("cities/NY/restaurants") + .where(field("type").equal("Italian"))) + .where(field("rating").greaterThanOrEqual(4.5)) + .sort(descending(field("__name__"))) + .execute() + .get(); + // [END union_stage] + System.out.println(results.getResults()); + } + + void unionStageStable() throws ExecutionException, InterruptedException { + // [START union_stage_stable] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities/SF/restaurants") + .where(field("type").equal("Chinese")) + .union( + firestore + .pipeline() + .collection("cities/NY/restaurants") + .where(field("type").equal("Italian"))) + .where(field("rating").greaterThanOrEqual(4.5)) + .sort(descending(field("__name__"))) + .execute() + .get(); + // [END union_stage_stable] + System.out.println(results.getResults()); + } + + void unnestStage() throws ExecutionException, InterruptedException { + // [START unnest_stage] + Pipeline.Snapshot results = + firestore + .pipeline() + .database() + .unnest("arrayField", "unnestedArrayField", new UnnestOptions().withIndexField("index")) + .execute() + .get(); + // [END unnest_stage] + System.out.println(results.getResults()); + } + + void unnestStageEmptyOrNonArray() throws ExecutionException, InterruptedException { + // [START unnest_edge_cases] + // Input + // { "identifier" : 1, "neighbors": [ "Alice", "Cathy" ] } + // { "identifier" : 2, "neighbors": [] } + // { "identifier" : 3, "neighbors": "Bob" } + + Pipeline.Snapshot results = + firestore + .pipeline() + .database() + .unnest("neighbors", "unnestedNeighbors", new UnnestOptions().withIndexField("index")) + .execute() + .get(); + + // Output + // { "identifier": 1, "neighbors": [ "Alice", "Cathy" ], + // "unnestedNeighbors": "Alice", "index": 0 } + // { "identifier": 1, "neighbors": [ "Alice", "Cathy" ], + // "unnestedNeighbors": "Cathy", "index": 1 } + // { "identifier": 3, "neighbors": "Bob", "index": null} + // [END unnest_edge_cases] + System.out.println(results.getResults()); + } + + void countFunction() throws ExecutionException, InterruptedException { + // [START count_function] + // Total number of books in the collection + Pipeline.Snapshot countAll = + firestore.pipeline().collection("books").aggregate(countAll().as("count")).execute().get(); + + // Number of books with nonnull `ratings` field + Pipeline.Snapshot countField = + firestore + .pipeline() + .collection("books") + .aggregate(count("ratings").as("count")) + .execute() + .get(); + // [END count_function] + System.out.println(countAll.getResults()); + System.out.println(countField.getResults()); + } + + void countIfFunction() throws ExecutionException, InterruptedException { + // [START count_if] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .aggregate(countIf(field("rating").greaterThan(4)).as("filteredCount")) + .execute() + .get(); + // [END count_if] + System.out.println(result.getResults()); + } + + void countDistinctFunction() throws ExecutionException, InterruptedException { + // [START count_distinct] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .aggregate(countDistinct("author").as("unique_authors")) + .execute() + .get(); + // [END count_distinct] + System.out.println(result.getResults()); + } + + void sumFunction() throws ExecutionException, InterruptedException { + // [START sum_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("cities") + .aggregate(sum("population").as("totalPopulation")) + .execute() + .get(); + // [END sum_function] + System.out.println(result.getResults()); + } + + void avgFunction() throws ExecutionException, InterruptedException { + // [START avg_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("cities") + .aggregate(average("population").as("averagePopulation")) + .execute() + .get(); + // [END avg_function] + System.out.println(result.getResults()); + } + + void minFunction() throws ExecutionException, InterruptedException { + // [START min_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .aggregate(minimum("price").as("minimumPrice")) + .execute() + .get(); + // [END min_function] + System.out.println(result.getResults()); + } + + void maxFunction() throws ExecutionException, InterruptedException { + // [START max_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .aggregate(maximum("price").as("maximumPrice")) + .execute() + .get(); + // [END max_function] + System.out.println(result.getResults()); + } + + void addFunction() throws ExecutionException, InterruptedException { + // [START add_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(add(field("soldBooks"), field("unsoldBooks")).as("totalBooks")) + .execute() + .get(); + // [END add_function] + System.out.println(result.getResults()); + } + + void subtractFunction() throws ExecutionException, InterruptedException { + // [START subtract_function] + int storeCredit = 7; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(subtract(field("price"), storeCredit).as("totalCost")) + .execute() + .get(); + // [END subtract_function] + System.out.println(result.getResults()); + } + + void multiplyFunction() throws ExecutionException, InterruptedException { + // [START multiply_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(multiply(field("price"), field("soldBooks")).as("revenue")) + .execute() + .get(); + // [END multiply_function] + System.out.println(result.getResults()); + } + + void divideFunction() throws ExecutionException, InterruptedException { + // [START divide_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(divide(field("ratings"), field("soldBooks")).as("reviewRate")) + .execute() + .get(); + // [END divide_function] + System.out.println(result.getResults()); + } + + void modFunction() throws ExecutionException, InterruptedException { + // [START mod_function] + int displayCapacity = 1000; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mod(field("unsoldBooks"), displayCapacity).as("warehousedBooks")) + .execute() + .get(); + // [END mod_function] + System.out.println(result.getResults()); + } + + void ceilFunction() throws ExecutionException, InterruptedException { + // [START ceil_function] + int booksPerShelf = 100; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(ceil(divide(field("unsoldBooks"), booksPerShelf)).as("requiredShelves")) + .execute() + .get(); + // [END ceil_function] + System.out.println(result.getResults()); + } + + void floorFunction() throws ExecutionException, InterruptedException { + // [START floor_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .addFields(floor(divide(field("wordCount"), field("pages"))).as("wordsPerPage")) + .execute() + .get(); + // [END floor_function] + System.out.println(result.getResults()); + } + + void roundFunction() throws ExecutionException, InterruptedException { + // [START round_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(round(multiply(field("soldBooks"), field("price"))).as("partialRevenue")) + .aggregate(sum("partialRevenue").as("totalRevenue")) + .execute() + .get(); + // [END round_function] + System.out.println(result.getResults()); + } + + void powFunction() throws ExecutionException, InterruptedException { + // [START pow_function] + double googleplexLat = 37.4221; + double googleplexLng = -122.0853; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("cities") + .addFields( + pow(multiply(subtract(field("lat"), googleplexLat), 111), 2) + .as("latitudeDifference"), + pow(multiply(subtract(field("lng"), googleplexLng), 111), 2) + .as("longitudeDifference")) + .select( + sqrt(add(field("latitudeDifference"), field("longitudeDifference"))) + // Inaccurate for large distances or close to poles + .as("approximateDistanceToGoogle")) + .execute() + .get(); + // [END pow_function] + System.out.println(result.getResults()); + } + + void sqrtFunction() throws ExecutionException, InterruptedException { + // [START sqrt_function] + double googleplexLat = 37.4221; + double googleplexLng = -122.0853; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("cities") + .addFields( + pow(multiply(subtract(field("lat"), googleplexLat), 111), 2) + .as("latitudeDifference"), + pow(multiply(subtract(field("lng"), googleplexLng), 111), 2) + .as("longitudeDifference")) + .select( + sqrt(add(field("latitudeDifference"), field("longitudeDifference"))) + // Inaccurate for large distances or close to poles + .as("approximateDistanceToGoogle")) + .execute() + .get(); + // [END sqrt_function] + System.out.println(result.getResults()); + } + + void expFunction() throws ExecutionException, InterruptedException { + // [START exp_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(exp(field("rating")).as("expRating")) + .execute() + .get(); + // [END exp_function] + System.out.println(result.getResults()); + } + + void lnFunction() throws ExecutionException, InterruptedException { + // [START ln_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(ln(field("rating")).as("lnRating")) + .execute() + .get(); + // [END ln_function] + System.out.println(result.getResults()); + } + + void logFunction() throws ExecutionException, InterruptedException { + // [START log_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(log(field("rating"), 2).as("log2Rating")) + .execute() + .get(); + // [END log_function] + System.out.println(result.getResults()); + } + + void arrayConcatFunction() throws ExecutionException, InterruptedException { + // [START array_concat] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(arrayConcat(field("genre"), field("subGenre")).as("allGenres")) + .execute() + .get(); + // [END array_concat] + System.out.println(result.getResults()); + } + + void arrayContainsFunction() throws ExecutionException, InterruptedException { + // [START array_contains] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(arrayContains(field("genre"), "mystery").as("isMystery")) + .execute() + .get(); + // [END array_contains] + System.out.println(result.getResults()); + } + + void arrayContainsAllFunction() throws ExecutionException, InterruptedException { + // [START array_contains_all] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + arrayContainsAll(field("genre"), Arrays.asList("fantasy", "adventure")) + .as("isFantasyAdventure")) + .execute() + .get(); + // [END array_contains_all] + System.out.println(result.getResults()); + } + + void arrayContainsAnyFunction() throws ExecutionException, InterruptedException { + // [START array_contains_any] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + arrayContainsAny(field("genre"), Arrays.asList("fantasy", "nonfiction")) + .as("isMysteryOrFantasy")) + .execute() + .get(); + // [END array_contains_any] + System.out.println(result.getResults()); + } + + void arrayLengthFunction() throws ExecutionException, InterruptedException { + // [START array_length] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(arrayLength(field("genre")).as("genreCount")) + .execute() + .get(); + // [END array_length] + System.out.println(result.getResults()); + } + + void arrayReverseFunction() throws ExecutionException, InterruptedException { + // [START array_reverse] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(arrayReverse(field("genre")).as("reversedGenres")) + .execute() + .get(); + // [END array_reverse] + System.out.println(result.getResults()); + } + + void equalFunction() throws ExecutionException, InterruptedException { + // [START equal_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(equal(field("rating"), 5).as("hasPerfectRating")) + .execute() + .get(); + // [END equal_function] + System.out.println(result.getResults()); + } + + void greaterThanFunction() throws ExecutionException, InterruptedException { + // [START greater_than] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(greaterThan(field("rating"), 4).as("hasHighRating")) + .execute() + .get(); + // [END greater_than] + System.out.println(result.getResults()); + } + + void greaterThanOrEqualToFunction() throws ExecutionException, InterruptedException { + // [START greater_or_equal] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(greaterThanOrEqual(field("published"), 1900).as("publishedIn20thCentury")) + .execute() + .get(); + // [END greater_or_equal] + System.out.println(result.getResults()); + } + + void lessThanFunction() throws ExecutionException, InterruptedException { + // [START less_than] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(lessThan(field("published"), 1923).as("isPublicDomainProbably")) + .execute() + .get(); + // [END less_than] + System.out.println(result.getResults()); + } + + void lessThanOrEqualToFunction() throws ExecutionException, InterruptedException { + // [START less_or_equal] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(lessThanOrEqual(field("rating"), 2).as("hasBadRating")) + .execute() + .get(); + // [END less_or_equal] + System.out.println(result.getResults()); + } + + void notEqualFunction() throws ExecutionException, InterruptedException { + // [START not_equal] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(notEqual(field("title"), "1984").as("not1984")) + .execute() + .get(); + // [END not_equal] + System.out.println(result.getResults()); + } + + void existsFunction() throws ExecutionException, InterruptedException { + // [START exists_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(exists(field("rating")).as("hasRating")) + .execute() + .get(); + // [END exists_function] + System.out.println(result.getResults()); + } + + void andFunction() throws ExecutionException, InterruptedException { + // [START and_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + and(greaterThan(field("rating"), 4), lessThan(field("price"), 10)) + .as("under10Recommendation")) + .execute() + .get(); + // [END and_function] + System.out.println(result.getResults()); + } + + void orFunction() throws ExecutionException, InterruptedException { + // [START or_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + or(equal(field("genre"), "Fantasy"), arrayContains(field("tags"), "adventure")) + .as("matchesSearchFilters")) + .execute() + .get(); + // [END or_function] + System.out.println(result.getResults()); + } + + void xorFunction() throws ExecutionException, InterruptedException { + // [START xor_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + xor( + arrayContains(field("tags"), "magic"), + arrayContains(field("tags"), "nonfiction")) + .as("matchesSearchFilters")) + .execute() + .get(); + // [END xor_function] + System.out.println(result.getResults()); + } + + void notFunction() throws ExecutionException, InterruptedException { + // [START not_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(not(arrayContains(field("tags"), "nonfiction")).as("isFiction")) + .execute() + .get(); + // [END not_function] + System.out.println(result.getResults()); + } + + void condFunction() throws ExecutionException, InterruptedException { + // [START cond_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + arrayConcat( + field("tags"), + conditional( + greaterThan(field("pages"), 100), + constant("longRead"), + constant("shortRead"))) + .as("extendedTags")) + .execute() + .get(); + // [END cond_function] + System.out.println(result.getResults()); + } + + void equalAnyFunction() throws ExecutionException, InterruptedException { + // [START eq_any] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + equalAny(field("genre"), Arrays.asList("Science Fiction", "Psychological Thriller")) + .as("matchesGenreFilters")) + .execute() + .get(); + // [END eq_any] + System.out.println(result.getResults()); + } + + void notEqualAnyFunction() throws ExecutionException, InterruptedException { + // [START not_eq_any] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select( + notEqualAny(field("author"), Arrays.asList("George Orwell", "F. Scott Fitzgerald")) + .as("byExcludedAuthors")) + .execute() + .get(); + // [END not_eq_any] + System.out.println(result.getResults()); + } + + void maxLogicalFunction() throws ExecutionException, InterruptedException { + // [START max_logical_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(logicalMaximum(field("rating"), 1).as("flooredRating")) + .execute() + .get(); + // [END max_logical_function] + System.out.println(result.getResults()); + } + + void minLogicalFunction() throws ExecutionException, InterruptedException { + // [START min_logical_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(logicalMinimum(field("rating"), 5).as("cappedRating")) + .execute() + .get(); + // [END min_logical_function] + System.out.println(result.getResults()); + } + + void mapGetFunction() throws ExecutionException, InterruptedException { + // [START map_get] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(mapGet(field("awards"), "pulitzer").as("hasPulitzerAward")) + .execute() + .get(); + // [END map_get] + System.out.println(result.getResults()); + } + + void byteLengthFunction() throws ExecutionException, InterruptedException { + // [START byte_length] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(byteLength(field("title")).as("titleByteLength")) + .execute() + .get(); + // [END byte_length] + System.out.println(result.getResults()); + } + + void charLengthFunction() throws ExecutionException, InterruptedException { + // [START char_length] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(charLength(field("title")).as("titleCharLength")) + .execute() + .get(); + // [END char_length] + System.out.println(result.getResults()); + } + + void startsWithFunction() throws ExecutionException, InterruptedException { + // [START starts_with] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(startsWith(field("title"), "The").as("needsSpecialAlphabeticalSort")) + .execute() + .get(); + // [END starts_with] + System.out.println(result.getResults()); + } + + void endsWithFunction() throws ExecutionException, InterruptedException { + // [START ends_with] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("inventory/devices/laptops") + .select(endsWith(field("name"), "16 inch").as("16InLaptops")) + .execute() + .get(); + // [END ends_with] + System.out.println(result.getResults()); + } + + void likeFunction() throws ExecutionException, InterruptedException { + // [START like] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(like(field("genre"), "%Fiction").as("anyFiction")) + .execute() + .get(); + // [END like] + System.out.println(result.getResults()); + } + + void regexContainsFunction() throws ExecutionException, InterruptedException { + // [START regex_contains] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select( + regexContains(field("title"), "Firestore (Enterprise|Standard)") + .as("isFirestoreRelated")) + .execute() + .get(); + // [END regex_contains] + System.out.println(result.getResults()); + } + + void regexFindFunction() throws ExecutionException, InterruptedException { + // [START regex_find] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(regexFind(field("email"), "@[A-Za-z0-9.-]+").as("domain")) + .execute() + .get(); + // [END regex_find] + System.out.println(result.getResults()); + } + + void regexFindAllFunction() throws ExecutionException, InterruptedException { + // [START regex_find_all] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(regexFindAll(field("comment"), "@[A-Za-z0-9_]+").as("mentions")) + .execute() + .get(); + // [END regex_find_all] + System.out.println(result.getResults()); + } + + void regexMatchFunction() throws ExecutionException, InterruptedException { + // [START regex_match] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select( + regexMatch(field("title"), "Firestore (Enterprise|Standard)") + .as("isFirestoreExactly")) + .execute() + .get(); + // [END regex_match] + System.out.println(result.getResults()); + } + + void strConcatFunction() throws ExecutionException, InterruptedException { + // [START str_concat] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(stringConcat(field("title"), " by ", field("author")).as("fullyQualifiedTitle")) + .execute() + .get(); + // [END str_concat] + System.out.println(result.getResults()); + } + + void strContainsFunction() throws ExecutionException, InterruptedException { + // [START string_contains] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("articles") + .select(stringContains(field("body"), "Firestore").as("isFirestoreRelated")) + .execute() + .get(); + // [END string_contains] + System.out.println(result.getResults()); + } + + void toUpperFunction() throws ExecutionException, InterruptedException { + // [START to_upper] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("authors") + .select(toUpper(field("name")).as("uppercaseName")) + .execute() + .get(); + // [END to_upper] + System.out.println(result.getResults()); + } + + void toLowerFunction() throws ExecutionException, InterruptedException { + // [START to_lower] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("authors") + .select(equal(toLower(field("genre")), "fantasy").as("isFantasy")) + .execute() + .get(); + // [END to_lower] + System.out.println(result.getResults()); + } + + void substrFunction() throws ExecutionException, InterruptedException { + // [START substr_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .where(startsWith(field("title"), "The ")) + .select( + substring(field("title"), constant(4), field("title").charLength()) + .as("titleWithoutLeadingThe")) + .execute() + .get(); + // [END substr_function] + System.out.println(result.getResults()); + } + + void strReverseFunction() throws ExecutionException, InterruptedException { + // [START str_reverse] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(reverse(field("name")).as("reversedName")) + .execute() + .get(); + // [END str_reverse] + System.out.println(result.getResults()); + } + + void strTrimFunction() throws ExecutionException, InterruptedException { + // [START trim_function] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(trim(field("name")).as("whitespaceTrimmedName")) + .execute() + .get(); + // [END trim_function] + System.out.println(result.getResults()); + } + + void unixMicrosToTimestampFunction() throws ExecutionException, InterruptedException { + // [START unix_micros_timestamp] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(unixMicrosToTimestamp(field("createdAtMicros")).as("createdAtString")) + .execute() + .get(); + // [END unix_micros_timestamp] + System.out.println(result.getResults()); + } + + void unixMillisToTimestampFunction() throws ExecutionException, InterruptedException { + // [START unix_millis_timestamp] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(unixMillisToTimestamp(field("createdAtMillis")).as("createdAtString")) + .execute() + .get(); + // [END unix_millis_timestamp] + System.out.println(result.getResults()); + } + + void unixSecondsToTimestampFunction() throws ExecutionException, InterruptedException { + // [START unix_seconds_timestamp] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(unixSecondsToTimestamp(field("createdAtSeconds")).as("createdAtString")) + .execute() + .get(); + // [END unix_seconds_timestamp] + System.out.println(result.getResults()); + } + + void timestampAddFunction() throws ExecutionException, InterruptedException { + // [START timestamp_add] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(timestampAdd(field("createdAt"), "day", 3653).as("expiresAt")) + .execute() + .get(); + // [END timestamp_add] + System.out.println(result.getResults()); + } + + void timestampSubFunction() throws ExecutionException, InterruptedException { + // [START timestamp_sub] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(timestampSubtract(field("expiresAt"), "day", 14).as("sendWarningTimestamp")) + .execute() + .get(); + // [END timestamp_sub] + System.out.println(result.getResults()); + } + + void timestampToUnixMicrosFunction() throws ExecutionException, InterruptedException { + // [START timestamp_unix_micros] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(timestampToUnixMicros(field("dateString")).as("unixMicros")) + .execute() + .get(); + // [END timestamp_unix_micros] + System.out.println(result.getResults()); + } + + void timestampToUnixMillisFunction() throws ExecutionException, InterruptedException { + // [START timestamp_unix_millis] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(timestampToUnixMillis(field("dateString")).as("unixMillis")) + .execute() + .get(); + // [END timestamp_unix_millis] + System.out.println(result.getResults()); + } + + void timestampToUnixSecondsFunction() throws ExecutionException, InterruptedException { + // [START timestamp_unix_seconds] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("documents") + .select(timestampToUnixSeconds(field("dateString")).as("unixSeconds")) + .execute() + .get(); + // [END timestamp_unix_seconds] + System.out.println(result.getResults()); + } + + void cosineDistanceFunction() throws ExecutionException, InterruptedException { + // [START cosine_distance] + double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(cosineDistance(field("embedding"), sampleVector).as("cosineDistance")) + .execute() + .get(); + // [END cosine_distance] + System.out.println(result.getResults()); + } + + void dotProductFunction() throws ExecutionException, InterruptedException { + // [START dot_product] + double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(dotProduct(field("embedding"), sampleVector).as("dotProduct")) + .execute() + .get(); + // [END dot_product] + System.out.println(result.getResults()); + } + + void euclideanDistanceFunction() throws ExecutionException, InterruptedException { + // [START euclidean_distance] + double[] sampleVector = new double[] {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(euclideanDistance(field("embedding"), sampleVector).as("euclideanDistance")) + .execute() + .get(); + // [END euclidean_distance] + System.out.println(result.getResults()); + } + + void vectorLengthFunction() throws ExecutionException, InterruptedException { + // [START vector_length] + Pipeline.Snapshot result = + firestore + .pipeline() + .collection("books") + .select(vectorLength(field("embedding")).as("vectorLength")) + .execute() + .get(); + // [END vector_length] + System.out.println(result.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/getting-started/stages-expressions + void stagesExpressionsExample() throws ExecutionException, InterruptedException { + // [START stages_expressions_example] + com.google.cloud.firestore.pipeline.expressions.Expression trailing30Days = + constant(com.google.cloud.Timestamp.now().toProto().getSeconds() * 1000) + .unixMillisToTimestamp() + .timestampSubtract("day", 30); + Pipeline.Snapshot snapshot = + firestore + .pipeline() + .collection("productViews") + .where(field("viewedAt").greaterThan(trailing30Days)) + .aggregate(countDistinct("productId").as("uniqueProductViews")) + .execute() + .get(); + // [END stages_expressions_example] + System.out.println(snapshot.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/where + void createWhereData() { + // [START create_where_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "CA"); + put("country", "USA"); + put("population", 870000); + } + }); + firestore + .collection("cities") + .document("LA") + .set( + new HashMap() { + { + put("name", "Los Angeles"); + put("state", "CA"); + put("country", "USA"); + put("population", 3970000); + } + }); + firestore + .collection("cities") + .document("NY") + .set( + new HashMap() { + { + put("name", "New York"); + put("state", "NY"); + put("country", "USA"); + put("population", 8530000); + } + }); + firestore + .collection("cities") + .document("TOR") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("state", null); + put("country", "Canada"); + put("population", 2930000); + } + }); + firestore + .collection("cities") + .document("MEX") + .set( + new HashMap() { + { + put("name", "Mexico City"); + put("state", null); + put("country", "Mexico"); + put("population", 9200000); + } + }); + // [END create_where_data] + } + + void whereEqualityExample() throws ExecutionException, InterruptedException { + // [START where_equality_example] + Pipeline.Snapshot cities = + firestore.pipeline().collection("cities").where(field("state").equal("CA")).execute().get(); + // [END where_equality_example] + System.out.println(cities.getResults()); + } + + void whereMultipleStagesExample() throws ExecutionException, InterruptedException { + // [START where_multiple_stages] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .where(field("location.country").equal("USA")) + .where(field("population").greaterThan(500000)) + .execute() + .get(); + // [END where_multiple_stages] + System.out.println(cities.getResults()); + } + + void whereComplexExample() throws ExecutionException, InterruptedException { + // [START where_complex] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .where( + or( + like(field("name"), "San%"), + and( + field("location.state").charLength().greaterThan(7), + field("location.country").equal("USA")))) + .execute() + .get(); + // [END where_complex] + System.out.println(cities.getResults()); + } + + void whereStageOrderExample() throws ExecutionException, InterruptedException { + // [START where_stage_order] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .limit(10) + .where(field("location.country").equal("USA")) + .execute() + .get(); + // [END where_stage_order] + System.out.println(cities.getResults()); + } + + void whereHavingExample() throws ExecutionException, InterruptedException { + // [START where_having_example] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .aggregate( + Aggregate.withAccumulators(sum("population").as("totalPopulation")) + .withGroups("location.state")) + .where(field("totalPopulation").greaterThan(10000000)) + .execute() + .get(); + // [END where_having_example] + System.out.println(cities.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/unnest + void unnestSyntaxExample() throws ExecutionException, InterruptedException { + // [START unnest_syntax] + Pipeline.Snapshot userScore = + firestore + .pipeline() + .collection("users") + .unnest("scores", "userScore", new UnnestOptions().withIndexField("attempt")) + .execute() + .get(); + // [END unnest_syntax] + System.out.println(userScore.getResults()); + } + + void unnestAliasIndexDataExample() { + // [START unnest_alias_index_data] + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "foo"); + put("scores", Arrays.asList(5, 4)); + put("userScore", 0); + } + }); + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "bar"); + put("scores", Arrays.asList(1, 3)); + put("attempt", 5); + } + }); + // [END unnest_alias_index_data] + } + + void unnestAliasIndexExample() throws ExecutionException, InterruptedException { + // [START unnest_alias_index] + Pipeline.Snapshot userScore = + firestore + .pipeline() + .collection("users") + .unnest("scores", "userScore", new UnnestOptions().withIndexField("attempt")) + .execute() + .get(); + // [END unnest_alias_index] + System.out.println(userScore.getResults()); + } + + void unnestNonArrayDataExample() { + // [START unnest_nonarray_data] + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "foo"); + put("scores", 1); + } + }); + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "bar"); + put("scores", null); + } + }); + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "qux"); + put( + "scores", + new HashMap() { + { + put("backupScores", 1); + } + }); + } + }); + // [END unnest_nonarray_data] + } + + void unnestNonArrayExample() throws ExecutionException, InterruptedException { + // [START unnest_nonarray] + Pipeline.Snapshot userScore = + firestore + .pipeline() + .collection("users") + .unnest("scores", "userScore", new UnnestOptions().withIndexField("attempt")) + .execute() + .get(); + // [END unnest_nonarray] + System.out.println(userScore.getResults()); + } + + void unnestEmptyArrayDataExample() { + // [START unnest_empty_array_data] + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "foo"); + put("scores", Arrays.asList(5, 4)); + } + }); + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "bar"); + put("scores", Arrays.asList()); + } + }); + // [END unnest_empty_array_data] + } + + void unnestEmptyArrayExample() throws ExecutionException, InterruptedException { + // [START unnest_empty_array] + Pipeline.Snapshot userScore = + firestore + .pipeline() + .collection("users") + .unnest("scores", "userScore", new UnnestOptions().withIndexField("attempt")) + .execute() + .get(); + // [END unnest_empty_array] + System.out.println(userScore.getResults()); + } + + void unnestPreserveEmptyArrayExample() throws ExecutionException, InterruptedException { + // [START unnest_preserve_empty_array] + // Seems like the unnest method is missing: + // https://github.com/googleapis/java-firestore/blob/742fab6583c9a6f9c47cf0496124c3c9b05fe0ee/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Pipeline.java#L995 + // Pipeline.Snapshot userScore = + // firestore + // .pipeline() + // .collection("users") + // .unnest( + // conditional( + // field("scores").equal(array()), + // array(field("scores")), + // field("scores") + // ).as("userScore"), + // new UnnestOptions().withIndexField("attempt")) + // .execute() + // .get(); + // [END unnest_preserve_empty_array] + // System.out.println(userScore.getResults()); + } + + void unnestNestedDataExample() { + // [START unnest_nested_data] + firestore + .collection("users") + .add( + new HashMap() { + { + put("name", "foo"); + put( + "record", + Arrays.asList( + new HashMap() { + { + put("scores", Arrays.asList(5, 4)); + put("avg", 4.5); + } + }, + new HashMap() { + { + put("scores", Arrays.asList(1, 3)); + put("old_avg", 2); + } + })); + } + }); + // [END unnest_nested_data] + } + + void unnestNestedExample() throws ExecutionException, InterruptedException { + // [START unnest_nested] + Pipeline.Snapshot userScore = + firestore + .pipeline() + .collection("users") + .unnest("record", "record") + .unnest("record.scores", "userScore", new UnnestOptions().withIndexField("attempt")) + .execute() + .get(); + // [END unnest_nested] + System.out.println(userScore.getResults()); + } + + // https://cloud.corp.google.com/firestore/docs/pipeline/stages/transformation/sample + void sampleSyntaxExample() throws ExecutionException, InterruptedException { + // [START sample_syntax] + Pipeline.Snapshot sampled1 = firestore.pipeline().database().sample(50).execute().get(); + + Pipeline.Snapshot sampled2 = + firestore.pipeline().database().sample(Sample.withPercentage(0.5)).execute().get(); + // [END sample_syntax] + System.out.println(sampled1.getResults()); + System.out.println(sampled2.getResults()); + } + + void sampleDocumentsDataExample() { + // [START sample_documents_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "California"); + } + }); + firestore + .collection("cities") + .document("NYC") + .set( + new HashMap() { + { + put("name", "New York City"); + put("state", "New York"); + } + }); + firestore + .collection("cities") + .document("CHI") + .set( + new HashMap() { + { + put("name", "Chicago"); + put("state", "Illinois"); + } + }); + // [END sample_documents_data] + } + + void sampleDocumentsExample() throws ExecutionException, InterruptedException { + // [START sample_documents] + Pipeline.Snapshot sampled = firestore.pipeline().collection("cities").sample(1).execute().get(); + // [END sample_documents] + System.out.println(sampled.getResults()); + } + + void sampleAllDocumentsExample() throws ExecutionException, InterruptedException { + // [START sample_all_documents] + Pipeline.Snapshot sampled = firestore.pipeline().collection("cities").sample(5).execute().get(); + // [END sample_all_documents] + System.out.println(sampled.getResults()); + } + + void samplePercentageDataExample() { + // [START sample_percentage_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "California"); + } + }); + firestore + .collection("cities") + .document("NYC") + .set( + new HashMap() { + { + put("name", "New York City"); + put("state", "New York"); + } + }); + firestore + .collection("cities") + .document("CHI") + .set( + new HashMap() { + { + put("name", "Chicago"); + put("state", "Illinois"); + } + }); + firestore + .collection("cities") + .document("ATL") + .set( + new HashMap() { + { + put("name", "Atlanta"); + put("state", "Georgia"); + } + }); + // [END sample_percentage_data] + } + + void samplePercentageExample() throws ExecutionException, InterruptedException { + // [START sample_percentage] + Pipeline.Snapshot sampled = + firestore + .pipeline() + .collection("cities") + .sample(Sample.withPercentage(0.5)) + .execute() + .get(); + // [END sample_percentage] + System.out.println(sampled.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/sort + void sortSyntaxExample() throws ExecutionException, InterruptedException { + // [START sort_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .sort(ascending(field("population"))) + .execute() + .get(); + // [END sort_syntax] + System.out.println(results.getResults()); + } + + void sortSyntaxExample2() throws ExecutionException, InterruptedException { + // [START sort_syntax_2] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .sort(ascending(charLength(field("name")))) + .execute() + .get(); + // [END sort_syntax_2] + System.out.println(results.getResults()); + } + + void sortDocumentIDExample() throws ExecutionException, InterruptedException { + // [START sort_document_id] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .sort(ascending(field("country")), ascending(field("__name__"))) + .execute() + .get(); + // [END sort_document_id] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/select + void selectSyntaxExample() throws ExecutionException, InterruptedException { + // [START select_syntax] + Pipeline.Snapshot names = + firestore + .pipeline() + .collection("cities") + .select( + stringConcat(field("name"), ", ", field("location.country")).as("name"), + field("population")) + .execute() + .get(); + // [END select_syntax] + System.out.println(names.getResults()); + } + + void selectPositionDataExample() { + // [START select_position_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("population", 800000); + put( + "location", + new HashMap() { + { + put("country", "USA"); + put("state", "California"); + } + }); + } + }); + firestore + .collection("cities") + .document("TO") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("population", 3000000); + put( + "location", + new HashMap() { + { + put("country", "Canada"); + put("province", "Ontario"); + } + }); + } + }); + // [END select_position_data] + } + + void selectPositionExample() throws ExecutionException, InterruptedException { + // [START select_position] + Pipeline.Snapshot names = + firestore + .pipeline() + .collection("cities") + .where(field("location.country").equal("Canada")) + .select( + stringConcat(field("name"), ", ", field("location.country")).as("name"), + field("population")) + .execute() + .get(); + // [END select_position] + System.out.println(names.getResults()); + } + + void selectBadPositionExample() throws ExecutionException, InterruptedException { + // [START select_bad_position] + Pipeline.Snapshot names = + firestore + .pipeline() + .collection("cities") + .select( + stringConcat(field("name"), ", ", field("location.country")).as("name"), + field("population")) + .where(field("location.country").equal("Canada")) + .execute() + .get(); + // [END select_bad_position] + System.out.println(names.getResults()); + } + + void selectNestedDataExample() { + // [START select_nested_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("population", 800000); + put( + "location", + new HashMap() { + { + put("country", "USA"); + put("state", "California"); + } + }); + put("landmarks", Arrays.asList("Golden Gate Bridge", "Alcatraz")); + } + }); + firestore + .collection("cities") + .document("TO") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("population", 3000000); + put("province", "ON"); + put( + "location", + new HashMap() { + { + put("country", "Canada"); + put("province", "Ontario"); + } + }); + put("landmarks", Arrays.asList("CN Tower", "Casa Loma")); + } + }); + firestore + .collection("cities") + .document("AT") + .set( + new HashMap() { + { + put("name", "Atlantis"); + put("population", null); + } + }); + // [END select_nested_data] + } + + void selectNestedExample() throws ExecutionException, InterruptedException { + // [START select_nested] + Pipeline.Snapshot locations = + firestore + .pipeline() + .collection("cities") + .select( + field("name").as("city"), + field("location.country").as("country"), + arrayGet(field("landmarks"), 0).as("topLandmark")) + .execute() + .get(); + // [END select_nested] + System.out.println(locations.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/remove_fields + void removeFieldsSyntaxExample() throws ExecutionException, InterruptedException { + // [START remove_fields_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .removeFields("population", "location.state") + .execute() + .get(); + // [END remove_fields_syntax] + System.out.println(results.getResults()); + } + + void removeFieldsNestedDataExample() { + // [START remove_fields_nested_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put( + "location", + new HashMap() { + { + put("country", "USA"); + put("state", "California"); + } + }); + } + }); + firestore + .collection("cities") + .document("TO") + .set( + new HashMap() { + { + put("name", "Toronto"); + put( + "location", + new HashMap() { + { + put("country", "Canada"); + put("province", "Ontario"); + } + }); + } + }); + // [END remove_fields_nested_data] + } + + void removeFieldsNestedExample() throws ExecutionException, InterruptedException { + // [START remove_fields_nested] + Pipeline.Snapshot results = + firestore.pipeline().collection("cities").removeFields("location.state").execute().get(); + // [END remove_fields_nested] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/limit + void limitSyntaxExample() throws ExecutionException, InterruptedException { + // [START limit_syntax] + Pipeline.Snapshot results = firestore.pipeline().collection("cities").limit(10).execute().get(); + // [END limit_syntax] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/find_nearest + void findNearestSyntaxExample() throws ExecutionException, InterruptedException { + // [START find_nearest_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .findNearest( + "embedding", + new double[] {1.5, 2.345}, + FindNearest.DistanceMeasure.EUCLIDEAN, + new FindNearestOptions()) + .execute() + .get(); + // [END find_nearest_syntax] + System.out.println(results.getResults()); + } + + void findNearestLimitExample() throws ExecutionException, InterruptedException { + // [START find_nearest_limit] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .findNearest( + "embedding", + new double[] {1.5, 2.345}, + FindNearest.DistanceMeasure.EUCLIDEAN, + new FindNearestOptions().withLimit(10)) + .execute() + .get(); + // [END find_nearest_limit] + System.out.println(results.getResults()); + } + + void findNearestDistanceDataExample() { + // [START find_nearest_distance_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("embedding", Arrays.asList(1.0, -1.0)); + } + }); + firestore + .collection("cities") + .document("TO") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("embedding", Arrays.asList(5.0, -10.0)); + } + }); + firestore + .collection("cities") + .document("AT") + .set( + new HashMap() { + { + put("name", "Atlantis"); + put("embedding", Arrays.asList(2.0, -4.0)); + } + }); + // [END find_nearest_distance_data] + } + + void findNearestDistanceExample() throws ExecutionException, InterruptedException { + // [START find_nearest_distance] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities") + .findNearest( + "embedding", + new double[] {1.3, 2.345}, + FindNearest.DistanceMeasure.EUCLIDEAN, + new FindNearestOptions().withDistanceField("computedDistance")) + .execute() + .get(); + // [END find_nearest_distance] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/offset + void offsetSyntaxExample() throws ExecutionException, InterruptedException { + // [START offset_syntax] + Pipeline.Snapshot results = + firestore.pipeline().collection("cities").offset(10).execute().get(); + // [END offset_syntax] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/add_fields + void addFieldsSyntaxExample() throws ExecutionException, InterruptedException { + // [START add_fields_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("users") + .addFields(stringConcat(field("firstName"), " ", field("lastName")).as("fullName")) + .execute() + .get(); + // [END add_fields_syntax] + System.out.println(results.getResults()); + } + + void addFieldsOverlapExample() throws ExecutionException, InterruptedException { + // [START add_fields_overlap] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("users") + .addFields(abs(field("age")).as("age")) + .addFields(add(field("age"), 10).as("age")) + .execute() + .get(); + // [END add_fields_overlap] + System.out.println(results.getResults()); + } + + void addFieldsNestingExample() throws ExecutionException, InterruptedException { + // [START add_fields_nesting] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("users") + .addFields(toLower(field("address.city")).as("address.city")) + .execute() + .get(); + // [END add_fields_nesting] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/input/collection + void collectionInputSyntaxExample() throws ExecutionException, InterruptedException { + // [START collection_input_syntax] + Pipeline.Snapshot results = + firestore.pipeline().collection("cities/SF/departments").execute().get(); + // [END collection_input_syntax] + System.out.println(results.getResults()); + } + + void collectionInputExampleData() { + // [START collection_input_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "California"); + } + }); + firestore + .collection("cities") + .document("NYC") + .set( + new HashMap() { + { + put("name", "New York City"); + put("state", "New York"); + } + }); + firestore + .collection("cities") + .document("CHI") + .set( + new HashMap() { + { + put("name", "Chicago"); + put("state", "Illinois"); + } + }); + firestore + .collection("states") + .document("CA") + .set( + new HashMap() { + { + put("name", "California"); + } + }); + // [END collection_input_data] + } + + void collectionInputExample() throws ExecutionException, InterruptedException { + // [START collection_input] + Pipeline.Snapshot results = + firestore.pipeline().collection("cities").sort(ascending(field("name"))).execute().get(); + // [END collection_input] + System.out.println(results.getResults()); + } + + void subcollectionInputExampleData() { + // [START subcollection_input_data] + firestore + .collection("cities/SF/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "SF Building Department"); + put("employees", 750); + } + }); + firestore + .collection("cities/NY/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "NY Building Department"); + put("employees", 1000); + } + }); + firestore + .collection("cities/CHI/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "CHI Building Department"); + put("employees", 900); + } + }); + firestore + .collection("cities/NY/departments") + .document("finance") + .set( + new HashMap() { + { + put("name", "NY Finance Department"); + put("employees", 1200); + } + }); + // [END subcollection_input_data] + } + + void subcollectionInputExample() throws ExecutionException, InterruptedException { + // [START subcollection_input] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities/NY/departments") + .sort(ascending(field("employees"))) + .execute() + .get(); + // [END subcollection_input] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/input/collection_group + void collectionGroupInputSyntaxExample() throws ExecutionException, InterruptedException { + // [START collection_group_input_syntax] + Pipeline.Snapshot results = firestore.pipeline().collectionGroup("departments").execute().get(); + // [END collection_group_input_syntax] + System.out.println(results.getResults()); + } + + void collectionGroupInputExampleData() { + // [START collection_group_data] + firestore + .collection("cities/SF/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "SF Building Department"); + put("employees", 750); + } + }); + firestore + .collection("cities/NY/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "NY Building Department"); + put("employees", 1000); + } + }); + firestore + .collection("cities/CHI/departments") + .document("building") + .set( + new HashMap() { + { + put("name", "CHI Building Department"); + put("employees", 900); + } + }); + firestore + .collection("cities/NY/departments") + .document("finance") + .set( + new HashMap() { + { + put("name", "NY Finance Department"); + put("employees", 1200); + } + }); + // [END collection_group_data] + } + + void collectionGroupInputExample() throws ExecutionException, InterruptedException { + // [START collection_group_input] + Pipeline.Snapshot results = + firestore + .pipeline() + .collectionGroup("departments") + .sort(ascending(field("employees"))) + .execute() + .get(); + // [END collection_group_input] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/input/database + void databaseInputSyntaxExample() throws ExecutionException, InterruptedException { + // [START database_syntax] + Pipeline.Snapshot results = firestore.pipeline().database().execute().get(); + // [END database_syntax] + System.out.println(results.getResults()); + } + + void databaseInputSyntaxExampleData() { + // [START database_input_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "California"); + put("population", 800000); + } + }); + firestore + .collection("states") + .document("CA") + .set( + new HashMap() { + { + put("name", "California"); + put("population", 39000000); + } + }); + firestore + .collection("countries") + .document("USA") + .set( + new HashMap() { + { + put("name", "United States of America"); + put("population", 340000000); + } + }); + // [END database_input_data] + } + + void databaseInputExample() throws ExecutionException, InterruptedException { + // [START database_input] + Pipeline.Snapshot results = + firestore.pipeline().database().sort(ascending(field("population"))).execute().get(); + // [END database_input] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/input/documents + void documentInputSyntaxExample() throws ExecutionException, InterruptedException { + // [START document_input_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .documents( + firestore.collection("cities").document("SF"), + firestore.collection("cities").document("NY")) + .execute() + .get(); + // [END document_input_syntax] + System.out.println(results.getResults()); + } + + void documentInputExampleData() { + // [START document_input_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "California"); + } + }); + firestore + .collection("cities") + .document("NYC") + .set( + new HashMap() { + { + put("name", "New York City"); + put("state", "New York"); + } + }); + firestore + .collection("cities") + .document("CHI") + .set( + new HashMap() { + { + put("name", "Chicago"); + put("state", "Illinois"); + } + }); + // [END document_input_data] + } + + void documentInputExample() throws ExecutionException, InterruptedException { + // [START document_input] + Pipeline.Snapshot results = + firestore + .pipeline() + .documents( + firestore.collection("cities").document("SF"), + firestore.collection("cities").document("NYC")) + .sort(ascending(field("name"))) + .execute() + .get(); + // [END document_input] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/union + void unionSyntaxExample() throws ExecutionException, InterruptedException { + // [START union_syntax] + Pipeline.Snapshot results = + firestore + .pipeline() + .collection("cities/SF/restaurants") + .union(firestore.pipeline().collection("cities/NYC/restaurants")) + .execute() + .get(); + // [END union_syntax] + System.out.println(results.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/aggregate + void aggregateSyntaxExample() throws ExecutionException, InterruptedException { + // [START aggregate_syntax] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .aggregate(countAll().as("total"), average("population").as("averagePopulation")) + .execute() + .get(); + // [END aggregate_syntax] + System.out.println(cities.getResults()); + } + + void aggregateGroupSyntax() throws ExecutionException, InterruptedException { + // [START aggregate_group_syntax] + Pipeline.Snapshot result = + firestore + .pipeline() + .collectionGroup("cities") + .aggregate( + Aggregate.withAccumulators( + countAll().as("cities"), sum("population").as("totalPopulation")) + .withGroups(field("location.state").as("state"))) + .execute() + .get(); + // [END aggregate_group_syntax] + System.out.println(result.getResults()); + } + + void aggregateExampleData() { + // [START aggregate_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "CA"); + put("country", "USA"); + put("population", 870000); + } + }); + firestore + .collection("cities") + .document("LA") + .set( + new HashMap() { + { + put("name", "Los Angeles"); + put("state", "CA"); + put("country", "USA"); + put("population", 3970000); + } + }); + firestore + .collection("cities") + .document("NY") + .set( + new HashMap() { + { + put("name", "New York"); + put("state", "NY"); + put("country", "USA"); + put("population", 8530000); + } + }); + firestore + .collection("cities") + .document("TOR") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("state", null); + put("country", "Canada"); + put("population", 2930000); + } + }); + firestore + .collection("cities") + .document("MEX") + .set( + new HashMap() { + { + put("name", "Mexico City"); + put("state", null); + put("country", "Mexico"); + put("population", 9200000); + } + }); + // [END aggregate_data] + } + + void aggregateWithoutGroupExample() throws ExecutionException, InterruptedException { + // [START aggregate_without_group] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .aggregate(countAll().as("total"), average("population").as("averagePopulation")) + .execute() + .get(); + // [END aggregate_without_group] + System.out.println(cities.getResults()); + } + + void aggregateGroupExample() throws ExecutionException, InterruptedException { + // [START aggregate_group_example] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .aggregate( + Aggregate.withAccumulators( + countAll().as("numberOfCities"), maximum("population").as("maxPopulation")) + .withGroups("country", "state")) + .execute() + .get(); + // [END aggregate_group_example] + System.out.println(cities.getResults()); + } + + void aggregateGroupComplexExample() throws ExecutionException, InterruptedException { + // [START aggregate_group_complex] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .aggregate( + Aggregate.withAccumulators(sum("population").as("totalPopulation")) + .withGroups(field("state").equal(null).as("stateIsNull"))) + .execute() + .get(); + // [END aggregate_group_complex] + System.out.println(cities.getResults()); + } + + // https://cloud.google.com/firestore/docs/pipeline/stages/transformation/distinct + void distinctSyntaxExample() throws ExecutionException, InterruptedException { + // [START distinct_syntax] + Pipeline.Snapshot cities1 = + firestore.pipeline().collection("cities").distinct("country").execute().get(); + + Pipeline.Snapshot cities2 = + firestore + .pipeline() + .collection("cities") + .distinct(toLower(field("state")).as("normalizedState"), field("country")) + .execute() + .get(); + // [END distinct_syntax] + System.out.println(cities1.getResults()); + System.out.println(cities2.getResults()); + } + + void distinctExampleData() { + // [START distinct_data] + firestore + .collection("cities") + .document("SF") + .set( + new HashMap() { + { + put("name", "San Francisco"); + put("state", "CA"); + put("country", "USA"); + } + }); + firestore + .collection("cities") + .document("LA") + .set( + new HashMap() { + { + put("name", "Los Angeles"); + put("state", "CA"); + put("country", "USA"); + } + }); + firestore + .collection("cities") + .document("NY") + .set( + new HashMap() { + { + put("name", "New York"); + put("state", "NY"); + put("country", "USA"); + } + }); + firestore + .collection("cities") + .document("TOR") + .set( + new HashMap() { + { + put("name", "Toronto"); + put("state", null); + put("country", "Canada"); + } + }); + firestore + .collection("cities") + .document("MEX") + .set( + new HashMap() { + { + put("name", "Mexico City"); + put("state", null); + put("country", "Mexico"); + } + }); + // [END distinct_data] + } + + void distinctExample() throws ExecutionException, InterruptedException { + // [START distinct_example] + Pipeline.Snapshot cities = + firestore.pipeline().collection("cities").distinct("country").execute().get(); + // [END distinct_example] + System.out.println(cities.getResults()); + } + + void distinctExpressionsExample() throws ExecutionException, InterruptedException { + // [START distinct_expressions] + Pipeline.Snapshot cities = + firestore + .pipeline() + .collection("cities") + .distinct(toLower(field("state")).as("normalizedState"), field("country")) + .execute() + .get(); + // [END distinct_expressions] + System.out.println(cities.getResults()); + } +} diff --git a/java-firestore/samples/snapshot/pom.xml b/java-firestore/samples/snapshot/pom.xml new file mode 100644 index 000000000000..23e9323bd045 --- /dev/null +++ b/java-firestore/samples/snapshot/pom.xml @@ -0,0 +1,133 @@ + + + 4.0.0 + com.google.cloud + firestore-snapshot + jar + Google Cloud Firestore Snapshot Samples + https://github.com/googleapis/java-firestore + + + + com.google.cloud.samples + shared-configuration + 1.2.2 + + + + 1.8 + 1.8 + UTF-8 + 2.66.0 + + + + + + com.google.cloud + google-cloud-firestore + 3.31.9 + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.4.4 + test + + + + + + org.apache.beam + beam-runners-direct-java + ${beam.version} + + + io.grpc + grpc-api + + + io.grpc + grpc-core + + + io.grpc + grpc-census + + + io.grpc + grpc-netty + + + + + org.apache.beam + beam-runners-google-cloud-dataflow-java + ${beam.version} + + + io.grpc + grpc-api + + + io.grpc + grpc-core + + + io.grpc + grpc-census + + + io.grpc + grpc-netty + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.6.1 + + + add-snippets-source + + add-source + + + + ../snippets/src/main/java + + + + + add-snippets-tests + + add-test-source + + + + ../snippets/src/test/java + + + + + + + + \ No newline at end of file diff --git a/java-firestore/samples/snippets/pom.xml b/java-firestore/samples/snippets/pom.xml new file mode 100644 index 000000000000..4cae68021530 --- /dev/null +++ b/java-firestore/samples/snippets/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + com.google.cloud + firestore-snippets + jar + Google Cloud Firestore Snippets + https://github.com/googleapis/java-firestore + + + + com.google.cloud.samples + shared-configuration + 1.2.2 + + + + 1.8 + 1.8 + UTF-8 + 2.66.0 + + + + + + + + + + com.google.cloud + libraries-bom + 26.65.0 + pom + import + + + + + + + com.google.cloud + google-cloud-firestore + + + + + + org.apache.beam + beam-runners-direct-java + ${beam.version} + + + org.apache.beam + beam-runners-google-cloud-dataflow-java + ${beam.version} + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.4.4 + test + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.5.1 + + + + quickstart + + exec + + + java + + -classpath + + com.example.firestore.Quickstart + ${firestore.project.id} + + + + + beam-sample + + exec + + + + + + + diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/Quickstart.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/Quickstart.java new file mode 100644 index 000000000000..8e057413c298 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/Quickstart.java @@ -0,0 +1,212 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore; + +import com.google.api.core.ApiFuture; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.cloud.firestore.DocumentReference; +// [START firestore_deps] +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +// [END firestore_deps] +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.WriteResult; +import com.google.common.collect.ImmutableMap; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * A simple Quick start application demonstrating how to connect to Firestore + * and add and query documents. + */ +public class Quickstart { + + private Firestore db; + + public Quickstart(String projectId) throws Exception { + // [START firestore_setup_client_create] + // Option 1: Initialize a Firestore client with a specific `projectId` and + // authorization credential. + // [START firestore_setup_client_create_with_project_id] + FirestoreOptions firestoreOptions = + FirestoreOptions.getDefaultInstance().toBuilder() + .setProjectId(projectId) + .setCredentials(GoogleCredentials.getApplicationDefault()) + .build(); + Firestore db = firestoreOptions.getService(); + // [END firestore_setup_client_create_with_project_id] + // [END firestore_setup_client_create] + this.db = db; + } + + /** + * Initialize Firestore using default project ID. + */ + public Quickstart() { + // [START firestore_setup_client_create] + + // Option 2: Initialize a Firestore client with default values inferred from + // your environment. + Firestore db = FirestoreOptions.getDefaultInstance().getService(); + // [END firestore_setup_client_create] + this.db = db; + } + + Firestore getDb() { + return db; + } + + /** + * Add named test documents with fields first, last, middle (optional), born. + * + * @param docName document name + */ + void addDocument(String docName) throws Exception { + switch (docName) { + case "alovelace": { + // [START firestore_setup_dataset_pt1] + DocumentReference docRef = db.collection("users").document("alovelace"); + // Add document data with id "alovelace" using a hashmap + Map data = new HashMap<>(); + data.put("first", "Ada"); + data.put("last", "Lovelace"); + data.put("born", 1815); + //asynchronously write data + ApiFuture result = docRef.set(data); + // ... + // result.get() blocks on response + System.out.println("Update time : " + result.get().getUpdateTime()); + // [END firestore_setup_dataset_pt1] + break; + } + case "aturing": { + // [START firestore_setup_dataset_pt2] + DocumentReference docRef = db.collection("users").document("aturing"); + // Add document data with an additional field ("middle") + Map data = new HashMap<>(); + data.put("first", "Alan"); + data.put("middle", "Mathison"); + data.put("last", "Turing"); + data.put("born", 1912); + + ApiFuture result = docRef.set(data); + System.out.println("Update time : " + result.get().getUpdateTime()); + // [END firestore_setup_dataset_pt2] + break; + } + case "cbabbage": { + DocumentReference docRef = db.collection("users").document("cbabbage"); + Map data = + new ImmutableMap.Builder() + .put("first", "Charles") + .put("last", "Babbage") + .put("born", 1791) + .build(); + ApiFuture result = docRef.set(data); + System.out.println("Update time : " + result.get().getUpdateTime()); + break; + } + default: + } + } + + void runQuery() throws Exception { + // [START firestore_setup_add_query] + // asynchronously query for all users born before 1900 + ApiFuture query = + db.collection("users").whereLessThan("born", 1900).get(); + // ... + // query.get() blocks on response + QuerySnapshot querySnapshot = query.get(); + List documents = querySnapshot.getDocuments(); + for (QueryDocumentSnapshot document : documents) { + System.out.println("User: " + document.getId()); + System.out.println("First: " + document.getString("first")); + if (document.contains("middle")) { + System.out.println("Middle: " + document.getString("middle")); + } + System.out.println("Last: " + document.getString("last")); + System.out.println("Born: " + document.getLong("born")); + } + // [END firestore_setup_add_query] + } + + void retrieveAllDocuments() throws Exception { + // [START firestore_setup_dataset_read] + // asynchronously retrieve all users + ApiFuture query = db.collection("users").get(); + // ... + // query.get() blocks on response + QuerySnapshot querySnapshot = query.get(); + List documents = querySnapshot.getDocuments(); + for (QueryDocumentSnapshot document : documents) { + System.out.println("User: " + document.getId()); + System.out.println("First: " + document.getString("first")); + if (document.contains("middle")) { + System.out.println("Middle: " + document.getString("middle")); + } + System.out.println("Last: " + document.getString("last")); + System.out.println("Born: " + document.getLong("born")); + } + // [END firestore_setup_dataset_read] + } + + void run() throws Exception { + String[] docNames = {"alovelace", "aturing", "cbabbage"}; + + // Adding document 1 + System.out.println("########## Adding document 1 ##########"); + addDocument(docNames[0]); + + // Adding document 2 + System.out.println("########## Adding document 2 ##########"); + addDocument(docNames[1]); + + // Adding document 3 + System.out.println("########## Adding document 3 ##########"); + addDocument(docNames[2]); + + // retrieve all users born before 1900 + System.out.println("########## users born before 1900 ##########"); + runQuery(); + + // retrieve all users + System.out.println("########## All users ##########"); + retrieveAllDocuments(); + System.out.println("###################################"); + } + + /** + * A quick start application to get started with Firestore. + * + * @param args firestore-project-id (optional) + */ + public static void main(String[] args) throws Exception { + // default project is will be used if project-id argument is not available + String projectId = (args.length == 0) ? null : args[0]; + Quickstart quickStart = (projectId != null) ? new Quickstart(projectId) : new Quickstart(); + quickStart.run(); + quickStart.close(); + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamRead.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamRead.java new file mode 100644 index 000000000000..2cd3e180d5aa --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamRead.java @@ -0,0 +1,134 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.beam; + +import com.google.cloud.firestore.FirestoreOptions; +import com.google.firestore.v1.DocumentRootName; +import com.google.firestore.v1.RunQueryRequest; +import com.google.firestore.v1.RunQueryResponse; +import com.google.firestore.v1.StructuredQuery; +import com.google.firestore.v1.Value; +import java.util.Objects; +import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; +import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreIO; +import org.apache.beam.sdk.io.gcp.firestore.RpcQosOptions; +import org.apache.beam.sdk.options.PipelineOptions; +import org.apache.beam.sdk.options.PipelineOptionsFactory; +import org.apache.beam.sdk.transforms.Create; +import org.apache.beam.sdk.transforms.DoFn; +import org.apache.beam.sdk.transforms.PTransform; +import org.apache.beam.sdk.transforms.ParDo; +import org.apache.beam.sdk.values.PCollection; + +public class ExampleFirestoreBeamRead { + + public static void main(String[] args) { + runRead(args, "cities-beam-sample"); + } + + public static void runRead(String[] args, String collectionId) { + FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance(); + + PipelineOptions options = + PipelineOptionsFactory.fromArgs(args).withValidation().as(PipelineOptions.class); + Pipeline pipeline = Pipeline.create(options); + + RpcQosOptions rpcQosOptions = + RpcQosOptions.newBuilder() + .withHintMaxNumWorkers(options.as(DataflowPipelineOptions.class).getMaxNumWorkers()) + .build(); + + pipeline + .apply(Create.of(collectionId)) + .apply( + new FilterDocumentsQuery( + firestoreOptions.getProjectId(), firestoreOptions.getDatabaseId())) + .apply(FirestoreIO.v1().read().runQuery().withRpcQosOptions(rpcQosOptions).build()) + .apply( + ParDo.of( + // transform each document to its name + new DoFn() { + @ProcessElement + public void processElement(ProcessContext c) { + c.output(Objects.requireNonNull(c.element()).getDocument().getName()); + } + })) + .apply( + ParDo.of( + // print the document name + new DoFn() { + @ProcessElement + public void processElement(ProcessContext c) { + System.out.println(c.element()); + } + })); + + pipeline.run().waitUntilFinish(); + } + + private static final class FilterDocumentsQuery + extends PTransform, PCollection> { + + private final String projectId; + private final String databaseId; + + public FilterDocumentsQuery(String projectId, String databaseId) { + this.projectId = projectId; + this.databaseId = databaseId; + } + + @Override + public PCollection expand(PCollection input) { + return input.apply( + ParDo.of( + new DoFn() { + @ProcessElement + public void processElement(ProcessContext c) { + // select from collection "cities-collection-" + StructuredQuery.CollectionSelector collection = + StructuredQuery.CollectionSelector.newBuilder() + .setCollectionId(Objects.requireNonNull(c.element())) + .build(); + // filter where country is equal to USA + StructuredQuery.Filter countryFilter = + StructuredQuery.Filter.newBuilder() + .setFieldFilter( + StructuredQuery.FieldFilter.newBuilder() + .setField( + StructuredQuery.FieldReference.newBuilder() + .setFieldPath("country") + .build()) + .setValue(Value.newBuilder().setStringValue("USA").build()) + .setOp(StructuredQuery.FieldFilter.Operator.EQUAL)) + .buildPartial(); + + RunQueryRequest runQueryRequest = + RunQueryRequest.newBuilder() + .setParent(DocumentRootName.format(projectId, databaseId)) + .setStructuredQuery( + StructuredQuery.newBuilder() + .addFrom(collection) + .setWhere(countryFilter) + .build()) + .build(); + c.output(runQueryRequest); + } + })); + } + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamWrite.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamWrite.java new file mode 100644 index 000000000000..28ffb4641b75 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/ExampleFirestoreBeamWrite.java @@ -0,0 +1,91 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.beam; + +import com.google.cloud.firestore.FirestoreOptions; +import com.google.firestore.v1.Document; +import com.google.firestore.v1.Value; +import com.google.firestore.v1.Write; +import org.apache.beam.runners.dataflow.options.DataflowPipelineOptions; +import org.apache.beam.sdk.Pipeline; +import org.apache.beam.sdk.io.gcp.firestore.FirestoreIO; +import org.apache.beam.sdk.io.gcp.firestore.RpcQosOptions; +import org.apache.beam.sdk.options.PipelineOptions; +import org.apache.beam.sdk.options.PipelineOptionsFactory; +import org.apache.beam.sdk.transforms.Create; + +public class ExampleFirestoreBeamWrite { + private static final FirestoreOptions FIRESTORE_OPTIONS = FirestoreOptions.getDefaultInstance(); + + public static void main(String[] args) { + runWrite(args, "cities-beam-sample"); + } + + public static void runWrite(String[] args, String collectionId) { + // create pipeline options from the passed in arguments + PipelineOptions options = + PipelineOptionsFactory.fromArgs(args).withValidation().as(PipelineOptions.class); + Pipeline pipeline = Pipeline.create(options); + + RpcQosOptions rpcQosOptions = + RpcQosOptions.newBuilder() + .withHintMaxNumWorkers(options.as(DataflowPipelineOptions.class).getMaxNumWorkers()) + .build(); + + // create some writes + Write write1 = + Write.newBuilder() + .setUpdate( + Document.newBuilder() + // resolves to + // projects//databases//documents//NYC + .setName(createDocumentName(collectionId, "NYC")) + .putFields("name", Value.newBuilder().setStringValue("New York City").build()) + .putFields("state", Value.newBuilder().setStringValue("New York").build()) + .putFields("country", Value.newBuilder().setStringValue("USA").build())) + .build(); + + Write write2 = + Write.newBuilder() + .setUpdate( + Document.newBuilder() + // resolves to + // projects//databases//documents//TOK + .setName(createDocumentName(collectionId, "TOK")) + .putFields("name", Value.newBuilder().setStringValue("Tokyo").build()) + .putFields("country", Value.newBuilder().setStringValue("Japan").build()) + .putFields("capital", Value.newBuilder().setBooleanValue(true).build())) + .build(); + + // batch write the data + pipeline + .apply(Create.of(write1, write2)) + .apply(FirestoreIO.v1().write().batchWrite().withRpcQosOptions(rpcQosOptions).build()); + + // run the pipeline + pipeline.run().waitUntilFinish(); + } + + private static String createDocumentName(String collectionId, String cityDocId) { + String documentPath = + String.format( + "projects/%s/databases/%s/documents", + FIRESTORE_OPTIONS.getProjectId(), FIRESTORE_OPTIONS.getDatabaseId()); + + return documentPath + "/" + collectionId + "/" + cityDocId; + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/README.md b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/README.md new file mode 100644 index 000000000000..dd9b1f38a4ea --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/beam/README.md @@ -0,0 +1,34 @@ +# Firestore Beam Samples + +## Running instructions +These examples will show you how to read and write data from/into a Firestore database using the Firestore Beam connector. + +1. Set up the following environment variables +``` +GOOGLE_CLOUD_PROJECT= +REGION= +TEMP_LOCATION=gs:///temp/ +NUM_WORKERS= +MAX_NUM_WORKERS= +``` +2. Run the command to write example data into the collection, "cities-beam-sample": +``` +mvn compile exec:java@beam-sample -Dexec.mainClass=com.example.firestore.beam.ExampleFirestoreBeamWrite \ +"-Dexec.args=--project=$GOOGLE_CLOUD_PROJECT \ +--runner=DataflowRunner \ +--region=$REGION \ +--tempLocation=$TEMP_LOCATION \ +--numWorkers=$NUM_WORKERS \ +--maxNumWorkers=$MAX_NUM_WORKERS" +``` + +3. Run the command to filter and read the data you wrote from the collection, "cities-beam-sample": +``` +mvn compile exec:java@beam-sample -Dexec.mainClass=com.example.firestore.beam.ExampleFirestoreBeamRead \ +"-Dexec.args=--project=$GOOGLE_CLOUD_PROJECT \ +--runner=DataflowRunner \ +--region=$REGION \ +--tempLocation=$TEMP_LOCATION \ +--numWorkers=$NUM_WORKERS \ +--maxNumWorkers=$MAX_NUM_WORKERS" +``` \ No newline at end of file diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java new file mode 100644 index 000000000000..78a8f1c13e29 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ListenDataSnippets.java @@ -0,0 +1,210 @@ +/* + * Copyright 2018 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.google.api.core.SettableApiFuture; +import com.google.cloud.firestore.DocumentChange; +import com.google.cloud.firestore.DocumentChange.Type; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.EventListener; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreException; +import com.google.cloud.firestore.ListenerRegistration; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QuerySnapshot; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Nullable; + +/** Snippets to demonstrate Firestore 'listen' operations. */ +@SuppressWarnings("Convert2Lambda") +public class ListenDataSnippets { + + private static final long TIMEOUT_SECONDS = 5; + + private final Firestore db; + + ListenDataSnippets(Firestore db) { + this.db = db; + } + + /** Listen to a single document, returning data after the first snapshot. */ + Map listenToDocument() throws Exception { + final SettableApiFuture> future = SettableApiFuture.create(); + + // [START firestore_listen_document] + DocumentReference docRef = db.collection("cities").document("SF"); + docRef.addSnapshotListener( + new EventListener() { + @Override + public void onEvent(@Nullable DocumentSnapshot snapshot, @Nullable FirestoreException e) { + if (e != null) { + System.err.println("Listen failed: " + e); + return; + } + + if (snapshot != null && snapshot.exists()) { + System.out.println("Current data: " + snapshot.getData()); + } else { + System.out.print("Current data: null"); + } + // [START_EXCLUDE silent] + if (!future.isDone()) { + future.set(snapshot.getData()); + } + // [END_EXCLUDE] + } + }); + // [END firestore_listen_document] + + return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } + + /** Listen to a query, returning the names of all cities in the first snapshot. */ + List listenForMultiple() throws Exception { + final SettableApiFuture> future = SettableApiFuture.create(); + + // [START firestore_listen_query_snapshots] + db.collection("cities") + .whereEqualTo("state", "CA") + .addSnapshotListener( + new EventListener() { + @Override + public void onEvent( + @Nullable QuerySnapshot snapshots, @Nullable FirestoreException e) { + if (e != null) { + System.err.println("Listen failed:" + e); + return; + } + + List cities = new ArrayList<>(); + for (DocumentSnapshot doc : snapshots) { + if (doc.get("name") != null) { + cities.add(doc.getString("name")); + } + } + System.out.println("Current cites in CA: " + cities); + // [START_EXCLUDE silent] + if (!future.isDone()) { + future.set(cities); + } + // [END_EXCLUDE] + } + }); + // [END firestore_listen_query_snapshots] + + return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } + + /** Listen to a query, returning the list of DocumentChange events in the first snapshot. */ + List listenForChanges() throws Exception { + SettableApiFuture> future = SettableApiFuture.create(); + + // [START firestore_listen_query_changes] + db.collection("cities") + .whereEqualTo("state", "CA") + .addSnapshotListener( + new EventListener() { + @Override + public void onEvent( + @Nullable QuerySnapshot snapshots, @Nullable FirestoreException e) { + if (e != null) { + System.err.println("Listen failed: " + e); + return; + } + + for (DocumentChange dc : snapshots.getDocumentChanges()) { + switch (dc.getType()) { + case ADDED: + System.out.println("New city: " + dc.getDocument().getData()); + break; + case MODIFIED: + System.out.println("Modified city: " + dc.getDocument().getData()); + break; + case REMOVED: + System.out.println("Removed city: " + dc.getDocument().getData()); + break; + default: + break; + } + } + // [START_EXCLUDE silent] + if (!future.isDone()) { + future.set(snapshots.getDocumentChanges()); + } + // [END_EXCLUDE] + } + }); + // [END firestore_listen_query_changes] + + return future.get(TIMEOUT_SECONDS, TimeUnit.SECONDS); + } + + /** Demonstrate how to detach an event listener. */ + void detachListener() { + // [START firestore_listen_detach] + Query query = db.collection("cities"); + ListenerRegistration registration = + query.addSnapshotListener( + new EventListener() { + // [START_EXCLUDE] + @Override + public void onEvent( + @Nullable QuerySnapshot snapshots, @Nullable FirestoreException e) {} + + // [END_EXCLUDE] + }); + + // ... + + // Stop listening to changes + registration.remove(); + // [END firestore_listen_detach] + } + + /** Demonstrate how to handle listening errors. */ + void listenErrors() { + // [START firestore_listen_handle_error] + db.collection("cities") + .addSnapshotListener( + new EventListener() { + @Override + public void onEvent( + @Nullable QuerySnapshot snapshots, @Nullable FirestoreException e) { + if (e != null) { + System.err.println("Listen failed: " + e); + return; + } + + for (DocumentChange dc : snapshots.getDocumentChanges()) { + if (dc.getType() == Type.ADDED) { + System.out.println("New city: " + dc.getDocument().getData()); + } + } + } + }); + // [END firestore_listen_handle_error] + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java new file mode 100644 index 000000000000..a5543f2532ba --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/ManageDataSnippets.java @@ -0,0 +1,492 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.FieldValue; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.SetOptions; +import com.google.cloud.firestore.TransactionOptions; +import com.google.cloud.firestore.WriteBatch; +import com.google.cloud.firestore.WriteResult; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ExecutionException; + +/** Snippets to demonstrate Firestore add, update and delete operations. */ +class ManageDataSnippets { + + private final Firestore db; + + ManageDataSnippets(Firestore db) { + this.db = db; + } + + /** + * Add a document to a collection using a map. + * + * @return document data + */ + Map addSimpleDocumentAsMap() throws Exception { + // [START firestore_data_set_from_map] + // Create a Map to store the data we want to set + Map docData = new HashMap<>(); + docData.put("name", "Los Angeles"); + docData.put("state", "CA"); + docData.put("country", "USA"); + docData.put("regions", Arrays.asList("west_coast", "socal")); + // Add a new document (asynchronously) in collection "cities" with id "LA" + ApiFuture future = db.collection("cities").document("LA").set(docData); + // ... + // future.get() blocks on response + System.out.println("Update time : " + future.get().getUpdateTime()); + // [END firestore_data_set_from_map] + return docData; + } + + /** + * Add a document to a collection using a map with different supported data types. + * + * @return document data + */ + Map addDocumentWithDifferentDataTypes() throws Exception { + // [START firestore_data_set_from_map_nested] + Map docData = new HashMap<>(); + docData.put("stringExample", "Hello, World"); + docData.put("booleanExample", false); + docData.put("numberExample", 3.14159265); + docData.put("nullExample", null); + + ArrayList arrayExample = new ArrayList<>(); + Collections.addAll(arrayExample, 5L, true, "hello"); + docData.put("arrayExample", arrayExample); + + Map objectExample = new HashMap<>(); + objectExample.put("a", 5L); + objectExample.put("b", true); + + docData.put("objectExample", objectExample); + + ApiFuture future = db.collection("data").document("one").set(docData); + System.out.println("Update time : " + future.get().getUpdateTime()); + // [END firestore_data_set_from_map_nested] + + return docData; + } + + /** + * Add a document to a collection as a custom object. + * + * @return entity added + */ + City addSimpleDocumentAsEntity() throws Exception { + // [START firestore_data_set_from_custom_type] + City city = + new City("Los Angeles", "CA", "USA", false, 3900000L, Arrays.asList("west_coast", "socal")); + ApiFuture future = db.collection("cities").document("LA").set(city); + // block on response if required + System.out.println("Update time : " + future.get().getUpdateTime()); + // [END firestore_data_set_from_custom_type] + + return city; + } + + /** set() providing a document ID. */ + void setRequiresId(Map data) { + // [START firestore_data_set_id_specified] + db.collection("cities").document("new-city-id").set(data); + // [END firestore_data_set_id_specified] + } + + /** + * Add a document without explicitly providing the document id. The document id gets automatically + * generated. + * + * @return auto generated id + */ + String addDocumentDataWithAutoGeneratedId() throws Exception { + // [START firestore_data_set_id_random_collection] + // Add document data with auto-generated id. + Map data = new HashMap<>(); + data.put("name", "Tokyo"); + data.put("country", "Japan"); + ApiFuture addedDocRef = db.collection("cities").add(data); + System.out.println("Added document with ID: " + addedDocRef.get().getId()); + // [END firestore_data_set_id_random_collection] + + return addedDocRef.get().getId(); + } + + /** + * Add data to a document after generating the document id. + * + * @return auto generated id + */ + String addDocumentDataAfterAutoGeneratingId() throws Exception { + City data = new City(); + + // [START firestore_data_set_id_random_document_ref] + // Add document data after generating an id. + DocumentReference addedDocRef = db.collection("cities").document(); + System.out.println("Added document with ID: " + addedDocRef.getId()); + + // later... + ApiFuture writeResult = addedDocRef.set(data); + // [END firestore_data_set_id_random_document_ref] + + // writeResult.get() blocks on operation + System.out.println("Update time : " + writeResult.get().getUpdateTime()); + return addedDocRef.getId(); + } + + /** Partially update a document using the .update(field1, value1..) method. */ + void updateSimpleDocument() throws Exception { + db.collection("cities").document("DC").set(new City("Washington D.C.")).get(); + // [START firestore_data_set_field] + // Update an existing document + DocumentReference docRef = db.collection("cities").document("DC"); + + // (async) Update one field + ApiFuture future = docRef.update("capital", true); + + // ... + WriteResult result = future.get(); + System.out.println("Write result: " + result); + // [END firestore_data_set_field] + } + + /** Partially update fields of a document using a map (field => value). */ + void updateUsingMap() throws Exception { + db.collection("cities").document("DC").set(new City("Washington D.C.")).get(); + // [START firestore_data_set_document_update] + // update multiple fields using a map + DocumentReference docRef = db.collection("cities").document("DC"); + + Map updates = new HashMap<>(); + updates.put("name", "Washington D.C."); + updates.put("country", "USA"); + updates.put("capital", true); + + // asynchronously update doc + ApiFuture writeResult = docRef.update(updates); + // ... + System.out.println("Update time : " + writeResult.get().getUpdateTime()); + // [END firestore_data_set_document_update] + } + + /** Partially update fields of a document using a map (field => value). */ + void updateAndCreateIfMissing() throws Exception { + // [START firestore_data_set_doc_upsert] + // asynchronously update doc, create the document if missing + Map update = new HashMap<>(); + update.put("capital", true); + + ApiFuture writeResult = + db.collection("cities").document("BJ").set(update, SetOptions.merge()); + // ... + System.out.println("Update time : " + writeResult.get().getUpdateTime()); + // [END firestore_data_set_doc_upsert] + } + + /** Partial update nested fields of a document. */ + void updateNestedFields() throws Exception { + // CHECKSTYLE OFF: VariableDeclarationUsageDistance + // [START firestore_data_set_nested_fields] + // Create an initial document to update + DocumentReference frankDocRef = db.collection("users").document("frank"); + Map initialData = new HashMap<>(); + initialData.put("name", "Frank"); + initialData.put("age", 12); + + Map favorites = new HashMap<>(); + favorites.put("food", "Pizza"); + favorites.put("color", "Blue"); + favorites.put("subject", "Recess"); + initialData.put("favorites", favorites); + + ApiFuture initialResult = frankDocRef.set(initialData); + // Confirm that data has been successfully saved by blocking on the operation + initialResult.get(); + + // Update age and favorite color + Map updates = new HashMap<>(); + updates.put("age", 13); + updates.put("favorites.color", "Red"); + + // Async update document + ApiFuture writeResult = frankDocRef.update(updates); + // ... + System.out.println("Update time : " + writeResult.get().getUpdateTime()); + // [END firestore_data_set_nested_fields] + // CHECKSTYLE ON: VariableDeclarationUsageDistance + } + + /** Update document with server timestamp. */ + void updateServerTimestamp() throws Exception { + db.collection("objects").document("some-id").set(new HashMap()).get(); + + // [START firestore_data_set_server_timestamp] + DocumentReference docRef = db.collection("objects").document("some-id"); + // Update the timestamp field with the value from the server + ApiFuture writeResult = docRef.update("timestamp", FieldValue.serverTimestamp()); + System.out.println("Update time : " + writeResult.get()); + // [END firestore_data_set_server_timestamp] + } + + /** Update array fields in a document. * */ + void updateDocumentArray() throws Exception { + // [START firestore_data_set_array_operations] + DocumentReference washingtonRef = db.collection("cities").document("DC"); + + // Atomically add a new region to the "regions" array field. + ApiFuture arrayUnion = + washingtonRef.update("regions", FieldValue.arrayUnion("greater_virginia")); + System.out.println("Update time : " + arrayUnion.get()); + + // Atomically remove a region from the "regions" array field. + ApiFuture arrayRm = + washingtonRef.update("regions", FieldValue.arrayRemove("east_coast")); + System.out.println("Update time : " + arrayRm.get()); + // [END firestore_data_set_array_operations] + } + + /** Delete specific fields when updating a document. */ + void deleteFields() throws Exception { + City city = new City("Beijing"); + city.setCapital(true); + db.collection("cities").document("BJ").set(city).get(); + + // [START firestore_data_delete_field] + DocumentReference docRef = db.collection("cities").document("BJ"); + Map updates = new HashMap<>(); + updates.put("capital", FieldValue.delete()); + // Update and delete the "capital" field in the document + ApiFuture writeResult = docRef.update(updates); + System.out.println("Update time : " + writeResult.get()); + // [END firestore_data_delete_field] + } + + /** Delete a document in a collection. */ + void deleteDocument() throws Exception { + db.collection("cities").document("DC").set(new City("Washington, D.C.")).get(); + // [START firestore_data_delete_doc] + // asynchronously delete a document + ApiFuture writeResult = db.collection("cities").document("DC").delete(); + // ... + System.out.println("Update time : " + writeResult.get().getUpdateTime()); + // [END firestore_data_delete_doc] + } + + // [START firestore_data_delete_collection] + /** + * Delete a collection in batches to avoid out-of-memory errors. Batch size may be tuned based on + * document size (atmost 1MB) and application requirements. + */ + void deleteCollection(CollectionReference collection, int batchSize) { + try { + // retrieve a small batch of documents to avoid out-of-memory errors + ApiFuture future = collection.limit(batchSize).get(); + int deleted = 0; + // future.get() blocks on document retrieval + List documents = future.get().getDocuments(); + for (QueryDocumentSnapshot document : documents) { + document.getReference().delete(); + ++deleted; + } + if (deleted >= batchSize) { + // retrieve and delete another batch + deleteCollection(collection, batchSize); + } + } catch (Exception e) { + System.err.println("Error deleting collection : " + e.getMessage()); + } + } + + // [END firestore_data_delete_collection] + + /** + * Run a simple transaction to perform a field value increment. + * + * @return transaction future + */ + ApiFuture runSimpleTransaction() throws Exception { + // [START firestore_transaction_document_update] + // Initialize doc + final DocumentReference docRef = db.collection("cities").document("SF"); + City city = new City("SF"); + city.setCountry("USA"); + city.setPopulation(860000L); + docRef.set(city).get(); + + // run an asynchronous transaction + ApiFuture futureTransaction = + db.runTransaction( + transaction -> { + // retrieve document and increment population field + DocumentSnapshot snapshot = transaction.get(docRef).get(); + long oldPopulation = snapshot.getLong("population"); + transaction.update(docRef, "population", oldPopulation + 1); + return null; + }); + // block on transaction operation using transaction.get() + // [END firestore_transaction_document_update] + return futureTransaction; + } + + /** + * Return information from a conditional transaction. + * + * @param population : set initial population. + */ + String returnInfoFromTransaction(long population) throws Exception { + Map map = new HashMap<>(); + map.put("population", population); + // Block until transaction is complete is using transaction.get() + db.collection("cities").document("SF").set(map).get(); + // [START firestore_transaction_document_update_conditional] + final DocumentReference docRef = db.collection("cities").document("SF"); + ApiFuture futureTransaction = + db.runTransaction( + transaction -> { + DocumentSnapshot snapshot = transaction.get(docRef).get(); + Long newPopulation = snapshot.getLong("population") + 1; + // conditionally update based on current population + if (newPopulation <= 1000000L) { + transaction.update(docRef, "population", newPopulation); + return "Population increased to " + newPopulation; + } else { + throw new Exception("Sorry! Population is too big."); + } + }); + // Print information retrieved from transaction + System.out.println(futureTransaction.get()); + // [END firestore_transaction_document_update_conditional] + return futureTransaction.get(); + } + + /** Write documents in a batch. */ + void writeBatch() throws Exception { + db.collection("cities").document("SF").set(new City()).get(); + db.collection("cities").document("LA").set(new City()).get(); + + // [START firestore_data_batch_writes] + // Get a new write batch + WriteBatch batch = db.batch(); + + // Set the value of 'NYC' + DocumentReference nycRef = db.collection("cities").document("NYC"); + batch.set(nycRef, new City()); + + // Update the population of 'SF' + DocumentReference sfRef = db.collection("cities").document("SF"); + batch.update(sfRef, "population", 1000000L); + + // Delete the city 'LA' + DocumentReference laRef = db.collection("cities").document("LA"); + batch.delete(laRef); + + // asynchronously commit the batch + ApiFuture> future = batch.commit(); + // ... + // future.get() blocks on batch commit operation + for (WriteResult result : future.get()) { + System.out.println("Update time : " + result.getUpdateTime()); + } + // [END firestore_data_batch_writes] + } + + public void updateDocumentIncrement() throws ExecutionException, InterruptedException { + final City city = new City(); + city.setPopulation(100L); + db.collection("cities").document("DC").set(city).get(); + + // [START firestore_data_set_numeric_increment] + DocumentReference washingtonRef = db.collection("cities").document("DC"); + + // Atomically increment the population of the city by 50. + final ApiFuture updateFuture = + washingtonRef.update("population", FieldValue.increment(50)); + // [END firestore_data_set_numeric_increment] + updateFuture.get(); + } + + /** + * Run a snapshot read to read past versions of documents. + * + * @return transaction future + */ + DocumentSnapshot runSnapshotReads() throws Exception { + // [START firestore_snapshot_read] + // Initialize a documnet + final DocumentReference documentReference = db.collection("cities").document("SF"); + City city = new City("SF"); + city.setCountry("USA"); + city.setPopulation(860008L); + // Write doc and save write result + WriteResult writeResult = documentReference.set(city).get(); + + // Create a reference to the cities collection + CollectionReference cities = db.collection("cities"); + // Create a query against the collection. + Query query = cities.whereEqualTo("capital", true); + + // In the transaction options, Set read time and and set to read-only + // Snapshot reads require read-only transactions + // As an example, set read time to the update time of the previous write operation + final Timestamp readTime = + com.google.protobuf.Timestamp.newBuilder() + .setSeconds(writeResult.getUpdateTime().getSeconds()) + .setNanos(writeResult.getUpdateTime().getNanos()) + .build(); + + TransactionOptions options = + TransactionOptions.createReadOnlyOptionsBuilder().setReadTime(readTime).build(); + + // run a transaction + ApiFuture futureTransaction = + db.runTransaction( + transaction -> { + // Execute a snapshot read document lookup + final DocumentSnapshot documentResult = transaction.get(documentReference).get(); + + // Execute a snapshot read query with the same transaction options + final QuerySnapshot queryResult = transaction.get(query).get(); + + return documentResult; + }, + options); + // [END firestore_snapshot_read] + return futureTransaction.get(); + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippets.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippets.java new file mode 100644 index 000000000000..b1a68ed3903b --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippets.java @@ -0,0 +1,134 @@ +/* + * Copyright 2024 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.WriteResult; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** Snippets to support firestore querying data documentation. */ +class MultipleRangeInequalityFiltersSnippets { + + private final Firestore db; + + MultipleRangeInequalityFiltersSnippets(Firestore db) { + this.db = db; + } + + /** Creates cities collection and add sample documents to test queries. */ + void prepareExamples() throws Exception { + // Data for each city + Map sfData = new HashMap<>(); + sfData.put("name", "San Francisco"); + sfData.put("state", "CA"); + sfData.put("country", "USA"); + sfData.put("capital", false); + sfData.put("population", 860000L); + sfData.put("density", 18000L); + sfData.put("regions", Arrays.asList("west_coast", "norcal")); + + Map laData = new HashMap<>(); + laData.put("name", "Los Angeles"); + laData.put("state", "CA"); + laData.put("country", "USA"); + laData.put("capital", false); + laData.put("population", 3900000L); + laData.put("density", 8300L); + laData.put("regions", Arrays.asList("west_coast", "socal")); + + Map dcData = new HashMap<>(); + dcData.put("name", "Washington D.C."); + dcData.put("state", null); + dcData.put("country", "USA"); + dcData.put("capital", true); + dcData.put("population", 680000L); + dcData.put("density", 11300L); + dcData.put("regions", Arrays.asList("east_coast")); + + Map tokData = new HashMap<>(); + tokData.put("name", "Tokyo"); + tokData.put("state", null); + tokData.put("country", "Japan"); + tokData.put("capital", true); + tokData.put("population", 9000000L); + tokData.put("density", 16000L); + tokData.put("regions", Arrays.asList("kanto", "honshu")); + + Map bjData = new HashMap<>(); + bjData.put("name", "Beijing"); + bjData.put("state", null); + bjData.put("country", "China"); + bjData.put("capital", true); + bjData.put("population", 21500000L); + bjData.put("density", 3500L); + bjData.put("regions", Arrays.asList("jingjinji", "hebei")); + + CollectionReference citiesCollection = db.collection("cities"); + + // Add each city document + addCityDocument(citiesCollection, "SF", sfData); + addCityDocument(citiesCollection, "LA", laData); + addCityDocument(citiesCollection, "DC", dcData); + addCityDocument(citiesCollection, "TOK", tokData); + addCityDocument(citiesCollection, "BJ", bjData); + + System.out.println("Data added successfully!"); + } + + private static void addCityDocument( + CollectionReference citiesRef, String documentId, Map data) { + ApiFuture future = citiesRef.document(documentId).set(data); + try { + WriteResult result = future.get(); + System.out.println("Update time : " + result.getUpdateTime()); + } catch (Exception e) { + System.err.println("Error adding document: " + e.getMessage()); + } + } + + /* Example of Query with range and inequality filters. */ + Query compoundMultiInequalities() { + // [START firestore_query_filter_compound_multi_ineq] + Query query = + db.collection("cities") + .whereGreaterThan("population", 1000000) + .whereLessThan("density", 10000); + // [END firestore_query_filter_compound_multi_ineq] + return query; + } + + /* Example of filtering indexes considering performance reasons. */ + void indexingConsiderations() { + // [START firestore_query_indexing_considerations] + db.collection("employees") + .whereGreaterThan("salary", 100000) + .whereGreaterThan("experience", 0) + .orderBy("salary") + .orderBy("experience"); + // [END firestore_query_indexing_considerations] + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/QueryDataSnippets.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/QueryDataSnippets.java new file mode 100644 index 000000000000..8c6d3a220b76 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/QueryDataSnippets.java @@ -0,0 +1,598 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.Query.Direction; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.WriteResult; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +/** Snippets to support firestore querying data documentation. */ +class QueryDataSnippets { + + private final Firestore db; + + QueryDataSnippets(Firestore db) { + this.db = db; + } + + /** + * Creates cities collection and add sample documents to test queries. + * + * @return collection reference + */ + void prepareExamples() throws Exception { + + // [START firestore_query_filter_dataset] + CollectionReference cities = db.collection("cities"); + List> futures = new ArrayList<>(); + futures.add( + cities + .document("SF") + .set( + new City( + "San Francisco", + "CA", + "USA", + false, + 860000L, + Arrays.asList("west_coast", "norcal")))); + futures.add( + cities + .document("LA") + .set( + new City( + "Los Angeles", + "CA", + "USA", + false, + 3900000L, + Arrays.asList("west_coast", "socal")))); + futures.add( + cities + .document("DC") + .set( + new City( + "Washington D.C.", null, "USA", true, 680000L, Arrays.asList("east_coast")))); + futures.add( + cities + .document("TOK") + .set( + new City( + "Tokyo", null, "Japan", true, 9000000L, Arrays.asList("kanto", "honshu")))); + futures.add( + cities + .document("BJ") + .set( + new City( + "Beijing", + null, + "China", + true, + 21500000L, + Arrays.asList("jingjinji", "hebei")))); + // (optional) block on documents successfully added + ApiFutures.allAsList(futures).get(); + // [END firestore_query_filter_dataset] + } + + /** + * Creates a sample query. + * + * @return query + */ + Query createQuery() throws Exception { + // [START firestore_query_filter_eq_boolean] + // Create a reference to the cities collection + CollectionReference cities = db.collection("cities"); + // Create a query against the collection. + Query query = cities.whereEqualTo("capital", true); + // retrieve query results asynchronously using query.get() + ApiFuture querySnapshot = query.get(); + + for (DocumentSnapshot document : querySnapshot.get().getDocuments()) { + System.out.println(document.getId()); + } + // [END firestore_query_filter_eq_boolean] + return query; + } + + /** + * Creates a sample query. + * + * @return query + */ + Query createQueryAlternate() throws Exception { + // [START firestore_query_filter_eq_string] + // Create a reference to the cities collection + CollectionReference cities = db.collection("cities"); + // Create a query against the collection. + Query query = cities.whereEqualTo("state", "CA"); + // retrieve query results asynchronously using query.get() + ApiFuture querySnapshot = query.get(); + + for (DocumentSnapshot document : querySnapshot.get().getDocuments()) { + System.out.println(document.getId()); + } + // [END firestore_query_filter_eq_string] + return query; + } + + /** + * Creates queries with simple where clauses. + * + * @return queries + */ + List createSimpleQueries() { + List querys = new ArrayList<>(); + CollectionReference cities = db.collection("cities"); + + // [START firestore_query_filter_single_examples] + Query stateQuery = cities.whereEqualTo("state", "CA"); + Query populationQuery = cities.whereLessThan("population", 1000000L); + Query nameQuery = cities.whereGreaterThanOrEqualTo("name", "San Francisco"); + // [END firestore_query_filter_single_examples] + + querys.add(stateQuery); + querys.add(populationQuery); + querys.add(nameQuery); + return querys; + } + + /** + * Creates a query based on array containment. + * + * @return query + */ + Query createArrayQuery() { + // [START firestore_query_filter_array_contains] + CollectionReference citiesRef = db.collection("cities"); + Query westCoastQuery = citiesRef.whereArrayContains("regions", "west_coast"); + // [END firestore_query_filter_array_contains] + + return westCoastQuery; + } + + /** + * Creates chained where clauses. + * + *

Note : equality and inequality clauses over multiple fields cannot be chained. + * + * @return query + */ + Query createChainedQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_filter_compound_multi_eq] + Query chainedQuery1 = cities.whereEqualTo("state", "CO").whereEqualTo("name", "Denver"); + // [END firestore_query_filter_compound_multi_eq] + return chainedQuery1; + } + + /** + * An instance of a currently unsupported chained query: equality with inequality. NOTE : Requires + * support for creation of composite indices. + * + * @return query + */ + Query createCompositeIndexChainedQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_filter_compound_multi_eq_lt] + Query chainedQuery2 = cities.whereEqualTo("state", "CA").whereLessThan("population", 1000000L); + // [END firestore_query_filter_compound_multi_eq_lt] + return chainedQuery2; + } + + /** + * An instance of a valid range/inequality query : range operators are limited to a single field. + * + * @return query + */ + Query createRangeQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_filter_range_valid] + Query validQuery1 = + cities.whereGreaterThanOrEqualTo("state", "CA").whereLessThanOrEqualTo("state", "IN"); + Query validQuery2 = cities.whereEqualTo("state", "CA").whereGreaterThan("population", 1000000); + // [END firestore_query_filter_range_valid] + return validQuery1; + } + + /** + * An instance of an invalid range query : range operators are limited to a single field. + * + * @return query + */ + Query createInvalidRangeQuery() { + CollectionReference cities = db.collection("cities"); + // Violates constraint : range operators are limited to a single field + // [START firestore_query_filter_range_invalid] + Query invalidRangeQuery = + cities.whereGreaterThanOrEqualTo("state", "CA").whereGreaterThan("population", 100000); + // [END firestore_query_filter_range_invalid] + return invalidRangeQuery; + } + + /** + * Creates a query that combines order by with limit. + * + * @return query + */ + Query createOrderByNameWithLimitQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_limit] + Query query = cities.orderBy("name").limit(3); + // [END firestore_query_order_limit] + return query; + } + + /** + * Creates a query that combines order by with limitToLast. + * + * @return query + */ + Query createOrderByNameWithLimitToLastQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_limit] + Query query = cities.orderBy("name").limitToLast(3); + // [END firestore_query_order_limit] + return query; + } + + /** + * Creates a query that orders by country and population(descending). + * + * @return query + */ + Query createOrderByCountryAndPopulation() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_multi] + Query query = cities.orderBy("state").orderBy("population", Direction.DESCENDING); + // [END firestore_query_order_multi] + return query; + } + + /** + * Creates a query that combines order by in descending order with the limit operator. + * + * @return query + */ + Query createOrderByNameDescWithLimitQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_desc_limit] + Query query = cities.orderBy("name", Direction.DESCENDING).limit(3); + // [END firestore_query_order_desc_limit] + return query; + } + + /** + * Creates a query that combines where clause with order by and limit operator. + * + * @return query + */ + Query createWhereWithOrderByAndLimitQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_limit_field_valid] + Query query = cities.whereGreaterThan("population", 2500000L).orderBy("population").limit(2); + // [END firestore_query_order_limit_field_valid] + return query; + } + + /** + * Creates a query using a range where clause with order by. Order by must be based on the same + * field as the range clause. + * + * @return query + */ + Query createRangeWithOrderByQuery() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_order_with_filter] + Query query = cities.whereGreaterThan("population", 2500000L).orderBy("population"); + // [END firestore_query_order_with_filter] + return query; + } + + /** + * Creates an instance of an invalid range combined with order. Violates the constraint that range + * and order by are required to be on the same field. + * + * @return query + */ + Query createInvalidRangeWithOrderByQuery() { + CollectionReference cities = db.collection("cities"); + // Violates the constraint that range and order by are required to be on the same field + // [START firestore_query_order_field_invalid] + Query query = cities.whereGreaterThan("population", 2500000L).orderBy("country"); + // [END firestore_query_order_field_invalid] + return query; + } + + /** + * Create a query defining the start point of a query. + * + * @return query + */ + Query createStartAtFieldQueryCursor() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_cursor_start_at_field_value_single] + Query query = cities.orderBy("population").startAt(4921000L); + // [END firestore_query_cursor_start_at_field_value_single] + return query; + } + + /** + * Create a query defining the start point of a query. + * + * @return query + */ + Query createEndAtFieldQueryCursor() { + CollectionReference cities = db.collection("cities"); + // [START firestore_query_cursor_end_at_field_value_single] + Query query = cities.orderBy("population").endAt(4921000L); + // [END firestore_query_cursor_end_at_field_value_single] + return query; + } + + /* Create queries with multiple cursor conditions. */ + void createMultipleCursorConditionsQuery() { + // [START firestore_query_cursor_start_at_field_value_multi] + // Will return all Springfields + Query query1 = db.collection("cities").orderBy("name").orderBy("state").startAt("Springfield"); + + // Will return "Springfield, Missouri" and "Springfield, Wisconsin" + Query query2 = + db.collection("cities").orderBy("name").orderBy("state").startAt("Springfield", "Missouri"); + // [END firestore_query_cursor_start_at_field_value_multi] + } + + /** + * Create a query using a snapshot as a start point. + * + * @return query + */ + Query createStartAtSnapshotQueryCursor() + throws InterruptedException, ExecutionException, TimeoutException { + // [START firestore_query_cursor_start_at_document] + // Fetch the snapshot with an API call, waiting for a maximum of 30 seconds for a result. + ApiFuture future = db.collection("cities").document("SF").get(); + DocumentSnapshot snapshot = future.get(30, TimeUnit.SECONDS); + + // Construct the query + Query query = db.collection("cities").orderBy("population").startAt(snapshot); + // [END firestore_query_cursor_start_at_document] + return query; + } + + /** Example of a paginated query. */ + List paginateCursor() throws InterruptedException, ExecutionException, TimeoutException { + // [START firestore_query_cursor_pagination] + // Construct query for first 25 cities, ordered by population. + CollectionReference cities = db.collection("cities"); + Query firstPage = cities.orderBy("population").limit(25); + + // Wait for the results of the API call, waiting for a maximum of 30 seconds for a result. + ApiFuture future = firstPage.get(); + List docs = future.get(30, TimeUnit.SECONDS).getDocuments(); + + // Construct query for the next 25 cities. + QueryDocumentSnapshot lastDoc = docs.get(docs.size() - 1); + Query secondPage = cities.orderBy("population").startAfter(lastDoc).limit(25); + + future = secondPage.get(); + docs = future.get(30, TimeUnit.SECONDS).getDocuments(); + // [END firestore_query_cursor_pagination] + return Arrays.asList(firstPage, secondPage); + } + + void collectionGroupQuery() throws ExecutionException, InterruptedException { + // CHECKSTYLE OFF: Indentation + // CHECKSTYLE OFF: RightCurlyAlone + // [START firestore_query_collection_group_dataset] + CollectionReference cities = db.collection("cities"); + + final List> futures = + Arrays.asList( + cities + .document("SF") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Golden Gate Bridge"); + put("type", "bridge"); + } + }), + cities + .document("SF") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Legion of Honor"); + put("type", "museum"); + } + }), + cities + .document("LA") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Griffith Park"); + put("type", "park"); + } + }), + cities + .document("LA") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "The Getty"); + put("type", "museum"); + } + }), + cities + .document("DC") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Lincoln Memorial"); + put("type", "memorial"); + } + }), + cities + .document("DC") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "National Air and Space Museum"); + put("type", "museum"); + } + }), + cities + .document("TOK") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Ueno Park"); + put("type", "park"); + } + }), + cities + .document("TOK") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "National Museum of Nature and Science"); + put("type", "museum"); + } + }), + cities + .document("BJ") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Jingshan Park"); + put("type", "park"); + } + }), + cities + .document("BJ") + .collection("landmarks") + .document() + .set( + new HashMap() { + { + put("name", "Beijing Ancient Observatory"); + put("type", "museum"); + } + })); + final List landmarks = ApiFutures.allAsList(futures).get(); + // [END firestore_query_collection_group_dataset] + + // [START firestore_query_collection_group_filter_eq] + final Query museums = db.collectionGroup("landmarks").whereEqualTo("type", "museum"); + final ApiFuture querySnapshot = museums.get(); + for (DocumentSnapshot document : querySnapshot.get().getDocuments()) { + System.out.println(document.getId()); + } + // [END firestore_query_collection_group_filter_eq] + // CHECKSTYLE ON: RightCurlyAlone + // CHECKSTYLE ON: Indentation + } + + public Query arrayContainsAnyQueries() { + // [START firestore_query_filter_array_contains_any] + CollectionReference citiesRef = db.collection("cities"); + + Query query = + citiesRef.whereArrayContainsAny("regions", Arrays.asList("west_coast", "east_coast")); + // [END firestore_query_filter_array_contains_any] + return query; + } + + public Query inQueryWithoutArray() { + // [START firestore_query_filter_in] + CollectionReference citiesRef = db.collection("cities"); + + Query query = citiesRef.whereIn("country", Arrays.asList("USA", "Japan")); + // [END firestore_query_filter_in] + return query; + } + + public Query inQueryWithArray() { + // [START firestore_query_filter_in_with_array] + CollectionReference citiesRef = db.collection("cities"); + + Query query = + citiesRef.whereIn( + "regions", Arrays.asList(Arrays.asList("west_coast"), Arrays.asList("east_coast"))); + // [END firestore_query_filter_in_with_array] + return query; + } + + Query notEqualsQuery() { + // [START firestore_query_filter_not_eq] + CollectionReference citiesRef = db.collection("cities"); + + Query query = citiesRef.whereNotEqualTo("capital", false); + // [END firestore_query_filter_not_eq] + return query; + } + + Query filterNotIn() { + // [START firestore_query_filter_not_in] + CollectionReference citiesRef = db.collection("cities"); + + Query query = citiesRef.whereNotIn("country", Arrays.asList("USA", "Japan")); + // [END firestore_query_filter_not_in] + return query; + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/References.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/References.java new file mode 100644 index 000000000000..a8a095f778cf --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/References.java @@ -0,0 +1,84 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.Firestore; + +/** Examples of references to a collection, document in a collection and subcollection. */ +public class References { + + private final Firestore db; + + public References(Firestore db) { + this.db = db; + } + + /** + * Return a reference to collection. + * + * @return collection reference + */ + public CollectionReference getCollectionRef() { + // [START firestore_data_reference_collection] + // Reference to the collection "users" + CollectionReference collection = db.collection("users"); + // [END firestore_data_reference_collection] + return collection; + } + + /** + * Return a reference to a document. + * + * @return document reference + */ + public DocumentReference getDocumentRef() { + // [START firestore_data_reference_document] + // Reference to a document with id "alovelace" in the collection "users" + DocumentReference document = db.collection("users").document("alovelace"); + // [END firestore_data_reference_document] + return document; + } + + /** + * Return a reference to a document using path. + * + * @return document reference + */ + public DocumentReference getDocumentRefUsingPath() { + // [START firestore_data_reference_document_path] + // Reference to a document with id "alovelace" in the collection "users" + DocumentReference document = db.document("users/alovelace"); + // [END firestore_data_reference_document_path] + return document; + } + + /** + * Return a reference to a document in a sub-collection. + * + * @return document reference in a subcollection + */ + public DocumentReference getSubCollectionDocumentRef() { + // [START firestore_data_reference_subcollection] + // Reference to a document in subcollection "messages" + DocumentReference document = + db.collection("rooms").document("roomA").collection("messages").document("message1"); + // [END firestore_data_reference_subcollection] + return document; + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/RetrieveDataSnippets.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/RetrieveDataSnippets.java new file mode 100644 index 000000000000..77002b248664 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/RetrieveDataSnippets.java @@ -0,0 +1,201 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.api.core.ApiFutures; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.cloud.firestore.WriteResult; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** Snippets to demonstrate Firestore data retrieval operations. */ +public class RetrieveDataSnippets { + + private final Firestore db; + + RetrieveDataSnippets(Firestore db) { + this.db = db; + } + + /** Create cities collection and add sample documents. */ + void prepareExamples() throws Exception { + // [START firestore_data_get_dataset] + CollectionReference cities = db.collection("cities"); + List> futures = new ArrayList<>(); + futures.add( + cities + .document("SF") + .set( + new City( + "San Francisco", + "CA", + "USA", + false, + 860000L, + Arrays.asList("west_coast", "norcal")))); + futures.add( + cities + .document("LA") + .set( + new City( + "Los Angeles", + "CA", + "USA", + false, + 3900000L, + Arrays.asList("west_coast", "socal")))); + futures.add( + cities + .document("DC") + .set( + new City( + "Washington D.C.", null, "USA", true, 680000L, Arrays.asList("east_coast")))); + futures.add( + cities + .document("TOK") + .set( + new City( + "Tokyo", null, "Japan", true, 9000000L, Arrays.asList("kanto", "honshu")))); + futures.add( + cities + .document("BJ") + .set( + new City( + "Beijing", + null, + "China", + true, + 21500000L, + Arrays.asList("jingjinji", "hebei")))); + // (optional) block on operation + ApiFutures.allAsList(futures).get(); + // [END firestore_data_get_dataset] + } + + /** + * Retrieves document in collection as map. + * + * @return map (string => object) + */ + public Map getDocumentAsMap() throws Exception { + // [START firestore_data_get_as_map] + DocumentReference docRef = db.collection("cities").document("SF"); + // asynchronously retrieve the document + ApiFuture future = docRef.get(); + // ... + // future.get() blocks on response + DocumentSnapshot document = future.get(); + if (document.exists()) { + System.out.println("Document data: " + document.getData()); + } else { + System.out.println("No such document!"); + } + // [END firestore_data_get_as_map] + return (document.exists()) ? document.getData() : null; + } + + /** + * Retrieves document in collection as a custom object. + * + * @return document data as City object + */ + public City getDocumentAsEntity() throws Exception { + // [START firestore_data_get_as_custom_type] + DocumentReference docRef = db.collection("cities").document("BJ"); + // asynchronously retrieve the document + ApiFuture future = docRef.get(); + // block on response + DocumentSnapshot document = future.get(); + City city = null; + if (document.exists()) { + // convert document to POJO + city = document.toObject(City.class); + System.out.println(city); + } else { + System.out.println("No such document!"); + } + // [END firestore_data_get_as_custom_type] + return city; + } + + /** + * Return multiple documents from a collection based on a query. + * + * @return list of documents of capital cities. + */ + public List getQueryResults() throws Exception { + // [START firestore_data_query] + // asynchronously retrieve multiple documents + ApiFuture future = db.collection("cities").whereEqualTo("capital", true).get(); + // future.get() blocks on response + List documents = future.get().getDocuments(); + for (DocumentSnapshot document : documents) { + System.out.println(document.getId() + " => " + document.toObject(City.class)); + } + // [END firestore_data_query] + return documents; + } + + /** + * Return all documents in the cities collection. + * + * @return list of documents + */ + public List getAllDocuments() throws Exception { + // [START firestore_data_get_all_documents] + // asynchronously retrieve all documents + ApiFuture future = db.collection("cities").get(); + // future.get() blocks on response + List documents = future.get().getDocuments(); + for (QueryDocumentSnapshot document : documents) { + System.out.println(document.getId() + " => " + document.toObject(City.class)); + } + // [END firestore_data_get_all_documents] + return documents; + } + + /** + * Return all subcollections of the cities/SF document. + * + * @return iterable of collection references. + */ + public Iterable listCollections() throws Exception { + // [START firestore_data_get_sub_collections] + Iterable collections = + db.collection("cities").document("SF").listCollections(); + + for (CollectionReference collRef : collections) { + System.out.println("Found subcollection with id: " + collRef.getId()); + } + // [END firestore_data_get_sub_collections] + return collections; + } + + /** Closes the gRPC channels associated with this instance and frees up their resources. */ + void close() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/model/City.java b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/model/City.java new file mode 100644 index 000000000000..a56b847f6475 --- /dev/null +++ b/java-firestore/samples/snippets/src/main/java/com/example/firestore/snippets/model/City.java @@ -0,0 +1,175 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets.model; + +import java.util.List; +import java.util.Objects; + +/** Represents a city : name, weather, population, country, capital, geo coordinates. */ +public class City { + + private String name; + private String state; + private String country; + private Boolean capital; + private Long population; + private List regions; + + // [START firestore_data_custom_type_definition] + public City() { + // Must have a public no-argument constructor + } + + // Initialize all fields of a city + public City( + String name, + String state, + String country, + Boolean capital, + Long population, + List regions) { + this.name = name; + this.state = state; + this.country = country; + this.capital = capital; + this.population = population; + this.regions = regions; + } + + // [END firestore_data_custom_type_definition] + + public City(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public Boolean getCapital() { + return capital; + } + + public void setCapital(Boolean capital) { + this.capital = capital; + } + + public Long getPopulation() { + return population; + } + + public void setPopulation(Long population) { + this.population = population; + } + + public List getRegions() { + return regions; + } + + public void setRegions(List regions) { + this.regions = regions; + } + + private String getDefinedValue(String s) { + if (s != null) { + return s; + } else { + return ""; + } + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (name != null) { + sb.append(name); + } + if (state != null) { + sb.append(" state : "); + sb.append(state); + sb.append(","); + } + if (country != null) { + sb.append(", "); + sb.append(country); + } + sb.append(" : ["); + if (population != null) { + sb.append(" population : "); + sb.append(population); + sb.append(","); + } + if (capital != null) { + sb.append(" capital : "); + sb.append(capital); + sb.append(","); + } + if (regions != null) { + sb.append(" regions : ["); + for (String r : regions) { + sb.append(r); + sb.append(", "); + } + sb.append("],"); + } + // remove trailing comma + if (sb.lastIndexOf(",") >= sb.length() - 1) { + sb.deleteCharAt(sb.length() - 1); + } + sb.append(" ]"); + return sb.toString(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof City)) { + return false; + } + City city = (City) obj; + return Objects.equals(name, city.name) + && Objects.equals(state, city.state) + && Objects.equals(country, city.country) + && Objects.equals(population, city.population) + && Objects.equals(capital, city.capital) + && Objects.equals(regions, city.regions); + } + + @Override + public int hashCode() { + return Objects.hash(name, state, country, capital, population, regions); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/BaseIntegrationTest.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/BaseIntegrationTest.java new file mode 100644 index 000000000000..61017ebaa96b --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/BaseIntegrationTest.java @@ -0,0 +1,90 @@ +/* + * Copyright 2018 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore; + +import static org.junit.Assert.assertNotNull; + +import com.example.firestore.snippets.ManageDataSnippetsIT; +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.QuerySnapshot; +import java.util.Map; +import org.junit.AfterClass; +import org.junit.BeforeClass; + +/** Base class for tests like {@link ManageDataSnippetsIT}. */ +public class BaseIntegrationTest { + + protected static String projectId; + protected static Firestore db; + + private static String getEnvVar(String varName) { + String value = System.getenv(varName); + assertNotNull( + String.format("Environment variable '%s' must be set to perform these tests.", varName), + value); + return value; + } + + @BeforeClass + public static void baseSetup() throws Exception { + projectId = getEnvVar("FIRESTORE_PROJECT_ID"); + FirestoreOptions firestoreOptions = + FirestoreOptions.getDefaultInstance().toBuilder() + .setCredentials(GoogleCredentials.getApplicationDefault()) + .setProjectId(projectId) + .build(); + db = firestoreOptions.getService(); + deleteAllDocuments(db); + } + + protected DocumentSnapshot getDocumentData(DocumentReference docRef) throws Exception { + return docRef.get().get(); + } + + protected Map getDocumentDataAsMap(DocumentReference docRef) throws Exception { + DocumentSnapshot snapshot = docRef.get().get(); + if (!snapshot.exists()) { + throw new RuntimeException("Document does not exist: " + docRef.getPath()); + } + + return snapshot.getData(); + } + + protected City getDocumentDataAsCity(DocumentReference docRef) throws Exception { + return docRef.get().get().toObject(City.class); + } + + protected static void deleteAllDocuments(Firestore db) throws Exception { + ApiFuture future = db.collection("cities").get(); + QuerySnapshot querySnapshot = future.get(); + for (DocumentSnapshot doc : querySnapshot.getDocuments()) { + // block on delete operation + db.collection("cities").document(doc.getId()).delete().get(); + } + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + db.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/QuickstartIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/QuickstartIT.java new file mode 100644 index 000000000000..3225a4f5e61b --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/QuickstartIT.java @@ -0,0 +1,118 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore; + +import static org.junit.Assert.assertTrue; + +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class QuickstartIT extends BaseIntegrationTest { + + private Quickstart quickstart; + private ByteArrayOutputStream bout; + private PrintStream out; + + @Before + public void setUp() throws Exception { + quickstart = new Quickstart(projectId); + bout = new ByteArrayOutputStream(); + out = new PrintStream(bout); + System.setOut(out); + deleteAllDocuments(); + } + + @Test + public void testQuickstart() throws Exception { + addData(); + + bout.reset(); + quickstart.runQuery(); + String output = bout.toString(); + // confirm that results do not contain aturing + assertTrue(output.contains("alovelace")); + assertTrue(output.contains("cbabbage")); + assertTrue(!output.contains("aturing")); + + bout.reset(); + quickstart.retrieveAllDocuments(); + output = bout.toString(); + // confirm that all documents are retrieved + assertTrue(output.contains("alovelace")); + assertTrue(output.contains("aturing")); + assertTrue(output.contains("cbabbage")); + } + + private void validate(DocumentReference docRef, Map data) throws Exception { + DocumentSnapshot documentSnapshot = docRef.get().get(); + assertTrue(Objects.equals(documentSnapshot.getData(), data)); + } + + private void addData() throws Exception { + Map expectedData = new HashMap<>(); + + quickstart.addDocument("alovelace"); + expectedData.put("first", "Ada"); + expectedData.put("last", "Lovelace"); + expectedData.put("born", 1815L); + validate(db.document("users/alovelace"), expectedData); + + expectedData.clear(); + expectedData.put("first", "Alan"); + expectedData.put("middle", "Mathison"); + expectedData.put("last", "Turing"); + expectedData.put("born", 1912L); + quickstart.addDocument("aturing"); + validate(db.document("users/aturing"), expectedData); + + expectedData.clear(); + expectedData.put("first", "Charles"); + expectedData.put("last", "Babbage"); + expectedData.put("born", 1791L); + quickstart.addDocument("cbabbage"); + validate(db.document("users/cbabbage"), expectedData); + } + + private void deleteAllDocuments() throws Exception { + ApiFuture future = db.collection("users").get(); + QuerySnapshot querySnapshot = future.get(); + for (DocumentSnapshot doc : querySnapshot.getDocuments()) { + // block on delete operation + db.document("users/" + doc.getId()).delete().get(); + } + } + + @After + public void tearDown() throws Exception { + deleteAllDocuments(); + quickstart.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/beam/ExampleFirestoreWriteReadTest.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/beam/ExampleFirestoreWriteReadTest.java new file mode 100644 index 000000000000..04d5a5662d77 --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/beam/ExampleFirestoreWriteReadTest.java @@ -0,0 +1,111 @@ +/* + * Copyright 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.beam; + +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.Firestore; +import com.google.cloud.firestore.FirestoreOptions; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.common.truth.Truth; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.ExecutionException; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +public class ExampleFirestoreWriteReadTest { + private ByteArrayOutputStream bout; + private static String projectId; + private static Firestore firestore; + private static String collectionId; + + @BeforeClass + public static void setUp() { + collectionId = "cities-collection-" + UUID.randomUUID().toString().substring(0, 10); + projectId = requireEnv("GOOGLE_CLOUD_PROJECT"); + firestore = FirestoreOptions.getDefaultInstance().getService(); + } + + @Before + public void setUpStream() { + bout = new ByteArrayOutputStream(); + System.setOut(new PrintStream(bout)); + } + + @AfterClass + public static void tearDown() { + if (firestore != null && collectionId != null) { + deleteCollection(firestore.collection(collectionId), 1); + } + } + + @Test + public void testWriteAndRead() throws ExecutionException, InterruptedException { + String[] args = { + "--project=" + projectId, "--region=us-central1", "--numWorkers=1", "--maxNumWorkers=1" + }; + // write the data to Firestore + ExampleFirestoreBeamWrite.runWrite(args, collectionId); + + ApiFuture apiFuture = firestore.collection(collectionId).get(); + QuerySnapshot querySnapshot = apiFuture.get(); + List documents = querySnapshot.getDocuments(); + Truth.assertThat(documents).hasSize(2); + + // filter and read it back + ExampleFirestoreBeamRead.runRead(args, collectionId); + + String output = bout.toString(); + Truth.assertThat(output).contains("/documents/" + collectionId + "/NYC"); + } + + private static String requireEnv(String varName) { + String value = System.getenv(varName); + Assert.assertNotNull( + String.format("Environment variable '%s' is required to perform these tests.", varName), + value); + return value; + } + + // from: https://firebase.google.com/docs/firestore/manage-data/delete-data#collections + private static void deleteCollection(CollectionReference collection, int batchSize) { + try { + // retrieve a small batch of documents to avoid out-of-memory errors + ApiFuture future = collection.limit(batchSize).get(); + int deleted = 0; + // future.get() blocks on document retrieval + List documents = future.get().getDocuments(); + for (QueryDocumentSnapshot document : documents) { + document.getReference().delete(); + ++deleted; + } + if (deleted >= batchSize) { + // retrieve and delete another batch + deleteCollection(collection, batchSize); + } + } catch (Exception e) { + System.err.println("Error deleting collection : " + e.getMessage()); + } + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ListenDataSnippetsIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ListenDataSnippetsIT.java new file mode 100644 index 000000000000..55d82c4cb112 --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ListenDataSnippetsIT.java @@ -0,0 +1,80 @@ +/* + * Copyright 2018 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.example.firestore.BaseIntegrationTest; +import com.google.cloud.firestore.DocumentChange; +import com.google.cloud.firestore.DocumentChange.Type; +import com.google.cloud.firestore.DocumentReference; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class ListenDataSnippetsIT extends BaseIntegrationTest { + + private static QueryDataSnippets queryDataSnippets; + private static ListenDataSnippets listenDataSnippets; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + queryDataSnippets = new QueryDataSnippets(db); + queryDataSnippets.prepareExamples(); + + listenDataSnippets = new ListenDataSnippets(db); + } + + @Test + public void testListenDocument() throws Exception { + Map expectedData = listenDataSnippets.listenToDocument(); + DocumentReference docRef = db.collection("cities").document("SF"); + assertTrue(Objects.equals(expectedData, getDocumentDataAsMap(docRef))); + } + + @Test + public void testListenForMultiple() throws Exception { + List cities = listenDataSnippets.listenForMultiple(); + + assertEquals("Two cities in CA", cities.size(), 2); + assertTrue("SF in CA", cities.contains("San Francisco")); + assertTrue("LA in CA", cities.contains("Los Angeles")); + } + + @Test + public void testListenForChanges() throws Exception { + List changes = listenDataSnippets.listenForChanges(); + + assertEquals("Two changes in snapshot.", changes.size(), 2); + assertEquals("First change is ADDED", changes.get(0).getType(), Type.ADDED); + assertEquals("Second change is ADDED", changes.get(1).getType(), Type.ADDED); + } + + @AfterClass + public static void tearDown() throws Exception { + deleteAllDocuments(db); + listenDataSnippets.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ManageDataSnippetsIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ManageDataSnippetsIT.java new file mode 100644 index 000000000000..b13c19e2d39f --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/ManageDataSnippetsIT.java @@ -0,0 +1,215 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import static junit.framework.TestCase.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.example.firestore.BaseIntegrationTest; +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentReference; +import com.google.cloud.firestore.DocumentSnapshot; +import java.util.Date; +import java.util.Map; +import java.util.Objects; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class ManageDataSnippetsIT extends BaseIntegrationTest { + + private static ManageDataSnippets manageDataSnippets; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + manageDataSnippets = new ManageDataSnippets(db); + } + + @Test + public void testAddDatasMap() throws Exception { + Map expectedData = manageDataSnippets.addSimpleDocumentAsMap(); + DocumentReference docRef = db.collection("cities").document("LA"); + assertTrue(Objects.equals(expectedData, getDocumentDataAsMap(docRef))); + } + + @Test + public void testAddDataWithDifferentDataTypes() throws Exception { + Map expectedData = manageDataSnippets.addDocumentWithDifferentDataTypes(); + DocumentReference docRef = db.collection("data").document("one"); + assertEquals(expectedData, getDocumentDataAsMap(docRef)); + } + + @Test + public void testAddDataAsEntity() throws Exception { + City city = manageDataSnippets.addSimpleDocumentAsEntity(); + DocumentReference docRef = db.collection("cities").document("LA"); + assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef))); + } + + @Test + public void testAddDocWithAutoGenId() throws Exception { + String autoId = manageDataSnippets.addDocumentDataWithAutoGeneratedId(); + City city = new City("Tokyo"); + city.setCountry("Japan"); + DocumentReference docRef = db.collection("cities").document(autoId); + assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef))); + } + + @Test + public void testAddDocAfterAutoGenId() throws Exception { + String autoId = manageDataSnippets.addDocumentDataAfterAutoGeneratingId(); + City city = new City(); + DocumentReference docRef = db.collection("cities").document(autoId); + assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef))); + } + + @Test + public void testUpdateSimpleDocument() throws Exception { + manageDataSnippets.updateSimpleDocument(); + DocumentReference docRef = db.collection("cities").document("DC"); + City city = new City("Washington D.C."); + city.setCapital(true); + assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef))); + } + + @Test + public void testUpdateUsingMap() throws Exception { + manageDataSnippets.updateUsingMap(); + DocumentReference docRef = db.collection("cities").document("DC"); + City city = new City("Washington D.C."); + city.setCapital(true); + city.setCountry("USA"); + assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef))); + } + + @Test + public void testUpdateAndCreateIfMissing() throws Exception { + manageDataSnippets.updateAndCreateIfMissing(); + DocumentReference docRef = db.collection("cities").document("BJ"); + assertTrue(getDocumentDataAsCity(docRef).getCapital()); + } + + @Test + public void testUpdateNestedFields() throws Exception { + manageDataSnippets.updateNestedFields(); + DocumentReference docRef = db.collection("users").document("frank"); + + DocumentSnapshot snapshot = getDocumentData(docRef); + assertEquals((long) snapshot.getLong("age"), 13); + assertEquals(snapshot.getString("favorites.color"), "Red"); + assertEquals(snapshot.getString("favorites.food"), "Pizza"); + } + + @Test + public void testUpdateServerTimestamp() throws Exception { + manageDataSnippets.updateServerTimestamp(); + DocumentReference docRef = db.collection("objects").document("some-id"); + DocumentSnapshot data = getDocumentData(docRef); + assertTrue(data.getDate("timestamp") instanceof Date); + } + + @Test + public void testUpdateDocumentArray() throws Exception { + manageDataSnippets.updateDocumentArray(); + DocumentReference docRef = db.collection("cities").document("DC"); + City city = getDocumentDataAsCity(docRef); + assertTrue(city.getRegions().contains("greater_virginia")); + assertTrue(!city.getRegions().contains("east_coast")); + } + + @Test + public void testDeleteFields() throws Exception { + manageDataSnippets.deleteFields(); + DocumentReference docRef = db.collection("cities").document("BJ"); + Map data = getDocumentDataAsMap(docRef); + assertFalse(data.containsKey("capital")); + } + + @Test(expected = Exception.class) + public void testDeleteDocument() throws Exception { + manageDataSnippets.deleteDocument(); + getDocumentDataAsMap(db.collection("cities").document("DC")); + } + + @Test + public void testSimpleTransaction() throws Exception { + DocumentReference docRef = db.collection("cities").document("SF"); + ApiFuture future = manageDataSnippets.runSimpleTransaction(); + future.get(); + Map data = getDocumentDataAsMap(docRef); + assertEquals(data.get("population"), 860000L + 1L); + } + + @Test + public void testTransactionReturnsInfo() throws Exception { + String info = manageDataSnippets.returnInfoFromTransaction(50L); + assertEquals(info, "Population increased to 51"); + try { + info = manageDataSnippets.returnInfoFromTransaction(5000001L); + assertTrue( + "returnInfoFromTransaction should have failed," + " instead returned info: " + info, + false); + } catch (Exception e) { + assertTrue(e.getMessage().contains("Sorry! Population is too big.")); + } + } + + @Test + public void testWriteBatchIsSuccessful() throws Exception { + manageDataSnippets.writeBatch(); + CollectionReference collection = db.collection("cities"); + ApiFuture document = collection.document("NYC").get(); + assertTrue(document.get().exists()); + DocumentReference documentReference = collection.document("SF"); + Map data = getDocumentDataAsMap(documentReference); + assertTrue(data.containsKey("population")); + document = collection.document("LA").get(); + assertFalse(document.get().exists()); + } + + @Test + public void testUpdateDocumentIncrementSuccessful() throws Exception { + manageDataSnippets.updateDocumentIncrement(); + CollectionReference collection = db.collection("cities"); + DocumentReference documentReference = collection.document("DC"); + final DocumentSnapshot data = documentReference.get().get(); + assertTrue(data.contains("population")); + assertEquals((Long) 150L, data.getLong("population")); + } + + @Test + public void testSnapshotReads() throws Exception { + + DocumentSnapshot doc = manageDataSnippets.runSnapshotReads(); + // Assert that population value is exactly the one from the write operation + assertEquals((Long) 860008L, doc.getLong("population")); + } + + @AfterClass + public static void tearDown() throws Exception { + manageDataSnippets.deleteCollection(db.collection("cities"), 10); + manageDataSnippets.deleteCollection(db.collection("users"), 10); + manageDataSnippets.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippetsIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippetsIT.java new file mode 100644 index 000000000000..828e2776bae6 --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/MultipleRangeInequalityFiltersSnippetsIT.java @@ -0,0 +1,81 @@ +/* + * Copyright 2024 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import static com.google.common.collect.Sets.newHashSet; +import static org.junit.Assert.assertEquals; + +import com.example.firestore.BaseIntegrationTest; +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QuerySnapshot; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class MultipleRangeInequalityFiltersSnippetsIT extends BaseIntegrationTest { + + private static MultipleRangeInequalityFiltersSnippets multipleRangeInequalityFiltersSnippets; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + multipleRangeInequalityFiltersSnippets = new MultipleRangeInequalityFiltersSnippets(db); + multipleRangeInequalityFiltersSnippets.prepareExamples(); + } + + @Test + public void testRangeMultipleInequalityFilter() throws Exception { + Query query = multipleRangeInequalityFiltersSnippets.compoundMultiInequalities(); + + Set expected = newHashSet("BJ", "LA"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + private Set getResultsAsSet(Query query) throws Exception { + List docIds = getResults(query); + return new HashSet<>(docIds); + } + + private List getResults(Query query) throws Exception { + // asynchronously retrieve query results + ApiFuture future = query.get(); + // block on response + QuerySnapshot querySnapshot = future.get(); + + List docIds = new ArrayList<>(); + for (DocumentSnapshot document : querySnapshot.getDocuments()) { + docIds.add(document.getId()); + } + return docIds; + } + + @AfterClass + public static void tearDown() throws Exception { + deleteAllDocuments(db); + multipleRangeInequalityFiltersSnippets.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/QueryDataSnippetsIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/QueryDataSnippetsIT.java new file mode 100644 index 000000000000..128a8c54cacf --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/QueryDataSnippetsIT.java @@ -0,0 +1,296 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import static com.google.common.collect.Sets.newHashSet; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.example.firestore.BaseIntegrationTest; +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.Query; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class QueryDataSnippetsIT extends BaseIntegrationTest { + + private static QueryDataSnippets queryDataSnippets; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + queryDataSnippets = new QueryDataSnippets(db); + queryDataSnippets.prepareExamples(); + } + + @Test + public void testCreateQuery() throws Exception { + Query q = queryDataSnippets.createQuery(); + Set result = getResultsAsSet(q); + Set expectedResults = new HashSet<>(Arrays.asList("DC", "TOK", "BJ")); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test + public void testSimpleQueryReturnsExpectedResults() throws Exception { + List> expectedResults = new ArrayList<>(); + + expectedResults.add(new HashSet<>(Arrays.asList("SF", "LA"))); + expectedResults.add(new HashSet<>(Arrays.asList("SF", "DC"))); + expectedResults.add(new HashSet<>(Arrays.asList("SF", "DC", "TOK"))); + + List queries = queryDataSnippets.createSimpleQueries(); + for (int i = 0; i < queries.size(); i++) { + Set results = getResultsAsSet(queries.get(i)); + assertTrue(Objects.equals(results, expectedResults.get(i))); + } + } + + @Test + public void testArrayQueryReturnsExpectedResults() throws Exception { + Set expected = new HashSet<>(Arrays.asList("SF", "LA")); + + Query query = queryDataSnippets.createArrayQuery(); + Set results = getResultsAsSet(query); + + assertTrue(Objects.equals(results, expected)); + } + + @Test + public void testChainedQuery() throws Exception { + Query q = queryDataSnippets.createChainedQuery(); + Set result = getResultsAsSet(q); + Set expectedResults = new HashSet<>(); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test + public void testRangeQuery() throws Exception { + Query q = queryDataSnippets.createRangeQuery(); + Set result = getResultsAsSet(q); + Set expectedResults = new HashSet<>(Arrays.asList("SF", "LA")); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test(expected = Exception.class) + public void testInvalidRangeQueryThrowsException() throws Exception { + Query q = queryDataSnippets.createInvalidRangeQuery(); + getResults(q); + } + + @Test + public void testOrderByNameWithLimitQuery() throws Exception { + Query q = queryDataSnippets.createOrderByNameWithLimitQuery(); + List result = getResults(q); + List expectedResults = Arrays.asList("BJ", "LA", "SF"); + assertEquals(result, expectedResults); + } + + @Test + public void testOrderByNameWithLimitToLastQuery() throws Exception { + Query q = queryDataSnippets.createOrderByNameWithLimitToLastQuery(); + List result = getResults(q); + List expectedResults = Arrays.asList("SF", "TOK", "DC"); + assertEquals(result, expectedResults); + } + + @Test + public void testOrderByNameDescWithLimitQuery() throws Exception { + Query q = queryDataSnippets.createOrderByNameDescWithLimitQuery(); + List result = getResults(q); + List expectedResults = Arrays.asList("DC", "TOK", "SF"); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test + public void testWhereWithOrderByAndLimitQuery() throws Exception { + Query q = queryDataSnippets.createWhereWithOrderByAndLimitQuery(); + List result = getResults(q); + List expectedResults = Arrays.asList("LA", "TOK"); + assertEquals(result, expectedResults); + } + + @Test + public void testRangeWithOrderByQuery() throws Exception { + Query q = queryDataSnippets.createRangeWithOrderByQuery(); + List result = getResults(q); + List expectedResults = Arrays.asList("LA", "TOK", "BJ"); + assertEquals(result, expectedResults); + } + + @Test(expected = Exception.class) + public void testInvalidRangeWithOrderByQuery() throws Exception { + Query q = queryDataSnippets.createInvalidRangeWithOrderByQuery(); + getResults(q); + } + + @Test + public void testStartAtFieldQueryCursor() throws Exception { + Query q = queryDataSnippets.createStartAtFieldQueryCursor(); + List expectedResults = Arrays.asList("TOK", "BJ"); + List result = getResults(q); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test + public void testEndAtFieldQueryCursor() throws Exception { + Query q = queryDataSnippets.createEndAtFieldQueryCursor(); + List expectedResults = Arrays.asList("DC", "SF", "LA"); + List result = getResults(q); + assertEquals(result, expectedResults); + } + + @Test + public void testMultipleCursorConditions() throws Exception { + // populate us_cities collection + Map city1 = + new ImmutableMap.Builder() + .put("name", "Springfield") + .put("state", "Massachusetts") + .build(); + Map city2 = + new ImmutableMap.Builder() + .put("name", "Springfield") + .put("state", "Missouri") + .build(); + Map city3 = + new ImmutableMap.Builder() + .put("name", "Springfield") + .put("state", "Wisconsin") + .build(); + + db.collection("us_cities").document("Massachusetts").set(city1).get(); + db.collection("us_cities").document("Missouri").set(city2).get(); + db.collection("us_cities").document("Wisconsin").set(city3).get(); + + Query query1 = + db.collection("us_cities").orderBy("name").orderBy("state").startAt("Springfield"); + + // all documents are retrieved + QuerySnapshot querySnapshot = query1.get().get(); + List docs = querySnapshot.getDocuments(); + assertEquals(3, docs.size()); + + // Will return "Springfield, Missouri" and "Springfield, Wisconsin" + Query query2 = + db.collection("us_cities") + .orderBy("name") + .orderBy("state") + .startAt("Springfield", "Missouri"); + + // only Missouri and Wisconsin are retrieved + List expectedResults = Arrays.asList("Missouri", "Wisconsin"); + List result = getResults(query2); + assertTrue(Objects.equals(result, expectedResults)); + } + + @Test + public void testCreateStartAtSnapshotQueryCursor() throws Exception { + Query q = queryDataSnippets.createStartAtSnapshotQueryCursor(); + List results = getResults(q); + List expectedResults = Arrays.asList("SF", "LA", "TOK", "BJ"); + assertEquals(expectedResults, results); + } + + @Test + public void testPaginateCursor() throws Exception { + // Snippet executes it's own query. Failures result in thrown Exceptions + List pages = queryDataSnippets.paginateCursor(); + List firstPage = getResults(pages.get(0)); + List secondPage = getResults(pages.get(1)); + assertEquals(Arrays.asList("DC", "SF", "LA", "TOK", "BJ"), firstPage); + assertEquals(new ArrayList(), secondPage); + } + + @Test + public void testQueryFilterArrayContainsAny() throws Exception { + Query query = queryDataSnippets.arrayContainsAnyQueries(); + Set expected = newHashSet("SF", "LA", "DC"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + @Test + public void testQueryFilterInQueryWithoutArray() throws Exception { + Query query = queryDataSnippets.inQueryWithoutArray(); + Set expected = newHashSet("SF", "LA", "DC", "TOK"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + @Test + public void testQueryFilterInQueryWithArray() throws Exception { + Query query = queryDataSnippets.inQueryWithArray(); + Set expected = newHashSet("DC"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + @Test + public void testQueryNotEquals() throws Exception { + Query query = queryDataSnippets.notEqualsQuery(); + Set expected = newHashSet("DC", "TOK", "BJ"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + @Test + public void testFilterNotIn() throws Exception { + Query query = queryDataSnippets.filterNotIn(); + Set expected = newHashSet("BJ"); + Set actual = getResultsAsSet(query); + assertEquals(expected, actual); + } + + private Set getResultsAsSet(Query query) throws Exception { + List docIds = getResults(query); + return new HashSet<>(docIds); + } + + private List getResults(Query query) throws Exception { + // asynchronously retrieve query results + ApiFuture future = query.get(); + // block on response + QuerySnapshot querySnapshot = future.get(); + List docIds = new ArrayList<>(); + for (DocumentSnapshot document : querySnapshot.getDocuments()) { + docIds.add(document.getId()); + } + return docIds; + } + + @AfterClass + public static void tearDown() throws Exception { + deleteAllDocuments(db); + queryDataSnippets.close(); + } +} diff --git a/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/RetrieveDataSnippetsIT.java b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/RetrieveDataSnippetsIT.java new file mode 100644 index 000000000000..f51197e5a365 --- /dev/null +++ b/java-firestore/samples/snippets/src/test/java/com/example/firestore/snippets/RetrieveDataSnippetsIT.java @@ -0,0 +1,130 @@ +/* + * Copyright 2017 Google Inc. + * + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.firestore.snippets; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.example.firestore.BaseIntegrationTest; +import com.example.firestore.snippets.model.City; +import com.google.api.core.ApiFuture; +import com.google.cloud.firestore.CollectionReference; +import com.google.cloud.firestore.DocumentSnapshot; +import com.google.cloud.firestore.QueryDocumentSnapshot; +import com.google.cloud.firestore.QuerySnapshot; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class RetrieveDataSnippetsIT extends BaseIntegrationTest { + + private static RetrieveDataSnippets retrieveDataSnippets; + + @BeforeClass + public static void setUpBeforeClass() throws Exception { + retrieveDataSnippets = new RetrieveDataSnippets(db); + retrieveDataSnippets.prepareExamples(); + } + + @Test + public void testRetrievalAsMap() throws Exception { + Map data = retrieveDataSnippets.getDocumentAsMap(); + assertEquals(data.get("name"), "San Francisco"); + assertEquals(data.get("country"), "USA"); + assertEquals(data.get("capital"), false); + assertEquals(data.get("population"), 860000L); + } + + @Test + public void testRetrieveAsEntity() throws Exception { + City city = retrieveDataSnippets.getDocumentAsEntity(); + assertEquals(city.getName(), "Beijing"); + assertEquals(city.getCountry(), "China"); + assertEquals(city.getCapital(), true); + assertEquals((long) city.getPopulation(), 21500000L); + } + + @Test + public void testRetrieveQueryResults() throws Exception { + List docs = retrieveDataSnippets.getQueryResults(); + assertEquals(docs.size(), 3); + Set docIds = new HashSet<>(); + for (DocumentSnapshot doc : docs) { + docIds.add(doc.getId()); + } + assertTrue(docIds.contains("BJ") && docIds.contains("TOK") && docIds.contains("DC")); + } + + @Test + public void testRetrieveAllDocuments() throws Exception { + List docs = retrieveDataSnippets.getAllDocuments(); + assertEquals(docs.size(), 5); + Set docIds = new HashSet<>(); + for (DocumentSnapshot doc : docs) { + docIds.add(doc.getId()); + } + assertTrue( + docIds.contains("SF") + && docIds.contains("LA") + && docIds.contains("DC") + && docIds.contains("TOK") + && docIds.contains("BJ")); + } + + @Test + public void testGetSubcollections() throws Exception { + // Add a landmark subcollection + Map data = new HashMap<>(); + data.put("foo", "bar"); + db.document("cities/SF/landmarks/example").set(data).get(); + + Iterable collections = retrieveDataSnippets.listCollections(); + + List collectionList = new ArrayList<>(); + for (CollectionReference collRef : collections) { + collectionList.add(collRef); + } + + assertEquals(collectionList.size(), 1); + assertEquals(collectionList.get(0).getId(), "landmarks"); + } + + private static void deleteAllDocuments() throws Exception { + ApiFuture future = db.collection("cities").get(); + QuerySnapshot querySnapshot = future.get(); + for (DocumentSnapshot doc : querySnapshot.getDocuments()) { + // block on delete operation + db.collection("cities").document(doc.getId()).delete().get(); + } + } + + @AfterClass + public static void tearDownAfterClass() throws Exception { + deleteAllDocuments(); + retrieveDataSnippets.close(); + } +} diff --git a/pom.xml b/pom.xml index 76fbb03a2f1f..3880ea45428c 100644 --- a/pom.xml +++ b/pom.xml @@ -111,6 +111,7 @@ java-eventarc-publishing java-filestore java-financialservices + java-firestore java-functions java-gdchardwaremanagement java-geminidataanalytics diff --git a/versions.txt b/versions.txt index 3edfa9233968..c031b6f15e43 100644 --- a/versions.txt +++ b/versions.txt @@ -976,3 +976,11 @@ proto-google-cloud-vectorsearch-v1:0.8.0:0.9.0-SNAPSHOT grpc-google-cloud-vectorsearch-v1:0.8.0:0.9.0-SNAPSHOT google-cloud-bigquery:2.61.0:2.62.0-SNAPSHOT google-cloud-bigquery-jdbc:0.5.0:0.6.0-SNAPSHOT +google-cloud-firestore:3.38.0:3.38.1-SNAPSHOT +google-cloud-firestore-admin:3.38.0:3.38.1-SNAPSHOT +google-cloud-firestore-bom:3.38.0:3.38.1-SNAPSHOT +grpc-google-cloud-firestore-admin-v1:3.38.0:3.38.1-SNAPSHOT +grpc-google-cloud-firestore-v1:3.38.0:3.38.1-SNAPSHOT +proto-google-cloud-firestore-admin-v1:3.38.0:3.38.1-SNAPSHOT +proto-google-cloud-firestore-v1:3.38.0:3.38.1-SNAPSHOT +proto-google-cloud-firestore-bundle-v1:3.38.0:3.38.1-SNAPSHOT